Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JPARSER::JProxy< T, false > Class Template Reference

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

#include <JParser.hh>

Inheritance diagram for JPARSER::JProxy< T, false >:

Public Member Functions

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

Protected Attributes

std::string __option
 
__custom
 

Friends

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

Detailed Description

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

Template specialisation of JProxy for non-fundamental data type.

Definition at line 271 of file JParser.hh.

Constructor & Destructor Documentation

◆ JProxy() [1/2]

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

Constructor.

Parameters
optiontextual value
valuecustom value

Definition at line 281 of file JParser.hh.

281 :
282 T(),
283 __option(option),
284 __custom(value)
285 {}

◆ JProxy() [2/2]

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

Constructor.

Parameters
valueactual value

Definition at line 293 of file JParser.hh.

293 :
294 T(value),
295 __option(),
296 __custom()
297 {}

Member Function Documentation

◆ getValue()

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

Get actual value.

Returns
value

Definition at line 305 of file JParser.hh.

306 {
307 return static_cast<const T&>(*this);
308 }

◆ getOption()

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

Get option.

Returns
option

Definition at line 316 of file JParser.hh.

317 {
318 return __option;
319 }

◆ getCustom()

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

Get custom value.

Returns
value

Definition at line 327 of file JParser.hh.

328 {
329 return __custom;
330 }

◆ operator=() [1/2]

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

Assignment operator.

Note that only the actual value is assigned.

Parameters
objectobject
Returns
this object

Definition at line 341 of file JParser.hh.

342 {
343 static_cast<T&>(*this) = static_cast<const T&>(object);
344
345 return *this;
346 }

◆ operator=() [2/2]

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

Assignment to a value.

Parameters
valuevalue
Returns
this object

Definition at line 355 of file JParser.hh.

356 {
357 static_cast<T&>(*this) = value;
358
359 return *this;
360 }

Friends And Related Symbol Documentation

◆ operator>>

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

Read option from input.

Parameters
ininput stream
objectoption
Returns
input stream

Definition at line 370 of file JParser.hh.

371 {
372 using namespace std;
373
374 string buffer;
375
376 if (getline(in, buffer)) {
377
378 if (buffer == object.__option) {
379
380 static_cast<T&>(object) = object.__custom;
381
382 } else {
383
384 istringstream is(buffer);
385
386 is >> static_cast<T&>(object);
387
388 in.setstate(is.rdstate());
389 }
390 }
391
392 return in;
393 }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478

◆ operator<<

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

Write options to output.

Parameters
outoutput stream
objectoption
Returns
output stream

Definition at line 403 of file JParser.hh.

404 {
405 return out << static_cast<const T&>(object);
406 }

Member Data Documentation

◆ __option

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

Definition at line 409 of file JParser.hh.

◆ __custom

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

Definition at line 410 of file JParser.hh.


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