Skip to content

Commit

Permalink
Merge pull request #161 from niklas88/json_header_only
Browse files Browse the repository at this point in the history
Latest nlohmann/json no submodule fixes #121
  • Loading branch information
niklas88 committed Dec 17, 2018
2 parents e715478 + c4a7c27 commit 41d3e2e
Show file tree
Hide file tree
Showing 34 changed files with 20,192 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
[submodule "third_party/json"]
path = third_party/json
url = https://github.com/nlohmann/json.git
[submodule "third_party/re2"]
path = third_party/re2
url = https://github.com/google/re2.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ include_directories(third_party/googletest/googletest/include)
# NLOHNMANN-JSON
################################
# Header only, nothing to include
include_directories(third_party/json/include/)
include_directories(third_party/json/)

################################
# STXXL
Expand Down
1 change: 0 additions & 1 deletion third_party/json
Submodule json deleted from 3ce432
49 changes: 49 additions & 0 deletions third_party/json/nlohmann/adl_serializer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

#include <utility>

#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>

namespace nlohmann
{

template<typename, typename>
struct adl_serializer
{
/*!
@brief convert a JSON value to any value type
This function is usually called by the `get()` function of the
@ref basic_json class (either explicit or via conversion operators).
@param[in] j JSON value to read from
@param[in,out] val value to write to
*/
template<typename BasicJsonType, typename ValueType>
static auto from_json(BasicJsonType&& j, ValueType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
{
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
}

/*!
@brief convert any value type to a JSON value
This function is usually called by the constructors of the @ref basic_json
class.
@param[in,out] j JSON value to write to
@param[in] val value to read from
*/
template <typename BasicJsonType, typename ValueType>
static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
{
::nlohmann::to_json(j, std::forward<ValueType>(val));
}
};

} // namespace nlohmann

0 comments on commit 41d3e2e

Please sign in to comment.