document_builder_t is now working.
This commit is contained in:
parent
59fc3d1bdb
commit
687ee1a7c3
4 changed files with 21 additions and 17 deletions
|
|
@ -124,7 +124,6 @@ pkginclude_HEADERS = \
|
|||
src/tuples.hpp \
|
||||
src/utils.h \
|
||||
src/value.h \
|
||||
src/xml.h \
|
||||
src/xpath.h
|
||||
|
||||
###############################################################################
|
||||
|
|
|
|||
17
src/node.cc
17
src/node.cc
|
|
@ -60,17 +60,22 @@ void output_xml_string(std::ostream& out, const string& str)
|
|||
}
|
||||
}
|
||||
|
||||
void parent_node_t::print(std::ostream& out) const
|
||||
void node_t::print_attributes(std::ostream& out) const
|
||||
{
|
||||
out << '<' << name();
|
||||
if (attributes) {
|
||||
typedef attributes_t::nth_index<0>::type attributes_by_order;
|
||||
foreach (const attr_pair& attr, attributes->get<0>())
|
||||
out << ' ' << document().lookup_name(attr.first)
|
||||
out << ' ' << *document().lookup_name(attr.first)
|
||||
<< "=\"" << attr.second << "\"";
|
||||
}
|
||||
IF_VERIFY()
|
||||
out << " type=\"parent_node_t\"";
|
||||
}
|
||||
|
||||
void parent_node_t::print(std::ostream& out) const
|
||||
{
|
||||
out << '<' << name();
|
||||
print_attributes(out);
|
||||
out << '>';
|
||||
|
||||
foreach (node_t * child, *this)
|
||||
|
|
@ -83,13 +88,11 @@ void terminal_node_t::print(std::ostream& out) const
|
|||
{
|
||||
if (data.empty()) {
|
||||
out << '<' << name();
|
||||
IF_VERIFY()
|
||||
out << " type=\"terminal_node_t\"";
|
||||
print_attributes(out);
|
||||
out << " />";
|
||||
} else {
|
||||
out << '<' << name();
|
||||
IF_VERIFY()
|
||||
out << " type=\"terminal_node_t\"";
|
||||
print_attributes(out);
|
||||
out << '>';
|
||||
output_xml_string(out, text());
|
||||
out << "</" << name() << '>';
|
||||
|
|
|
|||
|
|
@ -102,8 +102,9 @@ public:
|
|||
return *polymorphic_downcast<const parent_node_t *>(this);
|
||||
}
|
||||
|
||||
virtual value_t to_value() const = 0;
|
||||
virtual value_t to_value() const = 0;
|
||||
virtual void print(std::ostream& out) const = 0;
|
||||
virtual void print_attributes(std::ostream& out) const;
|
||||
|
||||
const char * name() const;
|
||||
nameid_t name_id() const {
|
||||
|
|
@ -168,6 +169,7 @@ public:
|
|||
T * create_child(nameid_t _name_id) {
|
||||
T * child = new T(_name_id, document(), *this);
|
||||
children.push_back(child);
|
||||
return child;
|
||||
}
|
||||
|
||||
void delete_child(node_t * child) {
|
||||
|
|
|
|||
|
|
@ -104,14 +104,14 @@ void parse_transaction(builder_t& builder,
|
|||
*e = '\0';
|
||||
}
|
||||
|
||||
builder.begin_node(ACCOUNT_PATH_NODE);
|
||||
builder.begin_node(ACCOUNT_PATH_NODE, true);
|
||||
builder.append_text(account_path);
|
||||
builder.end_node(ACCOUNT_PATH_NODE);
|
||||
|
||||
// Parse the optional amount
|
||||
|
||||
if (amount) {
|
||||
builder.begin_node(AMOUNT_EXPR_NODE);
|
||||
builder.begin_node(AMOUNT_EXPR_NODE, true);
|
||||
builder.append_text(amount);
|
||||
builder.end_node(AMOUNT_EXPR_NODE);
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ void parse_transaction(builder_t& builder,
|
|||
// Parse the optional note
|
||||
|
||||
if (note) {
|
||||
builder.begin_node(NOTE_NODE);
|
||||
builder.begin_node(NOTE_NODE, true);
|
||||
builder.append_text(note);
|
||||
builder.end_node(NOTE_NODE);
|
||||
}
|
||||
|
|
@ -246,7 +246,7 @@ void parse_entry(std::istream& in,
|
|||
|
||||
builder.begin_node(ENTRY_NODE);
|
||||
|
||||
builder.begin_node(PAYEE_NODE);
|
||||
builder.begin_node(PAYEE_NODE, true);
|
||||
assert(payee);
|
||||
builder.append_text(*payee != '\0' ? payee : "<Unspecified payee>");
|
||||
builder.end_node(PAYEE_NODE, end_of_line);
|
||||
|
|
@ -319,7 +319,7 @@ void textual_parser_t::parse(std::istream& in,
|
|||
|
||||
builder.push_attr(TIME_ATTR, date);
|
||||
builder.push_attr(ACCOUNT_ATTR, p);
|
||||
builder.begin_node(CHECKIN_NODE);
|
||||
builder.begin_node(CHECKIN_NODE, true);
|
||||
builder.append_text(n);
|
||||
builder.end_node(CHECKIN_NODE, end_of_line);
|
||||
break;
|
||||
|
|
@ -334,7 +334,7 @@ void textual_parser_t::parse(std::istream& in,
|
|||
|
||||
builder.push_attr(TIME_ATTR, date);
|
||||
builder.push_attr(ACCOUNT_ATTR, p);
|
||||
builder.begin_node(CHECKIN_NODE);
|
||||
builder.begin_node(CHECKIN_NODE, true);
|
||||
builder.append_text(n);
|
||||
builder.end_node(CHECKIN_NODE, end_of_line);
|
||||
break;
|
||||
|
|
@ -430,7 +430,7 @@ void textual_parser_t::parse(std::istream& in,
|
|||
|
||||
case '=': { // automated entry
|
||||
builder.begin_node(AUTO_ENTRY_NODE);
|
||||
builder.begin_node(RULE_NODE);
|
||||
builder.begin_node(RULE_NODE, true);
|
||||
builder.append_text(skip_ws(line + 1));
|
||||
builder.end_node(RULE_NODE);
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ void textual_parser_t::parse(std::istream& in,
|
|||
|
||||
case '~': // period entry
|
||||
builder.begin_node(PERIOD_ENTRY_NODE);
|
||||
builder.begin_node(PERIOD_NODE);
|
||||
builder.begin_node(PERIOD_NODE, true);
|
||||
builder.append_text(skip_ws(line + 1));
|
||||
builder.end_node(PERIOD_NODE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue