Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ParameterOption.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ParameterOption.h (C) 2000-2025 */
9/* */
10/* Class representing the set of parameters that can modify the */
11/* data set options. */
12/*---------------------------------------------------------------------------*/
13
14#ifndef ARCANE_UTILS_INTERNAL_PARAMETEROPTION_H
15#define ARCANE_UTILS_INTERNAL_PARAMETEROPTION_H
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
21#include "arcane/utils/String.h"
22#include "arcane/utils/List.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
45class ARCANE_UTILS_EXPORT
47{
48 public:
49
50 static constexpr const char* ANY_TAG = "/";
51 static constexpr Integer ANY_INDEX = -1;
52 static constexpr Integer GET_INDEX = -2;
53
54 public:
55
60
65 explicit ParameterOptionAddrPart(const StringView tag);
66
73 ParameterOptionAddrPart(const StringView tag, const Integer index);
74
75 public:
76
77 StringView tag() const;
78 Integer index() const;
79
82 void setTag(const StringView tag);
83 void setIndex(const Integer index);
84
86 bool isAny() const;
87
94 bool operator==(const ParameterOptionAddrPart& other) const;
95 // TODO AH: To be removed when migrating to C++20.
96 bool operator!=(const ParameterOptionAddrPart& other) const;
97
98 private:
99
100 StringView m_tag;
101 Integer m_index;
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
128class ARCANE_UTILS_EXPORT
130{
131 public:
132
137 explicit ParameterOptionAddr(StringView addr_str_view);
138
139 public:
140
141 // We must not block multiple ParameterOptionAddrPart(ANY):
142 // Construction by iteration: aaaa/bb/ANY/ANY/cc
149
159 ParameterOptionAddrPart* addrPart(const Integer index_of_part) const;
160
161 ParameterOptionAddrPart* lastAddrPart() const;
162
169 Integer nbAddrPart() const;
170
194 bool getIndexInAddr(const ParameterOptionAddr& addr_with_get_index, ArrayView<Integer> indexes) const;
195
201
202 public:
203
213 bool operator==(const ParameterOptionAddr& other) const;
214
215 // TODO AH: To be removed when migrating to C++20.
216 bool operator!=(const ParameterOptionAddr& other) const;
217
218 private:
219
221};
222
223/*---------------------------------------------------------------------------*/
224/*---------------------------------------------------------------------------*/
225
230class ARCANE_UTILS_EXPORT
231ParameterOptionElement
232{
233 public:
234
235 ParameterOptionElement(const StringView addr, const StringView value);
236
237 ParameterOptionAddr addr() const;
238
239 StringView value() const;
240
241 bool operator==(const ParameterOptionAddr& addr) const;
242
243 private:
244
245 ParameterOptionAddr m_addr;
246 StringView m_value;
247};
248
249/*---------------------------------------------------------------------------*/
250/*---------------------------------------------------------------------------*/
251
255class ARCANE_UTILS_EXPORT
257{
258 public:
259
270 void addParameter(const String& parameter, const String& value);
271
272 void addElement(StringView addr, StringView value);
273
274 // ParameterOptionElement element(const Integer index)
275 // {
276 // return m_elements[index];
277 // }
278
279 // An empty StringView is equal to a null StringView.
280 // Since we are working with Strings and the distinction
281 // empty/null is important, we use std::optional.
282 std::optional<StringView> value(const ParameterOptionAddr& addr);
283
290 bool isExistAddr(const ParameterOptionAddr& addr);
291
300
322 void getIndexInAddr(const ParameterOptionAddr& addr_with_get_index, UniqueArray<Integer>& indexes);
323
324 private:
325
327};
328
329/*---------------------------------------------------------------------------*/
330/*---------------------------------------------------------------------------*/
331
332} // End namespace Arcane
333
334/*---------------------------------------------------------------------------*/
335/*---------------------------------------------------------------------------*/
336
337#endif
Declarations of types used in Arcane.
Modifiable view of an array of type T.
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.
Class representing a collection of XML elements (a set of Arcane options).
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 &parameter, 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.
View of a UTF-8 character string.
Definition StringView.h:44
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.