15#include "arcane/utils/internal/ParameterOption.h"
17#include "arcane/utils/ApplicationInfo.h"
18#include "arcane/utils/ValueConvert.h"
19#include "arcane/utils/Array.h"
20#include "arcane/utils/FatalErrorException.h"
21#include "arcane/utils/ITraceMng.h"
22#include "arcane/utils/Ref.h"
47 ARCANE_ASSERT(tag != ANY_TAG, (
"ANY_TAG without ANY_INDEX is forbidden"));
48 ARCANE_ASSERT(!tag.empty(), (
"tag is empty"));
59 ARCANE_ASSERT(index == ANY_INDEX || tag != ANY_TAG, (
"ANY_TAG without ANY_INDEX is forbidden"));
60 ARCANE_ASSERT(!tag.empty(), (
"tag is empty"));
75Integer ParameterOptionAddrPart::
87 ARCANE_ASSERT(m_index == ANY_INDEX || tag != ANY_TAG, (
"ANY_TAG without ANY_INDEX is forbidden"));
88 ARCANE_ASSERT(!tag.empty(), (
"tag is empty"));
96void ParameterOptionAddrPart::
108 return (m_tag == ANY_TAG && m_index == ANY_INDEX);
117 return (m_tag == other.m_tag || m_tag == ANY_TAG || other.m_tag == ANY_TAG) &&
118 (m_index == other.m_index || m_index == ANY_INDEX || other.m_index == ANY_INDEX || m_index == GET_INDEX || other.m_index == GET_INDEX);
124bool ParameterOptionAddrPart::
136std::ostream&
operator<<(std::ostream& o,
const ParameterOptionAddrPart& h)
138 o << (h.tag() == ParameterOptionAddrPart::ANY_TAG ?
"ANY" : h.tag())
139 <<
"[" << (h.index() == ParameterOptionAddrPart::ANY_INDEX ?
"ANY" : (h.index() == ParameterOptionAddrPart::GET_INDEX ?
"GET" : std::to_string(h.index())))
158 bool have_a_no_any =
false;
162 if (span_line[i] ==
'[') {
167 ARCANE_FATAL(
"Invalid parameter option (empty tag) -- Current read : {0}", current);
169 if (index_begin >= span_line.
size()) {
171 ARCANE_FATAL(
"Invalid parameter option (']' not found) -- Current read : {0}", current);
174 else if (span_line[i] ==
']') {
175 if (index_begin == -1) {
177 ARCANE_FATAL(
"Invalid parameter option (']' found without '[' before) -- Current read : {0}", current);
181 if (index_begin == i) {
183 have_a_no_any =
true;
188 bool is_bad = builtInGetValue(index, index_str);
191 ARCANE_FATAL(
"Invalid index in parameter option -- Current read : {0}", current);
194 have_a_no_any =
true;
198 else if (span_line[i] ==
'/') {
199 if (i + 1 == span_line.
size()) {
201 ARCANE_FATAL(
"Invalid parameter option ('/' found at the end of the param option) -- Current read : {0}", current);
204 if (index_begin == -1) {
212 have_a_no_any =
true;
221 if (index_begin == -1) {
222 size =
static_cast<Integer>(span_line.
size()) - begin;
225 ARCANE_FATAL(
"Invalid parameter option (empty tag) -- Current read : {0}", current);
229 have_a_no_any =
true;
231 if (!have_a_no_any) {
253 if (index_of_part >= m_parts.size()) {
254 if (m_parts[m_parts.size() - 1]->isAny()) {
255 return lastAddrPart();
259 return m_parts[index_of_part].get();
268 return m_parts[m_parts.size() - 1].get();
277 return m_parts.size();
286 if (!
operator==(addr_with_get_index))
293 if (addr_with_get_index.
addrPart(i)->index() == ParameterOptionAddrPart::GET_INDEX) {
295 if (index_tag == ParameterOptionAddrPart::ANY_INDEX)
297 indexes[index++] = index_tag;
310 for (
const auto& elem : m_parts) {
311 if (elem->index() == ParameterOptionAddrPart::GET_INDEX) {
325 if (lastAddrPart()->isAny()) {
328 else if (other.lastAddrPart()->
isAny()) {
338 for (
Integer i = 0; i < nb_iter; ++i) {
349bool ParameterOptionAddr::
361std::ostream&
operator<<(std::ostream& o,
const ParameterOptionAddr& h)
363 Integer nb_part = h.nbAddrPart();
365 o << *(h.addrPart(0));
366 for (
Integer i = 1; i < nb_part; ++i) {
367 o <<
"/" << *(h.addrPart(i));
378ParameterOptionElement::
405bool ParameterOptionElement::
408 return m_addr == addr;
418 addElement(parameter.
view().
subView(2), value.view());
425void ParameterOptionElementsCollection::
428 m_elements.add({ addr, value });
437std::optional<StringView> ParameterOptionElementsCollection::
440 for (
const auto& elem : m_elements) {
453 for (
const auto& elem : m_elements) {
467 for (
const auto& elem : m_elements) {
481 for (
const auto& elem : m_elements) {
482 if (elem.addr().getIndexInAddr(addr_with_get_index, new_indexes)) {
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Vue modifiable d'un tableau d'un type T.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
void addRange(ConstReferenceType val, Int64 n)
Ajoute n élément de valeur val à la fin du tableau.
Classe représentant une partie d'une adresse d'option du jeu de données. À noter qu'en XML,...
ParameterOptionAddrPart()
Constructeur. Définit le tag en ANY_TAG et l'index en ANY_INDEX.
bool isAny() const
isAny si ANY_TAG et ANY_INDEX.
bool operator==(const ParameterOptionAddrPart &other) const
Opérateur d'égalité. Le tag ANY_TAG est égal à tous les tags. L'index ANY_INDEX est égal à tous les i...
void setTag(const StringView tag)
Classe représentant une adresse d'option du jeu de données. Cette adresse doit être de la forme : "ta...
bool operator==(const ParameterOptionAddr &other) const
Opérateur d'égalité. Cet opérateur tient compte des ANY_TAG / ANY_INDEX. L'adresse "aaa[1]/bbb[2]/ANY...
ParameterOptionAddrPart * addrPart(const Integer index_of_part) const
Méthode permettant de récupérer une partie de l'adresse. Si l'adresse termine par un ANY_TAG[ANY_INDE...
ParameterOptionAddr(StringView addr_str_view)
Constructeur.
Integer nbAddrPart() const
Méthode permettant de récupérer le nombre de partie de l'adresse. Les parties égales à "ANY_TAG[ANY_I...
Integer nbIndexToGetInAddr() const
Méthode permettant de savoir combien il y a de "GET_INDEX" dans l'adresse.
bool getIndexInAddr(const ParameterOptionAddr &addr_with_get_index, ArrayView< Integer > indexes) const
Méthode permettant de récupérer un ou plusieurs indices dans l'adresse.
void addAddrPart(ParameterOptionAddrPart *part)
Méthode permettant d'ajouter une partie à la fin de l'adresse actuelle.
bool isExistAddr(const ParameterOptionAddr &addr)
Méthode permettant de savoir si une adresse est présente dans la liste d'éléments....
Integer countAddr(const ParameterOptionAddr &addr)
Méthode permettant de savoir combien de fois une adresse est présente dans la liste d'élements....
void addParameter(const String ¶meter, const String &value)
Méthode permettant d'ajouter un paramètre d'option dans la liste des paramètres d'options.
void getIndexInAddr(const ParameterOptionAddr &addr_with_get_index, UniqueArray< Integer > &indexes)
Méthode permettant de récupérer un ou plusieurs indices dans la liste d'adresses.
constexpr __host__ __device__ SizeType size() const noexcept
Retourne la taille du tableau.
Vue d'un tableau d'éléments de type T.
Vue sur une chaîne de caractères UTF-8.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Retourne la conversion de l'instance dans l'encodage UTF-8.
StringView subView(Int64 pos) const
Sous-chaîne commençant à la position pos.
Chaîne de caractères unicode.
bool startsWith(const String &s) const
Indique si la chaîne commence par les caractères de s.
StringView view() const
Retourne une vue sur la chaîne actuelle.
Vecteur 1D de données avec sémantique par valeur (style STL).
std::ostream & operator<<(std::ostream &o, eExecutionPolicy exec_policy)
Affiche le nom de la politique d'exécution.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.