?? ini_file.h
字號:
#ifndef _INI_FILE_H
#define _INI_FILE_H
#pragma warning(disable:4786)
#include "autobuf_file.h"
#include "list"
#include "string"
typedef std::list<std::string> string_list;
typedef string_list::iterator string_it;
typedef std::string string;
extern void ini_for_each(string_list& s, const char* from, const char* sep /*"\x0d\x0a"*/)
{
char* f = NULL;
char* g = NULL;
int sep_l = strlen(sep);
for(;;)
{
f = strstr(from, sep);
if( !f )
{
if( from[0] )
s.push_back(from);
break;
}
if( f!=from )
s.push_back(string(from, f-from));
from = f + sep_l;
}
}
extern string ini_get_value(const char* inifile, const char* key, const char* def)
{
charbuf buf;
int length = load_file_charbuf(inifile, buf);
if( !length )
return "";
string_list lst;
ini_for_each(lst, buf.data(), "\x0d\x0a");
for( string_it it=lst.begin(); it!=lst.end(); it++ )
{
string& ref = *it;
string_list key_and_value;
ini_for_each(key_and_value, ref.c_str(), "=");
if( key_and_value.size() != 2 )
continue;
if( key_and_value.front().compare(key) == 0 )
{
return key_and_value.back();
}
}
return def;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -