Jpp 21.0.0-rc.3
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 113 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 122 of file JParser.hh.

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

◆ JProxy() [2/2]

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

Constructor.

Parameters
valueactual value

Definition at line 134 of file JParser.hh.

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

Member Function Documentation

◆ getValue()

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

Get actual value.

Returns
value

Definition at line 146 of file JParser.hh.

147 {
148 return __value;
149 }

◆ getOption()

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

Get option.

Returns
option

Definition at line 157 of file JParser.hh.

158 {
159 return __option;
160 }

◆ getCustom()

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

Get custom value.

Returns
value

Definition at line 168 of file JParser.hh.

169 {
170 return __custom;
171 }

◆ operator const T &()

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

Type conversion operator.

Returns
object

Definition at line 179 of file JParser.hh.

180 {
181 return __value;
182 }

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

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

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

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

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

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

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

Member Data Documentation

◆ __value

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

Definition at line 261 of file JParser.hh.

◆ __option

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

Definition at line 262 of file JParser.hh.

◆ __custom

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

Definition at line 263 of file JParser.hh.


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