13 : fDoc(nullptr), fParser(new TDOMParser), fOdb(nullptr)
21 fParser->ParseFile(buffer);
23 fParser->ParseBuffer(buffer, size);
28 std::runtime_error(
"XmlOdb::XmlOdb: Malformed ODB dump: cannot get XML document");
31 if(strcmp(
fOdb->GetNodeName(),
"odb") != 0) {
32 std::runtime_error(
"XmlOdb::XmlOdb: Malformed ODB dump: cannot find <odb> tag");
53 if(!node->HasChildren()) {
56 node = node->GetChildren();
57 while(node !=
nullptr) {
59 if(nodename == name) {
62 node = node->GetNextNode();
78 std::string pathname = path;
79 std::vector<std::string> elems;
81 std::size_t slash = pathname.find_first_of(
'/');
86 slash = pathname.find_first_of(
'/', last);
87 elems.push_back(pathname.substr(last, slash - last));
89 if(slash == std::string::npos) {
94 for(
auto& elem : elems) {
109 TList* list = node->GetAttributes();
110 if(list !=
nullptr) {
111 std::string buffer = (
static_cast<TXMLAttr*
>(list->At(0)))->GetValue();
122 if(node ==
nullptr) {
132 std::vector<int> temp;
133 if(node ==
nullptr) {
136 if(!node->HasChildren()) {
139 TList* list = node->GetAttributes();
140 if(list ==
nullptr) {
145 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
146 if(strcmp(attr->GetName(),
"num_values") == 0) {
147 size = atoi(attr->GetValue());
150 temp.assign(size, 0);
151 TXMLNode* child = node->GetChildren();
154 if(TList* index = child->GetAttributes()) {
155 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
156 int value = atoi(child->GetText());
157 temp.at(indexnum) = value;
158 }
else if(child->GetText() !=
nullptr) {
159 int indexnum = counter++;
160 temp.at(indexnum) = atoi(child->GetText());
162 child = child->GetNextNode();
163 if(child ==
nullptr) {
174 std::vector<std::string> temp;
175 if(node ==
nullptr) {
178 if(!node->HasChildren()) {
181 TList* list = node->GetAttributes();
182 if(list ==
nullptr) {
187 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
188 if(strcmp(attr->GetName(),
"num_values") == 0) {
189 size = atoi(attr->GetValue());
192 temp.assign(size,
"");
193 TXMLNode* child = node->GetChildren();
196 if(TList* index = child->GetAttributes()) {
197 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
198 const char* value = child->GetText();
201 std::string value_str;
202 if(value ==
nullptr) {
207 temp.at(indexnum) = value_str;
208 }
else if(child->GetText() !=
nullptr) {
209 int indexnum = counter++;
210 temp.at(indexnum).assign(child->GetText());
212 child = child->GetNextNode();
213 if(child ==
nullptr) {
224 std::vector<double> temp;
225 if(node ==
nullptr) {
228 if(!node->HasChildren()) {
231 TList* list = node->GetAttributes();
232 if(list ==
nullptr) {
237 while(
auto* attr =
static_cast<TXMLAttr*
>(iter.Next())) {
238 if(strcmp(attr->GetName(),
"num_values") == 0) {
239 size = atoi(attr->GetValue());
242 temp.assign(size, 0.0);
243 TXMLNode* child = node->GetChildren();
246 if(TList* index = child->GetAttributes()) {
247 int indexnum = atoi((
static_cast<TXMLAttr*
>(index->At(0)))->GetValue());
248 double value = atof(child->GetText());
249 temp.at(indexnum) = value;
250 }
else if(child->GetText() !=
nullptr) {
251 int indexnum = counter++;
252 temp.at(indexnum) = atof(child->GetText());
254 child = child->GetNextNode();
255 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