JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
serializer_for.hpp
Go to the documentation of this file.
1/// \file jsonv/serialization/serializer_for.hpp
2///
3/// Copyright (c) 2015-2020 by Travis Gockel. All rights reserved.
4///
5/// This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
6/// as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
7/// version.
8///
9/// \author Travis Gockel (travis@gockelhut.com)
10#pragma once
11
12#include <jsonv/config.hpp>
14
15namespace jsonv
16{
17
18/// \addtogroup Serialization
19/// \{
20
21template <typename T>
23 public serializer
24{
25public:
26 virtual const std::type_info& get_type() const override
27 {
28 return typeid(T);
29 }
30
32 const void* from
33 ) const override
34 {
35 return to_json(context, *static_cast<const T*>(from));
36 }
37
38protected:
40 const T& from
41 ) const = 0;
42};
43
44/// \}
45
46}
An adapter for enumeration types.
virtual value to_json(const serialization_context &context, const void *from) const override
Create a value from the value in the given region of memory.
virtual const std::type_info & get_type() const override
Get the run-time type this serialize knows how to encode.
A serializer holds the method for converting an arbitrary C++ type into a value.
Represents a single JSON value, which can be any one of a potential kind, each behaving slightly diff...
Definition value.hpp:107
Copyright (c) 2014-2020 by Travis Gockel.
Conversion between C++ types and JSON values.