#include "otmlemitter.h" #include "otmldocument.h" std::string OTMLEmitter::emitNode(const OTMLNodePtr& node, int currentDepth) { std::stringstream ss; // emit nodes if(currentDepth >= 0) { // fill spaces for current depth for(int i=0;ihasTag()) { ss << node->tag(); // add ':' to if the node is unique or has value if(node->hasValue() || node->isUnique() || node->isNull()) ss << ":"; } else ss << "-"; // emit node value if(node->isNull()) ss << " ~"; else if(node->hasValue()) { ss << " "; std::string value = node->value(); // emit multiline values if(value.find("\n") != std::string::npos) { if(value[value.length()-1] == '\n' && value[value.length()-2] == '\n') ss << "|+"; else if(value[value.length()-1] == '\n') ss << "|"; else ss << "|-"; // multilines for(std::size_t pos = 0; pos < value.length(); ++pos) { ss << "\n"; // fill spaces for multiline depth for(int i=0;isize();++i) { if(currentDepth >= 0 || i != 0) ss << "\n"; ss << emitNode(node->atIndex(i), currentDepth+1); } return ss.str(); }