Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JPARSER::JOption< T > Class Template Reference

Auxiliary class to handle optional I/O. More...

#include <JParser.hh>

Public Member Functions

 JOption ()
 Default constructor. More...
 
 JOption (const T &value)
 Constructor. More...
 
bool getStatus () const
 Get status. More...
 
 operator const T & () const
 Type conversion operator. More...
 
const JOption< T > & operator= (const T &value)
 Assignment to a value. More...
 
Tclone () const
 Get clone of this object. More...
 

Protected Attributes

bool __status
 
T __value
 

Friends

std::istream & operator>> (std::istream &in, JOption &object)
 Read option from input. More...
 
std::ostream & operator<< (std::ostream &out, const JOption &object)
 Write options to output. More...
 

Detailed Description

template<class T>
class JPARSER::JOption< T >

Auxiliary class to handle optional I/O.

Definition at line 106 of file JParser.hh.

Constructor & Destructor Documentation

template<class T >
JPARSER::JOption< T >::JOption ( )
inline

Default constructor.

Definition at line 111 of file JParser.hh.

111  :
112  __status(false),
113  __value()
114  {}
template<class T >
JPARSER::JOption< T >::JOption ( const T value)
inline

Constructor.

Definition at line 120 of file JParser.hh.

120  :
121  __status(false),
122  __value(value)
123  {}

Member Function Documentation

template<class T >
bool JPARSER::JOption< T >::getStatus ( ) const
inline

Get status.

Returns
status

Definition at line 131 of file JParser.hh.

132  {
133  return __status;
134  }
template<class T >
JPARSER::JOption< T >::operator const T & ( ) const
inline

Type conversion operator.

Returns
object

Definition at line 142 of file JParser.hh.

143  {
144  return __value;
145  }
template<class T >
const JOption<T>& JPARSER::JOption< T >::operator= ( const T value)
inline

Assignment to a value.

Parameters
valuevalue
Returns
this object

Definition at line 154 of file JParser.hh.

155  {
156  __status = true;
157  __value = value;
158 
159  return *this;
160  }
template<class T >
T* JPARSER::JOption< T >::clone ( ) const
inline

Get clone of this object.

Returns
pointer to newly created object if status is okay; else NULL

Definition at line 168 of file JParser.hh.

169  {
170  if (__status)
171  return new T(__value);
172  else
173  return NULL;
174  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T

Friends And Related Function Documentation

template<class T >
std::istream& operator>> ( std::istream &  in,
JOption< T > &  object 
)
friend

Read option from input.

Parameters
ininput stream
objectoption
Returns
input stream

Definition at line 184 of file JParser.hh.

185  {
186  object.__status = true;
187 
188  if (!(in >> object.__value)) {
189  in.clear();
190  }
191 
192  return in;
193  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
template<class T >
std::ostream& operator<< ( std::ostream &  out,
const JOption< T > &  object 
)
friend

Write options to output.

Parameters
outoutput stream
objectoption
Returns
output stream

Definition at line 203 of file JParser.hh.

204  {
205  if (object.__status) {
206  out << object.__value;
207  }
208 
209  return out;
210  }

Member Data Documentation

template<class T >
bool JPARSER::JOption< T >::__status
protected

Definition at line 213 of file JParser.hh.

template<class T >
T JPARSER::JOption< T >::__value
protected

Definition at line 214 of file JParser.hh.


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