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

1077  :
1079  object(object)
1080  {
1081  this->object = false;
1082  }
then echo n User name
Definition: JCookie.sh:45
JParserElementInterface(const std::string &name="arg", const std::string &help="")
Constructor.
Definition: JParser.hh:356

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

1093  {
1094  this->object = true;
1095 
1096  return in;
1097  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
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 1106 of file JParser.hh.

1107  {
1108  return out << object;
1109  }
virtual bool JPARSER::JParserTemplateElement< bool >::getStatus ( ) const
inlinevirtual

Status of object.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1117 of file JParser.hh.

1118  {
1119  return true;
1120  }
virtual bool JPARSER::JParserTemplateElement< bool >::getInitialisationStatus ( ) const
inlinevirtual

Get initialisation status of parameter.

Returns
true

Implements JPARSER::JParserElementInterface.

Definition at line 1128 of file JParser.hh.

1129  {
1130  return true;
1131  }
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 1140 of file JParser.hh.

1141  {}
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 1149 of file JParser.hh.

1150  {
1151  return false;
1152  }
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  }
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  }
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  }
Auxiliary data structure for alignment of data.
Definition: JPrint.hh:267
virtual bool getStatus() const =0
Get status of parameter.
const std::string & getName() const
Get name of parameter.
Definition: JParser.hh:369
bool getLongprint(std::ostream &out)
Get long print option.
Definition: JPrint.hh:157
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
bool getShortprint(std::ostream &out)
Get short print option.
Definition: JPrint.hh:111
const std::string & getHelp() const
Get help of parameter.
Definition: JParser.hh:380

Member Data Documentation

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

Definition at line 1156 of file JParser.hh.

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

Definition at line 453 of file JParser.hh.

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: