Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPARSER::JParserTemplateElement< JCounter > Class 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.
 
virtual std::istream & read (std::istream &in) override
 Stream input.
 
virtual std::ostream & write (std::ostream &out) const override
 Stream output.
 
virtual bool getStatus () const override
 Status of object.
 
virtual bool getInitialisationStatus () const override
 Get initialisation status of parameter.
 
virtual void setInitialiationStatus (const bool value) override
 Set initialisation status of parameter.
 
virtual bool gcount () const override
 Read counter.
 
const std::string & getName () const
 Get name of parameter.
 
const std::string & getHelp () const
 Get help of parameter.
 
virtual void print (std::ostream &out) const
 Print.
 

Protected Attributes

std::string __name
 
std::string __help
 

Private Attributes

JCounterobject
 

Detailed Description

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

1379 :
1380 JParserElementInterface(name, help),
1381 object(object)
1382 {
1383 this->object = JCounter();
1384 }
Auxiliary class to handle multiple boolean-like I/O.
Definition JParser.hh:423
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor.
Definition JParser.hh:557

Member Function Documentation

◆ read()

virtual std::istream & JPARSER::JParserTemplateElement< JCounter >::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 1394 of file JParser.hh.

1395 {
1396 return in >> object;
1397 }

◆ write()

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

Stream output.

Parameters
outoutput stream
Returns
output stream

Implements JLANG::JStreamOutput.

Definition at line 1406 of file JParser.hh.

1407 {
1408 return out << object;
1409 }

◆ getStatus()

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

Status of object.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1417 of file JParser.hh.

1418 {
1419 return true;
1420 }

◆ getInitialisationStatus()

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

Get initialisation status of parameter.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1428 of file JParser.hh.

1429 {
1430 return true;
1431 }

◆ setInitialiationStatus()

virtual void JPARSER::JParserTemplateElement< JCounter >::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 1440 of file JParser.hh.

1441 {}

◆ gcount()

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

Read counter.

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

Reimplemented from JPARSER::JParserElementInterface.

Definition at line 1449 of file JParser.hh.

1450 {
1451 return false;
1452 }

◆ getName()

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

Get name of parameter.

Returns
name

Definition at line 570 of file JParser.hh.

571 {
572 return __name;
573 }

◆ getHelp()

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

Get help of parameter.

Returns
help

Definition at line 581 of file JParser.hh.

582 {
583 return __help;
584 }

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

617 {
618 using namespace std;
619
620 out << "<" << getName() << ">";
621
622 if (getStatus() && !getShortprint(out)) {
623
624 int width = WIDTH - getName().length();
625
626 if (width > 0) {
627 out << setw(width) << " ";
628 }
629
630 out << " = ";
631
632 write(out);
633 }
634
635 if (getLongprint(out) && getHelp() != "") {
636 out << " \"" << getHelp() << "\"";
637 }
638 }
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.
virtual bool getStatus() const =0
Get status of parameter.
const std::string & getName() const
Get name of parameter.
Definition JParser.hh:570
const std::string & getHelp() const
Get help of parameter.
Definition JParser.hh:581
Auxiliary data structure for alignment of data.
Definition JManip.hh:231

Member Data Documentation

◆ object

Definition at line 1456 of file JParser.hh.

◆ __name

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

Definition at line 653 of file JParser.hh.

◆ __help

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

Definition at line 654 of file JParser.hh.


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