Jpp
Public Member Functions | Protected Attributes | Private Attributes | List of all members
JPARSER::JParserTemplateElement< JCounter > Class Template Reference

Template specialisation of JPARSER::JParserTemplateElement for type JCounter. More...

#include <JParser.hh>

Inheritance diagram for JPARSER::JParserTemplateElement< JCounter >:
JPARSER::JParserElementInterface JLANG::JStreamInput JLANG::JStreamOutput

Public Member Functions

 JParserTemplateElement (JCounter &object, const std::string &name, const std::string &help="")
 Constructor. More...
 
virtual std::istream & read (std::istream &in)
 Stream input. More...
 
virtual std::ostream & write (std::ostream &out) const
 Stream output. More...
 
virtual bool getStatus () const
 Status of object. More...
 
virtual bool getInitialisationStatus () const
 Get initialisation status of parameter. More...
 
virtual void setInitialiationStatus (const bool value)
 Set initialisation status of parameter. More...
 
virtual bool gcount () const
 Read counter. More...
 
const std::string & getName () const
 Get name of parameter. More...
 
const std::string & getHelp () const
 Get help of parameter. More...
 
virtual void print (std::ostream &out) const
 Print. More...
 

Protected Attributes

std::string __name
 
std::string __help
 

Private Attributes

JCounterobject
 

Detailed Description

template<>
class JPARSER::JParserTemplateElement< JCounter >

Template specialisation of JPARSER::JParserTemplateElement for type JCounter.

The value is by default set to zero and set incremented in method read() without reading any data. This makes it possible to parse mutiple options in one go (e.g. -aaa). This class implements the JPARSER::JParserElementInterface interface.

Definition at line 1167 of file JParser.hh.

Constructor & Destructor Documentation

◆ JParserTemplateElement()

JPARSER::JParserTemplateElement< JCounter >::JParserTemplateElement ( JCounter object,
const std::string &  name,
const std::string &  help = "" 
)
inline

Constructor.

The constructor assigns the default value false to the referenced parameter.

Parameters
objectreference to object
namename of object
helphelp of object

Definition at line 1180 of file JParser.hh.

1180  :
1181  JParserElementInterface(name, help),
1182  object(object)
1183  {
1184  this->object = JCounter();
1185  }

Member Function Documentation

◆ read()

virtual std::istream& JPARSER::JParserTemplateElement< JCounter >::read ( std::istream &  in)
inlinevirtual

Stream input.

This method sets the value to true, without reading any data.

Parameters
ininput stream
Returns
input stream

Implements JLANG::JStreamInput.

Definition at line 1195 of file JParser.hh.

1196  {
1197  return in >> object;
1198  }

◆ write()

virtual std::ostream& JPARSER::JParserTemplateElement< JCounter >::write ( std::ostream &  out) const
inlinevirtual

Stream output.

Parameters
outoutput stream
Returns
output stream

Implements JLANG::JStreamOutput.

Definition at line 1207 of file JParser.hh.

1208  {
1209  return out << object;
1210  }

◆ getStatus()

virtual bool JPARSER::JParserTemplateElement< JCounter >::getStatus ( ) const
inlinevirtual

Status of object.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1218 of file JParser.hh.

1219  {
1220  return true;
1221  }

◆ getInitialisationStatus()

virtual bool JPARSER::JParserTemplateElement< JCounter >::getInitialisationStatus ( ) const
inlinevirtual

Get initialisation status of parameter.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1229 of file JParser.hh.

1230  {
1231  return true;
1232  }

◆ setInitialiationStatus()

virtual void JPARSER::JParserTemplateElement< JCounter >::setInitialiationStatus ( const bool  value)
inlinevirtual

Set initialisation status of parameter.

This implementation doesn't do anything.

Parameters
valueinitialisation status

Implements JPARSER::JParserElementInterface.

Definition at line 1241 of file JParser.hh.

1242  {}

◆ gcount()

virtual bool JPARSER::JParserTemplateElement< JCounter >::gcount ( ) const
inlinevirtual

Read counter.

Returns
true if at least one character to be read; else false

Reimplemented from JPARSER::JParserElementInterface.

Definition at line 1250 of file JParser.hh.

1251  {
1252  return false;
1253  }

◆ getName()

const std::string& JPARSER::JParserElementInterface::getName ( ) const
inlineinherited

Get name of parameter.

Returns
name

Definition at line 369 of file JParser.hh.

370  {
371  return __name;
372  }

◆ getHelp()

const std::string& JPARSER::JParserElementInterface::getHelp ( ) const
inlineinherited

Get help of parameter.

Returns
help

Definition at line 380 of file JParser.hh.

381  {
382  return __help;
383  }

◆ print()

virtual void JPARSER::JParserElementInterface::print ( std::ostream &  out) const
inlinevirtualinherited

Print.

Parameters
outoutput stream
Returns
output stream

Reimplemented in JPARSER::JParserTemplateElement< JType_t, true >.

Definition at line 416 of file JParser.hh.

417  {
418  using namespace std;
419 
420  out << "<" << getName() << ">";
421 
422  if (getStatus() && !getShortprint(out)) {
423 
424  int width = WIDTH - getName().length();
425 
426  if (width > 0) {
427  out << setw(width) << " ";
428  }
429 
430  out << " = ";
431 
432  write(out);
433  }
434 
435  if (getLongprint(out) && getHelp() != "") {
436  out << " \"" << getHelp() << "\"";
437  }
438  }

Member Data Documentation

◆ object

Definition at line 1257 of file JParser.hh.

◆ __name

std::string JPARSER::JParserElementInterface::__name
protectedinherited

Definition at line 453 of file JParser.hh.

◆ __help

std::string JPARSER::JParserElementInterface::__help
protectedinherited

Definition at line 454 of file JParser.hh.


The documentation for this class was generated from the following file:
JPARSER::JParserElementInterface::getHelp
const std::string & getHelp() const
Get help of parameter.
Definition: JParser.hh:380
JPARSER::JParserElementInterface::getName
const std::string & getName() const
Get name of parameter.
Definition: JParser.hh:369
JPARSER::JParserElementInterface::getStatus
virtual bool getStatus() const =0
Get status of parameter.
JPARSER::JCounter
Auxiliary class to handle multiple boolean-like I/O.
Definition: JParser.hh:218
getLongprint
bool getLongprint(std::ostream &out)
Get long print option.
Definition: JPrint.hh:157
JPARSER::JParserElementInterface::JParserElementInterface
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor.
Definition: JParser.hh:356
WIDTH
Auxiliary data structure for alignment of data.
Definition: JPrint.hh:267
JPARSER::JParserElementInterface::__name
std::string __name
Definition: JParser.hh:453
JPARSER::JParserTemplateElement< JCounter >::object
JCounter & object
Definition: JParser.hh:1257
std
Definition: jaanetDictionary.h:36
JLANG::JStreamOutput::write
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
getShortprint
bool getShortprint(std::ostream &out)
Get short print option.
Definition: JPrint.hh:111
JPARSER::JParserElementInterface::__help
std::string __help
Definition: JParser.hh:454