20     bson_t queryOperatorDoc;
 
   21     bson_t orArray, orCase1, orCase2;
 
   22     bson_t *valueDocument;
 
   25     if (matchNullValues) {
 
   28         BSON_APPEND_ARRAY_BEGIN(doc, 
"$or", &orArray);
 
   30         BSON_APPEND_DOCUMENT_BEGIN(&orArray, 
"0", &orCase1);
 
   31         BSON_APPEND_NULL(&orCase1, key);
 
   32         bson_append_document_end(&orArray, &orCase1);
 
   34         BSON_APPEND_DOCUMENT_BEGIN(&orArray, 
"1", &orCase2);
 
   38         BSON_APPEND_DOCUMENT_BEGIN(matchNullValues ? &orCase2 : doc, key, &queryOperatorDoc);
 
   39         valueDocument = &queryOperatorDoc;
 
   40         valueKey = queryOperator;
 
   42         valueDocument = (matchNullValues ? &orCase2 : doc);
 
   47         auto atomic = std::static_pointer_cast<Atomic>(
term);
 
   48         switch (
atomic->atomicType()) {
 
   51                 BSON_APPEND_UTF8(valueDocument, valueKey, 
atomic->stringForm().data());
 
   54                 auto numeric = std::static_pointer_cast<Numeric>(
atomic);
 
   55                 switch (numeric->xsdType()) {
 
   58                         BSON_APPEND_DOUBLE(valueDocument, valueKey, numeric->asDouble());
 
   63                         BSON_APPEND_INT32(valueDocument, valueKey, numeric->asInteger());
 
   67                         BSON_APPEND_INT64(valueDocument, valueKey, numeric->asLong());
 
   71                         BSON_APPEND_INT32(valueDocument, valueKey, numeric->asShort());
 
   74                         BSON_APPEND_BOOL(valueDocument, valueKey, numeric->asBoolean());
 
   84         append(valueDocument, valueKey,
 
   85                ((ListTerm *) 
term.get())->elements());
 
   89         BSON_APPEND_UTF8(valueDocument, valueKey, (varPrefix + varKey).data());
 
   93         bson_append_document_end(matchNullValues ? &orCase2 : doc, &queryOperatorDoc);
 
   95     if (matchNullValues) {
 
   96         bson_append_document_end(&orArray, &orCase2);
 
   97         bson_append_array_end(doc, &orArray);
 
static std::string variableKey(const std::string_view &varName)