Jpp 21.0.0
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 >
JPropertiesElement & operator= (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 >
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 293 of file JProperties.hh.

Constructor & Destructor Documentation

◆ JPropertiesElement() [1/2]

JEEP::JPropertiesElement::JPropertiesElement ( )
inline

Default constructor.

Definition at line 300 of file JProperties.hh.

300 :
301 end_marker(false)
302 {}

◆ JPropertiesElement() [2/2]

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

Constructor.

Parameters
valuereference to template object

Definition at line 311 of file JProperties.hh.

311 :
312 end_marker(false)
313 {
314 reset(new JPropertiesTemplateElement<T>(value));
315 }
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 324 of file JProperties.hh.

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

◆ operator=()

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

Assignment operator.

Parameters
valuereference to template object
Returns
this JPropertiesElement

Definition at line 337 of file JProperties.hh.

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

◆ getValue() [1/2]

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

Get value.

Returns
value of this JPropertiesElement

Definition at line 351 of file JProperties.hh.

352 {
353 const JPropertiesTemplateElement<T>* p = dynamic_cast<const JPropertiesTemplateElement<T>*>(this->get());
354
355 if (p != NULL)
356 return p->object;
357 else
358 THROW(JPropertiesException, "Inconsistent data type.");
359 }
#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 368 of file JProperties.hh.

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

◆ setValue()

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

Set value of this JPropertiesElement.

Parameters
valuevalue

Definition at line 386 of file JProperties.hh.

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

◆ toString()

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

Convert to string.

Returns
value of this JPropertiesElement

Definition at line 402 of file JProperties.hh.

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

◆ toValue()

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

Convert to template type.

Returns
value of this JPropertiesElement

Definition at line 418 of file JProperties.hh.

419 {
420 T value;
421
422 std::istringstream in(this->toString());
423
424 in >> value;
425
426 return value;
427 }
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 436 of file JProperties.hh.

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

◆ getEndMarker()

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

Get end marker.

Returns
end marker

Definition at line 447 of file JProperties.hh.

448 {
449 return end_marker;
450 }

◆ 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 458 of file JProperties.hh.

459 {
460 end_marker = marker;
461 }

Member Data Documentation

◆ end_marker

bool JEEP::JPropertiesElement::end_marker
private

Definition at line 465 of file JProperties.hh.


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