File: bson-writer.h

package info (click to toggle)
libmongodb-perl 1.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,004 kB
  • ctags: 2,932
  • sloc: perl: 12,511; ansic: 9,566; makefile: 22
file content (58 lines) | stat: -rw-r--r-- 1,952 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright 2013 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.
 */


#ifndef BSON_WRITER_H
#define BSON_WRITER_H


#include "bson.h"


BSON_BEGIN_DECLS


/**
 * bson_writer_t:
 *
 * The bson_writer_t structure is a helper for writing a series of BSON
 * documents to a single malloc() buffer. You can provide a realloc() style
 * function to grow the buffer as you go.
 *
 * This is useful if you want to build a series of BSON documents right into
 * the target buffer for an outgoing packet. The offset parameter allows you to
 * start at an offset of the target buffer.
 */
typedef struct _bson_writer_t bson_writer_t;


bson_writer_t *bson_writer_new        (uint8_t           **buf,
                                       size_t             *buflen,
                                       size_t              offset,
                                       bson_realloc_func   realloc_func,
                                       void               *realloc_func_ctx);
void           bson_writer_destroy    (bson_writer_t      *writer);
size_t         bson_writer_get_length (bson_writer_t      *writer);
bool           bson_writer_begin      (bson_writer_t      *writer,
                                       bson_t            **bson);
void           bson_writer_end        (bson_writer_t      *writer);
void           bson_writer_rollback   (bson_writer_t      *writer);


BSON_END_DECLS


#endif /* BSON_WRITER_H */