]> git.jsancho.org Git - bongodb.git/blob - src/bongodb.h
Initial commit
[bongodb.git] / src / bongodb.h
1 /*
2  * BongoDB, an embedded document-based engine
3  * Copyright (C) 2015 by Javier Sancho Fernandez <jsf at jsancho dot org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __BONGODB_H_
20 #define __BONGODB_H_
21
22
23 /* BongoDB Client */
24
25 typedef struct {
26   char *key;
27   char *value;
28   bongo_record_tag_t *next;
29 } bongo_record_tag_t;
30
31 typedef struct {
32   bongo_record_tag_t *tags;
33   bongo_record_node_t *next;
34 } bongo_record_node_t;
35
36 typedef struct {
37   const char *col_name;
38   int n_records;
39   bongo_record_node_t *records;
40   struct bongo_collection_node_t *next;
41 } bongo_collection_node_t;
42
43 typedef struct {
44   const char *db_name;
45   int n_collections;
46   bongo_collection_node_t *collections;
47   struct bongo_database_node_t *next;
48 } bongo_database_node_t;
49
50 typedef struct {
51   int n_databases;
52   bongo_database_node_t *databases;
53 } bongo_client_t;
54
55 bongo_client_t *bongo_client_new(void);
56 bongo_database_node_t *bongo_database_node_new(bongo_client_t *bongo_client, const char *db_name);
57 bongo_collection_node_t *bongo_collection_node_new(bongo_database_node_t *bongo_database_node, const char *col_name);
58 bongo_database_node_t *bongo_database_node_search(bongo_client_t *bongo_client, const char *db_name);
59 bongo_collection_node_t *bongo_collection_node_search(bongo_database_node_t *bongo_database_node, const char *col_name);
60 void bongo_collection_node_destroy(bongo_collection_node_t *bongo_collection_node);
61 void bongo_database_node_destroy(bongo_database_node_t *bongo_database_node);
62 void bongo_client_destroy(bongo_client_t *bongo_client);
63
64
65 /* BongoDB Database */
66
67 typedef struct {
68   bongo_database_node_t *database_node;
69 } bongo_database_t;
70
71 bongo_database_t *bongo_client_get_database(bongo_client_t *bongo_client, const char *db_name);
72 void bongo_database_destroy(bongo_database_t *bongo_database);
73
74
75 /* BongoDB Collection */
76
77 typedef struct {
78   bongo_collection_node_t *collection_node;
79 } bongo_collection_t;
80
81 bongo_collection_t *bongo_client_get_collection(bongo_client_t *bongo_client, const char *db_name, const char *col_name);
82 void bongo_collection_destroy(bongo_collection_t *bongo_collection);
83
84
85 #endif /* __BONGODB_H_ */