From cb8e61b4314770e7c887f3f356f839a4881deadb Mon Sep 17 00:00:00 2001 From: zsccat Date: Thu, 4 Jun 2020 12:51:44 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'source-code/source/plugins/TLAC/FileSystem'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New function added "GetStringValue" to get string value from the config file --- source-code/source/plugins/TLAC/FileSystem/ConfigFile.cpp | 8 ++++++++ source-code/source/plugins/TLAC/FileSystem/ConfigFile.h | 1 + 2 files changed, 9 insertions(+) diff --git a/source-code/source/plugins/TLAC/FileSystem/ConfigFile.cpp b/source-code/source/plugins/TLAC/FileSystem/ConfigFile.cpp index 379fda2..76d2e5d 100644 --- a/source-code/source/plugins/TLAC/FileSystem/ConfigFile.cpp +++ b/source-code/source/plugins/TLAC/FileSystem/ConfigFile.cpp @@ -47,6 +47,14 @@ namespace TLAC::FileSystem return found ? (float)atof(pair->second.c_str()) : 0.0f; } + std::string ConfigFile::GetStringValue(const std::string& key) + { + auto pair = ConfigMap.find(key); + bool found = pair != ConfigMap.end(); + + return found ? pair->second : ""; + } + void ConfigFile::Parse(std::ifstream &fileStream) { std::string line; diff --git a/source-code/source/plugins/TLAC/FileSystem/ConfigFile.h b/source-code/source/plugins/TLAC/FileSystem/ConfigFile.h index 8f453ea..bf96e27 100644 --- a/source-code/source/plugins/TLAC/FileSystem/ConfigFile.h +++ b/source-code/source/plugins/TLAC/FileSystem/ConfigFile.h @@ -17,6 +17,7 @@ namespace TLAC::FileSystem int GetIntegerValue(const std::string& key); bool GetBooleanValue(const std::string& key); float GetFloatValue(const std::string& key); + std::string GetStringValue(const std::string& key); protected: virtual void Parse(std::ifstream &fileStream) override;