#include "mongoc-prelude.h"

#ifndef MONGOC_OPTS_H
#define MONGOC_OPTS_H

#include <bson/bson.h>

#include "mongoc-client-session.h"
#include "mongoc-bulk-operation-private.h"
#include "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 */
