14#include "arcane/utils/Collection.h"
15#include "arcane/utils/Enumerator.h"
16#include "arcane/utils/OStringStream.h"
17#include "arcane/utils/ArgumentException.h"
18#include "arcane/utils/ScopedPtr.h"
20#include "arcane/impl/CaseDocumentLangTranslator.h"
22#include "arcane/core/AbstractCaseDocumentVisitor.h"
23#include "arcane/core/CaseOptions.h"
24#include "arcane/core/CaseOptionService.h"
25#include "arcane/core/ICaseMng.h"
26#include "arcane/core/ICaseDocument.h"
27#include "arcane/core/CaseNodeNames.h"
38class CaseDocumentLangTranslatorVisitor
44 CaseDocumentLangTranslatorVisitor(
ITraceMng* tm,
const String& new_lang)
47 m_new_lang = new_lang;
54 info() <<
"BeginOpt " << _getName(opt) <<
" {";
62 info() <<
"SimpleOpt " << _getName(opt);
66 info() <<
"MultiSimple " << _getName(opt);
70 info() <<
"MultiExtended " << _getName(opt);
74 info() <<
"Extended " << _getName(opt);
78 info() <<
"MultiEnum " << _getName(opt);
79 info() <<
"WARNING: MultiEnum not handled in translator";
83 info() <<
"Enum " << _getName(opt);
88 info() <<
"BeginService " << _getName(opt);
92 info() <<
"EndService " << _getName(opt);
96 info() <<
"BeginMultiService " << _getName(opt) <<
" index=" << index;
100 info() <<
"EndMultiService " << _getName(opt) <<
" index=" << index;
108 if (name != new_name)
109 m_stream() << full_xpath <<
"/" << name <<
":" << new_name <<
'\n';
118 if (name != new_name)
119 m_stream() << full_xpath <<
":" << new_name <<
'\n';
131 int v = opt->enumValueAsInt();
133 m_stream() << opt->
xpathFullName() <<
":text#" << new_name <<
'\n';
140 info() <<
"ALL: " << m_stream.str();
145 String convertString() {
return m_stream.str(); }
156CaseDocumentLangTranslator::
165CaseDocumentLangTranslator::
166~CaseDocumentLangTranslator()
173void CaseDocumentLangTranslator::
181String CaseDocumentLangTranslator::
185 throw ArgumentException(A_FUNCINFO,
"Invalid value for langage");
186 CaseDocumentLangTranslatorVisitor my_visitor(
traceMng(), new_lang);
189 ICaseOptions* o = *i;
190 info() <<
" OptName=" << o->rootTagName();
191 o->visit(&my_visitor);
193 my_visitor.printAll();
195 ICaseDocument* cd = cm->caseDocument();
196 CaseNodeNames* current_cnn = cd->caseNodeNames();
197 ScopedPtrT<CaseNodeNames> cnn{
new CaseNodeNames(new_lang) };
202 _addConvert(cd->fragment()->rootElement(), cnn->root);
203 _addConvert(cd->timeloopElement(), cnn->timeloop);
204 _addConvert(cd->titleElement(), cnn->title);
205 _addConvert(cd->descriptionElement(), cnn->description);
206 _addConvert(cd->modulesElement(), cnn->modules);
209 const XmlNodeList& mesh_elems = cd->meshElements();
210 for (
Integer i = 0, n = mesh_elems.size(); i < n; ++i) {
211 XmlNode xnode(mesh_elems.node(i));
212 _addConvert(xnode, cnn->mesh);
213 _addConvert(xnode.child(current_cnn->mesh_file), cnn->mesh_file);
216 _addConvert(cd->functionsElement(), cnn->functions);
226 return my_visitor.convertString() + m_global_convert_string;
232void CaseDocumentLangTranslator::
236 m_global_convert_string = m_global_convert_string + node.xpathFullName() +
":" + new_name +
"\n";
Abstract visitor for a scalar data point.
Base class for a data set option.
String name() const
Returns the option name corresponding to the data set language.
String translatedName(const String &lang) const
Name of the option in the language lang. Returns name() if no translation exists.
XmlNode rootElement() const
Returns the root element of the DOM.
String nameOfValue(int value, const String &lang) const
Returns the name corresponding to the value value for the language lang.
Enumerated data set option.
Option for the extended type dataset.
Multi-enumeration data set option.
Option for the extended list of types dataset.
Base class for a service option that can appear multiple times.
Base class for implementing options using services.
Base class for simple options (single value).
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 isPresent() const
Returns true if the option is present.
EnumeratorT< ICaseOptions * > Enumerator
virtual XmlNode rootElement() const =0
Returns the element associated with this options list.
Interface for a list of data set options.
virtual String rootTagName() const =0
Name of the element in the data set language.
virtual String translatedName(const String &lang) const =0
Name in the language lang of the option. Returns rootTagTrueName() if no translation exists.
Output stream linked to a String.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
String xpathFullName() const
XPath name of the node with its ancestors.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
Collection< ICaseOptions * > CaseOptionsCollection
Collection of dataset options.