NEST  2.6.0,not_revisioned_source_dir@0
Functions
How to access the value contained in a Token.

Class Token defines the standard user interface for accessing SLI Datum types from tokens (see there). More...

Functions

template<typename FT >
FT getValue (const Token &t)
 getValue provides easy read-access to a Token's contents. More...
 
template<typename FT >
void setValue (const Token &t, FT const &value)
 setValue provides easy write-access to a Token's contents. More...
 
template<typename FT , class D >
Token newToken2 (FT const &value)
 Create a new Token from a fundamental data type. More...
 
template<typename FT >
Token newToken (FT const &value)
 Create a new Token from a fundamental data type. More...
 

Detailed Description

Class Token defines the standard user interface for accessing SLI Datum types from tokens (see there).

However, this user interface returns objects of class Datum, from which the actual value would still need to be extracted. The utilitiy functions described in this group shortcut this step and provide direct access to the underlying fundamental values contained in a token.

Function Documentation

template<typename FT >
FT getValue ( const Token t)

getValue provides easy read-access to a Token's contents.

getValue returns the value of the Datum contained inside the Token.

The general getValue function assumes that the datum was directly derived from a C++ type (most probably some container or stream). All other cases will be handled by specialization of this template.

For example, AggregateDatum types are directly derived from a C++ type.

       SLI Datum          derived from C++ type
      ------------------------------------------
       BoolDatum          Name
       HandleDatum        DatumHandle (whatever that might be...)     
       LiteralDatum       Name
       NameDatum          Name
       ParserDatum        Parser
       StringDatum        string
       SymbolDatum        Name
       
       (What else?)

Hence, getValue may be used in the following ways:

    call                      can be used on Token containing SLI-type
   --------------------------------------------------------------------
    Name   getValue<Name>     {Bool|Literal|Name|Symbol}Datum
    DatumHandle
       getValue<DatumHandle>  HandleDatum
    Parser getValue<Parser>   ParserDatum
    string getValue<string>   StringDatum

The following specialized variants of getValue() can be used in addition:

    call                                    can be used on Token containing SLI-type
   ---------------------------------------------------------------------------------
    long             GetValue<long>              IntegerDatum
    double           GetValue<double>            DoubleDatum
    bool             GetValue<bool>              BoolDatum
    string           GetValue<string>            NameDatum
    string           GetValue<string>            LiteralDatum
    string           GetValue<string>            SymbolDatum
    vector<long>     GetValue<vector<long> >     ArrayDatum
    vector<double>   GetValue<vector<double> >   ArrayDatum
    valarray<long>   GetValue<valarray<long> >   ArrayDatum
    valarray<double> GetValue<valarray<double> > ArrayDatum

What about the rest? (ElementFactoryDatum, el_prtdatum, FunctionDatum, GenericDatum, NumericDatum, lockPTRDatum, ReferenceDatum, SmartPtrDatum, TrieDatum)

Exceptions
TypeMismatchThe specified fundamental datatype does not match the Token's contents, or a template specialization for this type is missing.

References Token::datum().

template<typename FT >
Token newToken ( FT const &  value)

Create a new Token from a fundamental data type.

This template is specialized for the most fundamental types. If it does not work, use newToken2() and specify the Datum type explicitely.

template<typename FT , class D >
Token newToken2 ( FT const &  value)

Create a new Token from a fundamental data type.

Specify the desired Datum type as the second template parameter!

template<typename FT >
void setValue ( const Token t,
FT const &  value 
)

setValue provides easy write-access to a Token's contents.

setValue updates the value of the Datum contained inside the Token.

setValue(Token, value) can be called on the same value/Datum pairs getValue handles. Note that the template parameter to setValue does not need to be specified explicitely, as it can be derived from the second argument.

Exceptions
TypeMismatchThe specified fundamental datatype does not match the Token's contents, or a template specialization for this type is missing.

References Token::datum().