1
0

config.h 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef _CONFIG_H
  2. #define _CONFIG_H
  3. #include <bfc/string/bfcstring.h>
  4. #include <bfc/pair.h>
  5. #include <bfc/critsec.h>
  6. #include <bfc/string/StringW.h>
  7. class StringPair : public Pair<StringW, StringW>
  8. {
  9. public:
  10. StringPair(StringW &_a, const wchar_t *_b)
  11. {
  12. b=_b;
  13. a.swap(_a);
  14. }
  15. };
  16. class ConfigFile
  17. {
  18. public:
  19. ConfigFile(const wchar_t *section, const wchar_t *name);
  20. ~ConfigFile();
  21. static void initialize();
  22. void setInt(const wchar_t *name, int val);
  23. int getInt(const wchar_t *name, int default_val);
  24. void setString(const wchar_t *name, const wchar_t *str);
  25. int getString(const wchar_t *name, wchar_t *buf, int buf_len, const wchar_t *default_str);
  26. int getStringLen(const wchar_t *name);
  27. private:
  28. StringW sectionname;
  29. StringW prettyname;
  30. StringPair *getPair(const wchar_t *name);
  31. StringPair *makePair(const wchar_t *name, const wchar_t *value);
  32. CriticalSection cs;
  33. };
  34. #endif