2017-01-20 19:30:11 +00:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <initializer_list>
|
2020-01-29 06:54:39 +00:00
|
|
|
#include <map>
|
2017-01-20 19:30:11 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
/// A string-based key-value container supporting serializing to and deserializing from a string
|
|
|
|
class ParamPackage {
|
|
|
|
public:
|
2020-01-29 06:54:39 +00:00
|
|
|
using DataType = std::map<std::string, std::string>;
|
2017-01-20 19:30:11 +00:00
|
|
|
|
|
|
|
ParamPackage() = default;
|
|
|
|
explicit ParamPackage(const std::string& serialized);
|
|
|
|
ParamPackage(std::initializer_list<DataType::value_type> list);
|
|
|
|
ParamPackage(const ParamPackage& other) = default;
|
|
|
|
ParamPackage(ParamPackage&& other) = default;
|
|
|
|
|
|
|
|
ParamPackage& operator=(const ParamPackage& other) = default;
|
|
|
|
ParamPackage& operator=(ParamPackage&& other) = default;
|
|
|
|
|
2020-08-31 19:06:16 +00:00
|
|
|
[[nodiscard]] std::string Serialize() const;
|
|
|
|
[[nodiscard]] std::string Get(const std::string& key, const std::string& default_value) const;
|
|
|
|
[[nodiscard]] int Get(const std::string& key, int default_value) const;
|
|
|
|
[[nodiscard]] float Get(const std::string& key, float default_value) const;
|
2018-07-20 21:17:26 +00:00
|
|
|
void Set(const std::string& key, std::string value);
|
2017-01-20 19:30:11 +00:00
|
|
|
void Set(const std::string& key, int value);
|
|
|
|
void Set(const std::string& key, float value);
|
2020-08-31 19:06:16 +00:00
|
|
|
[[nodiscard]] bool Has(const std::string& key) const;
|
2018-08-26 08:23:12 +00:00
|
|
|
void Erase(const std::string& key);
|
|
|
|
void Clear();
|
2017-01-20 19:30:11 +00:00
|
|
|
|
2020-01-29 06:54:39 +00:00
|
|
|
// For range-based for
|
|
|
|
DataType::iterator begin();
|
|
|
|
DataType::const_iterator begin() const;
|
|
|
|
DataType::iterator end();
|
|
|
|
DataType::const_iterator end() const;
|
|
|
|
|
2017-01-20 19:30:11 +00:00
|
|
|
private:
|
|
|
|
DataType data;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Common
|