Jpp 21.0.0-rc.1
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 272 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 282 of file JParser.hh.

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

◆ JProxy() [2/2]

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

Constructor.

Parameters
valueactual value

Definition at line 294 of file JParser.hh.

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

Member Function Documentation

◆ getValue()

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

Get actual value.

Returns
value

Definition at line 306 of file JParser.hh.

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

◆ getOption()

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

Get option.

Returns
option

Definition at line 317 of file JParser.hh.

318 {
319 return __option;
320 }

◆ getCustom()

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

Get custom value.

Returns
value

Definition at line 328 of file JParser.hh.

329 {
330 return __custom;
331 }

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

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

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

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

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

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

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

Member Data Documentation

◆ __option

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

Definition at line 410 of file JParser.hh.

◆ __custom

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

Definition at line 411 of file JParser.hh.


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