guc_settings.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <unordered_map>
  3. #include <vector>
  4. #include <string>
  5. #include <optional>
  6. #include <memory>
  7. #include <util/generic/hash.h>
  8. #include <library/cpp/json/json_writer.h>
  9. class TGUCSettings {
  10. public:
  11. TGUCSettings() = default;
  12. TGUCSettings(const TString& serialized);
  13. using TPtr = std::shared_ptr<TGUCSettings>;
  14. void Setup(const std::unordered_map<std::string, std::string>& runtimeSettings);
  15. std::optional<std::string> Get(const std::string&) const;
  16. void Set(const std::string&, const std::string&, bool isLocal = false);
  17. void Commit();
  18. void RollBack();
  19. void ExportToJson(NJson::TJsonValue& value) const;
  20. void ImportFromJson(const NJson::TJsonValue& value);
  21. TString SerializeToString() const;
  22. size_t GetHash() const noexcept;
  23. bool operator==(const TGUCSettings& other) const;
  24. private:
  25. std::unordered_map<std::string, std::string> Settings_;
  26. std::unordered_map<std::string, std::string> RollbackSettings_;
  27. std::unordered_map<std::string, std::string> SessionSettings_;
  28. };