MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 属性 | Protected 类型 | Protected 成员函数 | Private 属性 | 静态 Private 属性 | 所有成员列表
common::Ini类 参考

Public 成员函数

 Ini ()
 
int load (const string &ini_file)
 
const map< string, string > & get (const string &section=DEFAULT_SECTION)
 
string get (const string &key, const string &default_value, const string &section=DEFAULT_SECTION)
 
int put (const string &key, const string &value, const string &section=DEFAULT_SECTION)
 
void to_string (string &output_str)
 

静态 Public 属性

static const string DEFAULT_SECTION = string("")
 
static const int MAX_CFG_LINE_LEN = 1024
 
static const char CFG_DELIMIT_TAG = ','
 
static const char CFG_COMMENT_TAG = '#'
 
static const char CFG_CONTINUE_TAG = '\\'
 
static const char CFG_SESSION_START_TAG = '['
 
static const char CFG_SESSION_END_TAG = ']'
 

Protected 类型

typedef map< string, map< string, string > > SessionsMap
 

Protected 成员函数

void insert_session (const string &session_name)
 
map< string, string > * switch_session (const string &session_name)
 
int insert_entry (map< string, string > *session_map, const string &line)
 

Private 属性

set< string > file_names_
 
SessionsMap sections_
 

静态 Private 属性

static const map< string, string > empty_map_
 

构造及析构函数说明

◆ Ini()

common::Ini::Ini ( )

To simplify the logic, no lock's when loading configuration So don't modify the data parallel

成员函数说明

◆ get() [1/2]

string common::Ini::get ( const string &  key,
const string &  default_value,
const string &  section = DEFAULT_SECTION 
)

get the value of the key in the section, if the key-value doesn't exist, use the input default_value

◆ get() [2/2]

const map< string, string > & common::Ini::get ( const string &  section = DEFAULT_SECTION)

get the map of the section if the section doesn't exist, return one empty section

◆ insert_entry()

int common::Ini::insert_entry ( map< string, string > *  session_map,
const string &  line 
)
protected

insert one entry to session_map line's format is "key=value"

◆ insert_session()

void common::Ini::insert_session ( const string &  session_name)
protected

insert one empty session to sections_

◆ load()

int common::Ini::load ( const string &  ini_file)

load one ini configuration it support load multiple ini configuration files

返回
, 0 means success, others means failed

◆ put()

int common::Ini::put ( const string &  key,
const string &  value,
const string &  section = DEFAULT_SECTION 
)

put the key-value pair to the section if the key-value already exist, just replace it if the section doesn't exist, it will create this section

◆ switch_session()

map< string, string > * common::Ini::switch_session ( const string &  session_name)
protected

switch session according to the session_name if the section doesn't exist, it will create one

◆ to_string()

void common::Ini::to_string ( string &  output_str)

output all configuration to one string


该类的文档由以下文件生成: