Skip to content
Newer
Older
100644 333 lines (295 sloc) 10.5 KB
af59f77 @banker minor: docs
banker authored Aug 3, 2011
1 /** @file gridfs.h
2 *
3 * @brief GridFS declarations
4 *
5 * */
10861d0 @banker minor: license updates
banker authored Jul 11, 2011
6
84d1b51 @banker CDRIVER-79 minor: fix copyright
banker authored Apr 12, 2012
7 /* Copyright 2009-2012 10gen Inc.
10861d0 @banker minor: license updates
banker authored Jul 11, 2011
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
8c72f56 @joshrotenberg set up other files, add a main page for examples and general docs
joshrotenberg authored Apr 22, 2011
20 */
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
21
22 #include "mongo.h"
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
23
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
24 #ifndef MONGO_GRIDFS_H_
25 #define MONGO_GRIDFS_H_
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
26
27 enum {DEFAULT_CHUNK_SIZE = 256 * 1024};
28
3a1cc6c fixes based on comments
Christopher Triolo authored Jun 25, 2010
29 typedef uint64_t gridfs_offset;
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
30
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
31 /* A GridFS represents a single collection of GridFS files in the database. */
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
32 typedef struct {
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
33 mongo *client; /**> The client to db-connection. */
34 const char *dbname; /**> The root database name */
35 const char *prefix; /**> The prefix of the GridFS's collections, default is NULL */
36 const char *files_ns; /**> The namespace where the file's metadata is stored */
37 const char *chunks_ns; /**. The namespace where the files's data is stored in chunks */
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
38 } gridfs;
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
39
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
40 /* A GridFile is a single GridFS file. */
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
41 typedef struct {
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
42 gridfs *gfs; /**> The GridFS where the GridFile is located */
43 bson *meta; /**> The GridFile's bson object where all its metadata is located */
44 gridfs_offset pos; /**> The position is the offset in the file */
45 bson_oid_t id; /**> The files_id of the gridfile */
46 char *remote_name; /**> The name of the gridfile as a string */
47 char *content_type; /**> The gridfile's content type */
48 gridfs_offset length; /**> The length of this gridfile */
49 int chunk_num; /**> The number of the current chunk being written to */
50 char *pending_data; /**> A buffer storing data still to be written to chunks */
51 int pending_len; /**> Length of pending_data buffer */
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
52 } gridfile;
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
53
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
54 MONGO_EXPORT gridfs* gridfs_create();
55 MONGO_EXPORT void gridfs_dispose(gridfs* gfs);
56 MONGO_EXPORT gridfile* gridfile_create();
57 MONGO_EXPORT void gridfile_dispose(gridfile* gf);
58 MONGO_EXPORT void gridfile_get_descriptor(gridfile* gf, bson* out);
da4520e @banker Integrate changes for Delphi and Matlab driver compatibility.
banker authored Feb 14, 2012
59
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
60 /**
61 * Initializes a GridFS object
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
62 * @param client - db connection
63 * @param dbname - database name
64 * @param prefix - collection prefix, default is fs if NULL or empty
d1bb65d @banker minor: whitespace and docs
banker authored Feb 11, 2011
65 * @param gfs - the GridFS object to initialize
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
66 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
67 * @return - MONGO_OK or MONGO_ERROR.
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
68 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
69 MONGO_EXPORT int gridfs_init( mongo *client, const char *dbname,
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
70 const char *prefix, gridfs *gfs );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
71
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
72 /**
73 * Destroys a GridFS object. Call this when finished with
74 * the object..
75 *
76 * @param gfs a grid
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
77 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
78 MONGO_EXPORT void gridfs_destroy( gridfs *gfs );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
79
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
80 /**
81 * Initializes a gridfile for writing incrementally with gridfs_write_buffer.
863b076 @banker CDRIVER-26 better GridFS buffer-by-buffer API
banker authored Feb 17, 2011
82 * Once initialized, you can write any number of buffers with gridfs_write_buffer.
83 * When done, you must call gridfs_writer_done to save the file metadata.
84 *
85 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
86 MONGO_EXPORT void gridfile_writer_init( gridfile *gfile, gridfs *gfs, const char *remote_name,
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
87 const char *content_type );
692b85e @banker CDRIVER-26 work with large (> 3 GB) files;
banker authored Feb 14, 2011
88
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
89 /**
90 * Write to a GridFS file incrementally. You can call this function any number
863b076 @banker CDRIVER-26 better GridFS buffer-by-buffer API
banker authored Feb 17, 2011
91 * of times with a new buffer each time. This allows you to effectively
92 * stream to a GridFS file. When finished, be sure to call gridfs_writer_done.
93 *
94 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
95 MONGO_EXPORT void gridfile_write_buffer( gridfile *gfile, const char *data,
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
96 gridfs_offset length );
692b85e @banker CDRIVER-26 work with large (> 3 GB) files;
banker authored Feb 14, 2011
97
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
98 /**
99 * Signal that writing of this gridfile is complete by
863b076 @banker CDRIVER-26 better GridFS buffer-by-buffer API
banker authored Feb 17, 2011
100 * writing any buffered chunks along with the entry in the
101 * files collection.
102 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
103 * @return - MONGO_OK or MONGO_ERROR.
863b076 @banker CDRIVER-26 better GridFS buffer-by-buffer API
banker authored Feb 17, 2011
104 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
105 MONGO_EXPORT int gridfile_writer_done( gridfile *gfile );
692b85e @banker CDRIVER-26 work with large (> 3 GB) files;
banker authored Feb 14, 2011
106
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
107 /**
108 * Store a buffer as a GridFS file.
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
109 * @param gfs - the working GridFS
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
110 * @param data - pointer to buffer to store in GridFS
111 * @param length - length of the buffer
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
112 * @param remotename - filename for use in the database
113 * @param contenttype - optional MIME type for this object
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
114 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
115 * @return - MONGO_OK or MONGO_ERROR.
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
116 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
117 MONGO_EXPORT int gridfs_store_buffer( gridfs *gfs, const char *data, gridfs_offset length,
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
118 const char *remotename,
119 const char *contenttype );
692b85e @banker CDRIVER-26 work with large (> 3 GB) files;
banker authored Feb 14, 2011
120
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
121 /**
122 * Open the file referenced by filename and store it as a GridFS file.
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
123 * @param gfs - the working GridFS
124 * @param filename - local filename relative to the process
125 * @param remotename - optional filename for use in the database
126 * @param contenttype - optional MIME type for this object
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
127 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
128 * @return - MONGO_OK or MONGO_ERROR.
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
129 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
130 MONGO_EXPORT int gridfs_store_file( gridfs *gfs, const char *filename,
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
131 const char *remotename, const char *contenttype );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
132
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
133 /**
134 * Removes the files referenced by filename from the db
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
135 * @param gfs - the working GridFS
136 * @param filename - the filename of the file/s to be removed
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
137 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
138 MONGO_EXPORT void gridfs_remove_filename( gridfs *gfs, const char *filename );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
139
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
140 /**
b2210a7 @banker minor: formatting and docs.
banker authored Aug 2, 2011
141 * Find the first file matching the provided query within the
142 * GridFS files collection, and return the file as a GridFile.
143 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
144 * @param gfs - the working GridFS
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
145 * @param query - a pointer to the bson with the query data
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
146 * @param gfile - the output GridFile to be initialized
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
147 *
148 * @return MONGO_OK if successful, MONGO_ERROR otherwise
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
149 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
150 MONGO_EXPORT int gridfs_find_query( gridfs *gfs, bson *query, gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
151
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
152 /**
153 * Find the first file referenced by filename within the GridFS
d1bb65d @banker minor: whitespace and docs
banker authored Feb 11, 2011
154 * and return it as a GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
155 * @param gfs - the working GridFS
156 * @param filename - filename of the file to find
157 * @param gfile - the output GridFile to be intialized
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
158 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
159 * @return MONGO_OK or MONGO_ERROR.
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
160 */
b0cb2a2 @banker Fix test suite on WIN32
banker authored Apr 10, 2012
161 MONGO_EXPORT int gridfs_find_filename( gridfs *gfs, const char *filename, gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
162
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
163 /**
164 * Initializes a GridFile containing the GridFS and file bson
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
165 * @param gfs - the GridFS where the GridFile is located
3a1cc6c fixes based on comments
Christopher Triolo authored Jun 25, 2010
166 * @param meta - the file object
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
167 * @param gfile - the output GridFile that is being initialized
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
168 *
35dda68 @banker Ensure that GridFS return values are MONGO_OK or MONGO_ERROR.
banker authored Aug 2, 2011
169 * @return - MONGO_OK or MONGO_ERROR.
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
170 */
b0cb2a2 @banker Fix test suite on WIN32
banker authored Apr 10, 2012
171 MONGO_EXPORT int gridfile_init( gridfs *gfs, bson *meta, gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
172
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
173 /**
174 * Destroys the GridFile
175 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
176 * @param oGridFIle - the GridFile being destroyed
177 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
178 MONGO_EXPORT void gridfile_destroy( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
179
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
180 /**
181 * Returns whether or not the GridFile exists
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
182 * @param gfile - the GridFile being examined
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
183 */
b0cb2a2 @banker Fix test suite on WIN32
banker authored Apr 10, 2012
184 MONGO_EXPORT bson_bool_t gridfile_exists( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
185
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
186 /**
187 * Returns the filename of GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
188 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
189 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
190 * @return - the filename of the Gridfile
191 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
192 MONGO_EXPORT const char *gridfile_get_filename( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
193
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
194 /**
195 * Returns the size of the chunks of the GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
196 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
197 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
198 * @return - the size of the chunks of the Gridfile
199 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
200 MONGO_EXPORT int gridfile_get_chunksize( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
201
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
202 /**
203 * Returns the length of GridFile's data
204 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
205 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
206 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
207 * @return - the length of the Gridfile's data
208 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
209 MONGO_EXPORT gridfs_offset gridfile_get_contentlength( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
210
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
211 /**
212 * Returns the MIME type of the GridFile
213 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
214 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
215 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
216 * @return - the MIME type of the Gridfile
217 * (NULL if no type specified)
218 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
219 MONGO_EXPORT const char *gridfile_get_contenttype( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
220
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
221 /**
222 * Returns the upload date of GridFile
223 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
224 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
225 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
226 * @return - the upload date of the Gridfile
227 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
228 MONGO_EXPORT bson_date_t gridfile_get_uploaddate( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
229
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
230 /**
231 * Returns the MD5 of GridFile
232 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
233 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
234 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
235 * @return - the MD5 of the Gridfile
236 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
237 MONGO_EXPORT const char *gridfile_get_md5( gridfile *gfile );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
238
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
239 /**
240 * Returns the field in GridFile specified by name
241 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
242 * @param gfile - the working GridFile
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
243 * @param name - the name of the field to be returned
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
244 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
245 * @return - the data of the field specified
246 * (NULL if none exists)
247 */
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
248 const char *gridfile_get_field( gridfile *gfile,
249 const char *name );
db8677d @tzusman Added support for boolean fields
tzusman authored Jul 6, 2010
250
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
251 /**
252 * Returns a boolean field in GridFile specified by name
db8677d @tzusman Added support for boolean fields
tzusman authored Jul 5, 2010
253 * @param gfile - the working GridFile
254 * @param name - the name of the field to be returned
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
255 *
db8677d @tzusman Added support for boolean fields
tzusman authored Jul 5, 2010
256 * @return - the boolean of the field specified
257 * (NULL if none exists)
258 */
70bc545 @banker minor: astyle
banker authored Jul 29, 2011
259 bson_bool_t gridfile_get_boolean( gridfile *gfile,
260 const char *name );
db8677d @tzusman Added support for boolean fields
tzusman authored Jul 5, 2010
261
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
262 /**
263 * Returns the metadata of GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
264 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
265 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
266 * @return - the metadata of the Gridfile in a bson object
267 * (an empty bson is returned if none exists)
268 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
269 MONGO_EXPORT void gridfile_get_metadata( gridfile *gfile, bson* out );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
270
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
271 /**
272 * Returns the number of chunks in the GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
273 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
274 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
275 * @return - the number of chunks in the Gridfile
276 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
277 MONGO_EXPORT int gridfile_get_numchunks( gridfile *gfile );
d1bb65d @banker minor: whitespace and docs
banker authored Feb 11, 2011
278
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
279 /**
280 * Returns chunk n of GridFile
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
281 * @param gfile - the working GridFile
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
282 *
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
283 * @return - the nth chunk of the Gridfile
284 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
285 MONGO_EXPORT void gridfile_get_chunk( gridfile *gfile, int n, bson* out );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
286
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
287 /**
288 * Returns a mongo_cursor of *size* chunks starting with chunk *start*
289 *
7dcc157 gridfile_get_chunks, and update to gridfile_read
Christopher Triolo authored Jun 25, 2010
290 * @param gfile - the working GridFile
291 * @param start - the first chunk in the cursor
292 * @param size - the number of chunks to be returned
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
293 *
7dcc157 gridfile_get_chunks, and update to gridfile_read
Christopher Triolo authored Jun 25, 2010
294 * @return - mongo_cursor of the chunks (must be destroyed after use)
295 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
296 MONGO_EXPORT mongo_cursor *gridfile_get_chunks( gridfile *gfile, int start, int size );
7dcc157 gridfile_get_chunks, and update to gridfile_read
Christopher Triolo authored Jun 25, 2010
297
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
298 /**
299 * Writes the GridFile to a stream
300 *
921079f Fixed the gridfs api to be like the rest of the c-driver
Christopher Triolo authored Jun 4, 2010
301 * @param gfile - the working GridFile
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
302 * @param stream - the file stream to write to
303 */
b0cb2a2 @banker Fix test suite on WIN32
banker authored Apr 10, 2012
304 MONGO_EXPORT gridfs_offset gridfile_write_file( gridfile *gfile, FILE *stream );
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
305
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
306 /**
307 * Reads length bytes from the GridFile to a buffer
d1bb65d @banker minor: whitespace and docs
banker authored Feb 11, 2011
308 * and updates the position in the file.
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
309 * (assumes the buffer is large enough)
310 * (if size is greater than EOF gridfile_read reads until EOF)
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
311 *
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
312 * @param gfile - the working GridFile
313 * @param size - the amount of bytes to be read
314 * @param buf - the buffer to read to
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
315 *
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
316 * @return - the number of bytes read
317 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
318 MONGO_EXPORT gridfs_offset gridfile_read( gridfile *gfile, gridfs_offset size, char *buf );
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
319
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
320 /**
321 * Updates the position in the file
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
322 * (If the offset goes beyond the contentlength,
323 * the position is updated to the end of the file.)
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
324 *
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
325 * @param gfile - the working GridFile
326 * @param offset - the position to update to
ea6daf7 @banker minor: ensure gridfs code conforms to driver style.
banker authored Aug 2, 2011
327 *
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
328 * @return - resulting offset location
329 */
e8c5570 @banker minor: fix some defines
banker authored Feb 14, 2012
330 MONGO_EXPORT gridfs_offset gridfile_seek( gridfile *gfile, gridfs_offset offset );
3c8ab65 Added gridfs_read and gridfs_seek
Christopher Triolo authored Jun 7, 2010
331
379db0b Added GridFS functionality to the c driver.
Christopher Triolo authored Jun 2, 2010
332 #endif
Something went wrong with that request. Please try again.