15#include "arcane/utils/ParameterCaseOption.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"
24#include "arcane/utils/internal/ParameterOption.h"
36ParameterCaseOption(ParameterOptionElementsCollection* parameter_options,
const String& lang)
37: m_is_fr(lang ==
"fr")
38, m_lines(parameter_options)
45getParameterOrNull(
const String& xpath_before_index,
const String& xpath_after_index,
Integer index)
const
51 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
52 addr.lastAddrPart()->setIndex(index);
53 addr.addAddrPart(
new ParameterOptionAddrPart(xpath_after_index.
view()));
55 std::optional<StringView> value = m_lines->value(addr);
56 if (value.has_value())
65getParameterOrNull(
const String& xpath_before_index,
Integer index,
bool allow_elems_after_index)
const
70 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
71 addr.lastAddrPart()->setIndex(index);
72 if (allow_elems_after_index) {
73 addr.addAddrPart(
new ParameterOptionAddrPart());
76 std::optional<StringView> value = m_lines->value(addr);
77 if (value.has_value())
86getParameterOrNull(
const String& full_xpath)
const
88 const ParameterOptionAddr addr{ _removeUselessPartInXpath(full_xpath.
view()) };
90 std::optional<StringView> value = m_lines->value(addr);
91 if (value.has_value())
99bool ParameterCaseOption::
100exist(
const String& full_xpath)
const
102 const ParameterOptionAddr addr{ _removeUselessPartInXpath(full_xpath.
view()) };
103 return m_lines->isExistAddr(addr);
109bool ParameterCaseOption::
110existAnyIndex(
const String& xpath_before_index,
const String& xpath_after_index)
const
112 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
113 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::ANY_INDEX);
115 addr.addAddrPart(
new ParameterOptionAddrPart(xpath_after_index.
view()));
117 return m_lines->isExistAddr(addr);
123bool ParameterCaseOption::
124existAnyIndex(
const String& full_xpath)
const
126 const ParameterOptionAddr addr{ _removeUselessPartInXpath(full_xpath.
view()) };
127 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::ANY_INDEX);
129 return m_lines->isExistAddr(addr);
135void ParameterCaseOption::
138 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
139 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::GET_INDEX);
140 addr.addAddrPart(
new ParameterOptionAddrPart(xpath_after_index.
view()));
142 m_lines->getIndexInAddr(addr, indexes);
148void ParameterCaseOption::
151 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
152 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::GET_INDEX);
153 if (allow_elems_after_index) {
154 addr.addAddrPart(
new ParameterOptionAddrPart());
157 m_lines->getIndexInAddr(addr, indexes);
164count(
const String& xpath_before_index,
const String& xpath_after_index)
const
166 ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
167 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::ANY_INDEX);
168 addr.addAddrPart(
new ParameterOptionAddrPart(xpath_after_index.
view()));
170 return m_lines->countAddr(addr);
177count(
const String& xpath_before_index)
const
179 const ParameterOptionAddr addr{ _removeUselessPartInXpath(xpath_before_index.
view()) };
180 addr.lastAddrPart()->setIndex(ParameterOptionAddrPart::ANY_INDEX);
182 return m_lines->countAddr(addr);
192_removeUselessPartInXpath(
StringView xpath)
const
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Vue sur une chaîne de caractères UTF-8.
StringView subView(Int64 pos) const
Sous-chaîne commençant à la position pos.
Chaîne de caractères unicode.
StringView view() const
Retourne une vue sur la chaîne actuelle.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.