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
|
#ifndef NULLSOFT_CONFIG_H_
#define NULLSOFT_CONFIG_H_
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#define BUFF_SIZE 8192
class ConfigW
{
public:
ConfigW();
ConfigW(const wchar_t *ini, const wchar_t *section);
~ConfigW();
public:
void Flush(void);
BOOL Write(const wchar_t *name, double value);
BOOL Write(const wchar_t *section, const wchar_t *name, double value);
BOOL Write(const wchar_t *name, long long value);
BOOL Write(const wchar_t *section, const wchar_t *name, long long value);
BOOL Write(const wchar_t *name, int value);
BOOL Write(const wchar_t *section, const wchar_t *name, int value);
BOOL Write(const wchar_t *name, const wchar_t *value);
BOOL Write(const wchar_t *section, const wchar_t *name, const wchar_t *value);
BOOL Write(const wchar_t *name, const char value);
BOOL Write(const wchar_t *section, const wchar_t *name, const char *value);
int ReadInt(const wchar_t *name, int defvalue);
long long ReadInt64(const wchar_t *name, long long defvalue);
double ReadDouble(const wchar_t *name, double defvalue);
const char* ReadStringA(const wchar_t *name, const char *defvalue);
const wchar_t* ReadStringW(const wchar_t *name, const wchar_t *defvalue);
int ReadInt(const wchar_t *section, const wchar_t *name, int defvalue);
long long ReadInt64(const wchar_t *section, const wchar_t *name, long long defvalue);
double ReadDouble(const wchar_t *section, const wchar_t *name, double defvalue);
const char* ReadStringA(const wchar_t *section, const wchar_t *name, const char *defvalue);
const wchar_t* ReadStringW(const wchar_t *section, const wchar_t *name, const wchar_t *defvalue);
BOOL SetSection(const wchar_t *section);
BOOL SetIniFile(const wchar_t *file);
BOOL IsFileExist(void);
const wchar_t* GetSection(void);
const wchar_t* GetFile(void);
private:
HANDLE CreateFileHandle();
void CreateFileWithBOM(void);
void RemoveEmptyFile(void);
private:
BOOL emptyBOM;
wchar_t buff[BUFF_SIZE];
char *buffA;
wchar_t *fileName;
wchar_t *defSection;
};
#endif //NULLSOFT_CONFIG_H_
|