config.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef NULLSOFT_CONFIG_H_
  2. #define NULLSOFT_CONFIG_H_
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <memory.h>
  8. #define BUFF_SIZE 8192
  9. class ConfigW
  10. {
  11. public:
  12. ConfigW();
  13. ConfigW(const wchar_t *ini, const wchar_t *section);
  14. ~ConfigW();
  15. public:
  16. void Flush(void);
  17. BOOL Write(const wchar_t *name, double value);
  18. BOOL Write(const wchar_t *section, const wchar_t *name, double value);
  19. BOOL Write(const wchar_t *name, long long value);
  20. BOOL Write(const wchar_t *section, const wchar_t *name, long long value);
  21. BOOL Write(const wchar_t *name, int value);
  22. BOOL Write(const wchar_t *section, const wchar_t *name, int value);
  23. BOOL Write(const wchar_t *name, const wchar_t *value);
  24. BOOL Write(const wchar_t *section, const wchar_t *name, const wchar_t *value);
  25. BOOL Write(const wchar_t *name, const char value);
  26. BOOL Write(const wchar_t *section, const wchar_t *name, const char *value);
  27. int ReadInt(const wchar_t *name, int defvalue);
  28. long long ReadInt64(const wchar_t *name, long long defvalue);
  29. double ReadDouble(const wchar_t *name, double defvalue);
  30. const char* ReadStringA(const wchar_t *name, const char *defvalue);
  31. const wchar_t* ReadStringW(const wchar_t *name, const wchar_t *defvalue);
  32. int ReadInt(const wchar_t *section, const wchar_t *name, int defvalue);
  33. long long ReadInt64(const wchar_t *section, const wchar_t *name, long long defvalue);
  34. double ReadDouble(const wchar_t *section, const wchar_t *name, double defvalue);
  35. const char* ReadStringA(const wchar_t *section, const wchar_t *name, const char *defvalue);
  36. const wchar_t* ReadStringW(const wchar_t *section, const wchar_t *name, const wchar_t *defvalue);
  37. BOOL SetSection(const wchar_t *section);
  38. BOOL SetIniFile(const wchar_t *file);
  39. BOOL IsFileExist(void);
  40. const wchar_t* GetSection(void);
  41. const wchar_t* GetFile(void);
  42. private:
  43. HANDLE CreateFileHandle();
  44. void CreateFileWithBOM(void);
  45. void RemoveEmptyFile(void);
  46. private:
  47. BOOL emptyBOM;
  48. wchar_t buff[BUFF_SIZE];
  49. char *buffA;
  50. wchar_t *fileName;
  51. wchar_t *defSection;
  52. };
  53. #endif //NULLSOFT_CONFIG_H_