knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Document.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_MONGO_DOCUMENT_H
7 #define KNOWROB_MONGO_DOCUMENT_H
8 
9 #include <mongoc.h>
10 
11 namespace knowrob::mongo {
16  class Document {
17  public:
18  explicit Document(bson_t *bson) : bson_(bson) {}
19 
20  Document(const Document &) = delete;
21 
22  ~Document() { bson_destroy(bson_); }
23 
27  bson_t *bson() const { return bson_; }
28 
29  static void print_canonical(bson_t *bson) {
30  size_t len;
31  auto str = bson_as_canonical_extended_json(bson, &len);
32  printf("%s\n", str);
33  bson_free(str);
34  }
35 
36  static void print_relaxed(bson_t *bson) {
37  size_t len;
38  auto str = bson_as_relaxed_extended_json(bson, &len);
39  printf("%s\n", str);
40  bson_free(str);
41  }
42 
43  protected:
44  bson_t *bson_;
45  };
46 
47 } // knowrob
48 
49 #endif //KNOWROB_MONGO_DOCUMENT_H
Document(const Document &)=delete
static void print_relaxed(bson_t *bson)
Definition: Document.h:36
static void print_canonical(bson_t *bson)
Definition: Document.h:29
bson_t * bson() const
Definition: Document.h:27
Document(bson_t *bson)
Definition: Document.h:18