Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Private Attributes | List of all members
JPARSER::JParserTemplateElement< bool > Class Template 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)
 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

bool & object
 

Detailed Description

template<>
class JPARSER::JParserTemplateElement< bool >

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

Constructor & Destructor Documentation

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

994  :
995  JParserElementInterface(name, help),
996  object(object)
997  {
998  this->object = false;
999  }
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor.
Definition: JParser.hh:355

Member Function Documentation

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

1010  {
1011  this->object = true;
1012 
1013  return in;
1014  }
virtual std::ostream& JPARSER::JParserTemplateElement< bool >::write ( std::ostream &  out) const
inlinevirtual

Stream output.

Parameters
outoutput stream
Returns
output stream

Implements JLANG::JStreamOutput.

Definition at line 1023 of file JParser.hh.

1024  {
1025  return out << object;
1026  }
virtual bool JPARSER::JParserTemplateElement< bool >::getStatus ( ) const
inlinevirtual

Status of object.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1034 of file JParser.hh.

1035  {
1036  return true;
1037  }
virtual bool JPARSER::JParserTemplateElement< bool >::getInitialisationStatus ( ) const
inlinevirtual

Get initialisation status of parameter.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1045 of file JParser.hh.

1046  {
1047  return true;
1048  }
virtual void JPARSER::JParserTemplateElement< bool >::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 1057 of file JParser.hh.

1058  {}
virtual bool JPARSER::JParserTemplateElement< bool >::gcount ( ) const
inlinevirtual

Read counter.

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

Reimplemented from JPARSER::JParserElementInterface.

Definition at line 1066 of file JParser.hh.

1067  {
1068  return false;
1069  }
const std::string& JPARSER::JParserElementInterface::getName ( ) const
inlineinherited

Get name of parameter.

Returns
name

Definition at line 368 of file JParser.hh.

369  {
370  return __name;
371  }
const std::string& JPARSER::JParserElementInterface::getHelp ( ) const
inlineinherited

Get help of parameter.

Returns
help

Definition at line 379 of file JParser.hh.

380  {
381  return __help;
382  }
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 415 of file JParser.hh.

416  {
417  out << "<" << getName() << ">";
418 
419  if (getStatus() && !getShortprint(out)) {
420 
421  out << " = ";
422 
423  write(out);
424  }
425 
426  if (getLongprint(out) && getHelp() != "") {
427  out << " \"" << getHelp() << "\"";
428  }
429  }
virtual bool getStatus() const =0
Get status of parameter.
const std::string & getName() const
Get name of parameter.
Definition: JParser.hh:368
bool getLongprint(std::ostream &out)
Get long print option.
Definition: JPrint.hh:138
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
bool getShortprint(std::ostream &out)
Get short print option.
Definition: JPrint.hh:92
const std::string & getHelp() const
Get help of parameter.
Definition: JParser.hh:379

Member Data Documentation

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

Definition at line 1073 of file JParser.hh.

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

Definition at line 444 of file JParser.hh.

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

Definition at line 445 of file JParser.hh.


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