本文整理汇总了C++中ConfigFile::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::Load方法的具体用法?C++ ConfigFile::Load怎么用?C++ ConfigFile::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::Load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnInit
virtual void OnInit()
{
CharSet::SetCharSet("gb2312");
MGUI::FontManager::Instance()->Load("Editor.font");
mConfig = new ConfigFile;
mConfig->Load("UIEditor.ini");
rml_node * node = mConfig->first_node("Media");
while (node != NULL)
{
String path = node->value();
ResourceManager::Instance()->AddArchive(new FilePathArchive(path));
node = node->next_sibling("Media");
}
node = mConfig->first_node("Font");
while (node != NULL)
{
String source = node->value();
MGUI::FontManager::Instance()->Load(source);
node = node->next_sibling("Font");
}
mMainFrame = new MainFrame();
}
示例2: Load_Compiled
Atlas* AtlasResourceCompiler::Load_Compiled()
{
std::string compiled_path = Get_Compiled_Path();
Platform* platform = Platform::Get();
// Compile time.
DBG_LOG("Loading atlas resource '%s'.", compiled_path.c_str());
// Load configuration settings.
ConfigFile config;
if (!config.Load(compiled_path.c_str()))
{
DBG_LOG("Failed to load atlas, config file could not be found: '%s'", compiled_path.c_str());
return NULL;
}
// Load the compile atlas file.
Atlas* atlas = new Atlas();
if (!atlas->Load_Compiled_Config(&config))
{
return NULL;
}
DBG_LOG("Finished loading compiled atlas from '%s'.", compiled_path.c_str());
return atlas;
}
示例3: Load
bool Config::Load(){
serverPort = 666;
isPublic = true;
memset(serverName,0,SERVERNAME_MAX); sprintf(serverName,"G Server");
enableLogging = true;
ignoreUnknownPackets = false;
spriteMaxX = 50;
spriteMaxY = 50;
usernameMax = 20;
ConfigFile file; file.Construct();
if(file.Load(CONFIG_FILE)){
file.Get("serverPort",&serverPort);
file.Get("isPublic",&isPublic);
file.Get("serverName",serverName,SERVERNAME_MAX);
file.Get("enableLogging",&enableLogging);
file.Get("ignoreUnknownPackets",&ignoreUnknownPackets);
file.Get("spriteMaxX",&spriteMaxX);
file.Get("spriteMaxY",&spriteMaxY);
file.Get("usernameMax",&usernameMax);
}else{
fprintf(stderr,"WARNING: %s not found. Generating with default settings.\n",CONFIG_FILE);
}
file.Clear();
file.Set("serverPort",serverPort);
file.Set("isPublic",isPublic);
file.Set("serverName",serverName);
file.Set("enableLogging",enableLogging);
file.Set("ignoreUnknownPackets",ignoreUnknownPackets);
file.Set("spriteMaxX",spriteMaxX);
file.Set("spriteMaxY",spriteMaxY);
file.Set("usernameMax",usernameMax);
if(file.Save(CONFIG_FILE)){
file.Destruct();
return true;
}else{
fprintf(stderr,"ERROR: Unable to save %s.\n",CONFIG_FILE);
file.Destruct();
return false;
}
}
示例4: main
int main()
{
ConfigFile conf;
cout<<"=====> Loading and parsing ./config.cfg..."<<endl;
enum ConfigFile::Error err = conf.Load("./config.cfg");
if(err == ConfigFile::no_error)
{
cout<<"\tFile loaded successfully !"<<endl;
}
else
{
cout<<"\tError while loading the file : "<<ConfigFile::GetErrorString(err);
return 1;
}
conf.Print();
cout<<endl;
cout<<"=====> Set MySentense to \"This world is great :)\""<<endl;
conf.SetValue("MySentense", "This world is great :)");
cout<<"=====> Add a new variable : NewVar=68"<<endl;
conf.SetValue("NewVar", "68");
conf.Print();
cout<<endl;
cout<<"=====> The size of MyArray is "<<conf.GetArrayValue<int>("MyArray").size()<<" and the third value is "<<conf.GetValue<int>("MyArray", 2)<<endl;
cout<<endl;
cout<<"=====> Here is the letter :"<<endl;
cout<<conf.GetValueString("MyMultilineValue")<<endl;
cout<<endl;
cout<<"=====> Saving new configuration file into ./newconfig.cfg"<<endl;
conf.WriteToFile("./newconfig.cfg");
return 0;
}