当前位置: 首页>>代码示例>>C++>>正文


C++ XMLText::SetValue方法代码示例

本文整理汇总了C++中XMLText::SetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLText::SetValue方法的具体用法?C++ XMLText::SetValue怎么用?C++ XMLText::SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLText的用法示例。


在下文中一共展示了XMLText::SetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeDictItem

void Configure::writeDictItem(int item)
{
    if (item > DICTNODE_NUM_MAX)
        return;
    SpinLock lock(m_cs);
    XMLElement* dictElement = XMLHandle(m_doc.RootElement()).FirstChildElement("dict").ToElement();
    XMLElement* e = util::XMLUtil::Child(dictElement, item);
    if (e == NULL) {
        e = m_doc.NewElement("d");
        e->SetAttribute("open",   m_dictNodes[item].open.c_str());
        e->SetAttribute("en",     m_dictNodes[item].en);

        XMLElement* textE = m_doc.NewElement("summary");
	    textE->InsertFirstChild(m_doc.NewText(m_dictNodes[item].summary.c_str()));
		e->InsertFirstChild(textE);

    	textE = m_doc.NewElement("path");
    	textE->InsertFirstChild(m_doc.NewText(m_dictNodes[item].path.c_str()));
    	e->InsertFirstChild(textE);

    	textE = m_doc.NewElement("name");
    	textE->InsertFirstChild(m_doc.NewText(m_dictNodes[item].name.c_str()));
    	e->InsertFirstChild(textE);

    	textE = m_doc.NewElement("detlan");
    	textE->InsertFirstChild(m_doc.NewText(m_dictNodes[item].detlan.c_str()));
    	e->InsertFirstChild(textE);

    	textE = m_doc.NewElement("srclan");
    	textE->InsertFirstChild(m_doc.NewText(m_dictNodes[item].srclan.c_str()));
    	e->InsertFirstChild(textE);

        dictElement->InsertEndChild(e);
    } else {
        e->SetAttribute("open",   m_dictNodes[item].open.c_str());
        e->SetAttribute("en",     m_dictNodes[item].en);

        XMLText* txt = e->FirstChildElement("path")->FirstChild()->ToText();
    	txt->SetValue(m_dictNodes[item].path.c_str());

        txt = e->FirstChildElement("name")->FirstChild()->ToText();
    	txt->SetValue(m_dictNodes[item].name.c_str());

        txt = XMLHandle(e).FirstChildElement("detlan").FirstChild().ToText();
        if (txt)
    	    txt->SetValue(m_dictNodes[item].detlan.c_str());

        txt = XMLHandle(e).FirstChildElement("srclan").FirstChild().ToText();
        if (txt)
    	    txt->SetValue(m_dictNodes[item].srclan.c_str());

        txt = XMLHandle(e).FirstChildElement("summary").FirstChild().ToText();
        if (txt)
            txt->SetValue(m_dictNodes[item].summary.c_str());
    }
    /*printf("writeDictItem(%s): %d, %s -> %s\n", ndname.c_str(), 
           item, m_dictNodes[item].srclan.c_str(), m_dictNodes[item].detlan.c_str());*/
    m_dirty = true;
}
开发者ID:kartorz,项目名称:AlphaDict,代码行数:59,代码来源:Configure.cpp

示例2: NewText

	XMLText* XMLDocument::NewText( const char* str )
	{
		XMLText* text = new (_textPool.Alloc()) XMLText( this );
		text->_memPool = &_textPool;
		text->SetValue( str );
		return text;
	}
开发者ID:dominik-uebele,项目名称:E1,代码行数:7,代码来源:tinyxml2.cpp

示例3: writeDetLan

void Configure::writeDetLan(const string& lan)
{
    if (m_detLan.compare(lan) != 0) {
        SpinLock lock(m_cs);
	    m_detLan = lan;
        XMLText* txt = XMLHandle(m_doc.RootElement()).FirstChildElement("detlan").FirstChild().ToText();
        if (txt) {
            txt->SetValue(lan.c_str());
            m_dirty = true;
        }
    }
}
开发者ID:kartorz,项目名称:AlphaDict,代码行数:12,代码来源:Configure.cpp

示例4: save

bool FractalConfiguration::save(string filename)
{
	if(invalidID())
		return true;

	// Check filename and append .xml
	if(!endsWith(filename, ".xml"))
		filename += ".xml";

	// Create document
	XMLDocument doc;

	// Root element
	XMLElement *root = doc.NewElement("fractal");
	root->SetAttribute("id", m_id.c_str());
	doc.InsertEndChild(root);

	// Add properties
	iterate();

	while(true)
	{
		if(!next())
			break;
		
		XMLElement *prop = doc.NewElement("property");
		prop->SetAttribute("name", getName().c_str());

		XMLText *text = doc.NewText("");

		if(isString())
		{
			prop->SetAttribute("type", "string");

			text->SetValue(getString().c_str());
		}
		else if(isInt())
		{
			prop->SetAttribute("type", "int");

			stringstream ss;
			ss << getInt();
			text->SetValue(ss.str().c_str());
		}
		else if(isDouble())
		{
			prop->SetAttribute("type", "double");

			stringstream ss;
			ss << getDouble();
			text->SetValue(ss.str().c_str());
		}
		else if(isBool())
		{
			prop->SetAttribute("type", "bool");

			if(getBool())
				text->SetValue("1");
			else
				text->SetValue("0");
		}

		prop->InsertEndChild(text);
		root->InsertEndChild(prop);
	}

	// Save to file
	if(doc.SaveFile(filename.c_str()) != XML_NO_ERROR)
	{
		m_last_error = doc.GetErrorStr1();
		return true;
	}

	resetDirty();

	return false;
}
开发者ID:svenhertle,项目名称:fractalimages,代码行数:77,代码来源:FractalConfiguration.cpp


注:本文中的XMLText::SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。