From fd841e416881cc0392e61ec312c1870f3a0004bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 2 Dec 2014 10:06:21 +0100 Subject: Initial import of libmongo-client version 0.1.8-2 --- src/sync-gridfs.h | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 src/sync-gridfs.h (limited to 'src/sync-gridfs.h') diff --git a/src/sync-gridfs.h b/src/sync-gridfs.h new file mode 100644 index 0000000..5d9ae1c --- /dev/null +++ b/src/sync-gridfs.h @@ -0,0 +1,193 @@ +/* sync-gridfs.h - libmong-client GridFS API + * Copyright 2011, 2012 Gergely Nagy + * + * 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. + */ + +/** @file src/sync-gridfs.h + * MongoDB GridFS API. + * + * @addtogroup mongo_sync + * @{ + */ + +#ifndef LIBMONGO_SYNC_GRIDFS_H +#define LIBMONGO_SYNC_GRIDFS_H 1 + +#include +#include +#include + +G_BEGIN_DECLS + +/** @defgroup mongo_sync_gridfs_api Mongo GridFS API + * + * The GridFS API - and related modules, like @ref + * mongo_sync_gridfs_chunk_api and @ref mongo_sync_gridfs_stream_api - + * provide a conveneint way to work with GridFS, and files stored on + * it. + * + * This module implements the GridFS support functions, which allow + * one to connect to or create new GridFS instances, list or remove + * files, or retrieve metadata about files opened by one of the + * sub-modules. + * + * @addtogroup mongo_sync_gridfs_api + * @{ + */ + +/** Opaque GridFS object. */ +typedef struct _mongo_sync_gridfs mongo_sync_gridfs; + +/** Create a new GridFS object. + * + * @param conn is the MongoDB connection to base the filesystem object + * on. + * @param ns_prefix is the prefix the GridFS collections should be + * under. + * + * @returns A newly allocated GridFS object, or NULL on error. + */ +mongo_sync_gridfs *mongo_sync_gridfs_new (mongo_sync_connection *conn, + const gchar *ns_prefix); + +/** Close and free a GridFS object. + * + * @param gfs is the GridFS object to free up. + * @param disconnect signals whether to free the underlying connection + * aswell. + */ +void mongo_sync_gridfs_free (mongo_sync_gridfs *gfs, gboolean disconnect); + +/** Get the default chunk size of a GridFS object. + * + * @param gfs is the GridFS object to get the default chunk size of. + * + * @returns The chunk size in bytes, or -1 on error. + */ +gint32 mongo_sync_gridfs_get_chunk_size (mongo_sync_gridfs *gfs); + +/** Set the default chunk size of a GridFS object. + * + * @param gfs is the GridFS object to set the default chunk size of. + * @param chunk_size is the desired default chunk size. + * + * @returns TRUE on success, FALSE otherwise. + */ +gboolean mongo_sync_gridfs_set_chunk_size (mongo_sync_gridfs *gfs, + gint32 chunk_size); + +/** List GridFS files matching a query. + * + * Finds all files on a GridFS, based on a custom query. + * + * @param gfs is the GridFS to list files from. + * @param query is the custom query based on which files shall be + * sought. Passing a NULL query will find all files, without + * restriction. + * + * @returns A newly allocated cursor object, or NULL on error. It is + * the responsibility of the caller to free the returned cursor once + * it is no longer needed. + */ +mongo_sync_cursor *mongo_sync_gridfs_list (mongo_sync_gridfs *gfs, + const bson *query); + +/** Delete files matching a query from GridFS. + * + * Finds all files on a GridFS, based on a custom query, and removes + * them. + * + * @param gfs is the GridFS to delete files from. + * @param query is the custom query based on which files shall be + * sought. Passing a NULL query will find all files, without + * restriction. + * + * @returns TRUE if all files were deleted successfully, FALSE + * otherwise. + */ +gboolean mongo_sync_gridfs_remove (mongo_sync_gridfs *gfs, + const bson *query); + +/* Metadata */ + +/** Get the file ID of a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The ObjectID of the file, or NULL on error. The returned + * pointer points to an internal area, and should not be modified or + * freed, and is only valid as long as the file object is valid. + */ +const guint8 *mongo_sync_gridfs_file_get_id (gpointer gfile); + +/** Get the length of a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The length of the file, or -1 on error. + */ +gint64 mongo_sync_gridfs_file_get_length (gpointer gfile); + +/** Get the chunk size of a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The maximum size of the chunks of the file, or -1 on error. + */ +gint32 mongo_sync_gridfs_file_get_chunk_size (gpointer gfile); + +/** Get the MD5 digest of a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The MD5 digest of the file, or NULL on error. The returned + * pointer points to an internal area, and should not be modified or + * freed, and is only valid as long as the file object is valid. + */ +const gchar *mongo_sync_gridfs_file_get_md5 (gpointer gfile); + +/** Get the upload date of a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The upload date of the file, or -1 on error. + */ +gint64 mongo_sync_gridfs_file_get_date (gpointer gfile); + +/** Get the full metadata of a GridFS file + * + * @param gfile is the GridFS file to work with. + * + * @returns A BSON object containing the full metadata, or NULL on + * error. The returned pointer points to an internal area, and should + * not be modified or freed, and is only valid as long as the file + * object is valid. + */ +const bson *mongo_sync_gridfs_file_get_metadata (gpointer gfile); + +/** Get the number of chunks in a GridFS file. + * + * @param gfile is the GridFS file to work with. + * + * @returns The number of chunks in the GridFS file, or -1 on error. + */ +gint64 mongo_sync_gridfs_file_get_chunks (gpointer gfile); + +/** @} */ + +G_END_DECLS + +/** @} */ + +#endif -- cgit v1.2.3