gqlite 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +0,0 @@
1
- #pragma once
2
-
3
- #include <stdbool.h>
4
-
5
- #ifdef __cplusplus
6
- extern "C" {
7
- #endif
8
-
9
- /**
10
- * The context is needed for most call to the API, it currently is mainly used to handle error reporting.
11
- * It also manage the memory for any string value returned by the API.
12
- */
13
- typedef struct gqlite_api_context* gqlite_api_context_t;
14
-
15
- /**
16
- * Connection to the database.
17
- */
18
- typedef struct gqlite_connection* gqlite_connection_t;
19
-
20
- /**
21
- * Represent a value (integer, double, string, map, array).
22
- */
23
- typedef struct gqlite_value* gqlite_value_t;
24
-
25
- /**
26
- * Create a new context.
27
- */
28
- gqlite_api_context_t gqlite_api_context_create();
29
- /**
30
- * Free context memory.
31
- */
32
- void gqlite_api_context_destroy(gqlite_api_context_t);
33
- /**
34
- * Return the error message. The memory is owned by the context,
35
- * it will be cleared when the context is freed or after the next function call.
36
- */
37
- const char* gqlite_api_context_get_message(gqlite_api_context_t);
38
- /**
39
- * Return true if an error has occured in the last call.
40
- */
41
- bool gqlite_api_context_has_error(gqlite_api_context_t);
42
- /**
43
- * Clear the error message.
44
- */
45
- void gqlite_api_context_clear_error(gqlite_api_context_t);
46
-
47
- /**
48
- * Create a connection, using the sqlite backend. Expect as argument an handle to a sqlite connection.
49
- */
50
- gqlite_connection_t gqlite_connection_create_from_sqlite(gqlite_api_context_t, void* _handle, gqlite_value_t _options);
51
-
52
- /**
53
- * Create a connection, using the sqlite backend. Using the database specified by the filename.
54
- */
55
- gqlite_connection_t gqlite_connection_create_from_sqlite_file(gqlite_api_context_t, const char* _filename, gqlite_value_t _options);
56
-
57
- /**
58
- * Destroy the connection. Does not delete any connection handle passed as an argument.
59
- */
60
- void gqlite_connection_destroy(gqlite_api_context_t, gqlite_connection_t);
61
-
62
- /**
63
- * Execute an OpenCypher query on the connection.
64
- * Return a null value if an error has occured during execution.
65
- */
66
- gqlite_value_t gqlite_connection_oc_query(gqlite_api_context_t, gqlite_connection_t, const char*, gqlite_value_t);
67
-
68
- /**
69
- * Create a value object to use in a query.
70
- */
71
- gqlite_value_t gqlite_value_create(gqlite_api_context_t);
72
-
73
- /**
74
- * Destroy a value.
75
- */
76
- void gqlite_value_destroy(gqlite_api_context_t, gqlite_value_t);
77
-
78
- /**
79
- * Convert value to json. The returned string is only valid until the next API call with the given context.
80
- */
81
- const char* gqlite_value_to_json(gqlite_api_context_t, gqlite_value_t);
82
-
83
- /**
84
- * Create value from json.
85
- */
86
- gqlite_value_t gqlite_value_from_json(gqlite_api_context_t, const char*);
87
-
88
- /**
89
- * Check if the value is valid.
90
- */
91
- bool gqlite_value_is_valid(gqlite_api_context_t, gqlite_value_t);
92
-
93
- #ifdef __cplusplus
94
- }
95
- #endif
data/ext/gqlite/gqlite.h DELETED
@@ -1,141 +0,0 @@
1
- #pragma once
2
-
3
- #include <exception>
4
- #include <memory>
5
- #include <string>
6
- #include <unordered_map>
7
- #include <vector>
8
-
9
- namespace gqlite
10
- {
11
- class backend;
12
- struct debug_stats;
13
- enum class exception_stage;
14
- enum class exception_code;
15
- struct exception_maker;
16
- struct exception_reader;
17
- /**
18
- * Represents an error that occurs during the execution of a query.
19
- */
20
- class exception : public std::exception
21
- {
22
- friend class exception_maker;
23
- friend class exception_reader;
24
- public:
25
- exception(exception&& _rhs);
26
- exception(const exception& _rhs);
27
- exception& operator=(const exception& _rhs);
28
- ~exception();
29
- /**
30
- * @return the error message
31
- */
32
- const char* what() const throw() override;
33
- private:
34
- struct data;
35
- exception(data* _d);
36
- data* const d;
37
- };
38
- /**
39
- * Represent the value type.
40
- */
41
- enum class value_type;
42
- class value;
43
- using value_map = std::unordered_map<std::string, value>;
44
- using value_vector = std::vector<value>;
45
- /**
46
- * Represent a value (boolean, integer, number, string, map or vector)
47
- */
48
- class value
49
- {
50
- public:
51
- value();
52
- value(const value& _rhs);
53
- value& operator=(const value& _rhs);
54
- ~value();
55
- public:
56
- value(bool _v);
57
- value(int64_t _v);
58
- value(double _v);
59
- value(const char* _v);
60
- value(const std::string& _v);
61
- value(const value_map& _v);
62
- /// not part of the public API
63
- template<typename _T_>
64
- value(const std::initializer_list<typename std::unordered_map<std::string, _T_>::value_type>& _v);
65
- value(const value_vector& _v);
66
- /// not part of the public API
67
- template<typename _T_>
68
- value(const std::vector<_T_>& _v);
69
- bool operator==(const value& _rhs) const;
70
- bool operator<(const value& _rhs) const;
71
- public:
72
- /**
73
- * @return the type hold by this value
74
- */
75
- value_type get_type() const;
76
- /**
77
- * Attempt to return a bool. Throw an exception if not possible.
78
- */
79
- bool to_bool() const;
80
- /**
81
- * Attempt to return an integer. Throw an exception if not possible.
82
- */
83
- int64_t to_integer() const;
84
- /**
85
- * Attempt to return a double. Throw an exception if not possible.
86
- */
87
- double to_double() const;
88
- /**
89
- * Attempt to return a string. Throw an exception if not possible.
90
- */
91
- std::string to_string() const;
92
- /**
93
- * Attempt to return a map. Throw an exception if not possible.
94
- */
95
- value_map to_map() const;
96
- /**
97
- * Attempt to return a vector. Throw an exception if not possible.
98
- */
99
- value_vector to_vector() const;
100
- public:
101
- /**
102
- * Attempt to return a json string to represent a value.
103
- */
104
- std::string to_json() const;
105
- /**
106
- * Construct a value from a json string. Throw an exception if not possible.
107
- */
108
- static value from_json(const std::string& _json);
109
- private:
110
- struct data;
111
- std::shared_ptr<data> d;
112
- };
113
- /**
114
- * Main class for connecting to a gqlite database.
115
- */
116
- class connection
117
- {
118
- connection(backend* _backend);
119
- public:
120
- connection();
121
- connection(const connection& _rhs);
122
- connection& operator=(const connection& _rhs);
123
- ~connection();
124
- /**
125
- * Create a sqlite connection from a \p _pointer to a valid sqlite handle.
126
- */
127
- static connection create_from_sqlite(void* _pointer, const value& _options = value());
128
- /**
129
- * Create a sqlite connection from a file.
130
- */
131
- static connection create_from_sqlite_file(const std::string& _filename, const value& _options = value());
132
- public:
133
- /**
134
- * Execute a query.
135
- */
136
- value execute_oc_query(const std::string& _string, const value_map& _variant = {});
137
- private:
138
- struct data;
139
- std::shared_ptr<data> d;
140
- };
141
- }