TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Param Class Reference

Helper class to factorize the readOn method of Objet_U classes. More...

#include <Param.h>

Public Types

enum  Nature { OPTIONAL = 0 , REQUIRED = 1 }
 Whether a registered parameter must be present in the input or may be omitted. More...

Public Member Functions

 Param (const char *owner_name)
 Build a Param that will parse the parameters of an object named owner_name.
void ajouter (const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
 Register an integer parameter.
void ajouter (const char *keyword, const double *value, Param::Nature nat=Param::OPTIONAL)
 Register a floating-point parameter.
void ajouter (const char *keyword, const std::string *value, Param::Nature nat=Param::OPTIONAL)
 Register a string parameter.
void ajouter (const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
 Register an Objet_U parameter read with its standard readOn.
void ajouter_arr_size_predefinie (const char *keyword, const ArrOfInt *value, Param::Nature nat=Param::OPTIONAL)
 Register an ArrOfInt whose size has already been fixed.
void ajouter_arr_size_predefinie (const char *keyword, const ArrOfDouble *value, Param::Nature nat=Param::OPTIONAL)
 Register an ArrOfDouble whose size has already been fixed.
void ajouter (const char *keyword, const std::vector< int > *value, Param::Nature nat=Param::OPTIONAL, int size=-1)
 Register a vector of integers.
void ajouter (const char *keyword, const std::vector< double > *value, Param::Nature nat=Param::OPTIONAL, int size=-1)
 Register a vector of doubles.
void ajouter (const char *keyword, const std::vector< std::string > *value, Param::Nature nat=Param::OPTIONAL, int size=-1)
 Register a vector of strings.
template<typename T>
void ajouter (const char *keyword, const std::vector< TRUST_Deriv< T > > *value, Param::Nature nat=Param::OPTIONAL, int size=-1)
 Register a vector of OWN_PTR-like objects (TRUST_Deriv<T>).
void ajouter (const char *keyword, const std::map< std::string, int > *value, Param::Nature nat=Param::OPTIONAL)
 Register a map from string keys to integer values.
void ajouter (const char *keyword, const std::map< std::string, double > *value, Param::Nature nat=Param::OPTIONAL)
 Register a map from string keys to double values.
void ajouter (const char *keyword, const std::map< std::string, std::string > *value, Param::Nature nat=Param::OPTIONAL)
 Register a map from string keys to string values.
template<typename T>
void ajouter (const char *keyword, const std::map< std::string, TRUST_Deriv< T > > *value, Param::Nature nat=Param::OPTIONAL)
 Register a map from string keys to OWN_PTR-like objects (TRUST_Deriv<T>).
void ajouter_flag (const char *keyword, const bool *value)
 Register a boolean flag whose mere presence switches it to true.
Paramajouter_param (const char *keyword, Param::Nature nat=Param::OPTIONAL)
 Register a nested Param block and return a reference to it so it can be populated in turn.
void ajouter_non_std (const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
 Register a keyword handled by Objet_U::lire_motcle_non_standard.
void ajouter_condition (const char *condition, const char *message, const char *name=0)
 Declare a post-read logical condition that must hold on the parameter values.
void supprimer (const char *keyword)
 Remove a previously-registered keyword from this Param.
void supprimer_condition (const char *name)
 Remove a previously-registered condition from this Param.
void dictionnaire (const char *option_name, int value)
 Add an (option name, integer value) entry to the dictionary attached to a previously registered integer parameter.
Paramdictionnaire_param (const char *option_name, int value)
 Same as dictionnaire, but also attaches a nested Param block that will be read when this option is selected.
void ajouter_int (const char *c, const int *val, Param::Nature nat=Param::OPTIONAL)
 Alias of ajouter(const char*, const int*, Nature).
void ajouter_double (const char *c, const double *val, Param::Nature nat=Param::OPTIONAL)
 Alias of ajouter(const char*, const double*, Nature).
void ajouter_objet (const char *c, const Objet_U *obj, Param::Nature nat=Param::OPTIONAL)
 Alias of ajouter(const char*, const Objet_U*, Nature).
int lire_avec_accolades_depuis (Entree &is)
 Parse the parameter block { ... } from is.
int lire_sans_accolade (Entree &is)
 Read all required keywords in the order they were registered, without enclosing braces.
int lire_avec_accolades (Entree &is)
 Alias of lire_avec_accolades_depuis.
int read (Entree &is, int with_acco=1)
 Low-level entry point used by lire_avec_accolades_depuis.
void print (Sortie &s) const
 Print the current state of the registered parameters as a { ... } block.
const LIST (Nom) &get_list_mots_lus() const
 List of keywords that have actually been read from the input.
double get_value (const Nom &mot_lu) const
 Retrieve the value of a simple-type parameter by its value_of_<keyword> name.
int check ()
 Validate that every required keyword was read and every condition holds.

Protected Member Functions

 Param ()
 Default-constructed Param with no owner; only for derived classes.
Objet_a_lirecreate_or_get_objet_a_lire (const char *keyword)
 Look up (or create) the Objet_a_lire associated with a keyword string.

Detailed Description

Helper class to factorize the readOn method of Objet_U classes.

Param provides a declarative, keyword-based way to parse a block of parameters from an input stream (typically a .data file enclosed in { ... }). Instead of manually reading tokens in a readOn method, the developer registers each expected keyword along with a pointer to the variable that should receive its value, then calls lire_avec_accolades_depuis() to perform the actual parsing.

Supported registrations include:

  • simple scalar types: int, double, std::string, bool (flag)
  • Objet_U references (standard and non-standard via lire_motcle_non_standard)
  • fixed-size arrays: ArrOfInt, ArrOfDouble (size must be set before reading)
  • STL containers: std::vector<T> and std::map<std::string, T> with T being int, double, std::string, or TRUST_Deriv<U> (see below for the exact syntaxes supported)
  • nested Param blocks (see ajouter_param)
  • dictionaries mapping string options to integer values (see dictionnaire)
  • logical post-conditions evaluated after the read (see ajouter_condition)

Each registered keyword can be marked as OPTIONAL (default) or REQUIRED. Missing required keywords cause the read to fail in check().

Synonyms (translations) for a keyword can be declared by separating alternative spellings with a pipe character. For example:

param.ajouter("keyword|french_keyword|japan_keyword", &my_var);

Any of the three spellings will be accepted in the input file. See Schema_Temps_base.cpp for a real-world example.

Typical usage
// Inside some Objet_U::readOn(Entree& is)
Param param(que_suis_je());
int a = 0, b = 0;
param.ajouter("a", &a, Param::REQUIRED);
param.ajouter("b", &b); // optional
param.lire_avec_accolades_depuis(is); // expects { a 1 b 2 }
Param(const char *owner_name)
Build a Param that will parse the parameters of an object named owner_name.
Definition Param.cpp:20
@ REQUIRED
Definition Param.h:115
Vector and map syntaxes
Every ajouter overload that registers a std::vector<T> or a std::map<std::string, T> (with T being int, double, std::string or TRUST_Deriv<U>) accepts two interchangeable syntaxes. Spaces are always required between all tokens.
  • Historical TRUST syntax
    • Vectors declare the element count first, followed by the elements:
      <keyword> 2 v1 v2
    • Maps are enclosed in {} with alternating key/value pairs:
      <keyword> { key1 val1 key2 val2 }
  • JSON/Python-like syntax
    • Vectors are enclosed in brackets with comma-separated elements:
      <keyword> [ v1 , v2 , ... ]
    • Maps use key : value pairs separated by commas (a trailing comma is allowed):
      <keyword> { key1 : val1 , key2 : val2 }

For TRUST_Deriv<U> (OWN_PTR-like) element types, each individual object must specify its concrete type first, followed by whatever content its readOn expects. In maps of such objects, each value is automatically named using its map key. For example, given a std::map<std::string, TRUST_Deriv<Nom>>:

my_map { nom1 : Nom foo , nom2 : Nom bar , nom3 : Motcle foobar }
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31

will produce a map where my_map.at("nom1") is named "nom1" and my_map.at("nom3") can be ref_cast to a Motcle.

Duplicate map keys are rejected with a fatal error, and for vectors whose expected size has been set via the size argument, a mismatch between the declared and the read length is also fatal.

For detailed examples, see the unit tests in unit_params.cpp.

Definition at line 111 of file Param.h.

Member Enumeration Documentation

◆ Nature

Whether a registered parameter must be present in the input or may be omitted.

Enumerator
OPTIONAL 
REQUIRED 

Definition at line 115 of file Param.h.

Constructor & Destructor Documentation

◆ Param() [1/2]

Param::Param ( const char * owner_name)

Build a Param that will parse the parameters of an object named owner_name.

Parameters
owner_nameHuman-readable name of the owning object, used to produce informative error messages when parsing fails.

Definition at line 20 of file Param.cpp.

◆ Param() [2/2]

Param::Param ( )
protected

Default-constructed Param with no owner; only for derived classes.

Member Function Documentation

◆ ajouter() [1/12]

void Param::ajouter ( const char * keyword,
const double * value,
Param::Nature nat = Param::OPTIONAL )

Register a floating-point parameter.

Expected syntax:

<keyword> <double_value>

For example:

tmax 1.5e-3
Parameters
keywordName of the keyword.
valuePointer to the double that will be written when the keyword is read.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 380 of file Param.cpp.

◆ ajouter() [2/12]

void Param::ajouter ( const char * keyword,
const int * value,
Param::Nature nat = Param::OPTIONAL )

Register an integer parameter.

Expected syntax in the input file:

<keyword> <integer_value>

For example, if the keyword is nb_pas_dt_max, the input would contain:

nb_pas_dt_max 100
Parameters
keywordName of the keyword (optionally with synonyms separated by |).
valuePointer to the int that will be written when the keyword is read. The pointer must remain valid until the read operation completes.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 364 of file Param.cpp.

◆ ajouter() [3/12]

void Param::ajouter ( const char * keyword,
const Objet_U * value,
Param::Nature nat = Param::OPTIONAL )

Register an Objet_U parameter read with its standard readOn.

The content that follows the keyword is forwarded to the object's operator>> (i.e. its readOn method). The exact expected syntax therefore depends on the concrete type of the object.

Expected syntax:

<keyword> <whatever readOn expects for this object>
Parameters
keywordName of the keyword.
valuePointer to the Objet_U subclass that will be filled when the keyword is read. Must remain valid until the read completes.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 394 of file Param.cpp.

◆ ajouter() [4/12]

void Param::ajouter ( const char * keyword,
const std::map< std::string, double > * value,
Param::Nature nat = Param::OPTIONAL )

Register a map from string keys to double values.

Expected syntax (either of the two below):

<keyword> { <key_1> <v_1> <key_2> <v_2> ... } // historical TRUST syntax
<keyword> { <key_1> : <v_1> , <key_2> : <v_2> , ... } // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::map<std::string, double> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 460 of file Param.cpp.

◆ ajouter() [5/12]

void Param::ajouter ( const char * keyword,
const std::map< std::string, int > * value,
Param::Nature nat = Param::OPTIONAL )

Register a map from string keys to integer values.

Expected syntax (either of the two below):

<keyword> { <key_1> <v_1> <key_2> <v_2> ... } // historical TRUST syntax
<keyword> { <key_1> : <v_1> , <key_2> : <v_2> , ... } // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::map<std::string, int> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 452 of file Param.cpp.

◆ ajouter() [6/12]

void Param::ajouter ( const char * keyword,
const std::map< std::string, std::string > * value,
Param::Nature nat = Param::OPTIONAL )

Register a map from string keys to string values.

Each string value is read as a single whitespace-delimited token.

Expected syntax (either of the two below):

<keyword> { <key_1> <s_1> <key_2> <s_2> ... } // historical TRUST syntax
<keyword> { <key_1> : <s_1> , <key_2> : <s_2> , ... } // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::map<std::string, std::string> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 467 of file Param.cpp.

◆ ajouter() [7/12]

template<typename T>
void Param::ajouter ( const char * keyword,
const std::map< std::string, TRUST_Deriv< T > > * value,
Param::Nature nat = Param::OPTIONAL )

Register a map from string keys to OWN_PTR-like objects (TRUST_Deriv<T>).

Each value must specify its concrete type first, followed by whatever content its readOn expects. After reading, each object is named using the key it is registered under (via nommer), and each value is type-checked against T: a value whose concrete type is not a subtype of T triggers a fatal error.

Expected syntax (either of the two below):

// Historical TRUST syntax
<keyword> { <key_1> <Type_1> <readOn content_1> <key_2> <Type_2> <readOn content_2> ... }
// JSON/Python-like syntax
<keyword> { <key_1> : <Type_1> <readOn content_1> , <key_2> : <Type_2> <readOn content_2> , ... }

See the class-level documentation for a concrete example.

Template Parameters
TBase type of the polymorphic objects stored as map values; each read value must be a subtype of T.
Parameters
keywordName of the keyword.
valuePointer to the std::map<std::string, TRUST_Deriv<T>> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 685 of file Param.h.

◆ ajouter() [8/12]

void Param::ajouter ( const char * keyword,
const std::string * value,
Param::Nature nat = Param::OPTIONAL )

Register a string parameter.

Expected syntax:

<keyword> <single_token>

The value is read as a single whitespace-delimited token.

Parameters
keywordName of the keyword.
valuePointer to the std::string that will be written when the keyword is read.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 387 of file Param.cpp.

◆ ajouter() [9/12]

void Param::ajouter ( const char * keyword,
const std::vector< double > * value,
Param::Nature nat = Param::OPTIONAL,
int size = -1 )

Register a vector of doubles.

Expected syntax (either of the two below):

<keyword> <N> <v_1> <v_2> ... <v_N> // historical TRUST syntax
<keyword> [ <v_1> , <v_2> , ... , <v_N> ] // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::vector<double> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).
sizeIf non-negative, the expected number of elements. Use -1 (the default) to accept any length.

Definition at line 436 of file Param.cpp.

◆ ajouter() [10/12]

void Param::ajouter ( const char * keyword,
const std::vector< int > * value,
Param::Nature nat = Param::OPTIONAL,
int size = -1 )

Register a vector of integers.

Expected syntax (either of the two below):

<keyword> <N> <v_1> <v_2> ... <v_N> // historical TRUST syntax
<keyword> [ <v_1> , <v_2> , ... , <v_N> ] // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::vector<int> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).
sizeIf non-negative, the expected number of elements. A read whose length differs from this value is treated as an error. Use -1 (the default) to accept any length.

Definition at line 427 of file Param.cpp.

◆ ajouter() [11/12]

void Param::ajouter ( const char * keyword,
const std::vector< std::string > * value,
Param::Nature nat = Param::OPTIONAL,
int size = -1 )

Register a vector of strings.

Each string element is read as a single whitespace-delimited token.

Expected syntax (either of the two below):

<keyword> <N> <s_1> <s_2> ... <s_N> // historical TRUST syntax
<keyword> [ <s_1> , <s_2> , ... , <s_N> ] // JSON/Python-like syntax
Parameters
keywordName of the keyword.
valuePointer to the std::vector<std::string> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).
sizeIf non-negative, the expected number of elements. Use -1 (the default) to accept any length.

Definition at line 444 of file Param.cpp.

◆ ajouter() [12/12]

template<typename T>
void Param::ajouter ( const char * keyword,
const std::vector< TRUST_Deriv< T > > * value,
Param::Nature nat = Param::OPTIONAL,
int size = -1 )

Register a vector of OWN_PTR-like objects (TRUST_Deriv<T>).

Each element must specify its concrete type first, followed by whatever content its readOn expects. At read time, each entry is type-checked: a value whose concrete type is not a subtype of T triggers a fatal error.

Expected syntax (either of the two below):

// Historical TRUST syntax
<keyword> <N> <Type_1> <readOn content_1> <Type_2> <readOn content_2> ...
// JSON/Python-like syntax
<keyword> [ <Type_1> <readOn content_1> , <Type_2> <readOn content_2> , ... ]
Template Parameters
TBase type of the polymorphic objects stored in the vector; each read element must be a subtype of T.
Parameters
keywordName of the keyword.
valuePointer to the std::vector<TRUST_Deriv<T>> that will be filled.
natWhether the keyword is REQUIRED or OPTIONAL (default).
sizeIf non-negative, the expected number of elements. Use -1 (the default) to accept any length.

Definition at line 646 of file Param.h.

◆ ajouter_arr_size_predefinie() [1/2]

void Param::ajouter_arr_size_predefinie ( const char * keyword,
const ArrOfDouble * value,
Param::Nature nat = Param::OPTIONAL )

Register an ArrOfDouble whose size has already been fixed.

Same contract as ajouter_arr_size_predefinie(const char*, const ArrOfInt*, ...) but for doubles.

Expected syntax (for an array of size N):

<keyword> <v_1> <v_2> ... <v_N>
Parameters
keywordName of the keyword.
valuePointer to the ArrOfDouble; its size must be set before calling lire_avec_accolades_depuis.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 417 of file Param.cpp.

◆ ajouter_arr_size_predefinie() [2/2]

void Param::ajouter_arr_size_predefinie ( const char * keyword,
const ArrOfInt * value,
Param::Nature nat = Param::OPTIONAL )

Register an ArrOfInt whose size has already been fixed.

The array must have been resized to its expected number of elements before the read takes place. Exactly that many integers will be consumed from the stream.

Expected syntax (for an array of size N):

<keyword> <v_1> <v_2> ... <v_N>
Parameters
keywordName of the keyword.
valuePointer to the ArrOfInt; its size must be set before calling lire_avec_accolades_depuis.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 411 of file Param.cpp.

◆ ajouter_condition()

void Param::ajouter_condition ( const char * condition,
const char * message,
const char * name = 0 )

Declare a post-read logical condition that must hold on the parameter values.

The condition is a formula expression, evaluated after the whole block has been read. Registered parameters contribute two kinds of variables to the expression:

  • is_read_<keyword>: 1 if the keyword was read, 0 otherwise
  • value_of_<keyword>: the numerical value, for simple-type parameters (int, double, bool flag) only

If the condition evaluates to false, the read fails and message is reported.

Parameters
conditionFormula string to evaluate.
messageHuman-readable explanation displayed when the condition fails.
nameOptional identifier for the condition, used by supprimer_condition. If nullptr, a name is generated.

Definition at line 496 of file Param.cpp.

◆ ajouter_double()

void Param::ajouter_double ( const char * c,
const double * val,
Param::Nature nat = Param::OPTIONAL )
inline

Alias of ajouter(const char*, const double*, Nature).

Definition at line 534 of file Param.h.

◆ ajouter_flag()

void Param::ajouter_flag ( const char * keyword,
const bool * value )

Register a boolean flag whose mere presence switches it to true.

The flag must hold false when it is registered (otherwise a fatal error is raised): flags are toggled on only when the keyword is encountered in the input. Flags are always optional.

Expected syntax (the keyword appears alone, no associated value):

<keyword>
Parameters
keywordName of the flag.
valuePointer to the bool that will be set to true if the keyword is present. Must be false at the moment of registration.

Definition at line 474 of file Param.cpp.

◆ ajouter_int()

void Param::ajouter_int ( const char * c,
const int * val,
Param::Nature nat = Param::OPTIONAL )
inline

Alias of ajouter(const char*, const int*, Nature).

Definition at line 532 of file Param.h.

◆ ajouter_non_std()

void Param::ajouter_non_std ( const char * keyword,
const Objet_U * value,
Param::Nature nat = Param::OPTIONAL )

Register a keyword handled by Objet_U::lire_motcle_non_standard.

Use this when the content that follows the keyword cannot be described by any of the standard overloads of ajouter and requires ad hoc parsing in the object itself.

Parameters
keywordName of the keyword.
valuePointer to the Objet_U whose lire_motcle_non_standard will be called with the keyword and the input stream.
natWhether the keyword is REQUIRED or OPTIONAL (default).

Definition at line 489 of file Param.cpp.

◆ ajouter_objet()

void Param::ajouter_objet ( const char * c,
const Objet_U * obj,
Param::Nature nat = Param::OPTIONAL )
inline

Alias of ajouter(const char*, const Objet_U*, Nature).

Definition at line 536 of file Param.h.

◆ ajouter_param()

Param & Param::ajouter_param ( const char * keyword,
Param::Nature nat = Param::OPTIONAL )

Register a nested Param block and return a reference to it so it can be populated in turn.

The nested block has its own { ... } scope in the input file.

Parameters
keywordName of the nested block.
natWhether the block is REQUIRED or OPTIONAL (default).
Returns
A reference to the newly-created nested Param, on which ajouter(...) can be called to declare its own sub-parameters.

Definition at line 401 of file Param.cpp.

◆ check()

int Param::check ( )

Validate that every required keyword was read and every condition holds.

Called automatically by lire_avec_accolades_depuis and lire_sans_accolade.

Returns
1 if every check succeeded, 0 otherwise.

Definition at line 184 of file Param.cpp.

◆ create_or_get_objet_a_lire()

Objet_a_lire & Param::create_or_get_objet_a_lire ( const char * keyword)
protected

Look up (or create) the Objet_a_lire associated with a keyword string.

renvoit Objet_a_lire correspondant au mot le rajoute au besoin a la liste

The keyword string may contain synonyms separated by |. If any of the spellings is already used, a fatal error is raised.

Parameters
keywordKeyword string, possibly containing synonyms.
Returns
A reference to the underlying Objet_a_lire to be configured by the caller.

Definition at line 314 of file Param.cpp.

◆ dictionnaire()

void Param::dictionnaire ( const char * nom_option,
int valeur )

Add an (option name, integer value) entry to the dictionary attached to a previously registered integer parameter.

Si le dernier parametre ajoute est de type "int", associe a ce parametre une ou plusieurs chaines de caracteres et pour chacune une valeur numerique.

Once a dictionary has been attached to an integer parameter, the input file must provide one of the option names (instead of a raw integer); the registered int receives the associated value.

Parameters
option_nameTextual option name as it will appear in the input file.
valueInteger value assigned to the parameter when option_name is encountered.

Il faut appeler dictionnaire pour chaque motcle autorise pour ce parametre Le parametre lu doit alors etre un motcle parmi ceux du dictionnaire de noms autorises.

Definition at line 293 of file Param.cpp.

◆ dictionnaire_param()

Param & Param::dictionnaire_param ( const char * option_name,
int value )

Same as dictionnaire, but also attaches a nested Param block that will be read when this option is selected.

Parameters
option_nameTextual option name.
valueInteger value assigned to the parameter when option_name is encountered.
Returns
A reference to the nested Param associated with this option.

Definition at line 300 of file Param.cpp.

◆ get_value()

double Param::get_value ( const Nom & mot_lu) const

Retrieve the value of a simple-type parameter by its value_of_<keyword> name.

Only works for parameters of simple types (int, double, bool flag).

Parameters
mot_luName in the form value_of_<keyword>.
Returns
The parameter value as a double; fatal if the parameter is unknown.

Definition at line 525 of file Param.cpp.

◆ lire_avec_accolades()

int Param::lire_avec_accolades ( Entree & is)
inline

Alias of lire_avec_accolades_depuis.

Definition at line 577 of file Param.h.

◆ lire_avec_accolades_depuis()

int Param::lire_avec_accolades_depuis ( Entree & is)

Parse the parameter block { ... } from is.

Read the is input with the parameters (defined with the Param object) inside: { .

Expects an opening brace, then alternating keywords and values (or blocks), then a closing brace. Required keywords that are missing, unknown keywords, and condition failures all trigger a fatal error.

Example
To read { a 1 b 2 }:
Param param(que_suis_je());
int a, b;
param.ajouter("a", &a);
param.ajouter("b", &b);
param.lire_avec_accolades_depuis(is);
Parameters
isInput stream positioned just before the opening brace.
Returns
1 on success; fatal on error.

.. } Example, to read: { a 1 b 2 } Param param(que_suis_je()); int a,b; param.ajouter("a",&a); param.ajouter("b",&b); param.lire_avec_accolades_depuis(is);

Definition at line 32 of file Param.cpp.

◆ lire_sans_accolade()

int Param::lire_sans_accolade ( Entree & is)

Read all required keywords in the order they were registered, without enclosing braces.

Only works when every registered parameter is REQUIRED. Optional parameters are not supported in this mode.

Parameters
isInput stream.
Returns
1 on success; fatal on error.

Definition at line 41 of file Param.cpp.

◆ LIST()

const Param::LIST ( Nom ) const &
inline

List of keywords that have actually been read from the input.

Definition at line 599 of file Param.h.

◆ print()

void Param::print ( Sortie & s) const

Print the current state of the registered parameters as a { ... } block.

Not implemented for every parameter type; falls back to a fatal error for unsupported types.

Parameters
sOutput stream to print into.

Definition at line 135 of file Param.cpp.

◆ read()

int Param::read ( Entree & is,
int with_acco = 1 )

Low-level entry point used by lire_avec_accolades_depuis.

Parameters
isInput stream.
with_accoMust be 1 (no other mode currently supported).
Returns
1 on success; fatal on error.

Definition at line 62 of file Param.cpp.

◆ supprimer()

void Param::supprimer ( const char * keyword)

Remove a previously-registered keyword from this Param.

Parameters
keywordName of the keyword to remove. Must have been registered earlier.

Definition at line 339 of file Param.cpp.

◆ supprimer_condition()

void Param::supprimer_condition ( const char * name)

Remove a previously-registered condition from this Param.

Parameters
nameName of the condition, as passed to ajouter_condition.

Definition at line 510 of file Param.cpp.


The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/cea-trust-platform/checkouts/master/src/Kernel/Utilitaires/Param.h
  • /home/docs/checkouts/readthedocs.org/user_builds/cea-trust-platform/checkouts/master/src/Kernel/Utilitaires/Param.cpp