14#include "arccore/common/ArcaNetReader.h"
16#include "arccore/base/FatalErrorException.h"
17#include "arccore/base/PlatformUtils.h"
18#include "arccore/common/JSONReader.h"
31: m_build_path(!
platform::getEnvironmentVariable(
"ARCCORE_ARCANET_PATH").null())
42 m_prog_part_name = prog_name;
43 if (!case_and_variations_values.
empty()) {
46 case_and_variations_values.
split(split_case,
':');
48 for (
const String& elem : split_case) {
50 if (elem.contains(
"=")) {
52 elem.split(split_variation,
'=');
53 if (split_variation.
size() != 2) {
56 m_variations_key_resolved.
add(split_variation[0]);
57 m_variations_value_resolved.add(split_variation[1]);
61 if (!m_case_name.empty()) {
62 ARCCORE_FATAL(
"You must choose a variation for '{0}'.", elem);
64 if (elem.contains(
"~")) {
66 elem.split(split_case_name_with_prog_subname,
'~');
67 if (split_case_name_with_prog_subname.
size() != 2) {
70 m_case_name = split_case_name_with_prog_subname[0];
71 m_prog_custom_part_name = m_prog_part_name +
"~" + split_case_name_with_prog_subname[1];
87 if (m_prog_part_name.empty()) {
96 m_explored.add(
"general");
97 _readConfigPart(cases,
"general");
100 if (!m_case_name.empty()) {
106 m_explored.add(m_case_name);
107 _readConfigPart(cases, m_case_name);
117 return config_part.
child(
"_");
127 if (!m_prog_custom_part_name.empty()) {
128 arcane_part = config_part.
child(m_prog_custom_part_name);
130 if (arcane_part.
null()) {
131 arcane_part = config_part.
child(m_prog_part_name);
142 return config_part.
child(part_name);
149_readDependPart(
const JSONValue& depend_part)
151 if (depend_part.
null())
157 String dependence_name = elem.valueAsStringView();
160 if (dependence_name.
contains(
"=")) {
162 dependence_name.
split(split_variation,
'=');
163 if (split_variation.
size() != 2) {
167 const JSONValue variation = m_root.
child(
"variations").
child(split_variation[0]).
child(split_variation[1]);
168 if (variation.null()) {
169 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' not found.", split_variation[0], split_variation[1]);
171 if (m_explored.contains(dependence_name)) {
172 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' already explored.", split_variation[0], split_variation[1]);
174 m_explored.add(dependence_name);
177 dependence_node = m_root.
child(
"commons").
child(dependence_name);
178 if (!dependence_node.
null()) {
179 if (m_explored.contains(dependence_name)) {
180 ARCCORE_FATAL(
"Element '//commons/{0}' already explored.", dependence_name);
182 m_explored.add(dependence_name);
187 bool is_excluded_variants =
true;
188 String cleaned_dependence_name;
189 UniqueArray<String> split_dependence_name;
191 if (dependence_name.
contains(
"!")) {
192 is_excluded_variants =
true;
193 dependence_name.
split(split_dependence_name,
'!');
194 cleaned_dependence_name = split_dependence_name[0];
196 else if (dependence_name.
contains(
"+")) {
197 is_excluded_variants =
false;
198 dependence_name.
split(split_dependence_name,
'+');
199 cleaned_dependence_name = split_dependence_name[0];
202 cleaned_dependence_name = dependence_name;
204 auto pos_elem = m_variations_key_resolved.span().findFirst(cleaned_dependence_name);
206 if (!pos_elem.has_value()) {
207 const JSONValue error_ = m_root.child(
"variations").child(cleaned_dependence_name);
209 ARCCORE_FATAL(
"Element '//commons/{0}' not found.", cleaned_dependence_name);
211 ARCCORE_FATAL(
"Element '{0}' not found in 'Case' cmd line option.", cleaned_dependence_name);
214 String value = m_variations_value_resolved[pos_elem.value()];
215 if (!split_dependence_name.empty()) {
216 ArrayView excluded_or_included_values(split_dependence_name.subView(1, split_dependence_name.size() - 1));
217 if (is_excluded_variants && excluded_or_included_values.contains(value)) {
218 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' is excluded.", cleaned_dependence_name, value);
220 if (!is_excluded_variants && !excluded_or_included_values.contains(value)) {
221 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' is not included.", cleaned_dependence_name, value);
226 dependence_name = cleaned_dependence_name +
"=" + value;
228 dependence_node = m_root.
child(
"variations").
child(cleaned_dependence_name).
child(value);
229 if (dependence_node.
null()) {
230 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' not found.", cleaned_dependence_name, value);
232 if (m_explored.contains(dependence_name)) {
233 ARCCORE_FATAL(
"Element '//variations/{0}/{1}' already explored.", cleaned_dependence_name, value);
235 m_explored.add(dependence_name);
239 _readConfigPart(dependence_node, dependence_name);
252 _readFileBeforePart(config_part);
253 _addElemInPath(node_name);
254 m_values.add(config_part);
255 _readArcanePart(config_part);
256 _readFileAfterPart(config_part);
261 _readFileBeforePart(config_part);
262 m_values.add(config_part);
263 _readFileAfterPart(config_part);
271_addElemInPath(
const String& elem)
274 for (
Integer i = 0; i < m_level_path; ++i)
283_readFileBeforePart(
const JSONValue& config_part)
285 const JSONValue depend_before_var = config_part.child(
"_").child(
"depend_b");
286 _readDependPart(depend_before_var);
293_readFileAfterPart(
const JSONValue& config_part)
295 const JSONValue depend_after_var = config_part.child(
"_").child(
"depend_a");
296 _readDependPart(depend_after_var);
303_readArcanePart(
const JSONValue& config_part)
305 if (!m_prog_custom_part_name.empty() && !config_part.child(m_prog_custom_part_name).null()) {
307 m_path += m_prog_custom_part_name;
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
Integer size() const
Number of elements in the vector.
JSONValue extractFilePart(const JSONValue &config_part)
Method allowing to get the file part of a JSONValue (from 'jsonValues()' array).
void read()
Method allowing to read the file and fill the chain of dependencies. First, you need to call 'init()'...
ArcaNetReader(const JSONValue &root)
Constructor.
JSONValue extractPart(const String &part_name, const JSONValue &config_part)
Method allowing to get a part of a JSONValue (from 'jsonValues()' array).
JSONValue extractProgPart(const JSONValue &config_part)
Method allowing to get the program part of a JSONValue (from 'jsonValues()' array).
void init(const String &case_and_variations_values, const String &prog_name)
Method allowing to initialise the file reader.
void add(ConstReferenceType val)
Adds element val to the end of the array.
List of values of a JSON document.
bool null() const
True if the node is null.
bool isNull() const
True if the value is of 'null' type.
JSONValue child(StringView name) const
Child value with name name. Returns a null value if not found.
Unicode character string.
bool empty() const
True if the string is empty (null or "").
void split(StringContainer &str_array, char c) const
Splits the string based on the character c.
bool contains(const String &s) const
Indicates if the string contains s.
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.