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


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

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


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

示例1: run

static void run(int argc, const char* argv[])
{
    PO po;
    PO::Option& inputOpt = po.add("input").requiresValue("<filename>");
    PO::Option& widgetId = po.add("widgetid").requiresValue("<filename>");
    PO::Option& prefH = po.add("pref-h");
    PO::Option& prefCpp = po.add("pref-cpp");
    PO::Option& skin = po.add("skin");
    po.parse(argc, argv);

    // Try to load the XML file
    TiXmlDocument* doc = NULL;

    std::string inputFilename = po.value_of(inputOpt);
    if (!inputFilename.empty()) {
        base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
        doc = new TiXmlDocument();
        doc->SetValue(inputFilename.c_str());
        if (!doc->LoadFile(inputFile.get()))
            throw std::runtime_error("invalid input file");
    }

    if (doc) {
        if (po.enabled(widgetId))
            gen_ui_class(doc, inputFilename, po.value_of(widgetId));
        else if (po.enabled(prefH))
            gen_pref_header(doc, inputFilename);
        else if (po.enabled(prefCpp))
            gen_pref_impl(doc, inputFilename);
        else if (po.enabled(skin))
            gen_skin_class(doc, inputFilename);
    }
}
开发者ID:sliekasirdis79,项目名称:aseprite,代码行数:33,代码来源:gen.cpp

示例2: LoadXMLFile

void XMLUtils::LoadXMLFile( TiXmlDocument& doc, bool condenseWhiteSpace, const wxString& path )
{
	if ( path.empty() )
	{
		THROW_WXFBEX( _("LoadXMLFile needs a path") )
	}

	if ( !::wxFileExists( path ) )
	{
		THROW_WXFBEX( _("The file does not exist.\nFile: ") << path )
	}

	TiXmlBase::SetCondenseWhiteSpace( condenseWhiteSpace );
	doc.SetValue( std::string( path.mb_str( wxConvFile ) ) );
	if ( !doc.LoadFile() )
	{
		// Ask user to all wxFB to convert the file to UTF-8 and add the XML declaration
		wxString msg = _("This xml file could not be loaded. This could be the result of an unsupported encoding.\n");
		msg 		+= _("Would you like wxFormBuilder to backup the file and convert it to UTF-8\?\n");
		msg			+= _("You will be prompted for the original encoding.\n\n");
		msg			+= _("Path: ");
		msg			+= path;
		if ( wxNO == wxMessageBox( msg, _("Unable to load file"), wxICON_QUESTION | wxYES_NO | wxYES_DEFAULT, wxTheApp->GetTopWindow() ) )
		{
			// User declined, give up
			THROW_WXFBEX( _("Unable to load file: ") << path );
		}

		// User accepted, convert the file
		wxFontEncoding chosenEncoding = StringUtils::GetEncodingFromUser( _("Please choose the original encoding.") );
		if ( wxFONTENCODING_MAX == chosenEncoding )
		{
			THROW_WXFBEX( _("Unable to load file: ") << path );
		}

		ConvertAndAddDeclaration( path, chosenEncoding );

		LoadXMLFile( doc, condenseWhiteSpace, path );
	}

	TiXmlDeclaration* declaration = NULL;
	TiXmlNode* firstChild = doc.FirstChild();
	if ( firstChild )
	{
		declaration = firstChild->ToDeclaration();
	}

	LoadXMLFileImp( doc, condenseWhiteSpace, path, declaration );
}
开发者ID:Three-DS,项目名称:wxformbuilder-3.5.0,代码行数:49,代码来源:stringutils.cpp

示例3: run

static void run(int argc, const char* argv[])
{
  PO po;
  PO::Option& inputFn = po.add("input").requiresValue("<filename>");
  PO::Option& widgetId = po.add("widgetid").requiresValue("<filename>");
  po.parse(argc, argv);

  // Try to load the XML file
  TiXmlDocument* doc = NULL;

  if (inputFn.enabled()) {
    base::FileHandle inputFile(base::open_file(inputFn.value(), "rb"));
    doc = new TiXmlDocument();
    doc->SetValue(inputFn.value().c_str());
    if (!doc->LoadFile(inputFile))
      throw std::runtime_error("invalid input file");
  }

  if (doc && widgetId.enabled())
    gen_ui_class(doc, inputFn.value(), widgetId.value());
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:21,代码来源:gen.cpp

示例4: Save

void EdWidget::Save(	const char* xmlFilename,
						KrConsole* console,
						const std::string& surfaceName,
						int nTrans,
						const KrRGBA* trans )
{
	TiXmlDocument doc;
	doc.SetValue( xmlFilename );

	TiXmlElement definition( "Definition" );
	definition.SetAttribute( "filename", surfaceName.c_str() );

	for( int i=0; i<nTrans; i++ )
	{
		char key[256];
		char value[256];
		sprintf( key, "Transparent%d", i );
		sprintf( value, "#%02x%02x%02x", trans[i].c.red, trans[i].c.green, trans[i].c.blue );

		definition.SetAttribute( key, value );
	}

	GlSListIterator< EdWidget* > it( children );
	for( it.Begin(); !it.Done(); it.Next() )
		it.Current()->BuildXML( &definition );

	doc.InsertEndChild( definition );
	doc.SaveFile();
	if ( doc.Error() )
	{
		console->Print( "Error saving XML. '%s'\n", doc.ErrorDesc() );
	}
	else
	{
		console->Print( "XML file '%s' saved.\n", xmlFilename );
	}
}
开发者ID:Zitrax,项目名称:brainblast,代码行数:37,代码来源:dom.cpp

示例5: run

static void run(int argc, const char* argv[])
{
  PO po;
  PO::Option& inputOpt = po.add("input").requiresValue("<filename>");
  PO::Option& widgetId = po.add("widgetid").requiresValue("<id>");
  PO::Option& prefH = po.add("pref-h");
  PO::Option& prefCpp = po.add("pref-cpp");
  PO::Option& theme = po.add("theme");
  PO::Option& strings = po.add("strings");
  PO::Option& commandIds = po.add("command-ids");
  PO::Option& widgetsDir = po.add("widgets-dir").requiresValue("<dir>");
  PO::Option& stringsDir = po.add("strings-dir").requiresValue("<dir>");
  PO::Option& guiFile = po.add("gui-file").requiresValue("<filename>");
  po.parse(argc, argv);

  // Try to load the XML file
  TiXmlDocument* doc = nullptr;

  std::string inputFilename = po.value_of(inputOpt);
  if (!inputFilename.empty() &&
      base::get_file_extension(inputFilename) == "xml") {
    base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
    doc = new TiXmlDocument();
    doc->SetValue(inputFilename.c_str());
    if (!doc->LoadFile(inputFile.get())) {
      std::cerr << doc->Value() << ":"
                << doc->ErrorRow() << ":"
                << doc->ErrorCol() << ": "
                << "error " << doc->ErrorId() << ": "
                << doc->ErrorDesc() << "\n";

      throw std::runtime_error("invalid input file");
    }
  }

  if (doc) {
    // Generate widget class
    if (po.enabled(widgetId))
      gen_ui_class(doc, inputFilename, po.value_of(widgetId));
    // Generate preference header file
    else if (po.enabled(prefH))
      gen_pref_header(doc, inputFilename);
    // Generate preference c++ file
    else if (po.enabled(prefCpp))
      gen_pref_impl(doc, inputFilename);
    // Generate theme class
    else if (po.enabled(theme))
      gen_theme_class(doc, inputFilename);
  }
  // Generate strings.ini.h file
  else if (po.enabled(strings)) {
    gen_strings_class(inputFilename);
  }
  // Generate command_ids.ini.h file
  else if (po.enabled(commandIds)) {
    gen_command_ids(inputFilename);
  }
  // Check all translation files (en.ini, es.ini, etc.)
  else if (po.enabled(widgetsDir) &&
           po.enabled(stringsDir)) {
    check_strings(po.value_of(widgetsDir),
                  po.value_of(stringsDir),
                  po.value_of(guiFile));
  }
}
开发者ID:aseprite,项目名称:aseprite,代码行数:65,代码来源:gen.cpp


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