Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
XmlInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* XmlInfo.h (C) 2000-2006 */
9/* */
10/* Informations sur un fichier XML. */
11/*---------------------------------------------------------------------------*/
12
13#ifndef ARCANE_XMLINFO_H
14#define ARCANE_XMLINFO_H
15
16#include "arcane/utils/Iostream.h"
17#include "arcane/ArcaneException.h"
18#include "arcane/IApplication.h"
19#include "arcane/IXmlDocumentHolder.h"
20#include "arcane/IIOMng.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25ARCANE_BEGIN_NAMESPACE
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
39{
40 public:
41 XmlInfo(IApplication* mng=0) : m_mng(mng) {}
42 virtual ~XmlInfo() {};
43
44 public:
50 static void error(const XmlNode& element, const String msg)
51 {
53 msgStr() << "** Error: Element <" << element.name()
54 << ">: " << msg << '.';
55 throw InternalErrorException("XmlInfo::_error", msgStr.str());
56 }
57
63 static void warning(const XmlNode& element, const String msg)
64 {
65 cerr << "** Warning: Element <" << element.name()
66 << ">: " << msg << ".\n";
67 }
68
75 static void attrError(const XmlNode& element, const char* attr_name)
76 {
78 msg() << "Attribute \"" << attr_name << "\" not specified";
79 error(element, String(msg.str()));
80 }
81
92 const String& file_name,
93 const String& schema_name = String())
94 {
95 IXmlDocumentHolder* xml_doc = mng->parseXmlFile(file_name.local(),
96 schema_name.local());
97 if (!xml_doc)
98 {
100 s() << "Can't read the file \"" << file_name << "\"";
101 throw InternalErrorException("XmlInfo::rootNode",s.str());
102 }
103 return xml_doc->documentNode().documentElement();
104 }
105
106 protected:
109};
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114ARCANE_END_NAMESPACE
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119#endif
Interface de l'application.
Interface du gestionnaire des entrées sorties.
Definition IIOMng.h:42
Gestionnaire d'un document DOM.
Exception lorsqu'une erreur interne survient.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Informations sur un fichier XML.
Definition XmlInfo.h:39
static void error(const XmlNode &element, const String msg)
Definition XmlInfo.h:50
static XmlNode rootNode(IIOMng *mng, const String &file_name, const String &schema_name=String())
Definition XmlInfo.h:91
static void warning(const XmlNode &element, const String msg)
Definition XmlInfo.h:63
IApplication * m_mng
Definition XmlInfo.h:108
static void attrError(const XmlNode &element, const char *attr_name)
Definition XmlInfo.h:75
Noeud d'un arbre DOM.
Definition XmlNode.h:51
String name() const
Nom du noeud.
Definition XmlNode.cc:132
Chaîne de caractères unicode.