libelemental 2.0.2
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Elemental::value_base Class Referenceabstract

A base class for qualified values. More...

#include <value.hh>

Inheritance diagram for Elemental::value_base:
Inheritance graph
[legend]

Public Member Functions

bool has_value () const throw ()
 Returns whether the value is defined.
 
virtual ustring get_string (const ustring &format=ustring()) const throw ()
 Returns a localized text representation of the value.
 
ustring get_tip () const throw ()
 Returns a localized message to be displayed as a tooltip.
 
void make_entry (EntriesView &view, const ustring &name, const ustring &format=ustring()) const throw ()
 Possibly adds the result of get_string() to an EntriesView.
 
virtual int compare (const value_base &other) const throw ()
 Compares two qualified values.
 

Public Attributes

Qualifier qualifier
 The qualification of the value's meaning.
 

Protected Member Functions

 value_base (Qualifier qualifier) throw ()
 
virtual ustring do_get_string (const ustring &format) const throw () =0
 Returns a localized text representation of a defined value.
 
virtual int compare_base (const value_base &other) const throw ()
 Compares the qualifications of two values.
 

Protected Attributes

bool always
 Whether an undefined value should make an entry.
 

Static Protected Attributes

static const int YIELD_COMPARE
 Indicates that comparison should be based on values, not definedness.
 

Detailed Description

A base class for qualified values.

Constructor & Destructor Documentation

◆ value_base()

Elemental::value_base::value_base ( Qualifier  qualifier)
throw (
)
protected
Parameters
qualifierThe qualification of the initial value.

Member Function Documentation

◆ compare()

virtual int Elemental::value_base::compare ( const value_base other) const
throw (
)
virtual

Compares two qualified values.

Derived classes may override this function, first calling compare_base, and use a dynamic_cast to check other.

Parameters
otherThe qualified value for comparison.
Returns
-1 if this value is undefined or is less than other; 0 if the values are equal; or 1 if other is undefined or this value is greater than other.

Reimplemented in Elemental::Message, Elemental::Event, Elemental::Series, Elemental::Block, Elemental::Phase, Elemental::LatticeType, Elemental::ColorValue, Elemental::Value< T >, Elemental::Value< double >, Elemental::Value< ustring >, and Elemental::ValueList< T >.

◆ compare_base()

virtual int Elemental::value_base::compare_base ( const value_base other) const
throw (
)
protectedvirtual

Compares the qualifications of two values.

This base function handles definedness only. Derived classes may override this function to handle qualifiers more specifically.

Parameters
otherThe qualified value for comparison.
Returns
-1 if this value sorts before other; 0 if the values sort equally; 1 if this value sorts after other; or YIELD_COMPARE if the result should be determined based on values.

Reimplemented in Elemental::Event.

◆ do_get_string()

virtual ustring Elemental::value_base::do_get_string ( const ustring &  format) const
throw (
)
protectedpure virtual

Returns a localized text representation of a defined value.

Derived classes must implement this function to produce a text representation based on the format. It will be called by get_string(), which will then decorate its output as appropriate for the current qualifier. If has_value() is false, the behavior is undefined.

Parameters
formatA compose-style format string. Derived classes may define the number of argument references expected in the string; the default is one. If format is empty, a minimal default should be used.
Returns
A UTF-8 string containing the localized representation.

Implemented in Elemental::Message, Elemental::Event, Elemental::Series, Elemental::Block, Elemental::Phase, Elemental::LatticeType, Elemental::ColorValue, Elemental::Value< T >, Elemental::Value< double >, Elemental::Value< ustring >, and Elemental::ValueList< T >.

◆ get_string()

virtual ustring Elemental::value_base::get_string ( const ustring &  format = ustring()) const
throw (
)
virtual

Returns a localized text representation of the value.

Parameters
formatAn optional compose-style format string with which to output the value. If not otherwise specified, the value is argument reference %%1.
Returns
A UTF-8 string containing the localized representation.

Reimplemented in Elemental::Message, and Elemental::Event.

◆ get_tip()

ustring Elemental::value_base::get_tip ( ) const
throw (
)

Returns a localized message to be displayed as a tooltip.

The message may also be displayed parenthetically to the value.

Returns
A UTF-8 string containing the tip text, if any.

◆ has_value()

bool Elemental::value_base::has_value ( ) const
throw (
)

Returns whether the value is defined.

Returns
false if the value is unknown or inapplicable; else true

◆ make_entry()

void Elemental::value_base::make_entry ( EntriesView view,
const ustring &  name,
const ustring &  format = ustring() 
) const
throw (
)

Possibly adds the result of get_string() to an EntriesView.

An entry will only be made if the value is defined or if always is true.

Parameters
viewThe EntriesView to be populated.
nameThe name of the value to be passed.
formatAn optional compose-style format for get_string().

Member Data Documentation

◆ always

bool Elemental::value_base::always
protected

Whether an undefined value should make an entry.

May be set by derived classes. If set to false (default), make_entry() will only populate an EntriesView if has_value() returns true. If set to true, an EntriesView will always be populated.

◆ YIELD_COMPARE

const int Elemental::value_base::YIELD_COMPARE
staticprotected

Indicates that comparison should be based on values, not definedness.

Returned by compare_base() when qualifiers are equivalent.


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