Jpp  19.1.0-rc.1
the software that should make you happy
Public Member Functions | Protected Attributes | Private Attributes | List of all members
JPARSER::JParserTemplateElement< bool > Class Reference

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

#include <JParser.hh>

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

Public Member Functions

 JParserTemplateElement (bool &object, const std::string &name="arg", const std::string &help="")
 Constructor. More...
 
virtual std::istream & read (std::istream &in) override
 Stream input. More...
 
virtual std::ostream & write (std::ostream &out) const override
 Stream output. More...
 
virtual bool getStatus () const override
 Status of object. More...
 
virtual bool getInitialisationStatus () const override
 Get initialisation status of parameter. More...
 
virtual void setInitialiationStatus (const bool value) override
 Set initialisation status of parameter. More...
 
virtual bool gcount () const override
 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

bool & object
 

Detailed Description

Template specialisation of JPARSER::JParserTemplateElement for type bool.

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

Definition at line 1279 of file JParser.hh.

Constructor & Destructor Documentation

◆ JParserTemplateElement()

JPARSER::JParserTemplateElement< bool >::JParserTemplateElement ( bool &  object,
const std::string &  name = "arg",
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 1292 of file JParser.hh.

1292  :
1293  JParserElementInterface(name, help),
1294  object(object)
1295  {
1296  this->object = false;
1297  }
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor.
Definition: JParser.hh:573

Member Function Documentation

◆ read()

virtual std::istream& JPARSER::JParserTemplateElement< bool >::read ( std::istream &  in)
inlineoverridevirtual

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 1307 of file JParser.hh.

1308  {
1309  this->object = true;
1310 
1311  return in;
1312  }

◆ write()

virtual std::ostream& JPARSER::JParserTemplateElement< bool >::write ( std::ostream &  out) const
inlineoverridevirtual

Stream output.

Parameters
outoutput stream
Returns
output stream

Implements JLANG::JStreamOutput.

Definition at line 1321 of file JParser.hh.

1322  {
1323  return out << object;
1324  }

◆ getStatus()

virtual bool JPARSER::JParserTemplateElement< bool >::getStatus ( ) const
inlineoverridevirtual

Status of object.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1332 of file JParser.hh.

1333  {
1334  return true;
1335  }

◆ getInitialisationStatus()

virtual bool JPARSER::JParserTemplateElement< bool >::getInitialisationStatus ( ) const
inlineoverridevirtual

Get initialisation status of parameter.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1343 of file JParser.hh.

1344  {
1345  return true;
1346  }

◆ setInitialiationStatus()

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

Set initialisation status of parameter.

This implementation doesn't do anything.

Parameters
valueinitialisation status

Implements JPARSER::JParserElementInterface.

Definition at line 1355 of file JParser.hh.

1356  {}

◆ gcount()

virtual bool JPARSER::JParserTemplateElement< bool >::gcount ( ) const
inlineoverridevirtual

Read counter.

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

Reimplemented from JPARSER::JParserElementInterface.

Definition at line 1364 of file JParser.hh.

1365  {
1366  return false;
1367  }

◆ getName()

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

Get name of parameter.

Returns
name

Definition at line 586 of file JParser.hh.

587  {
588  return __name;
589  }

◆ getHelp()

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

Get help of parameter.

Returns
help

Definition at line 597 of file JParser.hh.

598  {
599  return __help;
600  }

◆ print()

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

Print.

Parameters
outoutput stream

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

Definition at line 632 of file JParser.hh.

633  {
634  using namespace std;
635 
636  out << "<" << getName() << ">";
637 
638  if (getStatus() && !getShortprint(out)) {
639 
640  int width = WIDTH - getName().length();
641 
642  if (width > 0) {
643  out << setw(width) << " ";
644  }
645 
646  out << " = ";
647 
648  write(out);
649  }
650 
651  if (getLongprint(out) && getHelp() != "") {
652  out << " \"" << getHelp() << "\"";
653  }
654  }
bool getShortprint(std::ostream &out)
Get short print option.
Definition: JManip.hh:75
bool getLongprint(std::ostream &out)
Get long print option.
Definition: JManip.hh:121
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
const std::string & getHelp() const
Get help of parameter.
Definition: JParser.hh:597
virtual bool getStatus() const =0
Get status of parameter.
const std::string & getName() const
Get name of parameter.
Definition: JParser.hh:586
Definition: JSTDTypes.hh:14
Auxiliary data structure for alignment of data.
Definition: JManip.hh:231

Member Data Documentation

◆ object

bool& JPARSER::JParserTemplateElement< bool >::object
private

Definition at line 1371 of file JParser.hh.

◆ __name

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

Definition at line 669 of file JParser.hh.

◆ __help

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

Definition at line 670 of file JParser.hh.


The documentation for this class was generated from the following file: