Skip to content
Snippets Groups Projects

ENH: Add retrieval and queries to Extern C interface

Merged Florian Spreckelsen requested to merge f-extended-c into f-files
2 unresolved threads
2 files
+ 66
3
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 56
3
@@ -177,6 +177,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
caosdb_connection_certificate_provider *out,
const char *path),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_certificate_provider =
new caosdb::configuration::PemFileCertificateProvider(
std::string(path));
@@ -202,6 +205,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
caosdb_authentication_authenticator *out,
const char *username, const char *password),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_authenticator =
new caosdb::authentication::PlainPasswordAuthenticator(
std::string(username), std::string(password));
@@ -229,6 +235,9 @@ ERROR_RETURN_CODE(
const int port, caosdb_authentication_authenticator *authenticator,
caosdb_connection_certificate_provider *provider),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto host_str = std::string(host);
if (authenticator != nullptr && provider != nullptr) {
auto wrapped_provider =
@@ -268,6 +277,9 @@ ERROR_RETURN_CODE(
caosdb_connection_connection_configuration *out, const char *host,
const int port),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_connection_configuration =
new caosdb::configuration::InsecureConnectionConfiguration(host, port);
out->_deletable = true;
@@ -293,6 +305,9 @@ ERROR_RETURN_CODE(
caosdb_connection_connection *out,
const caosdb_connection_connection_configuration *configuration),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
caosdb::configuration::ConnectionConfiguration *config =
static_cast<caosdb::configuration::ConnectionConfiguration *>(
configuration->wrapped_connection_configuration);
@@ -352,8 +367,12 @@ ERROR_RETURN_CODE(
int caosdb_connection_connection_manager_get_default_connection(
caosdb_connection_connection *out),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_connection =
caosdb::connection::ConnectionManager::GetDefaultConnection().get();
out->_deletable = false;
return 0;
})
@@ -361,13 +380,16 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_connection_connection_manager_get_connection(
caosdb_connection_connection *out, const char *name),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_connection =
caosdb::connection::ConnectionManager::GetConnection(
std::string(name))
.get();
// managed by the connection manager now, so not
// to be deleted manually
out->_deletable = false;
// managed by the connection manager now, so not
// to be deleted manually
out->_deletable = false;
return 0;
})
@@ -379,6 +401,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
caosdb_connection_connection *connection,
caosdb_transaction_transaction *out),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_connection =
static_cast<caosdb::connection::Connection *>(
connection->wrapped_connection);
@@ -449,11 +474,15 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
caosdb_transaction_transaction *transaction,
caosdb_transaction_result_set *out),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
out->wrapped_result_set =
(void *)(&(wrapped_transaction->GetResultSet()));
out->_deletable = false;
return 0;
})
@@ -499,6 +528,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_entity(caosdb_entity_entity *out), {
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_entity = new caosdb::entity::Entity();
out->_deletable = true;
return 0;
@@ -517,6 +549,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
ERROR_RETURN_CODE(
GENERIC_ERROR, int caosdb_entity_create_property(caosdb_entity_property *out),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_property = new caosdb::entity::Property();
out->_deletable = true;
return 0;
@@ -534,6 +569,9 @@ ERROR_RETURN_CODE(
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_parent(caosdb_entity_parent *out), {
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
out->wrapped_parent = new caosdb::entity::Parent();
out->_deletable = true;
return 0;
@@ -576,6 +614,9 @@ ERROR_RETURN_CODE(
int caosdb_entity_entity_get_error(caosdb_entity_entity *entity,
caosdb_entity_message *out, int index),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
out->wrapped_message = wrapped_entity->GetErrors().mutable_at(index);
@@ -599,6 +640,9 @@ ERROR_RETURN_CODE(
int caosdb_entity_entity_get_warning(caosdb_entity_entity *entity,
caosdb_entity_message *out, int index),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
out->wrapped_message = wrapped_entity->GetWarnings().mutable_at(index);
@@ -622,6 +666,9 @@ ERROR_RETURN_CODE(
int caosdb_entity_entity_get_info(caosdb_entity_entity *entity,
caosdb_entity_message *out, int index),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
out->wrapped_message = wrapped_entity->GetInfos().mutable_at(index);
@@ -645,6 +692,9 @@ ERROR_RETURN_CODE(
int caosdb_entity_entity_get_property(caosdb_entity_entity *entity,
caosdb_entity_property *out, int index),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
out->wrapped_property = wrapped_entity->GetProperties().mutable_at(index);
@@ -668,6 +718,9 @@ ERROR_RETURN_CODE(
int caosdb_entity_entity_get_parent(caosdb_entity_entity *entity,
caosdb_entity_parent *out, int index),
{
if (out->_deletable) {
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR;
}
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
out->wrapped_parent = wrapped_entity->GetParents().mutable_at(index);
Loading