Skip to content

Instantly share code, notes, and snippets.

@secretrobotron
Created November 16, 2010 21:08
Show Gist options
  • Save secretrobotron/702515 to your computer and use it in GitHub Desktop.
Save secretrobotron/702515 to your computer and use it in GitHub Desktop.
void CXMLConfigurator::ParseXML(TiXmlElement const* root_element, std::string const* root_prefix) {
if (root_element) {
const TiXmlElement* child_element = root_element->FirstChildElement();
while(child_element) {
std::string prefix;
prefix = *root_prefix + ".";
const char* tag = child_element->Value();
const char* text = child_element->GetText();
if (tag) {
std::string key(prefix + tag);
if (text) {
std::string value(text);
CBaseDator* dator = new CDator<std::string>(value);
CBaseDatorPtr sptr(dator);
Register(key, sptr);
} //if
ParseXML(child_element, &key);
child_element = child_element->NextSiblingElement();
} //if
} //while
} //if
}
std::string* CXMLConfigurator::GetStr(std::string const& key) {
CBaseDatorPtr* ptr = CConfigurator::Get(key);
if (ptr) {
CDator<std::string>* dator = (CDator<std::string>* )(ptr->get());
return new std::string(*dator);
} //if
return new std::string("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment