示例#1
0
int main()
{
	XML XmlFile("test.xml");
	std::vector<XMLNode<std::string, double> > agents;
	agents = XmlFile.QueryElement<std::string, double, std::string> ( "agent" );
	printer( agents );

	for ( unsigned int i = 0; i < agents.size(); i++ )
	{
		std::vector<XMLNode<std::string, double> > modules;
		modules = XmlFile.QueryElement<std::string, double, std::string> ( "module", &(agents[i]) );
		printer( modules );
	}

	return 0;
}
FCrashDescription::FCrashDescription( FString WERXMLFilepath ) :
	// WER XML files are forced to be in the first version
	CrashDescriptionVersion( ECrashDescVersions::VER_1_NewCrashFormat ),
	BuiltFromCL( -1 ),
	TimeOfCrash( FDateTime::UtcNow() ),
	bHasMiniDumpFile( false ),
	bHasLogFile( false ),
	bHasVideoFile( false ),
	bHasCompleteData( false )
{
	InitializeIDs();

	// This is for the current system that uses files from Windows Error Reporting.
	// Will be replaced with the unified version soon.
	FXmlFile XmlFile( WERXMLFilepath );

	ReportName = FPaths::GetPath( WERXMLFilepath );
	FPaths::NormalizeDirectoryName( ReportName );
	// Grab the last component...
	ReportName = FPaths::GetCleanFilename( ReportName );

	const bool bIsValid = XmlFile.IsValid();
	if( bIsValid )
	{
		const FXmlNode* OSVersionInformationNode = XmlFile.GetRootNode()->FindChildNode( TEXT( "OSVersionInformation" ) );
		const FXmlNode* ProblemSignaturesNode = XmlFile.GetRootNode()->FindChildNode( TEXT( "ProblemSignatures" ) );
		const FXmlNode* DynamicSignaturesNode = XmlFile.GetRootNode()->FindChildNode( TEXT( "DynamicSignatures" ) );

		FString Product;
		int EngineVersionComponents = 0;

		if( OSVersionInformationNode )
		{
			const FXmlNode* ProductNode = OSVersionInformationNode->FindChildNode( TEXT( "Product" ) );
			if( ProductNode )
			{
				Product = ProductNode->GetContent();
			}
		}

		if( ProblemSignaturesNode )
		{
			const FXmlNode* GameNameNode = ProblemSignaturesNode->FindChildNode( TEXT( "Parameter0" ) );
			if( GameNameNode )
			{
				GameName = GameNameNode->GetContent();
			}

			const FXmlNode* BuildVersionNode = ProblemSignaturesNode->FindChildNode( TEXT( "Parameter1" ) );
			if( BuildVersionNode )
			{
				BuildVersion = BuildVersionNode->GetContent();
				EngineVersionComponents++;
			}

			const FXmlNode* Parameter8Node = ProblemSignaturesNode->FindChildNode( TEXT( "Parameter8" ) );
			if( Parameter8Node )
			{
				const FString Parameter8Value = Parameter8Node->GetContent();

				TArray<FString> ParsedParameters8;
				Parameter8Value.ParseIntoArray( ParsedParameters8, TEXT( "!" ), false );

				if( ParsedParameters8.Num() > 1 )
				{
					CommandLine = UnescapeXMLString( ParsedParameters8[1] );
				}

				if( ParsedParameters8.Num() > 2 )
				{
					ErrorMessage.Add( ParsedParameters8[2] );
				}
			}

			const FXmlNode* Parameter9Node = ProblemSignaturesNode->FindChildNode( TEXT( "Parameter9" ) );
			if( Parameter9Node )
			{
				const FString Parameter9Value = Parameter9Node->GetContent();

				TArray<FString> ParsedParameters9;
				Parameter9Value.ParseIntoArray( ParsedParameters9, TEXT( "!" ), false );

				if( ParsedParameters9.Num() > 0 )
				{
					BranchName = ParsedParameters9[0].Replace( TEXT( "+" ), TEXT( "/" ) );

					const FString DepotRoot = TEXT( "//depot/" );
					if( BranchName.StartsWith( DepotRoot ) )
					{
						BranchName = BranchName.Mid( DepotRoot.Len() );
					}
					EngineVersionComponents++;
				}

				if( ParsedParameters9.Num() > 1 )
				{
					const FString BaseDirectory = ParsedParameters9[1];

					TArray<FString> SubDirs;
					BaseDirectory.ParseIntoArray( SubDirs, TEXT( "/" ), true );
					const int SubDirsNum = SubDirs.Num();
					const FString PlatformName = SubDirsNum > 0 ? SubDirs[SubDirsNum - 1] : TEXT("");
					if( Product.Len() > 0 )
					{
						Platform = FString::Printf( TEXT( "%s [%s]" ), *PlatformName, *Product );
					}
					else
					{
						Platform = PlatformName;
					}
				}

				if( ParsedParameters9.Num() > 2 )
				{
					EngineMode = ParsedParameters9[2];
				}

				if( ParsedParameters9.Num() > 3 )
				{
					TTypeFromString<uint32>::FromString( BuiltFromCL, *ParsedParameters9[3] );
					EngineVersionComponents++;
				}
			}
		}

		if( DynamicSignaturesNode )
		{
			const FXmlNode* LanguageNode = DynamicSignaturesNode->FindChildNode( TEXT( "Parameter2" ) );
			if( LanguageNode )
			{
				LanguageLCID = LanguageNode->GetContent();
			}
		}

		// We have all three components of the engine version, so initialize it.
		if( EngineVersionComponents == 3 )
		{
			InitializeEngineVersion();
		}

		bHasCompleteData = true;
	}
	else
	{
		bHasCompleteData = false;
	}
}
示例#3
0
void WServer::CreateWtXmlConfiguration()
{
	//<server> element
	Wt::rapidxml::xml_node<> *NodeServer = XmlDoc.allocate_node(Wt::rapidxml::node_element, "server");
	XmlDoc.append_node(NodeServer);

	//<application-settings> element
	Wt::rapidxml::xml_node<> *NodeAppSett = XmlDoc.allocate_node(Wt::rapidxml::node_element, "application-settings");
	NodeAppSett->append_attribute(XmlDoc.allocate_attribute("location", "*"));
	NodeServer->append_node(NodeAppSett);

	//<session-management> element
	Wt::rapidxml::xml_node<> *NodeSessMgmt = XmlDoc.allocate_node(Wt::rapidxml::node_element, "session-management");
	NodeAppSett->append_node(NodeSessMgmt);

	//<session-management> child element <shared-process>
	Wt::rapidxml::xml_node<> *NodeSharedProcess = XmlDoc.allocate_node(Wt::rapidxml::node_element, "shared-process");
	NodeSessMgmt->append_node(NodeSharedProcess);

	//<shared-process> child element <num-processes>
	NodeSharedProcess->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "num-processes", "1"));

	//<session-management> child element <tracking>
	Wt::rapidxml::xml_node<> *NodeTracking = XmlDoc.allocate_node(Wt::rapidxml::node_element, "tracking");
	switch(_Configurations->GetEnum("SessionTracking", ModulesDatabase::Server, 1))
	{
		default:
		case 1:
			NodeTracking->value("Auto");
		break;
		case 2:
			NodeTracking->value("URL");
		break;
	}
	NodeSessMgmt->append_node(NodeTracking);

	//<session-management> child element <reload-is-new-session>
	NodeSessMgmt->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "reload-is-new-session", "false"));

	//<session-management> child element <timeout>
	int ConfSessionTimeout = _Configurations->GetInt("SessionTimeout", ModulesDatabase::Server, 600);
	if(ConfSessionTimeout < 60) ConfSessionTimeout = 60;
	std::string ConfSessionTimeoutStr = boost::lexical_cast<std::string>(ConfSessionTimeout);
	NodeSessMgmt->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "timeout", ConfSessionTimeoutStr.c_str()));

	//<connector-fcgi> element
	Wt::rapidxml::xml_node<> *NodeConnectorFcgi = XmlDoc.allocate_node(Wt::rapidxml::node_element, "connector-fcgi");
	NodeAppSett->append_node(NodeConnectorFcgi);

	//<connector-fcgi> child element <run-directory>
	NodeConnectorFcgi->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "run-directory", "C:/witty")); //TODO Gotta understand this first

	//<connector-fcgi> child element <num-threads>
	NodeConnectorFcgi->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "num-threads", "5")); //TODO Gotta understand this first

	//<connector-isapi> element
	Wt::rapidxml::xml_node<> *NodeConnectorIsapi = XmlDoc.allocate_node(Wt::rapidxml::node_element, "connector-isapi");
	NodeAppSett->append_node(NodeConnectorIsapi);

	//<connector-isapi> child element <num-threads>
	NodeConnectorIsapi->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "num-threads", "10")); //TODO Gotta understand this first

	//<connector-isapi> child element <max-memory-request-size>
	NodeConnectorIsapi->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "max-memory-request-size", "128")); //TODO Gotta understand this first

	//<debug> element
	switch(_Configurations->GetEnum("JavascriptDebug", ModulesDatabase::Server, 1))
	{
		default:
		case 1:
			NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "debug", "false"));
		break;
		case 2:
			NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "debug", "true"));
		break;
		case 3:
			NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "debug", "naked"));
		break;
	}

	//<log-file> element
	std::string LogFileStr = _Configurations->GetStr("LogDirectory", ModulesDatabase::Logging) + "/server.log";
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "log-file", LogFileStr.c_str()));

	//<log-config> element
	std::string LogConfigStr = "*";
	if(!_Configurations->GetBool("LogDebugLevel", ModulesDatabase::Logging, false))
	{
		LogConfigStr += " -debug";
	}
	if(!_Configurations->GetBool("LogInfoLevel", ModulesDatabase::Logging, false))
	{
		LogConfigStr += " -info";
	}
	if(!_Configurations->GetBool("LogWarnLevel", ModulesDatabase::Logging, true))
	{
		LogConfigStr += " -warning";
	}
	if(!_Configurations->GetBool("LogSecureLevel", ModulesDatabase::Logging, true))
	{
		LogConfigStr += " -secure";
	}
	if(!_Configurations->GetBool("LogErrorLevel", ModulesDatabase::Logging, true))
	{
		LogConfigStr += " -error";
	}
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "log-config", LogConfigStr.c_str()));

	//<max-request-size> element
	std::string MaxReqSizeStr = boost::lexical_cast<std::string>(_Configurations->GetInt("MaxRequestSize", ModulesDatabase::Server, 128));
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "max-request-size", MaxReqSizeStr.c_str()));

	//<ajax-puzzle> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "ajax-puzzle", _Configurations->GetBool("DosPuzzle", ModulesDatabase::Server, false) ? "true" : "false"));

	//<strict-event-serialization> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "strict-event-serialization", "false")); //TODO: Gotta understand this first

	//<webgl-detection> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "webgl-detection", "false")); //TODO: Configuration to change detection

	//<redirect-message> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "redirect-message", "Click here if the page does not refreshes."));

	//<behind-reverse-proxy> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "behind-reverse-proxy", _Configurations->GetBool("ReverseProxy", ModulesDatabase::Server, false) ? "true" : "false"));

	//<progressive-bootstrap> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "progressive-bootstrap", "false"));

	//<session-id-cookie> element
	NodeAppSett->append_node(XmlDoc.allocate_node(Wt::rapidxml::node_element, "session-id-cookie", "true"));

	//<properties> element
	Wt::rapidxml::xml_node<> *NodeProperties = XmlDoc.allocate_node(Wt::rapidxml::node_element, "properties");
	NodeAppSett->append_node(NodeProperties);

	std::string PropertyBaseUrl = _Configurations->GetStr("BaseURL", ModulesDatabase::Server);
	if(!PropertyBaseUrl.empty())
	{
		Wt::rapidxml::xml_node<> *NodePropertyBaseURL = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", PropertyBaseUrl.c_str());
		NodePropertyBaseURL->append_attribute(XmlDoc.allocate_attribute("name", "baseURL"));
		NodeProperties->append_node(NodePropertyBaseURL);
	}

	std::string ResourceUrlStr =  _Configurations->GetStr("ResourcesURL", ModulesDatabase::Styles, "resources/");
	Wt::rapidxml::xml_node<> *NodePropertyResourceURL = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", ResourceUrlStr.c_str());
	NodePropertyResourceURL->append_attribute(XmlDoc.allocate_attribute("name", "resourcesURL"));
	NodeProperties->append_node(NodePropertyResourceURL);

	//Google OAuth
	std::string GoogleClientIdStr = _Configurations->GetStr("GoogleClientId", ModulesDatabase::Authentication);
	std::string GoogleClientSecretStr = _Configurations->GetStr("GoogleClientSecret", ModulesDatabase::Authentication);
	std::string RedirectStr = PropertyBaseUrl + "oauth2callback";
	if(_Configurations->GetBool("GoogleOAuth", ModulesDatabase::Authentication, false) && !GoogleClientIdStr.empty() && !GoogleClientSecretStr.empty())
	{
		Wt::rapidxml::xml_node<> *NodeGoogleClientId = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", GoogleClientIdStr.c_str());
		NodeGoogleClientId->append_attribute(XmlDoc.allocate_attribute("name", "google-oauth2-client-id"));
		NodeProperties->append_node(NodeGoogleClientId);

		Wt::rapidxml::xml_node<> *NodeGoogleClientSecret = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", GoogleClientSecretStr.c_str());
		NodeGoogleClientSecret->append_attribute(XmlDoc.allocate_attribute("name", "google-oauth2-client-secret"));
		NodeProperties->append_node(NodeGoogleClientSecret);

		Wt::rapidxml::xml_node<> *NodeGoogleRedirect = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", RedirectStr.c_str());
		NodeGoogleRedirect->append_attribute(XmlDoc.allocate_attribute("name", "google-oauth2-redirect-endpoint"));
		NodeProperties->append_node(NodeGoogleRedirect);
	}

	//Facebook OAuth
	std::string FacebookAppIdStr = _Configurations->GetStr("FacebookAppId", ModulesDatabase::Authentication);
	std::string FacebookAppSecretStr = _Configurations->GetStr("FacebookAppSecret", ModulesDatabase::Authentication);
	if(_Configurations->GetBool("FacebookOAuth", ModulesDatabase::Authentication, false) && !FacebookAppIdStr.empty() && !FacebookAppSecretStr.empty())
	{
		Wt::rapidxml::xml_node<> *NodeFacebookAppId = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", FacebookAppIdStr.c_str());
		NodeFacebookAppId->append_attribute(XmlDoc.allocate_attribute("name", "facebook-oauth2-app-id"));
		NodeProperties->append_node(NodeFacebookAppId);

		Wt::rapidxml::xml_node<> *NodeFacebookAppSecret = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", FacebookAppSecretStr.c_str());
		NodeFacebookAppSecret->append_attribute(XmlDoc.allocate_attribute("name", "facebook-oauth2-app-secret"));
		NodeProperties->append_node(NodeFacebookAppSecret);

		Wt::rapidxml::xml_node<> *NodeGoogleRedirect = XmlDoc.allocate_node(Wt::rapidxml::node_element, "property", RedirectStr.c_str());
		NodeGoogleRedirect->append_attribute(XmlDoc.allocate_attribute("name", "facebook-oauth2-redirect-endpoint"));
		NodeProperties->append_node(NodeGoogleRedirect);
	}

	//Write to file
	std::ofstream XmlFile("wt_config.xml", std::ios::trunc);
	XmlFile << XmlDoc;
	XmlFile.close();
}