void CustomXmlDataWriter::writeValue(const Variant& value) { CustomXmlData data; bool isOk = value.tryCast(data); assert(isOk); if (!isOk) { stream_.setState(std::ios_base::failbit); return; } beginOpenTag("name"); endOpenTag(); stream_ << quoted(data.name_); closeTag("name"); beginOpenTag("filename"); endOpenTag(); stream_ << quoted(data.filename_); closeTag("filename"); beginOpenTag("createdBy"); endOpenTag(); stream_ << quoted(data.createdBy_); closeTag("createdBy"); beginOpenTag("visibility"); endOpenTag(); stream_ << data.visibility_; closeTag("visibility"); beginOpenTag("position"); endOpenTag(); stream_ << data.position_; closeTag("position"); }
void zu::xml_writer::do_assignment_node(zu::assignment_node * const node, int lvl) { CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); node->lvalue()->accept(this, lvl + 2); openTag("rvalue", lvl + 2); node->rvalue()->accept(this, lvl + 4); closeTag("rvalue", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_mem_alloc_node(zu::mem_alloc_node * const node, int lvl){ // FIXME CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); openTag("total_elements", lvl + 2); node->total_elements()->accept(this, lvl + 4); closeTag("total_elements", lvl + 2); closeTag(node, lvl); }
void cpt::semantics::XMLwriter::processFunctionCall(cpt::node::expression::FunctionCall * const node, int lvl) { os() << std::string(lvl, ' ') << "<" << node->name() \ << " identifier='" << node->identifier() << "'" \ << ">" << std::endl; openTag("arguments", lvl+2); node->arguments()->accept(this, lvl+4); closeTag("arguments", lvl+2); closeTag(node, lvl); }
void cpt::semantics::XMLwriter::processIfNode(cpt::node::IfNode * const node, int lvl) { openTag(node, lvl); openTag("condition", lvl + 2); node->condition()->accept(this, lvl + 4); closeTag("condition", lvl + 2); openTag("then", lvl + 2); node->block()->accept(this, lvl + 4); closeTag("then", lvl + 2); closeTag(node, lvl); }
void cpt::semantics::XMLwriter::processDoWhileNode(cpt::node::DoWhileNode * const node, int lvl) { openTag(node, lvl); openTag("instruction", lvl + 2); node->instruction()->accept(this, lvl + 4); closeTag("instruction", lvl + 2); openTag("condition", lvl + 2); node->condition()->accept(this, lvl + 4); closeTag("condition", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_if_node(zu::if_node * const node, int lvl) { openTag(node, lvl); openTag("condition", lvl + 2); node->condition()->accept(this, lvl + 4); closeTag("condition", lvl + 2); openTag("then", lvl + 2); node->block()->accept(this, lvl + 4); closeTag("then", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_mem_index_node(zu::mem_index_node * const node, int lvl){ // FIXME openTag(node, lvl); openTag("base address", lvl + 2); node->base_addr()->accept(this, lvl + 4); closeTag("base address", lvl + 2); openTag("offset", lvl + 2); node->offset()->accept(this, lvl + 4); closeTag("offset", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_function_invocation_node(zu::function_invocation_node * const node, int lvl) { // FIXME CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); openTag("identifier", lvl + 2); node->identifier()->accept(this, lvl + 4); closeTag("identifier", lvl + 2); openTag("arguments", lvl + 2); if(node->args() != nullptr) node->args()->accept(this, lvl + 4); closeTag("arguments", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_block_node(zu::block_node * const node, int lvl){ CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); openTag("declarations", lvl + 2); if(node->declarations() != nullptr) node->declarations()->accept(this, lvl + 4); closeTag("declarations", lvl + 2); openTag("instructions", lvl + 2); if(node->instructions() != nullptr) node->instructions()->accept(this, lvl + 4); closeTag("instructions", lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_if_else_node(zu::if_else_node * const node, int lvl) { openTag(node, lvl); openTag("condition", lvl + 2); node->condition()->accept(this, lvl + 4); closeTag("condition", lvl + 2); openTag("then", lvl + 2); node->thenblock()->accept(this, lvl + 4); closeTag("then", lvl + 2); openTag("else", lvl + 2); if(node->elseblock() != nullptr) node->elseblock()->accept(this, lvl + 4); closeTag("else", lvl + 2); closeTag(node, lvl); }
//--------------------------------------------------------------------------- void cpt::semantics::XMLwriter::processBlock(cpt::node::Block * const node, int lvl) { openTag(node, lvl); if(node->declarations() != NULL) { openTag("declarations", lvl+2); node->declarations()->accept(this, lvl+4); closeTag("declarations", lvl+2); } if(node->instructions() != NULL) { openTag("instructions", lvl+2); node->instructions()->accept(this, lvl+4); closeTag("instructions", lvl+2); } closeTag(node, lvl); }
//--------------------------------------------------------------------------- void cpt::semantics::XMLwriter::processVariableDeclaration(cpt::node::VariableDeclaration * const node, int lvl) { os() << std::string(lvl, ' ') << "<" << node->name() \ << " identifier='" << node->identifier() << "'" \ << " type='" << type2str(node->type()) << "'" \ << " is_public='" << node->is_public() << "'" \ << " is_const='" << node->is_const() << "'" \ << ">" << std::endl; if(node->initial_value() != NULL) { openTag("initial_value", lvl+2); node->initial_value()->accept(this, lvl+4); closeTag("initial_value", lvl+2); } closeTag(node, lvl); }
void ZLStatisticsXMLWriter::writeStatistics(const ZLMapBasedStatistics &statistics) { addTag("statistics", false); std::string charSequenceSizeString; std::string volumeString; std::string squaresVolumeString; std::string sizeString; ZLStringUtil::appendNumber(charSequenceSizeString, statistics.getCharSequenceSize()); ZLStringUtil::appendNumber(sizeString, statistics.getSize()); ZLStringUtil::appendNumber(volumeString, statistics.getVolume()); ZLStatisticsXMLWriter::appendLongNumber(squaresVolumeString, statistics.getSquaresVolume()); addAttribute("charSequenceSize", charSequenceSizeString); addAttribute("size", sizeString); addAttribute("volume", volumeString); addAttribute("squaresVolume", squaresVolumeString); //ZLStatisticsItem *ptr = statistics.begin(); //const ZLStatisticsItem *end = statistics.end(); shared_ptr<ZLStatisticsItem> ptr = statistics.begin(); const shared_ptr<ZLStatisticsItem> end = statistics.end(); while (*ptr != *end) { writeSequence(ptr->sequence().toHexSequence(), ptr->frequency()); ptr->next(); } //delete ptr; //delete end; closeTag(); }
void cpt::semantics::XMLwriter::processSequence(cdk::node::Sequence * const node, int lvl) { os() << std::string(lvl, ' ') << "<Sequence size='" << node->size() << "'>" << std::endl; for (size_t i = 0; i < node->size(); i++) { node->node(i)->accept(this, lvl + 2); } closeTag(node, lvl); }
void cpt::semantics::XMLwriter::processPrintNode(cpt::node::PrintNode * const node, int lvl) { os() << std::string(lvl, ' ') << "<" << node->name() \ << " print_newline='" << node->print_newline() << "'" \ << ">" << std::endl; node->argument()->accept(this, lvl + 2); closeTag(node, lvl); }
void zu::xml_writer::do_var_declaration_node(zu::var_declaration_node * const node, int lvl){ // FIXME openTag(node, lvl); openTag("visibility", lvl + 2); os() << std::string(lvl + 4, ' ') << node->visibility() << std::endl; closeTag("visibility", lvl + 2); openTag("external", lvl + 2); os() << std::string(lvl + 4, ' ') << node->ext() << std::endl; closeTag("external", lvl + 2); openTag("type type=" + convert_types(node->type()), lvl + 2); closeTag("type", lvl + 2); openTag("identifier", lvl + 2); node->identifier()->accept(this, lvl + 4); closeTag("identifier", lvl + 2); closeTag(node, lvl); }
void cpt::semantics::XMLwriter::processIncrement(cpt::node::expression::Increment * const node, int lvl) { os() << std::string(lvl, ' ') << "<" << node->name() \ << " is_prefix='" << node->is_prefix() << "'" \ << ">" << std::endl; node->argument()->accept(this, lvl+2); closeTag(node, lvl); }
void zu::xml_writer::do_println_node(zu::println_node * const node, int lvl) { // FIXME CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); node->argument()->accept(this, lvl + 2); closeTag(node, lvl); }
bool CustomXmlDataWriter::write(const Variant& value) { beginOpenTag(value.type()->name()); writeValue(value); closeTag(value.type()->name()); return !fail(); }
//--------------------------------------------------------------------------- void cpt::semantics::XMLwriter::processForDownToNode(cpt::node::ForDownToNode * const node, int lvl) { openTag(node, lvl); openTag("LeftValue", lvl+2); node->leftvalue()->accept(this, lvl+4); closeTag("LeftValue", lvl+2); openTag("Start", lvl+2); node->start()->accept(this, lvl+4); closeTag("Start", lvl+2); openTag("End", lvl+2); node->end()->accept(this, lvl+4); closeTag("End", lvl+2); openTag("Step", lvl+2); node->step()->accept(this, lvl+4); closeTag("Step", lvl+2); node->block()->accept(this, lvl+4); closeTag(node, lvl); }
/** * Adds a new node. * @param name the name of the new node (tag) */ void DomNode::addNode( const char *name ) { closeTag( true ); str += " <"; str += name; hasChildren = false; ++documentLevel; }
inline void XmlNode::appendHead(std::ostream& ss) const { ss << "<" << name << attributes << closeTag() << ">"; }
void zu::xml_writer::do_sequence_node(cdk::sequence_node * const node, int lvl) { os() << std::string(lvl, ' ') << "<sequence_node size='" << node->size() << "'>" << std::endl; for (size_t i = 0; i < node->size(); i++){ if(node->node(i) != nullptr) node->node(i)->accept(this, lvl + 2); } closeTag(node, lvl); }
void zu::xml_writer::do_function_declaration_node(zu::function_declaration_node * const node, int lvl) { // FIXME openTag(node, lvl); openTag("identifier", lvl + 2); node->identifier()->accept(this, lvl + 4); closeTag("identifier", lvl + 2); openTag("visibility", lvl + 2); os() << std::string(lvl + 4, ' ') << node->visibility() << std::endl; closeTag("visibility", lvl + 2); openTag("external", lvl + 2); os() << std::string(lvl + 4, ' ') << node->ext() << std::endl; closeTag("external", lvl + 2); if(node->return_type() != nullptr){ openTag("return_type type=" + convert_types(node->return_type()), lvl + 2); closeTag("return_type", lvl + 2); } openTag("arguments", lvl + 2); if(node->args() != nullptr) node->args()->accept(this, lvl + 4); closeTag("arguments", lvl + 2); openTag("literal", lvl + 2); if(node->literal() != nullptr) node->literal()->accept(this, lvl + 4); closeTag("literal", lvl + 2); closeTag(node, lvl); }
inline void zu::xml_writer::processBinaryExpression(cdk::binary_expression_node * const node, int lvl) { CHECK_TYPES(_compiler, _symtab, node); openTag(node, lvl); if(node->left() != nullptr) node->left()->accept(this, lvl + 2); if(node->right() != nullptr) node->right()->accept(this, lvl + 2); closeTag(node, lvl); }
//--------------------------------------------------------------------------- void cpt::semantics::XMLwriter::processFunctionDeclaration(cpt::node::FunctionDeclaration * const node, int lvl) { os() << std::string(lvl, ' ') << "<" << node->name() \ << " identifier='" << node->identifier() << "'" \ << " type='" << type2str(node->type()) << "'" \ << " is_public='" << node->is_public() << "'"; os() << ">" << std::endl; if(node->arguments() != NULL) { openTag("Arguments", lvl+2); node->arguments()->accept(this, lvl+4); closeTag("Arguments", lvl+2); } if(node->literal() != NULL) { openTag("Literal", lvl+2); node->literal()->accept(this, lvl+4); closeTag("Literal", lvl+2); } closeTag(node, lvl); }
xmlLogger::~xmlLogger() { #if USE_PC_LOGGER /** Closes the global "session" tag */ if(m_logging_enabled) { closeTag(); } #endif }
void OutputDevice::close() { while (closeTag()) {} for (std::map<std::string, OutputDevice*>::iterator i = myOutputDevices.begin(); i != myOutputDevices.end(); ++i) { if (i->second == this) { myOutputDevices.erase(i); break; } } delete this; }
XmlOutput& XmlOutput::operator<<(const xml_output& o) { switch(o.xo_type) { case tNothing: break; case tRaw: addRaw(o.xo_text); break; case tDeclaration: addDeclaration(o.xo_text, o.xo_value); break; case tTag: newTagOpen(o.xo_text); break; case tCloseTag: if (o.xo_value.count()) closeAll(); else if (o.xo_text.count()) closeTo(o.xo_text); else closeTag(); break; case tAttribute: addAttribute(o.xo_text, o.xo_value); break; case tData: { // Special case to be able to close tag in normal // way ("</tag>", not "/>") without using addRaw().. if (!o.xo_text.count()) { closeOpen(); break; } QString output = doConversion(o.xo_text); output.replace('\n', "\n" + currentIndent); addRaw(QString("\n%1%2").arg(currentIndent).arg(output)); } break; case tComment: { QString output("<!--%1-->"); addRaw(output.arg(o.xo_text)); } break; case tCDATA: { QString output("<![CDATA[\n%1\n]]>"); addRaw(output.arg(o.xo_text)); } break; } return *this; }