ini.h 839 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include <string>
  3. #include <vector>
  4. #include "util/json.h"
  5. namespace ylib
  6. {
  7. class ini
  8. {
  9. public:
  10. ini();
  11. ~ini();
  12. bool open(const std::string& filepath);
  13. void close();
  14. std::string read(const std::string& name,const std::string& key,const std::string& default_value = "") const;
  15. bool write(const std::string& name,const std::string& key,const std::string& value);
  16. #ifndef _WIN321
  17. bool del(const std::string& name, const std::string& key);
  18. // 一级NAME
  19. std::vector<std::string> names();
  20. // 二级KEY
  21. std::vector<std::string> keys(const std::string& name);
  22. bool exist_key(const std::string& name,const std::string& key);
  23. bool exist_name(const std::string& name);
  24. ylib::json to_json();
  25. #endif
  26. private:
  27. std::string m_filepath;
  28. void* m_point = nullptr;
  29. };
  30. }