Jpp
 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...
 
T * clone () const
 Get clone of this object. More...
 

Protected Attributes

bool __status
 
__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 103 of file JParser.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 108 of file JParser.hh.

108  :
109  __status(false),
110  __value()
111  {}
template<class T >
JPARSER::JOption< T >::JOption ( const T &  value)
inline

Constructor.

Definition at line 117 of file JParser.hh.

117  :
118  __status(false),
119  __value(value)
120  {}

Member Function Documentation

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

Get status.

Returns
status

Definition at line 128 of file JParser.hh.

129  {
130  return __status;
131  }
template<class T >
JPARSER::JOption< T >::operator const T & ( ) const
inline

Type conversion operator.

Returns
object

Definition at line 139 of file JParser.hh.

140  {
141  return __value;
142  }
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 151 of file JParser.hh.

152  {
153  __status = true;
154  __value = value;
155 
156  return *this;
157  }
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 165 of file JParser.hh.

166  {
167  if (__status)
168  return new T(__value);
169  else
170  return NULL;
171  }

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

182  {
183  object.__status = true;
184 
185  if (!(in >> object.__value)) {
186  in.clear();
187  }
188 
189  return in;
190  }
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 200 of file JParser.hh.

201  {
202  if (object.__status) {
203  out << object.__value;
204  }
205 
206  return out;
207  }

Member Data Documentation

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

Definition at line 210 of file JParser.hh.

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

Definition at line 211 of file JParser.hh.


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