From 7ddabe188ac6f12e20c7c7cd70ff03dad98fdeee Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 17 Mar 2021 22:19:40 +0000 Subject: [PATCH] Update 3rdParty/Radon From https://github.com/szewczukk/Radon/commit/9203ff8b029584d3026660714862976a7c13a97e --- 3rdParty/Radon/Radon/include/File.hpp | 2 +- 3rdParty/Radon/Radon/include/Key.hpp | 2 +- 3rdParty/Radon/Radon/include/Named.hpp | 2 +- 3rdParty/Radon/Radon/include/Radon.hpp | 2 +- 3rdParty/Radon/Radon/include/Section.hpp | 2 +- 3rdParty/Radon/Radon/source/File.cpp | 20 ++++++++++---------- 3rdParty/Radon/Radon/source/Key.cpp | 15 ++++++++++++--- 3rdParty/Radon/Radon/source/Named.cpp | 2 +- 3rdParty/Radon/Radon/source/Section.cpp | 12 +++++++----- 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/3rdParty/Radon/Radon/include/File.hpp b/3rdParty/Radon/Radon/include/File.hpp index 04d2e2039..ce7012945 100644 --- a/3rdParty/Radon/Radon/include/File.hpp +++ b/3rdParty/Radon/Radon/include/File.hpp @@ -26,4 +26,4 @@ namespace radon std::vector
sections; std::string path; }; -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/include/Key.hpp b/3rdParty/Radon/Radon/include/Key.hpp index d3135b1c5..8d36ea5d0 100644 --- a/3rdParty/Radon/Radon/include/Key.hpp +++ b/3rdParty/Radon/Radon/include/Key.hpp @@ -32,4 +32,4 @@ namespace radon friend class File; }; -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/include/Named.hpp b/3rdParty/Radon/Radon/include/Named.hpp index 49a02a358..dbbdd1bb0 100644 --- a/3rdParty/Radon/Radon/include/Named.hpp +++ b/3rdParty/Radon/Radon/include/Named.hpp @@ -21,4 +21,4 @@ namespace radon protected: std::string name; }; -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/include/Radon.hpp b/3rdParty/Radon/Radon/include/Radon.hpp index 106139b89..de898f963 100644 --- a/3rdParty/Radon/Radon/include/Radon.hpp +++ b/3rdParty/Radon/Radon/include/Radon.hpp @@ -6,4 +6,4 @@ #include "Key.hpp" #include "Named.hpp" #include "Radon.hpp" -#include "Section.hpp" +#include "Section.hpp" \ No newline at end of file diff --git a/3rdParty/Radon/Radon/include/Section.hpp b/3rdParty/Radon/Radon/include/Section.hpp index 3a74703e8..89412d947 100644 --- a/3rdParty/Radon/Radon/include/Section.hpp +++ b/3rdParty/Radon/Radon/include/Section.hpp @@ -29,4 +29,4 @@ namespace radon friend class File; }; -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/source/File.cpp b/3rdParty/Radon/Radon/source/File.cpp index 77d9b4d3a..488d2d084 100644 --- a/3rdParty/Radon/Radon/source/File.cpp +++ b/3rdParty/Radon/Radon/source/File.cpp @@ -15,7 +15,7 @@ namespace radon this->path = path; if (reading) { - std::ifstream stream(path); + std::ifstream stream(path.c_str()); if (stream.is_open()) { @@ -47,15 +47,15 @@ namespace radon Section *File::getSection(const std::string & name) { - for (auto & section : sections) + for (int i = 0; i < (int)sections.size(); i++) { - if (section.getName() == name) + if (sections[i].getName() == name) { - return §ion; + return §ions[i]; } } - return nullptr; + return NULL; } @@ -69,14 +69,14 @@ namespace radon { std::ofstream file(path.data(), std::ios::out | std::ios::trunc); - for (auto & section : sections) + for (int i = 0; i < (int)sections.size(); i++) { - file << "[" << section.getName() << "] \n"; - for (auto & key : section.keys) + file << "[" << sections[i].getName() << "] \n"; + for(int j = 0; j < (int)sections[i].keys.size(); j++) { - file << key.getName() << "=" << key.getStringValue() << "\n"; + file << sections[i].keys[j].getName() << "=" << sections[i].keys[j].getStringValue() << "\n"; } } file.close(); } -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/source/Key.cpp b/3rdParty/Radon/Radon/source/Key.cpp index 3357e1b16..415fce5e4 100644 --- a/3rdParty/Radon/Radon/source/Key.cpp +++ b/3rdParty/Radon/Radon/source/Key.cpp @@ -1,6 +1,15 @@ // Copyright Dmitro bjornus Szewczuk 2017 #include "../include/Radon.hpp" +#include + +std::string Float2String(float fVal) +{ + std::ostringstream ss; + ss << fVal; + std::string s(ss.str()); + return s; +} namespace radon { @@ -17,7 +26,7 @@ namespace radon Key::Key(const std::string & name, const float & value) - : Named(name), value(std::to_string(value)) + : Named(name), value(Float2String(value)) { } @@ -36,7 +45,7 @@ namespace radon void Key::setValue(float & value) { - this->value = std::to_string(value); + this->value = Float2String(value); } @@ -44,4 +53,4 @@ namespace radon { this->value = value; } -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/source/Named.cpp b/3rdParty/Radon/Radon/source/Named.cpp index f2853ba15..d6b26f27f 100644 --- a/3rdParty/Radon/Radon/source/Named.cpp +++ b/3rdParty/Radon/Radon/source/Named.cpp @@ -26,4 +26,4 @@ namespace radon { return name; } -} +} \ No newline at end of file diff --git a/3rdParty/Radon/Radon/source/Section.cpp b/3rdParty/Radon/Radon/source/Section.cpp index 1de7772a7..f9ad56af0 100644 --- a/3rdParty/Radon/Radon/source/Section.cpp +++ b/3rdParty/Radon/Radon/source/Section.cpp @@ -17,19 +17,21 @@ namespace radon { } + Key *Section::getKey(const std::string & name) { - for (auto & key : keys) + for (int i = 0; i < (int)keys.size(); i++) { - if (key.getName() == name) - return &key; + if (keys[i].getName() == name) + return &keys[i]; } - return nullptr; + return NULL; } + void Section::addKey(Key key) { keys.push_back(key); } -} +} \ No newline at end of file