boost_sqlite 1
A sqlite C++ library
Loading...
Searching...
No Matches
json.hpp
1//
2// Copyright (c) 2022 Klemens Morgenstern (klemens.morgenstern@gmx.net)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BOOST_SQLITE_JSON_HPP
9#define BOOST_SQLITE_JSON_HPP
10
11#include <boost/sqlite/detail/config.hpp>
12#include <boost/sqlite/field.hpp>
13#include <boost/sqlite/value.hpp>
14#include <boost/json/fwd.hpp>
15#include <boost/json/storage_ptr.hpp>
16
17BOOST_SQLITE_BEGIN_NAMESPACE
18
19struct resultset;
20struct field;
21struct value;
22
24constexpr int json_subtype = static_cast<int>('J');
25
26BOOST_SQLITE_DECL void tag_invoke(const struct set_result_tag &, sqlite3_context * ctx, const json::value & value);
27
30inline bool is_json(const value & v) { return v.type() == value_type::text && v.subtype() == json_subtype; }
31inline bool is_json(const field & f) { return f.type() == value_type::text && f.get_value().subtype() == json_subtype; }
33
36BOOST_SQLITE_DECL json::value as_json(const value & v, json::storage_ptr ptr = {});
37BOOST_SQLITE_DECL json::value as_json(const field & f, json::storage_ptr ptr = {});
39
40BOOST_SQLITE_DECL void tag_invoke( const json::value_from_tag &, json::value& val, const value & f);
41BOOST_SQLITE_DECL void tag_invoke( const json::value_from_tag &, json::value& val, const field & f);
42BOOST_SQLITE_DECL void tag_invoke( const json::value_from_tag &, json::value& val, resultset && rs);
43
44BOOST_SQLITE_END_NAMESPACE
45
46
47#endif //BOOST_SQLITE_JSON_HPP
json::value as_json(const value &v, json::storage_ptr ptr={})
Convert the value or field to a json.
bool is_json(const value &v)
Check if the value or field is a json.
Definition json.hpp:30
A holder for a sqlite field, i.e. something returned from a query.
Definition field.hpp:22
A holder for a sqlite values used for internal APIs.
Definition value.hpp:39