Example #1
0
Sobby::Config::ParentEntry::ParentEntry(const xmlpp::Element& elem):
	Entry(elem.get_name() )
{
	xmlpp::Node::NodeList list = elem.get_children();
	for(xmlpp::Node::NodeList::iterator iter = list.begin();
	    iter != list.end();
	    ++ iter)
	{
		xmlpp::Element* child = dynamic_cast<xmlpp::Element*>(*iter);
		if(child == NULL) continue;

		if(child->get_child_text() &&
		   !child->get_child_text()->is_white_space())
		{
			ValueEntry* entry = new TypedValueEntry<Glib::ustring>(
				*child
			);

			m_map[child->get_name()] = entry;
		}
		else
		{
			m_map[child->get_name()] = new ParentEntry(*child);
		}
	}
}
Example #2
0
void Note::fromXML(const xmlpp::Element &root)
{
    using namespace xmlpp;

    Attribute *attr;
    // title
    attr = root.get_attribute("title");
    sTitle = "";
    if (attr)
    {
        sTitle = attr->get_value();
    }
    // visibility
    attr = root.get_attribute("visible");
    bVisible = false;
    if (attr)
    {
        bVisible = Item::strToBool(attr->get_value());
    }
    // text
    sText = "";
    if (root.has_child_text())
    {
        sText = root.get_child_text()->get_content();
    }
}
Example #3
0
void Note::toXML(xmlpp::Element &root) const
{
    using namespace xmlpp;

    root.set_attribute("title", sTitle);
    root.set_attribute("visible", Item::boolToStr(bVisible));
    root.add_child_text(sText);
}
Example #4
0
void FileItem::toXML(xmlpp::Element &root)
{
    using namespace xmlpp;

    Element *tmp = root.add_child("file");
    tmp->set_attribute("name",sFileName);
}
Example #5
0
void CharacterList::fromXML(const xmlpp::Element &root)
{
    using namespace xmlpp;

    clear();
    Node::NodeList node = root.get_children("character");
    for (Node::NodeList::const_iterator it = node.begin(); it != node.end(); it++)
    {
        Element *elem = dynamic_cast<Element*>(*it);
        string name;
        Attribute *attr = elem->get_attribute("name");
        if (attr != NULL)
        {
            name = attr->get_value();
        }
        string playerName="";
        attr = elem->get_attribute("playername");
        if (attr != NULL)
        {
            playerName = attr->get_value();
        }
        Character character = Character(name,playerName);
        character.fromXML(*elem);
        vCharacters.push_back(character);
    }        
}
Example #6
0
void Character::toXML(xmlpp::Element &root) const
{
    using namespace xmlpp;

    for (vector<std::string>::const_iterator it = vSkills.begin(); it != vSkills.end(); it++)
    {
        Element *tmp = root.add_child("skill");
        tmp->set_attribute("value",*it);
    }
}
Example #7
0
void Character::toXML(const IOConfig &config, xmlpp::Element &root) const
{
    using namespace xmlpp;

    for (vector<std::string>::const_iterator it = vProperties.begin(); it != vProperties.end(); it++)
    {
        Element *tmp = root.add_child(config.propertyName());
        tmp->set_attribute("value",*it);
    }
}
Example #8
0
void Sobby::Config::ParentEntry::save(xmlpp::Element& elem) const
{
	for(map_type::const_iterator iter = m_map.begin();
	    iter != m_map.end();
	    ++ iter)
	{
		Entry* entry = iter->second;
		xmlpp::Element* child = elem.add_child(entry->get_name() );
		entry->save(*child);
	}
}
Example #9
0
void CharacterList::toXML(xmlpp::Element &root) const
{
    using namespace xmlpp;

    for (vector<Character>::const_iterator it = vCharacters.begin(); it != vCharacters.end(); it++)
    {
        Element *tmp = root.add_child("character");
        tmp->set_attribute("name",it->name());
        tmp->set_attribute("playername",it->playerName());
        it->toXML(*tmp);
    }
}
Example #10
0
void Character::fromXML(const xmlpp::Element &root)
{
    using namespace xmlpp;

    clearSkills();
    Node::NodeList list = root.get_children("skill");
    for (Node::NodeList::const_iterator it = list.begin(); it != list.end(); it++)
    {
        Element *elem = dynamic_cast<Element *>(*it);
        string value;
        Attribute *attr = elem->get_attribute("value");
        if (attr != NULL)
        {
            value = attr->get_value();
        }
        vSkills.push_back(value);
    }
}
Example #11
0
void Character::fromXML(const IOConfig &config, const xmlpp::Element &root)
{
    using namespace xmlpp;

    clearProperties();
    Node::NodeList list = root.get_children(config.propertyName());
    for (Node::NodeList::const_iterator it = list.begin(); it != list.end(); it++)
    {
        Element *elem = dynamic_cast<Element *>(*it);
        string value;
        Attribute *attr = elem->get_attribute("value");
        if (attr)
        {
            value = attr->get_value();
        }
        vProperties.push_back(value);
    }
}
ElementHandler::Data UnitSpecializedElementHandler::extract(const xmlpp::Element & element) const
{
	Data ret;

	ret.parameter = parameter_;
	ret.unit = unitName_;

	std::string value = element.get_attribute_value(ret.unit);
	if ( value.empty() )
		throw ExtractionError("Missing value attribute in element");
	try
	{
		ret.value = boost::lexical_cast<float>(value);
	}
	catch ( boost::bad_lexical_cast & )
	{
		throw ExtractionError("Unable to parse value as float: " + value);
	}
	return ret;
}
Example #13
0
void FileItem::fromXML(const xmlpp::Element &root) throw(xmlpp::exception, invalid_argument, overflow_error)
{
    using namespace xmlpp;
    
    Node::NodeList list = root.get_children("file");
    string name = "";
    if (list.size()==0)
    {
        throw xmlpp::exception("Missing file name");
    }
    else
    {
        Element *tmp = dynamic_cast<Element*>(list.front());
        Attribute *attr = tmp->get_attribute("name");
        if (attr!=NULL)
        {
            name = attr->get_value();
        }
    }
    setFileName(name);
}