Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to create an FDB instance from config path via C-API (for pyfdb) #20

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/fdb5/api/FDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
#include "fdb5/api/FDB.h"
#include "fdb5/api/FDBFactory.h"
#include "fdb5/api/helpers/FDBToolRequest.h"
#include "fdb5/config/Config.h"
#include "fdb5/database/Key.h"
#include "fdb5/io/HandleGatherer.h"
#include "fdb5/message/MessageDecoder.h"


namespace fdb5 {

//----------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/fdb5/api/fdb_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ int fdb_new_handle(fdb_handle_t** fdb) {
});
}

int fdb_new_handle_from_config_path(fdb_handle_t** fdb, const char* path) {
return wrapApiFunction([fdb, path] {
*fdb = new fdb_handle_t(Config::make(path));
});
}

int fdb_archive(fdb_handle_t* fdb, fdb_key_t* key, const char* data, size_t length) {
return wrapApiFunction([fdb, key, data, length] {
ASSERT(fdb);
Expand Down
9 changes: 8 additions & 1 deletion src/fdb5/api/fdb_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int fdb_delete_datareader(fdb_datareader_t* dr);


/** \defgroup FDB API */
/** @{ */
/** @{*/

struct fdb_handle_t;
/** Opaque type for the FDB object. */
Expand All @@ -294,6 +294,13 @@ typedef struct fdb_handle_t fdb_handle_t;
* \returns Return code (#FdbErrorValues)
*/
int fdb_new_handle(fdb_handle_t** fdb);

/** Creates a FDB instance from a given path to an FDB (alternative to read FDB5_CONFIG_FILE).
* \param fdb FDB instance. Returned instance must be deleted using #fdb_delete_handle.
* \param path Path to an fdb config file
* \returns Return code (#FdbErrorValues)
*/
int fdb_new_handle_from_config_path(fdb_handle_t** fdb, const char* path);

/** Archives binary data to a FDB instance.
* \warning this is a low-level API. The provided key and the corresponding data are not checked for consistency
Expand Down
Loading