Repository: conan-io/conan-center-index

Issue:
[request] oatpp/1.0.0
### Package Details
  * Package Name/Version: **oatpp/1.0.0**
  * Website: **https://oatpp.io/**
  * Source code: **https://github.com/oatpp/oatpp**


### Description Of The Library / Tool
Modern Web Framework for C++. High performance, simple API, cross platform, zero dependency.


Discussion:
i want i want i want

Resolving patch:
diff --git a/recipes/oatpp/all/conanfile.py b/recipes/oatpp/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/conanfile.py
@@ -0,0 +1,70 @@
+from conans import ConanFile, CMake, tools
+from conans.errors import ConanInvalidConfiguration
+import os
+
+
+class OatppConan(ConanFile):
+    name = "oatpp"
+    description = "Modern Web Framework for C++"
+    homepage = "https://github.com/oatpp/oatpp"
+    license = "Apache-2.0"
+    topics = ("conan", "oat++", "oatpp", "web-framework")
+    url = "https://github.com/conan-io/conan-center-index"
+    generators = "cmake"
+    settings = "os", "compiler", "build_type", "arch"
+    options = {"shared": [True, False], "fPIC": [True, False]}
+    default_options = {"shared": False, "fPIC": True}
+    exports_sources = "CMakeLists.txt"
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        os.rename("oatpp-{0}".format(self.version), self._source_subfolder)
+
+    def configure(self):
+        if self.settings.os == "Windows" and self.options.shared:
+            raise ConanInvalidConfiguration("oatpp can not be built as shared library on Windows")
+
+        if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5":
+            raise ConanInvalidConfiguration("oatpp requires GCC >=5")
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+
+        self._cmake = CMake(self)
+        self._cmake.definitions["OATPP_BUILD_TESTS"] = False
+        self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
+        self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
+        cmake = self._configure_cmake()
+        cmake.install()
+        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
+
+    def package_info(self):
+        self.cpp_info.includedirs = [os.path.join("include", "oatpp-{}".format(self.version), "oatpp")]
+        self.cpp_info.libdirs = [os.path.join("lib",  "oatpp-{}".format(self.version))]
+        self.cpp_info.libs = tools.collect_libs(self)
+        if self.settings.os == "Linux":
+            self.cpp_info.system_libs = ["pthread"]
+        if self.settings.os == "Windows":
+            self.cpp_info.system_libs.append("ws2_32")


Test patch:
diff --git a/recipes/oatpp/all/test_package/CMakeLists.txt b/recipes/oatpp/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/test_package/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+add_executable(${PROJECT_NAME} example.cpp DeserializerTest.cpp)
+target_link_libraries(${PROJECT_NAME} CONAN_PKG::oatpp)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
diff --git a/recipes/oatpp/all/test_package/DeserializerTest.cpp b/recipes/oatpp/all/test_package/DeserializerTest.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/test_package/DeserializerTest.cpp
@@ -0,0 +1,181 @@
+/***************************************************************************
+ *
+ * Project         _____    __   ____   _      _
+ *                (  _  )  /__\ (_  _)_| |_  _| |_
+ *                 )(_)(  /(__)\  )( (_   _)(_   _)
+ *                (_____)(__)(__)(__)  |_|    |_|
+ *
+ *
+ * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************/
+
+#include "DeserializerTest.hpp"
+
+#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
+#include "oatpp/core/macro/codegen.hpp"
+
+namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
+
+namespace {
+
+#include OATPP_CODEGEN_BEGIN(DTO)
+  
+typedef oatpp::data::mapping::type::Object DTO;
+typedef oatpp::parser::Caret ParsingCaret;
+typedef oatpp::parser::json::mapping::Serializer Serializer;
+typedef oatpp::parser::json::mapping::Deserializer Deserializer;
+
+class EmptyDto : public DTO {
+
+  DTO_INIT(EmptyDto, DTO)
+
+};
+
+class Test1 : public DTO {
+  
+  DTO_INIT(Test1, DTO)
+  
+  DTO_FIELD(String, strF);
+  
+};
+  
+class Test2 : public DTO {
+  
+  DTO_INIT(Test2, DTO)
+  
+  DTO_FIELD(Int32, int32F);
+  
+};
+  
+class Test3 : public DTO {
+  
+  DTO_INIT(Test3, DTO)
+  
+  DTO_FIELD(Float32, float32F);
+  
+};
+
+class Test4 : public DTO {
+
+  DTO_INIT(Test4, DTO)
+
+  DTO_FIELD(EmptyDto::ObjectWrapper, object);
+  DTO_FIELD(List<EmptyDto::ObjectWrapper>::ObjectWrapper, list);
+  DTO_FIELD(Fields<EmptyDto::ObjectWrapper>::ObjectWrapper, map);
+
+};
+  
+#include OATPP_CODEGEN_END(DTO)
+  
+}
+  
+void DeserializerTest::onRun(){
+  
+  auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared();
+  
+  auto obj1 = mapper->readFromString<Test1>("{}");
+  
+  OATPP_ASSERT(obj1);
+  OATPP_ASSERT(!obj1->strF);
+  
+  obj1 = mapper->readFromString<Test1>("{\"strF\":\"value1\"}");
+  
+  OATPP_ASSERT(obj1);
+  OATPP_ASSERT(obj1->strF);
+  OATPP_ASSERT(obj1->strF->equals("value1"));
+  
+  obj1 = mapper->readFromString<Test1>("{\n\r\t\f\"strF\"\n\r\t\f:\n\r\t\f\"value1\"\n\r\t\f}");
+  
+  OATPP_ASSERT(obj1);
+  OATPP_ASSERT(obj1->strF);
+  OATPP_ASSERT(obj1->strF->equals("value1"));
+  
+  auto obj2 = mapper->readFromString<Test2>("{\"int32F\": null}");
+  
+  OATPP_ASSERT(obj2);
+  OATPP_ASSERT(!obj2->int32F);
+  
+  obj2 = mapper->readFromString<Test2>("{\"int32F\": 32}");
+  
+  OATPP_ASSERT(obj2);
+  OATPP_ASSERT(obj2->int32F->getValue() == 32);
+  
+  obj2 = mapper->readFromString<Test2>("{\"int32F\":    -32}");
+  
+  OATPP_ASSERT(obj2);
+  OATPP_ASSERT(obj2->int32F->getValue() == -32);
+  
+  auto obj3 = mapper->readFromString<Test3>("{\"float32F\": null}");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(!obj3->float32F);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": 32}");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F->getValue() == 32);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": 1.32e1}");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": 1.32e+1 }");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": 1.32e-1 }");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": -1.32E-1 }");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F);
+  
+  obj3 = mapper->readFromString<Test3>("{\"float32F\": -1.32E1 }");
+  
+  OATPP_ASSERT(obj3);
+  OATPP_ASSERT(obj3->float32F);
+  
+  auto list = mapper->readFromString<Test1::List<Test1::Int32>>("[1, 2, 3]");
+  OATPP_ASSERT(list);
+  OATPP_ASSERT(list->count() == 3);
+  OATPP_ASSERT(list->get(0)->getValue() == 1);
+  OATPP_ASSERT(list->get(1)->getValue() == 2);
+  OATPP_ASSERT(list->get(2)->getValue() == 3);
+
+  // Empty test
+
+  auto obj4 = mapper->readFromString<Test4>("{\"object\": {}, \"list\": [], \"map\": {}}");
+  OATPP_ASSERT(obj4);
+  OATPP_ASSERT(obj4->object);
+  OATPP_ASSERT(obj4->list);
+  OATPP_ASSERT(obj4->list->count() == 0);
+  OATPP_ASSERT(obj4->map->count() == 0);
+
+  obj4 = mapper->readFromString<Test4>("{\"object\": {\n\r\t}, \"list\": [\n\r\t], \"map\": {\n\r\t}}");
+  OATPP_ASSERT(obj4);
+  OATPP_ASSERT(obj4->object);
+  OATPP_ASSERT(obj4->list);
+  OATPP_ASSERT(obj4->list->count() == 0);
+  OATPP_ASSERT(obj4->map->count() == 0);
+
+}
+  
+}}}}}
diff --git a/recipes/oatpp/all/test_package/DeserializerTest.hpp b/recipes/oatpp/all/test_package/DeserializerTest.hpp
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/test_package/DeserializerTest.hpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ *
+ * Project         _____    __   ____   _      _
+ *                (  _  )  /__\ (_  _)_| |_  _| |_
+ *                 )(_)(  /(__)\  )( (_   _)(_   _)
+ *                (_____)(__)(__)(__)  |_|    |_|
+ *
+ *
+ * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ***************************************************************************/
+
+#ifndef oatpp_test_parser_json_mapping_DeserializerTest_hpp
+#define oatpp_test_parser_json_mapping_DeserializerTest_hpp
+
+#include "oatpp-test/UnitTest.hpp"
+
+namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping {
+  
+class DeserializerTest : public UnitTest{
+public:
+  
+  DeserializerTest():UnitTest("TEST[parser::json::mapping::DeserializerTest]"){}
+  void onRun() override;
+  
+};
+  
+}}}}}
+
+#endif /* oatpp_test_parser_json_mapping_DeserializerTest_hpp */
diff --git a/recipes/oatpp/all/test_package/conanfile.py b/recipes/oatpp/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/test_package/conanfile.py
@@ -0,0 +1,18 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+
+class OatppTestConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/oatpp/all/test_package/example.cpp b/recipes/oatpp/all/test_package/example.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/oatpp/all/test_package/example.cpp
@@ -0,0 +1,31 @@
+#include "DeserializerTest.hpp"
+
+#include "oatpp/core/concurrency/SpinLock.hpp"
+#include "oatpp/core/base/Environment.hpp"
+
+#include <iostream>
+#include <atomic>
+
+
+void runTests() {
+    OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest);
+}
+
+int main() {
+    oatpp::base::Environment::init();
+  
+    runTests();
+    
+    /* Print how much objects were created during app running, and what have left-probably leaked */
+    /* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */
+    std::cout << "\nEnvironment:\n";
+    std::cout << "objectsCount = " << oatpp::base::Environment::getObjectsCount() << "\n";
+    std::cout << "objectsCreated = " << oatpp::base::Environment::getObjectsCreated() << "\n\n";
+    
+    OATPP_ASSERT(oatpp::base::Environment::getObjectsCount() == 0);
+    
+    oatpp::base::Environment::destroy();
+
+
+    return 0;
+}