Ver Fonte

Rename KvReader class

"KvFileReader" is a better naming convention for
pointing out that its responsibility is the file
reading part.
Patrick-Christopher Mattulat há 3 anos atrás
pai
commit
787b47d6a1

+ 2 - 2
CMakeLists.txt

@@ -89,7 +89,7 @@ set(SOURCE_FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvPair.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvDocument.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvParser.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvReader.cpp)
+        ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvFileReader.cpp)
 
 if (${LS_STD_BUILD_WITH_TESTS})
     set(TEST_FILES
@@ -142,7 +142,7 @@ if (${LS_STD_BUILD_WITH_TESTS})
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvPairTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvDocumentTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvParserTest.cpp
-            ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvReaderTest.cpp
+            ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvFileReaderTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/exception/EventNotHandledExceptionTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/exception/EventNotSubscribedExceptionTest.cpp
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/exception/FileNotFoundExceptionTest.cpp

+ 6 - 6
include/ls_std/io/kv/KvReader.hpp → include/ls_std/io/kv/KvFileReader.hpp

@@ -3,12 +3,12 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2021-05-02
+ * Changed:         2021-07-15
  *
  * */
 
-#ifndef LS_STD_KV_READER_HPP
-#define LS_STD_KV_READER_HPP
+#ifndef LS_STD_KV_FILE_READER_HPP
+#define LS_STD_KV_FILE_READER_HPP
 
 #include <ls_std/base/Class.hpp>
 #include <ls_std/io/IReader.hpp>
@@ -18,12 +18,12 @@
 
 namespace ls_std
 {
-  class KvReader : public ls_std::Class, public ls_std::IReader
+  class KvFileReader : public ls_std::Class, public ls_std::IReader
   {
     public:
 
-      explicit KvReader(const std::shared_ptr<ls_std::KvDocument> &_document, const std::string &_absolutePath);
-      ~KvReader() override = default;
+      explicit KvFileReader(const std::shared_ptr<ls_std::KvDocument> &_document, const std::string &_absolutePath);
+      ~KvFileReader() override = default;
 
       // implementation
 

+ 1 - 1
include/ls_std/ls_std.hpp

@@ -61,7 +61,7 @@
 #include "io/kv/KvPair.hpp"
 #include "io/kv/KvDocument.hpp"
 #include "io/kv/KvParser.hpp"
-#include "io/kv/KvReader.hpp"
+#include "io/kv/KvFileReader.hpp"
 
 #include "logic/State.hpp"
 #include "logic/StateConnection.hpp"

+ 10 - 10
source/ls_std/io/kv/KvReader.cpp → source/ls_std/io/kv/KvFileReader.cpp

@@ -3,24 +3,24 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2021-05-02
+ * Changed:         2021-07-15
  *
  * */
 
-#include <ls_std/io/kv/KvReader.hpp>
+#include <ls_std/io/kv/KvFileReader.hpp>
 #include <ls_std/exception/IllegalArgumentException.hpp>
 #include <ls_std/io/FileReader.hpp>
 #include <ls_std/io/kv/KvParser.hpp>
 
-ls_std::KvReader::KvReader(const std::shared_ptr<ls_std::KvDocument> &_document, const std::string &_absolutePath)
-    : ls_std::Class("KvReader"),
+ls_std::KvFileReader::KvFileReader(const std::shared_ptr<ls_std::KvDocument> &_document, const std::string &_absolutePath)
+    : ls_std::Class("KvFileReader"),
       kvFile(ls_std::File{""})
 {
   this->_assignDocument(_document);
   this->_assignFile(ls_std::File{_absolutePath});
 }
 
-ls_std::byte_field ls_std::KvReader::read()
+ls_std::byte_field ls_std::KvFileReader::read()
 {
   ls_std::byte_field data = ls_std::FileReader{this->kvFile}.read();
   ls_std::KvParser{this->document}.parse(data);
@@ -28,22 +28,22 @@ ls_std::byte_field ls_std::KvReader::read()
   return data;
 }
 
-std::shared_ptr<ls_std::KvDocument> ls_std::KvReader::getDocument()
+std::shared_ptr<ls_std::KvDocument> ls_std::KvFileReader::getDocument()
 {
   return this->document;
 }
 
-void ls_std::KvReader::setDocument(const std::shared_ptr<ls_std::KvDocument> &_document)
+void ls_std::KvFileReader::setDocument(const std::shared_ptr<ls_std::KvDocument> &_document)
 {
   this->_assignDocument(_document);
 }
 
-void ls_std::KvReader::setFile(const ls_std::File &_kvFile)
+void ls_std::KvFileReader::setFile(const ls_std::File &_kvFile)
 {
   this->_assignFile(_kvFile);
 }
 
-void ls_std::KvReader::_assignDocument(const std::shared_ptr<ls_std::KvDocument> &_document)
+void ls_std::KvFileReader::_assignDocument(const std::shared_ptr<ls_std::KvDocument> &_document)
 {
   if (_document == nullptr)
   {
@@ -53,7 +53,7 @@ void ls_std::KvReader::_assignDocument(const std::shared_ptr<ls_std::KvDocument>
   this->document = _document;
 }
 
-void ls_std::KvReader::_assignFile(ls_std::File _kvFile)
+void ls_std::KvFileReader::_assignFile(ls_std::File _kvFile)
 {
   if (!_kvFile.exists())
   {

+ 10 - 10
test/cases/io/kv/KvReaderTest.cpp → test/cases/io/kv/KvFileReaderTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-12-25
- * Changed:         2021-05-02
+ * Changed:         2021-07-15
  *
  * */
 
@@ -13,12 +13,12 @@
 
 namespace
 {
-  class KvReaderTest : public ::testing::Test
+  class KvFileReaderTest : public ::testing::Test
   {
     protected:
 
-      KvReaderTest() = default;
-      ~KvReaderTest() override = default;
+      KvFileReaderTest() = default;
+      ~KvFileReaderTest() override = default;
 
       void SetUp() override
       {}
@@ -27,19 +27,19 @@ namespace
       {}
   };
 
-  TEST_F(KvReaderTest, getDocument)
+  TEST_F(KvFileReaderTest, getDocument)
   {
     std::string kvPath = TestHelper::getResourcesFolderLocation() + "server_settings.kv";
-    ls_std::KvReader reader{std::make_shared<ls_std::KvDocument>(), kvPath};
+    ls_std::KvFileReader reader{std::make_shared<ls_std::KvDocument>(), kvPath};
 
     ASSERT_TRUE(reader.getDocument() != nullptr);
   }
 
-  TEST_F(KvReaderTest, read)
+  TEST_F(KvFileReaderTest, read)
   {
     std::string kvPath = TestHelper::getResourcesFolderLocation() + "server_settings.kv";
     std::shared_ptr<ls_std::KvDocument> document = std::make_shared<ls_std::KvDocument>();
-    ls_std::KvReader reader{document, kvPath};
+    ls_std::KvFileReader reader{document, kvPath};
 
     reader.read();
     ASSERT_EQ(3, document->getPairs().size());
@@ -52,13 +52,13 @@ namespace
     ASSERT_STREQ("deamon", document->getPairs().at("service-name").getValue().c_str());
   }
 
-  TEST_F(KvReaderTest, setDocument)
+  TEST_F(KvFileReaderTest, setDocument)
   {
     std::string kvPath = TestHelper::getResourcesFolderLocation() + "server_settings.kv";
     std::shared_ptr<ls_std::KvDocument> document1 = std::make_shared<ls_std::KvDocument>();
     std::shared_ptr<ls_std::KvDocument> document2 = std::make_shared<ls_std::KvDocument>();
 
-    ls_std::KvReader reader{document1, kvPath};
+    ls_std::KvFileReader reader{document1, kvPath};
     ASSERT_TRUE(reader.getDocument() == document1);
 
     reader.setDocument(document2);