Build as shared library on Windows using Visual Studio compiler (#10)
* Build on Windows using Visual Studio and export symbols from DLL * Fix two warnings on raised by Visual Studio 2015 compiler + disable -Wall and -Wextra when using Visual Studio compiler * Fix indentation (TAB instead of spaces)
This commit is contained in:
parent
0de3d164d7
commit
42b32c500c
@ -31,12 +31,18 @@ target_include_directories(json-schema-validator
|
||||
target_compile_features(json-schema-validator
|
||||
PUBLIC
|
||||
cxx_range_for) # for C++11 - flags
|
||||
target_compile_options(json-schema-validator
|
||||
# Enable more compiler warnings, except when using Visual Studio compiler
|
||||
if(NOT MSVC)
|
||||
target_compile_options(json-schema-validator
|
||||
PUBLIC
|
||||
-Wall -Wextra) # bad, better use something else based on compiler type
|
||||
-Wall -Wextra)
|
||||
endif()
|
||||
target_link_libraries(json-schema-validator
|
||||
PUBLIC
|
||||
json-hpp)
|
||||
target_compile_definitions(json-schema-validator
|
||||
PRIVATE
|
||||
-DJSON_SCHEMA_VALIDATOR_EXPORTS)
|
||||
|
||||
# regex with boost if gcc < 4.8 - default is std::regex
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@ -113,5 +119,3 @@ else()
|
||||
message(STATUS "Consider setting JSON_SCHEMA_TEST_SUITE_PATH to a path in which JSON-Schema-Test-Suite is located (github.com/json-schema-org/JSON-Schema-Test-Suite).")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
|
||||
json document;
|
||||
|
||||
try {
|
||||
document << std::cin;
|
||||
std::cin >> document;
|
||||
validator.validate(document);
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "schema validation failed\n";
|
||||
|
||||
@ -26,6 +26,16 @@
|
||||
#ifndef NLOHMANN_JSON_SCHEMA_HPP__
|
||||
#define NLOHMANN_JSON_SCHEMA_HPP__
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef JSON_SCHEMA_VALIDATOR_EXPORTS
|
||||
# define JSON_SCHEMA_VALIDATOR_API __declspec(dllexport)
|
||||
# else
|
||||
# define JSON_SCHEMA_VALIDATOR_API __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define JSON_SCHEMA_VALIDATOR_API
|
||||
#endif
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
// make yourself a home - welcome to nlohmann's namespace
|
||||
@ -83,7 +93,7 @@ public:
|
||||
//
|
||||
// This is done implement the requirements described in section 8.2.
|
||||
//
|
||||
class json_uri
|
||||
class JSON_SCHEMA_VALIDATOR_API json_uri
|
||||
{
|
||||
std::string urn_;
|
||||
|
||||
@ -155,7 +165,7 @@ namespace json_schema_draft4
|
||||
|
||||
extern json draft4_schema_builtin;
|
||||
|
||||
class json_validator
|
||||
class JSON_SCHEMA_VALIDATOR_API json_validator
|
||||
{
|
||||
std::vector<std::shared_ptr<json>> schema_store_;
|
||||
std::shared_ptr<json> root_schema_;
|
||||
|
||||
@ -344,7 +344,7 @@ void json_validator::validate(const json &instance, const json &schema_, const s
|
||||
try {
|
||||
validate(instance, attr.value(), name);
|
||||
ok = false;
|
||||
} catch (std::exception &e) {
|
||||
} catch (std::exception &) {
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user