json/include/nlohmann/detail/json_metadata.hpp
Raphael Grimm 1b11773cd6 Allow to add metadata to json nodes
* by default no metadata is allowed and the library behaves as it already did
* if a user explicitly adds metadata (last template parameter) each node has a data member of this type and access functions for this member
* add test for this feature
2021-09-24 23:32:20 +02:00

31 lines
446 B
C++

#pragma once
namespace nlohmann
{
namespace detail
{
template<class MetaDataType>
class json_metadata
{
public:
using metadata_t = MetaDataType;
metadata_t& metadata()
{
return m_metadata;
}
const metadata_t& metadata() const
{
return m_metadata;
}
private:
metadata_t m_metadata;
};
template<>
class json_metadata<void>
{
//no metadata
};
} // namespace detail
} // namespace nlohmann