|
degate 0.1.1
|
#include <XMLImporter.h>

Public Member Functions | |
| XMLImporter () | |
| virtual | ~XMLImporter () |
Protected Member Functions | |
| template<typename T > | |
| T | parse_number (const xmlpp::Element *const node, std::string const &attribute_str) const |
| Parse a string and convert it to a number (e.g. | |
| template<typename T > | |
| T | parse_number (const xmlpp::Element *const node, std::string const &attribute_str, T default_value) |
| Parse a string and convert it to a number (e.g. | |
| const xmlpp::Element * | get_dom_twig (const xmlpp::Element *const start_node, std::string const &element_name) const |
| color_t | parse_color_string (std::string const &color_string) const |
| Parse a HTML RGBA color description, e.g. | |
Definition at line 32 of file XMLImporter.h.
| degate::XMLImporter::XMLImporter | ( | ) | [inline] |
Definition at line 82 of file XMLImporter.h.
{};
| virtual degate::XMLImporter::~XMLImporter | ( | ) | [inline, virtual] |
Definition at line 83 of file XMLImporter.h.
{};
| const xmlpp::Element * XMLImporter::get_dom_twig | ( | const xmlpp::Element *const | start_node, |
| std::string const & | element_name | ||
| ) | const [protected] |
Definition at line 38 of file XMLImporter.cc.
{
xmlpp::Node::NodeList node_list = start_node->get_children(element_name);
if(!node_list.empty()) {
const xmlpp::Element * element = dynamic_cast<const xmlpp::Element*>(node_list.front());
return element;
}
return NULL;
}
| color_t XMLImporter::parse_color_string | ( | std::string const & | color_string | ) | const [protected] |
Parse a HTML RGBA color description, e.g.
'#23FF42A0'.
Definition at line 48 of file XMLImporter.cc.
References MERGE_CHANNELS.
{
const unsigned int correct_length = 1 + 4 * 2;
if(color_string.size() != correct_length) return 0;
int r = 0;
int g = 0;
int b = 0;
int a = 0;
std::istringstream iss_r(color_string.substr(1, 2));
std::istringstream iss_g(color_string.substr(3, 2));
std::istringstream iss_b(color_string.substr(5, 2));
std::istringstream iss_a(color_string.substr(7, 2));
iss_r >> std::hex >> r;
iss_g >> std::hex >> g;
iss_b >> std::hex >> b;
iss_a >> std::hex >> a;
return MERGE_CHANNELS(r,g,b,a);
}
| T degate::XMLImporter::parse_number | ( | const xmlpp::Element *const | node, |
| std::string const & | attribute_str | ||
| ) | const [inline, protected] |
Parse a string and convert it to a number (e.g.
double, long, unsigned int, ...).
| InvalidPointerException | is thrown, if you node is a NULL pointer. |
| XMLAttributeMissingException | The XML attribute is not present. |
Definition at line 45 of file XMLImporter.h.
{
assert(node != NULL);
if(node == NULL) throw InvalidPointerException("Parameter must be != NULL.");
if(node->get_attribute(attribute_str) == NULL) {
throw XMLAttributeMissingException(std::string("attribute is not present: ") + attribute_str);
}
else return parse_number<T>(node->get_attribute_value(attribute_str));
}
| T degate::XMLImporter::parse_number | ( | const xmlpp::Element *const | node, |
| std::string const & | attribute_str, | ||
| T | default_value | ||
| ) | [inline, protected] |
Parse a string and convert it to a number (e.g.
double, long, unsigned int, ...).
| InvalidPointerException | is thrown, if you node is a NULL pointer. |
Definition at line 63 of file XMLImporter.h.
{
assert(node != NULL);
if(node == NULL) throw InvalidPointerException();
if(node->get_attribute(attribute_str) == NULL) return default_value;
else return parse_number<T>(node->get_attribute_value(attribute_str));
}
1.7.4