#include "knowrob/reasoner/mongolog/bson_pl.h"
#include "knowrob/storage/mongo/MongoException.h"
#include <iostream>
Go to the source code of this file.
|
PlTerm | bson_to_term (const bson_t *doc) |
|
bool | bsonpl_append (bson_t *doc, const char *key, const PlTerm &term, bson_error_t *err) |
|
bool | bsonpl_concat (bson_t *doc, const PlTerm &term, bson_error_t *err) |
|
◆ APPEND_BSON_PL_PAIR
#define APPEND_BSON_PL_PAIR |
( |
|
list, |
|
|
|
key, |
|
|
|
value, |
|
|
|
type |
|
) |
| |
Value: ((PlTail*)list)->append(PlCompound("-", \
PlTermv(PlTerm(key), PlCompound(
type, PlTerm(value))))) &&
false
Definition at line 11 of file bson_pl.cpp.
◆ bson_to_term()
PlTerm bson_to_term |
( |
const bson_t * |
doc | ) |
|
Definition at line 210 of file bson_pl.cpp.
212 static bson_visitor_t visitor = get_bson_visitor();
215 PlTail out_list(
term);
216 if (bson_iter_init(&iter, doc)) {
217 if(bson_iter_visit_all(&iter, &visitor, &out_list)) {
221 MONGOC_ERROR_BSON_INVALID,
222 "BSON iteration prematurely stopped.");
◆ bsonpl_append()
bool bsonpl_append |
( |
bson_t * |
doc, |
|
|
const char * |
key, |
|
|
const PlTerm & |
term, |
|
|
bson_error_t * |
err |
|
) |
| |
Definition at line 311 of file bson_pl.cpp.
312 if(PL_is_list((term_t)
term)) {
315 BSON_APPEND_DOCUMENT_BEGIN(doc, key, &nested_doc);
317 bson_append_document_end(doc, &nested_doc);
324 else if(std::string_view(
term.name()) ==
"bson_t") {
327 if(
term.arity()!=1) {
330 MONGOC_ERROR_BSON_INVALID,
331 "invalid bson_t term -- arity should be 1: %s", (
char*)
term
335 const PlTerm &bson_value =
term[1];
336 auto *sub_bson = (bson_t*)bson_value.operator
void *();
338 bool success = bson_concat(doc, sub_bson);
339 bson_destroy(sub_bson);
345 MONGOC_ERROR_BSON_INVALID,
346 "invalid bson_t term -- void pointer is null: %s", (
char*)
term
353 return bsonpl_append_typed(doc,key,
term,err);
bool bsonpl_concat(bson_t *doc, const PlTerm &term, bson_error_t *err)
◆ bsonpl_concat()
bool bsonpl_concat |
( |
bson_t * |
doc, |
|
|
const PlTerm & |
term, |
|
|
bson_error_t * |
err |
|
) |
| |
Definition at line 357 of file bson_pl.cpp.
361 if(!list.next(member)) {
365 else if(PL_is_list((term_t)member)) {
371 }
while(list.next(member));
376 const char *key = (
char*)member;
bool bsonpl_append(bson_t *doc, const char *key, const PlTerm &term, bson_error_t *err)