| 1 |
/* |
| 2 |
* Copyright 2009-present MongoDB, Inc. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <mongoc/mongoc-prelude.h> |
| 18 |
|
| 19 |
#ifndef MONGOC_OPTS_H |
| 20 |
#define MONGOC_OPTS_H |
| 21 |
|
| 22 |
#include <bson/bson.h> |
| 23 |
|
| 24 |
#include <mongoc/mongoc-client-session.h> |
| 25 |
#include <mongoc/mongoc-bulk-operation-private.h> |
| 26 |
#include <mongoc/mongoc-opts-helpers-private.h> |
| 27 |
|
| 28 |
{{ header_comment }} |
| 29 |
|
| 30 |
{% for struct_type, description in opts_structs.items() %} |
| 31 |
{% if not description.generate_code %}{% continue %}{% endif %} |
| 32 |
typedef struct _{{ struct_type }} { |
| 33 |
{% for opt_name, info in description.items() %} |
| 34 |
{% if info['type'] == 'utf8' %} |
| 35 |
{% set the_type = 'const char *' %} |
| 36 |
{% elif info['type'] in ('document', 'array') %} |
| 37 |
{% set the_type = 'bson_t' %} |
| 38 |
{% elif info['type'] == 'timestamp' %} |
| 39 |
{% set the_type = 'mongoc_timestamp_t' %} |
| 40 |
{% else %} |
| 41 |
{% set the_type = info['type'] %} |
| 42 |
{% endif %} |
| 43 |
{% set the_name = info.get('field', opt_name) %} |
| 44 |
{% set space = '' if the_type.endswith('*') else ' ' %} |
| 45 |
{{ the_type }}{{ space }}{{ the_name }}; |
| 46 |
{% if info.check_set %} |
| 47 |
bool {{ the_name }}_is_set; |
| 48 |
{% endif %} |
| 49 |
{% endfor %} |
| 50 |
{% if not description.is_shared %} |
| 51 |
bson_t extra; |
| 52 |
{% endif %} |
| 53 |
} {{ struct_type }}; |
| 54 |
|
| 55 |
{% endfor %} |
| 56 |
{% for struct_type, description in opts_structs.items() %} |
| 57 |
{% if description.is_shared or not description.generate_code %}{% continue %}{% endif %} |
| 58 |
{% set struct_name = struct_type.split('_t', -1)[0] %} |
| 59 |
bool |
| 60 |
_{{ struct_name }}_parse ( |
| 61 |
mongoc_client_t *client, |
| 62 |
const bson_t *opts, |
| 63 |
{{ struct_type }} *{{ struct_name }}, |
| 64 |
bson_error_t *error); |
| 65 |
|
| 66 |
void |
| 67 |
_{{ struct_name }}_cleanup ({{ struct_type }} *{{ struct_name }}); |
| 68 |
|
| 69 |
{% endfor %} |
| 70 |
#endif /* MONGOC_OPTS_H */ |