/*
 * Copyright 2009-present MongoDB, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <mongoc/mongoc-prelude.h>

#ifndef MONGOC_OPTS_H
#define MONGOC_OPTS_H

#include <bson/bson.h>

#include <mongoc/mongoc-client-session.h>
#include <mongoc/mongoc-bulk-operation-private.h>
#include <mongoc/mongoc-opts-helpers-private.h>

{{ header_comment }}

{% for struct_type, description in opts_structs.items() %}
{% if not description.generate_code %}{% continue %}{% endif %}
typedef struct _{{ struct_type }} {
{% for opt_name, info in description.items() %}
{% if info['type'] == 'utf8' %}
{% set the_type = 'const char *' %}
{% elif info['type'] in ('document', 'array') %}
{% set the_type = 'bson_t' %}
{% elif info['type'] == 'timestamp' %}
{% set the_type = 'mongoc_timestamp_t' %}
{% else %}
{% set the_type = info['type'] %}
{% endif %}
{% set the_name = info.get('field', opt_name) %}
{% set space = '' if the_type.endswith('*') else ' ' %}
   {{ the_type }}{{ space }}{{ the_name }};
{% if info.check_set %}
   bool {{ the_name }}_is_set;
{% endif %}
{% endfor %}
{% if not description.is_shared %}
   bson_t extra;
{% endif %}
} {{ struct_type }};

{% endfor %}
{% for struct_type, description in opts_structs.items() %}
{% if description.is_shared or not description.generate_code %}{% continue %}{% endif %}
{% set struct_name = struct_type.split('_t', -1)[0] %}
bool
_{{ struct_name }}_parse (
   mongoc_client_t *client,
   const bson_t *opts,
   {{ struct_type }} *{{ struct_name }},
   bson_error_t *error);

void
_{{ struct_name }}_cleanup ({{ struct_type }} *{{ struct_name }});

{% endfor %}
#endif /* MONGOC_OPTS_H */
