Jpp  19.1.0
the software that should make you happy
Public Member Functions | Protected Attributes | Friends | List of all members
JPARSER::JProxy< T, true > Class Template Reference

Template specialisation of JProxy for fundamental data type. More...

#include <JParser.hh>

Public Member Functions

 JProxy (const std::string &option, const T &value)
 Constructor. More...
 
 JProxy (const T &value)
 Constructor. More...
 
const T & getValue () const
 Get actual value. More...
 
const std::string & getOption () const
 Get option. More...
 
const T & getCustom () const
 Get custom value. More...
 
 operator const T & () const
 Type conversion operator. More...
 
JProxyoperator= (const JProxy &object)
 Assignment operator. More...
 
JProxyoperator= (const T &value)
 Assignment to a value. More...
 

Protected Attributes

__value
 
std::string __option
 
__custom
 

Friends

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

Detailed Description

template<class T>
class JPARSER::JProxy< T, true >

Template specialisation of JProxy for fundamental data type.

Definition at line 115 of file JParser.hh.

Constructor & Destructor Documentation

◆ JProxy() [1/2]

template<class T >
JPARSER::JProxy< T, true >::JProxy ( const std::string &  option,
const T &  value 
)
inline

Constructor.

Parameters
optiontextual value
valuecustom value

Definition at line 124 of file JParser.hh.

124  :
125  __value (),
126  __option(option),
127  __custom(value)
128  {}

◆ JProxy() [2/2]

template<class T >
JPARSER::JProxy< T, true >::JProxy ( const T &  value)
inline

Constructor.

Parameters
valueactual value

Definition at line 136 of file JParser.hh.

136  :
137  __value (value),
138  __option(),
139  __custom()
140  {}

Member Function Documentation

◆ getValue()

template<class T >
const T& JPARSER::JProxy< T, true >::getValue ( ) const
inline

Get actual value.

Returns
value

Definition at line 148 of file JParser.hh.

149  {
150  return __value;
151  }

◆ getOption()

template<class T >
const std::string& JPARSER::JProxy< T, true >::getOption ( ) const
inline

Get option.

Returns
option

Definition at line 159 of file JParser.hh.

160  {
161  return __option;
162  }

◆ getCustom()

template<class T >
const T& JPARSER::JProxy< T, true >::getCustom ( ) const
inline

Get custom value.

Returns
value

Definition at line 170 of file JParser.hh.

171  {
172  return __custom;
173  }

◆ operator const T &()

template<class T >
JPARSER::JProxy< T, true >::operator const T & ( ) const
inline

Type conversion operator.

Returns
object

Definition at line 181 of file JParser.hh.

182  {
183  return __value;
184  }

◆ operator=() [1/2]

template<class T >
JProxy& JPARSER::JProxy< T, true >::operator= ( const JProxy< T, true > &  object)
inline

Assignment operator.

Note that only the actual value is assigned.

Parameters
objectobject
Returns
this object

Definition at line 195 of file JParser.hh.

196  {
197  __value = object.__value;
198 
199  return *this;
200  }

◆ operator=() [2/2]

template<class T >
JProxy& JPARSER::JProxy< T, true >::operator= ( const T &  value)
inline

Assignment to a value.

Parameters
valuevalue
Returns
this object

Definition at line 209 of file JParser.hh.

210  {
211  __value = value;
212 
213  return *this;
214  }

Friends And Related Function Documentation

◆ operator>>

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

Read option from input.

Parameters
ininput stream
objectoption
Returns
input stream

Definition at line 224 of file JParser.hh.

225  {
226  using namespace std;
227 
228  string buffer;
229 
230  if (getline(in, buffer)) {
231 
232  if (buffer == object.__option) {
233 
234  object.__value = object.__custom;
235 
236  } else {
237 
238  istringstream is(buffer);
239 
240  is >> object.__value;
241 
242  in.setstate(is.rdstate());
243  }
244  }
245 
246  return in;
247  }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
Definition: JSTDTypes.hh:14

◆ operator<<

template<class T >
std::ostream& operator<< ( std::ostream &  out,
const JProxy< T, true > &  object 
)
friend

Write options to output.

Parameters
outoutput stream
objectoption
Returns
output stream

Definition at line 257 of file JParser.hh.

258  {
259  return out << object.__value;
260  }

Member Data Documentation

◆ __value

template<class T >
T JPARSER::JProxy< T, true >::__value
protected

Definition at line 263 of file JParser.hh.

◆ __option

template<class T >
std::string JPARSER::JProxy< T, true >::__option
protected

Definition at line 264 of file JParser.hh.

◆ __custom

template<class T >
T JPARSER::JProxy< T, true >::__custom
protected

Definition at line 265 of file JParser.hh.


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