Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 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.
 
 operator const T & () const
 Type conversion operator.
 
JProxyoperator= (const JProxy &object)
 Assignment operator.
 
JProxyoperator= (const T &value)
 Assignment to a value.
 

Protected Attributes

__value
 
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, true >

Template specialisation of JProxy for fundamental data type.

Definition at line 114 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 123 of file JParser.hh.

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

◆ JProxy() [2/2]

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

Constructor.

Parameters
valueactual value

Definition at line 135 of file JParser.hh.

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

Member Function Documentation

◆ getValue()

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

Get actual value.

Returns
value

Definition at line 147 of file JParser.hh.

148 {
149 return __value;
150 }

◆ getOption()

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

Get option.

Returns
option

Definition at line 158 of file JParser.hh.

159 {
160 return __option;
161 }

◆ getCustom()

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

Get custom value.

Returns
value

Definition at line 169 of file JParser.hh.

170 {
171 return __custom;
172 }

◆ operator const T &()

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

Type conversion operator.

Returns
object

Definition at line 180 of file JParser.hh.

181 {
182 return __value;
183 }

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

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

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

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

Friends And Related Symbol 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 223 of file JParser.hh.

224 {
225 using namespace std;
226
227 string buffer;
228
229 if (getline(in, buffer)) {
230
231 if (buffer == object.__option) {
232
233 object.__value = object.__custom;
234
235 } else {
236
237 istringstream is(buffer);
238
239 is >> object.__value;
240
241 in.setstate(is.rdstate());
242 }
243 }
244
245 return in;
246 }
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, true > & object )
friend

Write options to output.

Parameters
outoutput stream
objectoption
Returns
output stream

Definition at line 256 of file JParser.hh.

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

Member Data Documentation

◆ __value

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

Definition at line 262 of file JParser.hh.

◆ __option

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

Definition at line 263 of file JParser.hh.

◆ __custom

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

Definition at line 264 of file JParser.hh.


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