Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ConfigurationReader.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* ConfigurationReader.cc (C) 2000-2023 */
9/* */
10/* Lecteurs de fichiers de configuration. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/impl/ConfigurationReader.h"
15#include "arcane/utils/JSONReader.h"
16#include "arcane/IConfiguration.h"
17#include "arcane/XmlNode.h"
18#include "arcane/XmlNodeList.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
30addValuesFromXmlNode(const XmlNode& root_elem,Integer priority)
31{
33
34 XmlNodeList sections = root_elem.children("add");
35 for( Integer i=0, n=sections.size(); i<n; ++i ){
37
38 String sec_name = sec_node.attrValue("name");
39 String sec_value = sec_node.attrValue("value");
40
41 if (sec_name.null()){
42 pwarning() << "Missing 'name' attribute in <section> in configuration file";
43 continue;
44 }
45
46 if (sec_value.null()){
47 pwarning() << "Missing 'value' attribute in <section> in configuration file";
48 continue;
49 }
50 //info() << "GET CONFIG name=" << sec_name << " value=" << sec_value;
51
52 all_names.clear();
53 sec_name.split(all_names,'.');
54 m_configuration->addValue(sec_name,sec_value,priority);
55 }
56}
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61void ConfigurationReader::
62_addValuesFromJSON(const JSONValue& jv,Integer priority,const String& base_name)
63{
64 for( JSONKeyValue v : jv.keyValueChildren() ){
65 String name = v.name();
66 JSONValue value = v.value();
67 if (value.isObject()){
68 _addValuesFromJSON(value,priority,base_name+name+".");
69 }
70 else if (value.isArray()){
71 // Ne traite pas les tableaux pour l'instant car ils ne sont
72 // pas supportés dans la configuration.
73 }
74 else{
75 String v_value = value.value();
76 //info() << "B=" << base_name << " N=" << name << " V=" << v_value;
77 m_configuration->addValue(base_name+name,v_value,priority);
78 }
79 }
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
86addValuesFromJSON(const JSONValue& jv,Integer priority)
87{
88 _addValuesFromJSON(jv,priority,String());
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94} // End namespace Arcane
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
void addValuesFromXmlNode(const XmlNode &element, Integer priority)
Ajoute des valeurs à la configuration.
void addValuesFromJSON(const JSONValue &jv, Integer priority)
Ajoute des valeurs à la configuration.
virtual void addValue(const String &name, const String &value, Integer priority)=0
Ajout une valeur à la configuration.
Représente une paire (clé,valeur) de JSON.
Definition JSONReader.h:123
Représente une valeur JSON.
Definition JSONReader.h:43
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Liste de noeuds d'un arbre DOM.
Definition XmlNodeList.h:33
Noeud d'un arbre DOM.
Definition XmlNode.h:51
Chaîne de caractères unicode.
TraceMessage pwarning() const
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-