Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JEEP::JPropertiesElement Class Reference

The property value class. More...

#include <JProperties.hh>

Inheritance diagram for JEEP::JPropertiesElement:

Public Member Functions

 JPropertiesElement ()
 Default constructor.
 
template<class T >
 JPropertiesElement (T &value)
 Constructor.
 
bool equals (const JPropertiesElement &element) const
 Equality between property elements.
 
template<class T >
JPropertiesElementoperator= (T &value)
 Assignment operator.
 
template<class T >
const T & getValue () const
 Get value.
 
template<class T >
T & getValue ()
 Get value.
 
template<class T >
void setValue (const T &value)
 Set value of this JPropertiesElement.
 
std::string toString () const
 Convert to string.
 
template<class T >
toValue () const
 Convert to template type.
 
template<class T >
 operator const T & () const
 Type conversion operator.
 
bool getEndMarker () const
 Get end marker.
 
void setEndMarker (const bool marker)
 Set end marker.
 

Private Attributes

bool end_marker
 

Detailed Description

The property value class.

This class consists of a pointer to the JPropertiesElementInterface. This class implements the assignment and type conversion operators.

Definition at line 294 of file JProperties.hh.

Constructor & Destructor Documentation

◆ JPropertiesElement() [1/2]

JEEP::JPropertiesElement::JPropertiesElement ( )
inline

Default constructor.

Definition at line 301 of file JProperties.hh.

301 :
302 end_marker(false)
303 {}

◆ JPropertiesElement() [2/2]

template<class T >
JEEP::JPropertiesElement::JPropertiesElement ( T & value)
inline

Constructor.

Parameters
valuereference to template object

Definition at line 312 of file JProperties.hh.

312 :
313 end_marker(false)
314 {
315 reset(new JPropertiesTemplateElement<T>(value));
316 }
void reset(T &value)
Reset value.

Member Function Documentation

◆ equals()

bool JEEP::JPropertiesElement::equals ( const JPropertiesElement & element) const
inline

Equality between property elements.

Parameters
elementproperties element
Returns
true if equal; else false

Definition at line 325 of file JProperties.hh.

326 {
327 return get()->equals(*element.get());
328 }

◆ operator=()

template<class T >
JPropertiesElement & JEEP::JPropertiesElement::operator= ( T & value)
inline

Assignment operator.

Parameters
valuereference to template object
Returns
this JPropertiesElement

Definition at line 338 of file JProperties.hh.

339 {
340 reset(new JPropertiesTemplateElement<T>(value));
341
342 return *this;
343 }

◆ getValue() [1/2]

template<class T >
const T & JEEP::JPropertiesElement::getValue ( ) const
inline

Get value.

Returns
value of this JPropertiesElement

Definition at line 352 of file JProperties.hh.

353 {
354 const JPropertiesTemplateElement<T>* p = dynamic_cast<const JPropertiesTemplateElement<T>*>(this->get());
355
356 if (p != NULL)
357 return p->object;
358 else
359 THROW(JPropertiesException, "Inconsistent data type.");
360 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ getValue() [2/2]

template<class T >
T & JEEP::JPropertiesElement::getValue ( )
inline

Get value.

Returns
value of this JPropertiesElement

Definition at line 369 of file JProperties.hh.

370 {
371 JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
372
373 if (p != NULL)
374 return p->object;
375 else
376 THROW(JPropertiesException, "Inconsistent data type.");
377 }

◆ setValue()

template<class T >
void JEEP::JPropertiesElement::setValue ( const T & value)
inline

Set value of this JPropertiesElement.

Parameters
valuevalue

Definition at line 387 of file JProperties.hh.

388 {
389 JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
390
391 if (p != NULL)
392 p->object = value;
393 else
394 THROW(JPropertiesException, "Inconsistent data type.");
395 }

◆ toString()

std::string JEEP::JPropertiesElement::toString ( ) const
inline

Convert to string.

Returns
value of this JPropertiesElement

Definition at line 403 of file JProperties.hh.

404 {
405 std::ostringstream os;
406
407 get()->write(os, "", '\0');
408
409 return os.str();
410 }

◆ toValue()

template<class T >
T JEEP::JPropertiesElement::toValue ( ) const
inline

Convert to template type.

Returns
value of this JPropertiesElement

Definition at line 419 of file JProperties.hh.

420 {
421 T value;
422
423 std::istringstream in(this->toString());
424
425 in >> value;
426
427 return value;
428 }
std::string toString() const
Convert to string.

◆ operator const T &()

template<class T >
JEEP::JPropertiesElement::operator const T & ( ) const
inline

Type conversion operator.

Returns
value of this JPropertiesElement

Definition at line 437 of file JProperties.hh.

438 {
439 return getValue<T>();
440 }
const T & getValue() const
Get value.

◆ getEndMarker()

bool JEEP::JPropertiesElement::getEndMarker ( ) const
inline

Get end marker.

Returns
end marker

Definition at line 448 of file JProperties.hh.

449 {
450 return end_marker;
451 }

◆ setEndMarker()

void JEEP::JPropertiesElement::setEndMarker ( const bool marker)
inline

Set end marker.

Parameters
markerif true stop reading after this properties element, else continue

Definition at line 459 of file JProperties.hh.

460 {
461 end_marker = marker;
462 }

Member Data Documentation

◆ end_marker

bool JEEP::JPropertiesElement::end_marker
private

Definition at line 466 of file JProperties.hh.


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