ini_file.h
3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* CC/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _INI_FILE_H_
#define _INI_FILE_H_
#include "common.h"
class INIFile {
public:
virtual ~INIFile();
public:
static INIFile* get_instance();
bool load_file(const char* file_name, bool casesensive = false);
void unload_file(const char* file_name, bool casesensive = false);
int32_t get_int(
const char* section_name, // section name
const char* key_name, // key name
int32_t default_value, // return value if key name not found
const char* file_name, // initialization file name
bool casesensive = false
);
int32_t get_string(
const char* section_name, // section name
const char* key_name, // key name
const char* default_value, // default string
char* dest_buff, // destination buffer
uint32_t buff_size, // size of destination buffer
const char* file_name, // initialization file name
bool casesensive = false
);
section_map_t get_section_map(const char* file_name, bool casesensive = false);
/**
* @brief 线程安全,对成员变量无影响
*
* @param [in/out] section_name : const char*
* @param [in/out] key_name : const char*
* @param [in/out] default_value : const char*
* @param [in/out] dest_buff : char*
* @param [in/out] buff_size : uint32_t
* @param [in/out] sections : const section_map_t&
* @param [in/out] casesensive : bool
* @return int32_t
* @retval
* @see
* @note
* @author chenyuzhen
* @date 2011/09/27 13:38:21
**/
int32_t get_string(
const char* section_name, const char* key_name, const char* default_value,
char* dest_buff, uint32_t buff_size, const section_map_t& sections,
bool casesensive = false)const;
/**
* @brief 线程安全,对成员变量无影响
*
* @param [in/out] section_name : const char*
* @param [in/out] key_name : const char*
* @param [in/out] default_value : int
* @param [in/out] sections : const section_map_t&
* @param [in/out] casesensive : bool
* @return int32_t
* @retval
* @see
* @note
* @author chenyuzhen
* @date 2011/09/27 13:41:50
**/
int32_t get_int(
const char* section_name, const char* key_name, int default_value,
const section_map_t& sections, bool casesensive = false)const;
/**
* @brief 线程安全,对成员变量无影响
*
* @param [in/out] file_name : const char*
* @param [in/out] sections : section_map_t&
* @param [in/out] casesensive : bool
* @return bool
* @retval
* @see
* @note
* @author chenyuzhen
* @date 2011/09/27 13:42:03
**/
bool load_file(const char* file_name, section_map_t& sections, bool casesensive = false) const;
private:
/**
* @brief 判断字符串是否为数字
*
* @param [in/out] str : const char*
* @return bool
* @retval
* @see
* @note
* @author chenyuzhen
* @date 2011/08/25 11:46:30
**/
bool is_number(const char* str)const;
map<string, section_map_t> _file_map;
};
#endif