14#include "arcane/core/CaseOptionExtended.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/StringBuilder.h"
19#include "arcane/utils/internal/ParameterCaseOption.h"
21#include "arcane/core/ICaseMng.h"
22#include "arcane/core/CaseOptionError.h"
23#include "arcane/core/ICaseDocumentVisitor.h"
24#include "arcane/core/XmlNodeList.h"
25#include "arcane/core/ICaseOptionList.h"
26#include "arcane/core/MeshHandle.h"
27#include "arcane/core/ICaseDocument.h"
28#include "arcane/core/CaseOptionException.h"
29#include "arcane/core/internal/StringVariableReplace.h"
30#include "arcane/core/internal/ICaseMngInternal.h"
63 Integer size = elem_list.size();
66 if (size == 0 && option_in_param.
empty() && is_optional) {
76 if (!option_in_param.
empty()) {
77 max_in_param = option_in_param[0];
78 for (
Integer index : option_in_param) {
79 if (index > max_in_param)
82 if (max_occurs >= 0) {
83 if (max_in_param > max_occurs) {
84 StringBuilder msg =
"Bad number of occurences in command line (greater than max)";
85 msg +=
" index_max_in_param=";
96 if (max_occurs >= 0) {
97 if (size > max_occurs) {
98 StringBuilder msg =
"Bad number of occurences (greater than max)";
101 msg +=
" max_occur=";
112 Integer final_size = std::max(size, std::max(min_occurs, max_in_param));
115 _allocate(final_size);
126 for (
Integer i = 0; i < final_size; ++i) {
130 if (option_in_param.
contains(i + 1)) {
138 str_val = velem.
value();
143 if (str_val.
null()) {
148 str_val = StringVariableReplace::replaceWithCmdLineArgs(params, str_val,
true);
153 if (str_val.
null()) {
158 tm->
info(5) <<
"TryConvert opt=" << _xpathFullName() <<
" i=" << i
160 <<
" value=" << str_val;
161 bool is_bad = _tryToConvert(str_val, i);
182 for (
Integer i = 0, s = _nbElem(); i < s; ++i)
192 visitor->applyVisitor(
this);
207 if (_isInitialized()) {
208 bool is_bad = _tryToConvert(def_value);
211 ARCANE_FATAL(
"Can not convert '{0}' to type '{1}' (option='{2}')",
218 _setDefaultValue(def_value);
235 CaseOptionSimple::_search(is_phase1);
242 bool has_valid_value =
true;
243 if (str_val.
null()) {
251 has_valid_value =
false;
253 _setHasValidValue(has_valid_value);
254 if (has_valid_value) {
257 <<
" value=" << str_val;
258 bool is_bad = _tryToConvert(str_val);
277 _checkIsInitialized();
290 visitor->applyVisitor(
this);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
bool empty() const
Capacity (number of allocated elements) of the vector.
bool contains(ConstReferenceType v) const
True if the array contains the value element v.
String name() const
Returns the option name corresponding to the data set language.
String _defaultValue() const
Returns the default value of the option or 0 if none exists.
ICaseMng * caseMng() const
Case manager.
ICaseDocumentFragment * caseDocumentFragment() const
Returns the document associated with this option.
bool isOptional() const
Allows knowing if an option is optional.
Integer maxOccurs() const
Maximum number of occurrences (for a multiple option) (-1 == unbounded).
XmlNode rootElement() const
Returns the root element of the DOM.
ITraceMng * traceMng() const
Trace manager.
ICaseOptionList * parentOptionList() const
Parent OptionList.
Integer minOccurs() const
Minimum number of occurrences (for a multiple option).
static void addInvalidTypeError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent, const String &value, const String &expected_type)
Error when a dataset value is not of the correct type. This error is collective.
static void addOptionNotFoundError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent)
Error when a dataset option is not found. This error is collective.
Exception related to the dataset.
void _search(bool is_phase1) override
Searches for the option value in the data set.
void setDefaultValue(const String &def_value)
Sets the default value of the option.
String m_value
Value of the option in unicode string format.
void print(const String &lang, std::ostream &o) const override
Prints the option value in the language lang, to the stream o.
void visit(ICaseDocumentVisitor *visitor) const override
Applies the visitor to this option.
UniqueArray< String > m_values
Values in unicode string format.
void print(const String &lang, std::ostream &o) const override
Prints the option value in the language lang, to the stream o.
void _search(bool is_phase1) override
Searches for the option value in the data set.
void visit(ICaseDocumentVisitor *visitor) const override
Applies the visitor to this option.
String xpathFullName() const
Full name in the format provided by the XPath standard.
bool hasValidValue() const
Indicates if the option has an invalid value.
bool isOptional() const
Indicates if the option is optional.
bool isPresent() const
Returns true if the option is present.
Visitor interface for a dataset option.
virtual const ParameterListWithCaseOption & parameters() const =0
List of parameters that can override the dataset.
virtual ICaseMngInternal * _internalImpl()=0
Internal implementation.
virtual MeshHandle meshHandle() const =0
Handle of the associated mesh.
virtual TraceMessage info()=0
Stream for an information message.
Class representing the set of parameters that can modify the dataset options.
void indexesInParam(const String &xpath_before_index, const String &xpath_after_index, UniqueArray< Integer > &indexes) const
Method allowing retrieval of the index or indices of the option.
String getParameterOrNull(const String &xpath_before_index, const String &xpath_after_index, Integer index) const
Method allowing retrieval of an option's value.
Parameter list with information to override dataset options.
ParameterCaseOption getParameterCaseOption(const String &language) const
Method to retrieve an object of type ParameterCaseOption.
Unicode character string constructor.
String toString() const
Returns the constructed character string.
Unicode character string.
bool null() const
Returns true if the string is null.
1D data vector with value semantics (STL style).
List of nodes of a DOM tree.
String value() const
Node value.
XmlNodeList children(const String &name) const
Set of child nodes of this node having the name name.
bool null() const
True if the node is null.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.