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 envoyant une exception FatalErrorException.
Integer size() const
Nombre d'éléments du vecteur.
JSONValue extractFilePart(const JSONValue &config_part)
Méthode permettant d'obtenir la partie fichier d'une JSONValue (à partir du tableau 'jsonValues()').
void read()
Méthode permettant de lire le fichier et de remplir la chaîne de dépendances. Il faut d'abord appeler...
ArcaNetReader(const JSONValue &root)
Constructeur.
JSONValue extractPart(const String &part_name, const JSONValue &config_part)
Méthode permettant d'obtenir une partie d'une JSONValue (à partir du tableau 'jsonValues()').
JSONValue extractProgPart(const JSONValue &config_part)
Méthode permettant d'obtenir la partie programme d'une JSONValue (à partir du tableau 'jsonValues()')...
void init(const String &case_and_variations_values, const String &prog_name)
Méthode permettant d'initialiser le lecteur de fichier.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Liste de valeurs d'un document JSON.
bool null() const
Vrai si le noeud est nul.
bool isNull() const
Vrai si la valeur est de type 'null'.
JSONValue child(StringView name) const
Valeur fille de nom name. Retourne une valeur nulle si non trouvé.
Chaîne de caractères unicode.
bool empty() const
Vrai si la chaîne est vide (nulle ou "").
void split(StringContainer &str_array, char c) const
Découpe la chaîne suivant le caractère c.
bool contains(const String &s) const
Indique si la chaîne contient s.
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.