summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
415985b)
Bad management for node-names stack (FIFO).
Both object and array shall push keys and also shall pop them
when entering/finishing the callbacks.
Also, new member key_ will store the key (and it won't be
pushed when detected, only when starting object/array).
std::stringstream result_;
std::stringstream current_object_;
std::stack<std::string> nodes_stack_;
std::stringstream result_;
std::stringstream current_object_;
std::stack<std::string> nodes_stack_;
bool start_object(std::size_t elements) override
{
bool start_object(std::size_t elements) override
{
+ nodes_stack_.push(key_);
if (!started_) { started_ = true ; return true; } // ignore first start object (which is whole json object {)
indent_ += ANNA_XML_INDENTATION_SPACES;
result_ << std::string(indent_, ' ') << "<" << nodes_stack_.top();
if (!started_) { started_ = true ; return true; } // ignore first start object (which is whole json object {)
indent_ += ANNA_XML_INDENTATION_SPACES;
result_ << std::string(indent_, ' ') << "<" << nodes_stack_.top();
if (close == "") result_ << "</" << nodes_stack_.top() << ">";
result_ << "\n";
current_object_.str("");
if (close == "") result_ << "</" << nodes_stack_.top() << ">";
result_ << "\n";
current_object_.str("");
return true;
}
bool start_array(std::size_t elements) override
{
return true;
}
bool start_array(std::size_t elements) override
{
+ nodes_stack_.push(key_);
result_ << current_object_.str() << ">\n";
current_object_.str("");
return true;
result_ << current_object_.str() << ">\n";
current_object_.str("");
return true;
bool key(string_t& val) override
{
if (val[0] != '@') {
bool key(string_t& val) override
{
if (val[0] != '@') {
- nodes_stack_.push(val);
}
else {
current_object_ << " " << val.substr(1) << "=";
}
else {
current_object_ << " " << val.substr(1) << "=";