Jpp 19.3.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 273 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 283 of file JParser.hh.

283 :
284 T(),
285 __option(option),
286 __custom(value)
287 {}

◆ JProxy() [2/2]

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

Constructor.

Parameters
valueactual value

Definition at line 295 of file JParser.hh.

295 :
296 T(value),
297 __option(),
298 __custom()
299 {}

Member Function Documentation

◆ getValue()

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

Get actual value.

Returns
value

Definition at line 307 of file JParser.hh.

308 {
309 return static_cast<const T&>(*this);
310 }

◆ getOption()

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

Get option.

Returns
option

Definition at line 318 of file JParser.hh.

319 {
320 return __option;
321 }

◆ getCustom()

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

Get custom value.

Returns
value

Definition at line 329 of file JParser.hh.

330 {
331 return __custom;
332 }

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

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

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

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

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

373 {
374 using namespace std;
375
376 string buffer;
377
378 if (getline(in, buffer)) {
379
380 if (buffer == object.__option) {
381
382 static_cast<T&>(object) = object.__custom;
383
384 } else {
385
386 istringstream is(buffer);
387
388 is >> static_cast<T&>(object);
389
390 in.setstate(is.rdstate());
391 }
392 }
393
394 return in;
395 }
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 405 of file JParser.hh.

406 {
407 return out << static_cast<const T&>(object);
408 }

Member Data Documentation

◆ __option

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

Definition at line 411 of file JParser.hh.

◆ __custom

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

Definition at line 412 of file JParser.hh.


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