13 : fDoc(nullptr), fParser(new TDOMParser), fOdb(nullptr)
21 fParser->ParseFile(buffer);
23 fParser->ParseBuffer(buffer, size);
27 std::runtime_error(
"XmlOdb::XmlOdb: Malformed ODB dump: cannot get XML document");
30 if(strcmp(
fOdb->GetNodeName(),
"odb") != 0) {
31 std::runtime_error(
"XmlOdb::XmlOdb: Malformed ODB dump: cannot find <odb> tag");
52 if(!node->HasChildren()) {
55 node = node->GetChildren();
56 while(node !=
nullptr) {
58 if(nodename == name) {
61 node = node->GetNextNode();
77 std::string pathname = path;
78 std::vector<std::string> elems;
80 std::size_t slash = pathname.find_first_of(
'/');
85 slash = pathname.find_first_of(
'/', last);
86 elems.push_back(pathname.substr(last, slash - last));
88 if(slash == std::string::npos) {
93 for(
auto& elem : elems) {
108 TList* list = node->GetAttributes();
109 if(list !=
nullptr) {
110 std::string buffer = (
static_cast<TXMLAttr*
>(list->At(0)))->GetValue();
121 if(node ==
nullptr) {
131 std::vector<int> temp;
132 if(node ==
nullptr) {
135 if(!node->HasChildren()) {
138 TList* list = node->GetAttributes();
139 if(list ==
nullptr) {
144 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
145 if(strcmp(attr->GetName(),
"num_values") == 0) {
146 size = atoi(attr->GetValue());
149 temp.assign(size, 0);
150 TXMLNode* child = node->GetChildren();
153 if(TList* index = child->GetAttributes()) {
154 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
155 int value = atoi(child->GetText());
156 temp.at(indexnum) = value;
157 }
else if(child->GetText() !=
nullptr) {
158 int indexnum = counter++;
159 temp.at(indexnum) = atoi(child->GetText());
161 child = child->GetNextNode();
162 if(child ==
nullptr) {
173 std::vector<std::string> temp;
174 if(node ==
nullptr) {
177 if(!node->HasChildren()) {
180 TList* list = node->GetAttributes();
181 if(list ==
nullptr) {
186 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
187 if(strcmp(attr->GetName(),
"num_values") == 0) {
188 size = atoi(attr->GetValue());
191 temp.assign(size,
"");
192 TXMLNode* child = node->GetChildren();
195 if(TList* index = child->GetAttributes()) {
196 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
197 const char* value = child->GetText();
200 std::string value_str;
201 if(value ==
nullptr) {
206 temp.at(indexnum) = value_str;
207 }
else if(child->GetText() !=
nullptr) {
208 int indexnum = counter++;
209 temp.at(indexnum).assign(child->GetText());
211 child = child->GetNextNode();
212 if(child ==
nullptr) {
223 std::vector<double> temp;
224 if(node ==
nullptr) {
227 if(!node->HasChildren()) {
230 TList* list = node->GetAttributes();
231 if(list ==
nullptr) {
236 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
237 if(strcmp(attr->GetName(),
"num_values") == 0) {
238 size = atoi(attr->GetValue());
241 temp.assign(size, 0.0);
242 TXMLNode* child = node->GetChildren();
245 if(TList* index = child->GetAttributes()) {
246 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
247 double value = atof(child->GetText());
248 temp.at(indexnum) = value;
249 }
else if(child->GetText() !=
nullptr) {
250 int indexnum = counter++;
251 temp.at(indexnum) = atof(child->GetText());
253 child = child->GetNextNode();
254 if(child ==
nullptr) {
std::vector< std::string > ReadStringArray(TXMLNode *node)
TXMLOdb(char *buffer, int size=0)
const char * GetNodeName(TXMLNode *)
std::vector< double > ReadDoubleArray(TXMLNode *node)
int ReadInt(const char *path, int index=0, int defaultValue=0xffffffff)
TXMLNode * FindPath(const char *path, TXMLNode *node=nullptr)
TXMLNode * FindNode(const char *name, TXMLNode *node=nullptr)
std::vector< int > ReadIntArray(TXMLNode *node)
static std::array< char, 256 > fTextBuffer