#pragma once #ifdef WIN32 #include #else #include #define stricmp strcasecmp #endif #include #include #include 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 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 values_; #ifdef WIN32 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); #ifndef WIN32 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); };