summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorzhupengfei <zhupengfei321@sina.cn>2018-08-26 10:23:12 +0200
committerfearlessTobi <thm.frey@gmail.com>2018-10-06 15:43:49 +0200
commit690f326613998ea9cc0737c2bef99d1ba2cb911c (patch)
treed17f178e7924e4ffb0d5b96e148490aa758289b6 /src/common
parentMerge pull request #1449 from lioncash/link (diff)
downloadyuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.gz
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.bz2
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.lz
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.xz
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.tar.zst
yuzu-690f326613998ea9cc0737c2bef99d1ba2cb911c.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/param_package.cpp18
-rw-r--r--src/common/param_package.h2
2 files changed, 19 insertions, 1 deletions
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp
index 9526ca0c6..b916b4866 100644
--- a/src/common/param_package.cpp
+++ b/src/common/param_package.cpp
@@ -20,7 +20,15 @@ constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0";
constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1";
constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2";
+/// A placeholder for empty param packages to avoid empty strings
+/// (they may be recognized as "not set" by some frontend libraries like qt)
+constexpr char EMPTY_PLACEHOLDER[] = "[empty]";
+
ParamPackage::ParamPackage(const std::string& serialized) {
+ if (serialized == EMPTY_PLACEHOLDER) {
+ return;
+ }
+
std::vector<std::string> pairs;
Common::SplitString(serialized, PARAM_SEPARATOR, pairs);
@@ -46,7 +54,7 @@ ParamPackage::ParamPackage(std::initializer_list<DataType::value_type> list) : d
std::string ParamPackage::Serialize() const {
if (data.empty())
- return "";
+ return EMPTY_PLACEHOLDER;
std::string result;
@@ -120,4 +128,12 @@ bool ParamPackage::Has(const std::string& key) const {
return data.find(key) != data.end();
}
+void ParamPackage::Erase(const std::string& key) {
+ data.erase(key);
+}
+
+void ParamPackage::Clear() {
+ data.clear();
+}
+
} // namespace Common
diff --git a/src/common/param_package.h b/src/common/param_package.h
index 7842cd4ef..6a0a9b656 100644
--- a/src/common/param_package.h
+++ b/src/common/param_package.h
@@ -32,6 +32,8 @@ public:
void Set(const std::string& key, int value);
void Set(const std::string& key, float value);
bool Has(const std::string& key) const;
+ void Erase(const std::string& key);
+ void Clear();
private:
DataType data;