ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
XMLCoreFactory Class Reference

#include <XMLCoreParser.h>

Inheritance diagram for XMLCoreFactory:
Collaboration diagram for XMLCoreFactory:

Public Member Functions

virtual ~XMLCoreFactory ()
 
void start (XMLCoreParser &parser, const XMLCoreNode &node)
 
void end (XMLCoreParser &parser, const XMLCoreNode &node)
 
void comment (XMLCoreParser &parser, const std::string &comment)
 
virtual void do_start (XMLCoreParser &parser, const XMLCoreNode &node)
 
virtual void do_end (XMLCoreParser &parser, const XMLCoreNode &node)
 
virtual void do_comment (XMLCoreParser &parser, const std::string &comment)
 
std::string get_name (const XMLCoreNode &node)
 
int sibling_number (const XMLCoreNode &node)
 

Static Public Member Functions

static int attribute_number (const XMLCoreNode &node)
 
static bool has_attribute (const XMLCoreNode &node, const std::string &name)
 
static int get_int (const XMLCoreNode &node, const std::string &name)
 
static double get_double (const XMLCoreNode &node, const std::string &name)
 
static bool get_boolean (const XMLCoreNode &node, const std::string &name)
 
static std::string get_ID (const XMLCoreNode &node, const std::string &name)
 
static std::string get_value (const XMLCoreNode &node, const std::string &name)
 
static std::string get_name (const XMLCoreNode &node, int index)
 
static std::string get_token (const XMLCoreNode &node, const std::string &name)
 
static bool check_int (const int n, const XMLCoreNode &node, const std::string &name)
 
static bool check_double (const int n, const XMLCoreNode &node, const std::string &name)
 

Protected Attributes

std::string m_xmlelementname
 

Detailed Description

Definition at line 70 of file XMLCoreParser.h.

Constructor & Destructor Documentation

◆ ~XMLCoreFactory()

XMLCoreFactory::~XMLCoreFactory ( )
virtual

Definition at line 63 of file XMLCoreParser.cxx.

64 {
66  {
67  std::cout << "XMLCoreFactory::~XMLCoreFactory> factory=" << this << std::endl;
68  }
69 }

Member Function Documentation

◆ attribute_number()

int XMLCoreFactory::attribute_number ( const XMLCoreNode node)
static

Definition at line 125 of file XMLCoreParser.cxx.

126 {
127  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
128 
129  return (attrs.size ());
130 }

◆ check_double()

bool XMLCoreFactory::check_double ( const int  n,
const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 299 of file XMLCoreParser.cxx.

300 {
301  std::string checkstring = get_value (node, name);
302  int counter = 0;
303 
304  //
305  // concatenate two times same string to
306  // check the last number of the string
307  // explicitly!
308  //
309  std::string t = checkstring + " " + checkstring;
310 
311  std::istringstream tmpstr (t.c_str());
312  while (tmpstr.good ())
313  {
314  double ii;
315  counter++;
316  tmpstr >> ii;
317  }
318 
319  //counter--;
320 
321  if (counter/2 != n)
322  {
323  std::cerr << "XMLCoreFactory::check_double error: (" << counter << ") no " << n
324  << " doubles in \"" << checkstring << "\" for attribute " <<
325  name << ". exit." << std::endl;
326 
327  std::string name1 = get_value (node, "name");
328  std::string volume = get_value (node, "volume");
329 
330  if (name1 != "" ) std::cerr << "for name=" << name << std::endl;
331  if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
332 
333  std::abort();
334  }
335 
336  return true;
337 }

◆ check_int()

bool XMLCoreFactory::check_int ( const int  n,
const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 260 of file XMLCoreParser.cxx.

261 {
262  std::string checkstring = get_value (node, name);
263  int counter = 0;
264 
265  //
266  // concatenate two times same string to
267  // check the last number of the string
268  // explicitly!
269  //
270  std::string t = checkstring + " " + checkstring;
271 
272  std::istringstream tmpstr (t.c_str());
273  while (tmpstr.good ())
274  {
275  int ii;
276  counter++;
277  tmpstr >> ii;
278  }
279  //counter--;
280 
281  if (counter/2 != n)
282  {
283  std::cerr << "XMLCoreFactory::check_int error: no " << n
284  << " ints in \"" << checkstring << "\" for attribute " <<
285  name << ". exit." << std::endl;
286 
287  std::string nodename = get_value (node, "name");
288  std::string volume = get_value (node, "volume");
289 
290  if (nodename != "" ) std::cerr << "for name=" << nodename << std::endl;
291  if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
292 
293  std::abort();
294  }
295 
296  return true;
297 }

◆ comment()

void XMLCoreFactory::comment ( XMLCoreParser parser,
const std::string &  comment 
)

Definition at line 91 of file XMLCoreParser.cxx.

92 {
94  {
95  std::cout << "XMLCoreFactory::comment>" << std::endl;
96  }
97 
99 }

◆ do_comment()

void XMLCoreFactory::do_comment ( XMLCoreParser parser,
const std::string &  comment 
)
virtual

Definition at line 117 of file XMLCoreParser.cxx.

118 {
120  {
121  std::cout << "XMLCoreFactory::do_comment>" << std::endl;
122  }
123 }

◆ do_end()

void XMLCoreFactory::do_end ( XMLCoreParser parser,
const XMLCoreNode node 
)
virtual

Reimplemented in IdDictParserNS::IdDictBaseFactory.

Definition at line 109 of file XMLCoreParser.cxx.

110 {
112  {
113  std::cout << "XMLCoreFactory::do_end>" << std::endl;
114  }
115 }

◆ do_start()

void XMLCoreFactory::do_start ( XMLCoreParser parser,
const XMLCoreNode node 
)
virtual

Reimplemented in IdDictParserNS::IdDictBaseFactory.

Definition at line 101 of file XMLCoreParser.cxx.

102 {
104  {
105  std::cout << "XMLCoreFactory::do_start>" << std::endl;
106  }
107 }

◆ end()

void XMLCoreFactory::end ( XMLCoreParser parser,
const XMLCoreNode node 
)

Definition at line 81 of file XMLCoreParser.cxx.

82 {
84  {
85  std::cout << "XMLCoreFactory::end>" << std::endl;
86  }
87 
88  do_end (parser, node);
89 }

◆ get_boolean()

bool XMLCoreFactory::get_boolean ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 162 of file XMLCoreParser.cxx.

163 {
164  bool result = false;
165 
166  std::string s = get_token (node, name);
167 
168  if (s == "TRUE") result = true;
169 
170  return (result);
171 }

◆ get_double()

double XMLCoreFactory::get_double ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 152 of file XMLCoreParser.cxx.

153 {
154  double result = 0;
155 
156  std::string s = get_value (node, name);
157  sscanf (s.c_str (), "%80lg", &result);
158 
159  return (result);
160 }

◆ get_ID()

std::string XMLCoreFactory::get_ID ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 173 of file XMLCoreParser.cxx.

174 {
175  std::string result = get_value (node, name);
176 
177  return (result);
178 }

◆ get_int()

int XMLCoreFactory::get_int ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 142 of file XMLCoreParser.cxx.

143 {
144  int result = 0;
145 
146  std::string s = get_value (node, name);
147  sscanf (s.c_str (), "%80d", &result);
148 
149  return (result);
150 }

◆ get_name() [1/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode node)

Definition at line 203 of file XMLCoreParser.cxx.

204 {
205  std::string result = node.get_node ().get_name ();
206 
207  return (result);
208 }

◆ get_name() [2/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode node,
int  index 
)
static

Definition at line 215 of file XMLCoreParser.cxx.

216 {
217  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
218 
219  CoreParser::DOMNamedNodeMap::const_iterator it;
220 
221  for (it = attrs.begin (); (index > 0) && (it != attrs.end ()); ++it)
222  {
223  --index;
224  }
225 
226  if (it == attrs.end ()) return ("");
227 
228  std::string result = (*it).first;
229 
230  return (result);
231 }

◆ get_token()

std::string XMLCoreFactory::get_token ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 233 of file XMLCoreParser.cxx.

234 {
235  std::string result = get_value (node, name);
236 
237  // trim the value
238 
239  while ((result.length () > 0) &&
240  (result.at(0) == ' ')) result.erase (0, 1);
241 
242  while ((result.length () > 0) &&
243  (result.at(result.length () - 1) == ' ')) result.erase (result.length () - 1, 1);
244 
245  // Convert to upper case
246 
247  for (std::string::size_type i = 0; i < result.length (); ++i)
248  {
249  static const std::string uc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
250  static const std::string lc = "abcdefghijklmnopqrstuvwxyz";
251  char c = result[i];
252  std::string::size_type p = lc.find (c);
253  if (p != std::string::npos) result[i] = lc[p];
254  }
255 
256  return (result);
257 }

◆ get_value()

std::string XMLCoreFactory::get_value ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 180 of file XMLCoreParser.cxx.

181 {
183  {
184  std::cout << "XMLCoreFactory::get_value> name=" << name << std::endl;
185  }
186 
187  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
188 
189  CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
190 
191  if (it == attrs.end ()) return ("");
192 
193  std::string result = (*it).second;
194 
196  {
197  std::cout << "XMLCoreFactory::get_value>2 value=" << result << std::endl;
198  }
199 
200  return (result);
201 }

◆ has_attribute()

bool XMLCoreFactory::has_attribute ( const XMLCoreNode node,
const std::string &  name 
)
static

Definition at line 132 of file XMLCoreParser.cxx.

133 {
134  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
135 
136  CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
137 
138  if (it == attrs.end ()) return (false);
139  return (true);
140 }

◆ sibling_number()

int XMLCoreFactory::sibling_number ( const XMLCoreNode node)

Definition at line 210 of file XMLCoreParser.cxx.

211 {
212  return (node.get_node ().sibling_number ());
213 }

◆ start()

void XMLCoreFactory::start ( XMLCoreParser parser,
const XMLCoreNode node 
)

Definition at line 71 of file XMLCoreParser.cxx.

72 {
74  {
75  std::cout << "XMLCoreFactory::start> factory=" << this << std::endl;
76  }
77 
78  do_start (parser, node);
79 }

Member Data Documentation

◆ m_xmlelementname

std::string XMLCoreFactory::m_xmlelementname
protected

Definition at line 103 of file XMLCoreParser.h.


The documentation for this class was generated from the following files:
XMLCoreFactory::do_comment
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:117
python.CaloScaleNoiseConfig.parser
parser
Definition: CaloScaleNoiseConfig.py:75
python.PoolAttributeHelper.attrs
list attrs
Definition: PoolAttributeHelper.py:89
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ReadCellNoiseFromCool.name1
name1
Definition: ReadCellNoiseFromCool.py:233
get_generator_info.result
result
Definition: get_generator_info.py:21
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
index
Definition: index.py:1
CoreParser::DOMNamedNodeMap
std::map< std::string, std::string > DOMNamedNodeMap
Definition: DOMNode.h:15
skel.it
it
Definition: skel.GENtoEVGEN.py:423
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
XMLCoreParserDebugger::debug
static bool debug()
Definition: XMLCoreParser.cxx:19
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
XMLCoreFactory::get_value
static std::string get_value(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:180
XMLCoreFactory::do_start
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DeMoScan.index
string index
Definition: DeMoScan.py:362
XMLCoreFactory::get_token
static std::string get_token(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:233
test_pyathena.counter
counter
Definition: test_pyathena.py:15
XMLCoreFactory::comment
void comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:91
python.compressB64.c
def c
Definition: compressB64.py:93
node
Definition: memory_hooks-stdcmalloc.h:74
XMLCoreFactory::do_end
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:109