ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictParserNS::RangeFactory Class Reference
Inheritance diagram for IdDictParserNS::RangeFactory:
Collaboration diagram for IdDictParserNS::RangeFactory:

Public Member Functions

void idd_start (IdDictParser &parser, const XMLCoreNode &node)
virtual void idd_end (IdDictParser &parser, const XMLCoreNode &node)
void do_start (XMLCoreParser &parser, const XMLCoreNode &node)
void do_end (XMLCoreParser &parser, const XMLCoreNode &node)
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_comment (XMLCoreParser &parser, const std::string &comment)

Static Public Member Functions

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_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 98 of file IdDictParser.cxx.

Member Function Documentation

◆ check_double()

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

Definition at line 184 of file XMLCoreParser.cxx.

184 {
185 std::string checkstring = get_value (node, name);
186 int counter = 0;
187 //
188 // concatenate two times same string to
189 // check the last number of the string
190 // explicitly!
191 //
192 std::string t = checkstring + " " + checkstring;
193 std::istringstream tmpstr (t.c_str());
194 while (tmpstr.good ()) {
195 double ii{};
196 counter++;
197 tmpstr >> ii;
198 }
199 if (counter/2 != n) {
200 std::cerr << "XMLCoreFactory::check_double error: (" << counter << ") no " << n
201 << " doubles in \"" << checkstring << "\" for attribute " <<
202 name << ". exit." << std::endl;
203 std::string name1 = get_value (node, "name");
204 std::string volume = get_value (node, "volume");
205 if (name1 != "" ) std::cerr << "for name=" << name << std::endl;
206 if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
207 std::abort();
208 }
209 return true;
210}
static std::string get_value(const XMLCoreNode &node, const std::string &name)

◆ check_int()

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

Definition at line 152 of file XMLCoreParser.cxx.

152 {
153 std::string checkstring = get_value (node, name);
154 int counter = 0;
155 //
156 // concatenate two times same string to
157 // check the last number of the string
158 // explicitly!
159 //
160 std::string t = checkstring + " " + checkstring;
161 std::istringstream tmpstr (t.c_str());
162 while (tmpstr.good ()) {
163 int ii;
164 counter++;
165 tmpstr >> ii;
166 }
167 if (counter/2 != n) {
168 std::cerr << "XMLCoreFactory::check_int error: no " << n
169 << " ints in \"" << checkstring << "\" for attribute " <<
170 name << ". exit." << std::endl;
171
172 std::string nodename = get_value (node, "name");
173 std::string volume = get_value (node, "volume");
174
175 if (nodename != "" ) std::cerr << "for name=" << nodename << std::endl;
176 if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
177
178 std::abort();
179 }
180 return true;
181}

◆ comment()

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

Definition at line 58 of file XMLCoreParser.cxx.

58 {
59 if (XMLCoreParserDebugger::debug ()){
60 std::cout << "XMLCoreFactory::comment>" << std::endl;
61 }
62 do_comment (parser,comment);
63}
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
void comment(XMLCoreParser &parser, const std::string &comment)

◆ do_comment()

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

Definition at line 80 of file XMLCoreParser.cxx.

80 {
81 if (XMLCoreParserDebugger::debug ()){
82 std::cout << "XMLCoreFactory::do_comment>" << std::endl;
83 }
84}

◆ do_end()

void IdDictBaseFactory::do_end ( XMLCoreParser & parser,
const XMLCoreNode & node )
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 157 of file IdDictParser.cxx.

157 {
158 idd_end (static_cast<IdDictParser&>(parser), node);
159 parser.down ();
160}
virtual void idd_end(IdDictParser &parser, const XMLCoreNode &node)

◆ do_start()

void IdDictBaseFactory::do_start ( XMLCoreParser & parser,
const XMLCoreNode & node )
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 150 of file IdDictParser.cxx.

151 {
152 parser.up ();
153 idd_start (static_cast<IdDictParser&>(parser), node);
154}
virtual void idd_start(IdDictParser &parser, const XMLCoreNode &node)

◆ end()

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

Definition at line 50 of file XMLCoreParser.cxx.

50 {
51 if (XMLCoreParserDebugger::debug ()){
52 std::cout << "XMLCoreFactory::end>" << std::endl;
53 }
54 do_end (parser, node);
55}
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)

◆ get_boolean()

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

Definition at line 108 of file XMLCoreParser.cxx.

108 {
109 bool result = false;
110 std::string s = get_token (node, name);
111 if (s == "TRUE") result = true;
112 return (result);
113}
static std::string get_token(const XMLCoreNode &node, const std::string &name)

◆ get_double()

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

Definition at line 100 of file XMLCoreParser.cxx.

100 {
101 double result = 0;
102 std::string s = get_value (node, name);
103 sscanf (s.c_str (), "%80lg", &result);
104 return (result);
105}

◆ get_ID()

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

Definition at line 115 of file XMLCoreParser.cxx.

115 {
116 std::string result = get_value (node, name);
117 return (result);
118}

◆ get_int()

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

Definition at line 92 of file XMLCoreParser.cxx.

92 {
93 int result = 0;
94 std::string s = get_value (node, name);
95 sscanf (s.c_str (), "%80d", &result);
96 return (result);
97}

◆ get_token()

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

Definition at line 135 of file XMLCoreParser.cxx.

135 {
136 std::string result = get_value (node, name);
137 // trim the value
138 while ((result.length () > 0) &&
139 (result.at(0) == ' ')) result.erase (0, 1);
140
141 while ((result.length () > 0) &&
142 (result.at(result.length () - 1) == ' ')) result.erase (result.length () - 1, 1);
143 // Convert to upper case
144 for (std::string::size_type i = 0; i < result.length (); ++i){
145 result[i] = std::toupper (result[i]);
146 }
147 return (result);
148}

◆ get_value()

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

Definition at line 121 of file XMLCoreParser.cxx.

121 {
122 if (XMLCoreParserDebugger::debug ()){
123 std::cout << "XMLCoreFactory::get_value> name=" << name << std::endl;
124 }
125 std::string result;
126 if (node.has_attrib (name))
127 result = node.get_attrib (name);
128 if (XMLCoreParserDebugger::debug ()) {
129 std::cout << "XMLCoreFactory::get_value>2 value=" << result << std::endl;
130 }
131 return (result);
132}
const std::string & get_attrib(const std::string &name) const
Retrieve the value of an attribute.
bool has_attrib(const std::string &name) const
Test for presence of an attribute with a given name.

◆ has_attribute()

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

Definition at line 87 of file XMLCoreParser.cxx.

87 {
88 return node.has_attrib (name);
89}

◆ idd_end()

void RegionEntryFactory::idd_end ( IdDictParser & parser,
const XMLCoreNode & node )
virtualinherited

Reimplemented from IdDictParserNS::IdDictBaseFactory.

Definition at line 480 of file IdDictParser.cxx.

480 {
481 if (Debugger::debug ()) {
482 Debugger::tab (parser.level());
483 std::cout << "RegionEntryFactory::idd_end>" << std::endl;
484 }
485 if (parser.m_regionentry != 0){
486 if (parser.m_region != 0) parser.m_region->add_entry (std::move(parser.m_regionentry));
487 else if (parser.m_subregion != 0) parser.m_subregion->add_entry (std::move(parser.m_regionentry));
488 else parser.m_regionentry.reset();
489 }
490}
static void tab(int n)

◆ idd_start()

void RangeFactory::idd_start ( IdDictParser & parser,
const XMLCoreNode & node )
virtual

Reimplemented from IdDictParserNS::RegionEntryFactory.

Definition at line 493 of file IdDictParser.cxx.

493 {
494 if (Debugger::debug ()) {
495 Debugger::tab (parser.level());
496 std::cout << "RangeFactory::idd_start>" << std::endl;
497 }
498 auto range = std::make_unique<IdDictRange> (get_value (node, "field"));
499 if (has_attribute (node, "value")){
500 range->set_range (get_value (node, "value"));
501 } else if (has_attribute (node, "values")) {
502 std::string labels = get_value (node, "values");
503 std::string::size_type pos = 0;
504 std::vector<std::string> label_vec;
505 for (;;){
506 std::string::size_type next;
507 next = labels.find_first_not_of (" ", pos);
508 if (next == std::string::npos) break;
509 pos = next;
510 next = labels.find_first_of (" ", pos);
511 label_vec.push_back (labels.substr (pos, next - pos));
512 if (next == std::string::npos) {
513 break;
514 } else {
515 pos = next;
516 }
517 }
518 range->set_range (label_vec);
519 } else {
520 const bool hasMin = has_attribute (node, "minvalue");
521 const bool hasMax = has_attribute (node, "maxvalue");
522 if (hasMin and hasMax) {
523 range->set_range (get_int (node, "minvalue"),
524 get_int (node, "maxvalue"));
525 }
526 //falls through to a case where there is *no* attribute value, values, minvalue, maxvalue
527 //https://its.cern.ch/jira/browse/ATLASSIM-7295
528 }
529 if (has_attribute (node, "wraparound")){
530 bool wraparound = get_boolean (node, "wraparound");
531 if (wraparound) range->set_wrap_around();
532 }
533 if (has_attribute (node, "prev_value")){
534 range->set_prev (get_int (node, "prev_value"));
535 }
536 if (has_attribute (node, "next_value")) {
537 range->set_next (get_int (node, "next_value"));
538 }
539 parser.m_regionentry = std::move(range);
540}
static bool has_attribute(const XMLCoreNode &node, const std::string &name)
static int get_int(const XMLCoreNode &node, const std::string &name)
static bool get_boolean(const XMLCoreNode &node, const std::string &name)

◆ start()

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

Definition at line 42 of file XMLCoreParser.cxx.

42 {
43 if (XMLCoreParserDebugger::debug ()){
44 std::cout << "XMLCoreFactory::start> factory=" << this << std::endl;
45 }
46 do_start (parser, node);
47}
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)

Member Data Documentation

◆ m_xmlelementname

std::string XMLCoreFactory::m_xmlelementname
protectedinherited

Definition at line 43 of file XMLCoreParser.h.


The documentation for this class was generated from the following file: