Beispiel #1
0
std::string xml_node::get_text() const
{
    if (children_.size() == 0)
    {
        return "";
    }
    if (children_.size() == 1)
    {
        return children_.front().text();
    }
    throw more_than_one_child(name_);
}
Beispiel #2
0
std::string const& xml_node::get_text() const
{
    // FIXME : return boost::optional<std::string const&>
    if (children_.empty())
    {
        if (is_text_)
        {
            return name_;
        }
        else
        {
            const static std::string empty;
            return empty;
        }
    }
    if (children_.size() == 1)
    {
        return children_.front().text();
    }
    throw more_than_one_child(name_);
}