16#include <TRUSTArray.h>
44 for (
auto &itr : list_parametre_a_lire_)
49 Cerr << proprietaire_ <<
" has optional param. not implemented for lire_sans_accolade" << finl;
54 list_parametre_lu_.add(mot);
64 assert(with_acco == 1);
66 Motcle accolade_ouverte(
"{");
67 Motcle accolade_fermee(
"}");
69 if (motlu != accolade_ouverte)
71 Cerr <<
"Error while reading the parameters of " << proprietaire_ << finl;
72 Cerr <<
"We expected : " << accolade_ouverte <<
" and not " << motlu << finl;
76 while (motlu != accolade_fermee)
81 for (
auto &itr : list_parametre_a_lire_)
89 list_parametre_lu_.add(mot);
96 Cerr <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << finl;
97 Cerr << motlu <<
" is not understood by " << proprietaire_ << finl;
98 Cerr <<
"The understood keywords are : ";
99 for (
int i = 0; i < list_parametre_a_lire_.size(); i++)
100 Cerr << list_parametre_a_lire_(i).get_names_message() <<
" ";
104 if (proprietaire_ ==
"Transformation")
106 if (motlu ==
"fonction")
108 Cerr <<
"Syntax has changed after the 1.6.3 version and fonction keyword is obsoleted." << finl;
109 Cerr <<
"Have a look at the TRUST documentation about Transformation keyword." << finl;
110 Cerr <<
"You should replace 'fonction' by 'methode formule expression nb_comp'" << finl;
111 Cerr <<
"where nb_comp is the number of components of your formulae following the old keyword 'fonction'" << finl;
114 if (motlu ==
"vecteur")
116 Cerr <<
"Syntax has changed after the 1.6.3 version." << finl;
117 Cerr <<
"Have a look at the TRUST documentation about Transformation keyword" << finl;
118 Cerr <<
"You should replace 'vecteur' by 'methode vecteur expression'" << finl;
121 if (motlu ==
"produit_scalaire")
123 Cerr <<
"Syntax has changed after the 1.6.3 version." << finl;
124 Cerr <<
"Have a look at the TRUST documentation about Transformation keyword" << finl;
125 Cerr <<
"You should replace 'produit_scalaire' by 'methode produit_scalaire'" << finl;
139 Motcle accolade_ouverte(
"{");
140 Motcle accolade_fermee(
"}");
141 s << accolade_ouverte << finl;
143 for (
int i = 0; i < list_parametre_a_lire_.size(); i++)
149 s << accolade_fermee << finl;
160 s <<
get_name() <<
" " << (*int_a_lire);
164 Cerr <<
" dico print not coded for this case " <<
get_name() << finl;
169 s <<
get_name() <<
" " << (*double_a_lire);
176 s <<
get_name() <<
" non standard !!!!";
179 Cerr <<
"print not coded for this case " <<
get_name() << finl;
189 for (
auto &itr : list_parametre_a_lire_)
195 if (!list_parametre_lu_.contient(name_var))
197 Cerr << obj.
get_name() <<
" of " << proprietaire_ <<
" has not been read while it is required." << finl;
209 int size = list_parametre_a_lire_.size();
210 for (
int i = 0; i < size; i++)
212 Nom mot_lu(
"is_read_");
213 mot_lu += list_parametre_a_lire_(i).get_name();
214 list_mot.add(mot_lu);
216 for (
int i = 0; i < size; i++)
221 Nom mot_lu(
"value_of_");
222 mot_lu += list_parametre_a_lire_(i).get_name();
223 list_mot.add(mot_lu);
226 int size_agrandi = list_mot.size();
227 int nb_condition = list_conditions_.size();
228 for (
int cond = 0; cond < nb_condition; cond++)
230 Nom condition = list_conditions_(cond);
233 for (
int j = 0; j < size_agrandi; j++)
234 parser.
addVar(list_mot(j));
237 for (
int j = 0; j < size; j++)
239 for (
int lu = 0; lu < list_parametre_lu_.size(); lu++)
241 Nom mot_lu(
"is_read_");
242 mot_lu += list_parametre_lu_(lu);
245 for (
int inc = size; inc < size_agrandi; inc++)
247 Nom mot_lu(list_mot(inc));
249 parser.
setVar(mot_lu, xx);
251 if (parser.
eval() == 0)
254 Cerr <<
" Condition " << list_nom_conditions_(cond) <<
" not verified: " << condition <<
" it's equal to " << parser.
eval() << finl;
255 Cerr << list_message_erreur_conditions_(cond) << finl;
263LIST(
Nom) split_mot(
const Nom& nom)
268 const char *marq = strchr(n0,
'|');
281 marq = strchr(n0,
'|');
295 const int sz = list_parametre_a_lire_.size();
302 const int sz = list_parametre_a_lire_.size();
305 Nom name(proprietaire_);
307 name +=
Nom(nom_option);
318 for (
const auto &itr1 : split_noms)
321 for (
auto &itr2 : list_parametre_a_lire_)
323 if (itr2.comprend_name(name_var))
325 Cerr << name_var <<
" was already a keyword of " << proprietaire_ << finl;
326 Cerr <<
"the old one will be ignored" << finl;
342 Motcle motcle(split_noms(0));
343 for (
auto &itr : list_parametre_a_lire_)
348 list_parametre_a_lire_.suppr(obj);
352 Cerr <<
"Error in Param::supprimer parametre " << mot <<
" not found in " << proprietaire_ << finl;
376 obj.
set_tid(
const_cast<trustIdType*
>(quoi));
391 obj.
set_string(
const_cast<std::string*
>(quoi));
405 Nom name(proprietaire_);
433 obj.
set_vec_int(
const_cast<std::vector<int>*
>(quoi));
441 obj.
set_vec_dbl(
const_cast<std::vector<double>*
>(quoi));
449 obj.
set_vec_str(
const_cast<std::vector<std::string>*
>(quoi));
457 obj.
set_map_int(
const_cast<std::map<std::string, int>*
>(quoi));
464 obj.
set_map_dbl(
const_cast<std::map<std::string, double>*
>(quoi));
471 obj.
set_map_str(
const_cast<std::map<std::string, std::string>*
>(quoi));
479 Cerr <<
"ERROR: flag '" << mot <<
"' is set to true before being passed to Param::ajouter_flag." << finl;
480 Cerr <<
" Flags should be set to false by default. Then, the value will be set to true if the keyword '"<<mot<<
"' is present in the .data file." << finl;
481 Cerr <<
" Change the default value of the flag to 'false' to fix this problem. (This error may come from the parameter not being initialized)" << finl;
487 obj.
set_flag(
const_cast<bool*
>(quoi));
498 list_conditions_.add(
Nom(condition));
499 list_message_erreur_conditions_.add(
Nom(message));
504 nom +=
Nom(list_conditions_.size());
508 list_nom_conditions_.add(nom);
513 int i = list_nom_conditions_.rang(nom);
516 Cerr <<
"Error in Param::supprimer_condition, condition " << nom <<
" not found in " << proprietaire_ << finl;
520 list_conditions_.suppr(list_conditions_(i));
521 list_message_erreur_conditions_.suppr(list_message_erreur_conditions_(i));
522 list_nom_conditions_.suppr(list_nom_conditions_(i));
527 int size = list_parametre_a_lire_.size();
529 for (
int i = 0; i < size; i++)
542 Cerr << mot_lu <<
" not found in Param::get_value" << finl;
543 Cerr <<
"the understood keywords are : ";
544 for (
int i = 0; i < list_parametre_a_lire_.size(); i++)
545 if (list_parametre_a_lire_(i).is_type_simple())
546 Cerr <<
" value_of_" << list_parametre_a_lire_(i).get_name();
Class defining operators and methods for all reading operation in an input flow (file,...
Une chaine de caractere (Nom) en majuscules.
class Nom Une chaine de caractere pour nommer les objets de TRUST
classe Objet_U Cette classe est la classe de base des Objets de TRUST
void set_objet(Objet_U *)
void set_map_int(std::map< std::string, int > *)
void set_tid(trustIdType *)
void set_double(double *)
void read(const Motcle &keyword, Entree &is)
void set_vec_int(std::vector< int > *)
void set_vec_dbl(std::vector< double > *)
void print(Sortie &s) const
int comprend_name(Motcle &mot) const
void set_map_str(std::map< std::string, std::string > *)
void set_arrofint(ArrOfInt *)
void set_nature(Objet_a_lire::Nature n)
void set_map_dbl(std::map< std::string, double > *)
void set_vec_expected_size(int s)
Motcles dictionnaire_noms
void set_arrofdouble(ArrOfDouble *)
ptrParam & add_dict(const char *, int, const char *=0)
void set_non_std(Objet_U *)
void set_vec_str(std::vector< std::string > *)
bool is_type_simple() const
void set_name(const LIST(Nom)&n)
const Nom & get_name() const
Param & create_param(const char *)
void set_string(std::string *)
void supprimer_condition(const char *name)
Remove a previously-registered condition from this Param.
Param(const char *owner_name)
Build a Param that will parse the parameters of an object named owner_name.
const LIST(Nom) &get_list_mots_lus() const
List of keywords that have actually been read from the input.
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
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 se...
Objet_a_lire & create_or_get_objet_a_lire(const char *keyword)
Look up (or create) the Objet_a_lire associated with a keyword string.
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 print(Sortie &s) const
Print the current state of the registered parameters as a { ... } block.
void dictionnaire(const char *option_name, int value)
Add an (option name, integer value) entry to the dictionary attached to a previously registered integ...
int lire_sans_accolade(Entree &is)
Read all required keywords in the order they were registered, without enclosing braces.
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.
int read(Entree &is, int with_acco=1)
Low-level entry point used by lire_avec_accolades_depuis.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
int check()
Validate that every required keyword was read and every condition holds.
Nature
Whether a registered parameter must be present in the input or may be omitted.
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.
int lire_avec_accolades_depuis(Entree &is)
Parse the parameter block { ... } from is.
void supprimer(const char *keyword)
Remove a previously-registered keyword from this Param.
Param()
Default-constructed Param with no owner; only for derived classes.
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.
double get_value(const Nom &mot_lu) const
Retrieve the value of a simple-type parameter by its value_of_<keyword> name.
classe Parser_U Version de la classe Parser, derivant de Objet_U.
void setVar(const char *sv, double val)
void setString(const std::string &s)
void addVar(const char *v)
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.