コード例 #1
0
ファイル: custom_xml_writer.cpp プロジェクト: wgsyd/wgtf
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");
}
コード例 #2
0
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);
}
コード例 #3
0
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);
}
コード例 #4
0
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);
}
コード例 #5
0
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);
}
コード例 #6
0
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);
}
コード例 #7
0
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);
}
コード例 #8
0
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);
}
コード例 #9
0
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);
}
コード例 #10
0
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);
}
コード例 #11
0
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);
}
コード例 #12
0
//---------------------------------------------------------------------------
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);
}
コード例 #13
0
//---------------------------------------------------------------------------
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);
}
コード例 #14
0
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();
}
コード例 #15
0
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);
}
コード例 #16
0
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);
}
コード例 #17
0
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);
}
コード例 #18
0
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);
}
コード例 #19
0
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);
}
コード例 #20
0
ファイル: custom_xml_writer.cpp プロジェクト: wgsyd/wgtf
bool CustomXmlDataWriter::write(const Variant& value)
{
	beginOpenTag(value.type()->name());
	writeValue(value);
	closeTag(value.type()->name());

	return !fail();
}
コード例 #21
0
//---------------------------------------------------------------------------
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);
}
コード例 #22
0
ファイル: rtfimport_dom.cpp プロジェクト: JeremiasE/KFormula
/**
 * 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;
}
コード例 #23
0
ファイル: XmlNode.cpp プロジェクト: suxinde2009/magellan
inline void XmlNode::appendHead(std::ostream& ss) const
{
    ss << "<"
       << name
       << attributes
       << closeTag()
       << ">";
}
コード例 #24
0
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);
}
コード例 #25
0
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);
}
コード例 #26
0
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);
}
コード例 #27
0
//---------------------------------------------------------------------------
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);
}
コード例 #28
0
ファイル: xmlLogger.cpp プロジェクト: teragonaudio/PulseDelay
xmlLogger::~xmlLogger()
{
#if USE_PC_LOGGER
  /** Closes the global "session" tag */
  if(m_logging_enabled)
  {
    closeTag();
  }
#endif
}
コード例 #29
0
ファイル: OutputDevice.cpp プロジェクト: p1tt1/sumo
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;
}
コード例 #30
0
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;
}