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 throwing a FatalErrorException.
Modifiable view of an array of type T.
constexpr Integer size() const noexcept
Returns the size of the array.
void addRange(ConstReferenceType val, Int64 n)
Adds n elements of value val to the end of the array.
Class representing a part of a data set option address. Note that in XML, the index starts at 1 and n...
ParameterOptionAddrPart()
Constructor. Sets the tag to ANY_TAG and the index to ANY_INDEX.
bool isAny() const
isAny if ANY_TAG and ANY_INDEX.
bool operator==(const ParameterOptionAddrPart &other) const
Equality operator. The ANY_TAG tag is equal to all tags. The ANY_INDEX index is equal to all indices....
void setTag(const StringView tag)
Class representing a data set option address. This address must be in the form: "tag/tag[index]/tag" ...
bool operator==(const ParameterOptionAddr &other) const
Equality operator. This operator takes into account ANY_TAG / ANY_INDEX. The address "aaa[1]/bbb[2]/A...
ParameterOptionAddrPart * addrPart(const Integer index_of_part) const
Method allowing a part of the address to be retrieved. If the address ends with an ANY_TAG[ANY_INDEX]...
ParameterOptionAddr(StringView addr_str_view)
Constructor.
Integer nbAddrPart() const
Method allowing the number of parts of the address to be retrieved. Parts equal to "ANY_TAG[ANY_INDEX...
Integer nbIndexToGetInAddr() const
Method allowing the number of "GET_INDEX" in the address to be known.
bool getIndexInAddr(const ParameterOptionAddr &addr_with_get_index, ArrayView< Integer > indexes) const
Method allowing one or more indices to be retrieved in the address.
void addAddrPart(ParameterOptionAddrPart *part)
Method allowing a part to be added to the end of the current address.
bool isExistAddr(const ParameterOptionAddr &addr)
Method allowing to know if an address is present in the list of elements. ANY_TAG/ANY_INDEX are taken...
Integer countAddr(const ParameterOptionAddr &addr)
Method allowing to know how many times an address is present in the list of elements....
void addParameter(const String ¶meter, const String &value)
Method allowing an option parameter to be added to the list of option parameters.
void getIndexInAddr(const ParameterOptionAddr &addr_with_get_index, UniqueArray< Integer > &indexes)
Method allowing one or more indices to be retrieved in the list of addresses.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
View of a UTF-8 character string.
constexpr Span< const Byte > bytes() const ARCCORE_NOEXCEPT
Returns the conversion of the instance in UTF-8 encoding.
StringView subView(Int64 pos) const
Substring starting at position pos.
Unicode character string.
bool startsWith(const String &s) const
Indicates if the string starts with the characters of s.
StringView view() const
Returns a view of the current string.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.