2022-05-03 03:56:07 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-07-18 08:56:03 +00:00
|
|
|
|
#if defined(WIN32) || defined(_WIN64)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#define stricmp strcasecmp
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
class simple_ini
|
|
|
|
|
{
|
|
|
|
|
typedef struct _key_val
|
|
|
|
|
{
|
|
|
|
|
std::string key;
|
|
|
|
|
std::string val;
|
|
|
|
|
|
|
|
|
|
bool operator==(const char* k)
|
|
|
|
|
{
|
|
|
|
|
return key == k;
|
|
|
|
|
}
|
|
|
|
|
bool operator<(const struct _key_val& r)
|
|
|
|
|
{
|
|
|
|
|
return key.compare(r.key) < 0;
|
|
|
|
|
}
|
|
|
|
|
}KEYVAL;
|
|
|
|
|
typedef struct _sec_key
|
|
|
|
|
{
|
|
|
|
|
std::string sec;
|
|
|
|
|
std::vector<KEYVAL> vals;
|
|
|
|
|
bool operator==(const char* s)
|
|
|
|
|
{
|
|
|
|
|
return sec == s;
|
|
|
|
|
}
|
|
|
|
|
bool operator<(const struct _sec_key& r)
|
|
|
|
|
{
|
|
|
|
|
return sec.compare(r.sec) < 0;
|
|
|
|
|
}
|
|
|
|
|
}SECKEY;
|
|
|
|
|
std::vector<SECKEY> values_;
|
|
|
|
|
|
2022-07-18 08:56:03 +00:00
|
|
|
|
#if defined(WIN32) || defined(_WIN64)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
std::string file_;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
simple_ini();
|
|
|
|
|
~simple_ini();
|
|
|
|
|
|
|
|
|
|
static std::string temporary_path(void);
|
|
|
|
|
static bool skip_empty(char*& ptr);
|
|
|
|
|
static void trime(char*& ptr);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
int load(const char* local_file);
|
2022-07-18 08:56:03 +00:00
|
|
|
|
#if !defined(WIN32) && !defined(_WIN64)
|
2022-05-03 03:56:07 +00:00
|
|
|
|
int save(const char* local_file);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
std::string get(const char* sec, const char* key, const char* default_val = "");
|
|
|
|
|
void set(const char* sec, const char* key, const char* val);
|
|
|
|
|
void remove(const char* sec, const char* key);
|
|
|
|
|
void remove(const char* sec);
|
|
|
|
|
void clear(void);
|
|
|
|
|
};
|