diff options
author | wwylele <wwylele@gmail.com> | 2017-01-20 20:30:11 +0100 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2017-03-01 22:30:57 +0100 |
commit | 8a8c0f348b0da4fd91c846211ede568a1f0f11c8 (patch) | |
tree | f80158deb9edba170bf73ddfe93326d02976ad09 /src/common/param_package.h | |
parent | Merge pull request #2603 from wwylele/please-signal (diff) | |
download | yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar.gz yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar.bz2 yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar.lz yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar.xz yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.tar.zst yuzu-8a8c0f348b0da4fd91c846211ede568a1f0f11c8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/param_package.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/common/param_package.h b/src/common/param_package.h new file mode 100644 index 000000000..c4c11b221 --- /dev/null +++ b/src/common/param_package.h @@ -0,0 +1,40 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <initializer_list> +#include <string> +#include <unordered_map> + +namespace Common { + +/// A string-based key-value container supporting serializing to and deserializing from a string +class ParamPackage { +public: + using DataType = std::unordered_map<std::string, std::string>; + + 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; + + std::string Serialize() const; + std::string Get(const std::string& key, const std::string& default_value) const; + int Get(const std::string& key, int default_value) const; + float Get(const std::string& key, float default_value) const; + void Set(const std::string& key, const std::string& value); + void Set(const std::string& key, int value); + void Set(const std::string& key, float value); + bool Has(const std::string& key) const; + +private: + DataType data; +}; + +} // namespace Common |