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
1 file
+ 3
2
Compare changes
  • Side-by-side
  • Inline
+ 607
14
/*
* This file is a part of the CaosDB Project.
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2021 Florian Spreckelsen <f.spreckelsen@indiscale.com>
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*
*/
#include "ccaosdb.h"
#include "caosdb/connection.h"
#include "caosdb/constants.h"
@@ -5,10 +26,12 @@
#include "caosdb/status_code.h"
#include "caosdb/logging.h"
#include <cassert>
#include <cstring>
#include <exception>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
extern "C" {
@@ -20,6 +43,7 @@ extern "C" {
*/
#define ERROR_RETURN_CODE(code, fun, body) \
fun { \
CAOSDB_LOG_TRACE(CCAOSDB_LOGGER_NAME) << "Enter " << #fun; \
try { \
body \
} catch (const std::exception &exc) { \
@@ -28,6 +52,90 @@ extern "C" {
} \
}
/**
* Macro for entity getters
*/
#define CAOSDB_ENTITY_GET(element, body_part) \
Please register or sign in to reply
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, \
char *out), \
{ \
auto *wrapped_entity = \
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); \
body_part return 0; \
})
/**
* Macro for entity setters
*/
#define CAOSDB_ENTITY_SET(element, value, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_entity_set_##element(caosdb_entity_entity *entity, \
const char *value), \
{ \
auto *wrapped_entity = \
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); \
body_part return 0; \
})
/**
* Macro for property getters
*/
#define CAOSDB_PROPERTY_GET(element, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_property_get_##element(caosdb_entity_property *property, \
char *out), \
{ \
auto *wrapped_property = \
static_cast<caosdb::entity::Property *>(property->wrapped_property); \
body_part return 0; \
})
/**
* Macro for property setters
*/
#define CAOSDB_PROPERTY_SET(element, value, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_property_set_##element(caosdb_entity_property *property, \
const char *value), \
{ \
auto *wrapped_property = \
static_cast<caosdb::entity::Property *>(property->wrapped_property); \
body_part return 0; \
})
/**
* Macro for parent getters
*/
#define CAOSDB_PARENT_GET(element, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_parent_get_##element(caosdb_entity_parent *parent, \
char *out), \
{ \
auto *wrapped_parent = \
static_cast<caosdb::entity::Parent *>(parent->wrapped_parent); \
body_part return 0; \
})
/**
* Macro for parent setters
*/
#define CAOSDB_PARENT_SET(element, value, body_part) \
ERROR_RETURN_CODE( \
GENERIC_ERROR, \
int caosdb_entity_parent_set_##element(caosdb_entity_parent *parent, \
const char *value), \
{ \
auto *wrapped_parent = \
static_cast<caosdb::entity::Parent *>(parent->wrapped_parent); \
body_part return 0; \
})
int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() {
return caosdb::LIBCAOSDB_VERSION_MAJOR;
}
@@ -56,6 +164,10 @@ const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE() {
return caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE;
}
int caosdb_status_code_OTHER_CLIENT_ERROR() {
return caosdb::StatusCode::OTHER_CLIENT_ERROR;
}
const char *caosdb_utility_get_env_var(const char *name, const char *fallback) {
return caosdb::utility::get_env_var(name, fallback);
}
@@ -69,9 +181,13 @@ 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));
out->_deletable = true;
return 0;
})
@@ -80,8 +196,11 @@ ERROR_RETURN_CODE(
int caosdb_connection_delete_certificate_provider(
caosdb_connection_certificate_provider *provider),
{
delete static_cast<caosdb::configuration::CertificateProvider *>(
provider->wrapped_certificate_provider);
if (provider->_deletable) {
delete static_cast<caosdb::configuration::CertificateProvider *>(
provider->wrapped_certificate_provider);
}
provider->_deletable = false;
return 0;
})
@@ -90,20 +209,28 @@ 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));
out->_deletable = true;
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_authentication_delete_authenticator(
caosdb_authentication_authenticator *authenticator),
{
delete static_cast<caosdb::authentication::Authenticator *>(
authenticator->wrapped_authenticator);
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_authentication_delete_authenticator(
caosdb_authentication_authenticator *authenticator),
{
if (authenticator->_deletable) {
delete static_cast<caosdb::authentication::Authenticator *>(
authenticator->wrapped_authenticator);
}
authenticator->_deletable = false;
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
@@ -112,6 +239,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 =
@@ -141,6 +271,7 @@ ERROR_RETURN_CODE(
out->wrapped_connection_configuration =
new caosdb::configuration::TlsConnectionConfiguration(host_str, port);
}
out->_deletable = true;
return 0;
})
@@ -150,8 +281,12 @@ 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;
return 0;
})
@@ -160,8 +295,11 @@ ERROR_RETURN_CODE(
int caosdb_connection_delete_connection_configuration(
caosdb_connection_connection_configuration *configuration),
{
delete static_cast<caosdb::configuration::ConnectionConfiguration *>(
configuration->wrapped_connection_configuration);
if (configuration->_deletable) {
delete static_cast<caosdb::configuration::ConnectionConfiguration *>(
configuration->wrapped_connection_configuration);
}
configuration->_deletable = false;
return 0;
})
@@ -171,10 +309,14 @@ 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);
out->wrapped_connection = new caosdb::connection::Connection(*config);
out->_deletable = true;
return 0;
})
@@ -182,8 +324,11 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_connection_delete_connection(
caosdb_connection_connection *connection),
{
delete static_cast<caosdb::connection::Connection *>(
connection->wrapped_connection);
if (connection->_deletable) {
delete static_cast<caosdb::connection::Connection *>(
connection->wrapped_connection);
}
connection->_deletable = false;
return 0;
})
@@ -226,8 +371,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;
})
@@ -235,10 +384,454 @@ 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;
return 0;
})
/****************************************************************************
* ENTITY STUFF AND TRANSACTIONS
****************************************************************************/
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_connection_connection_create_transaction(
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);
out->wrapped_transaction =
wrapped_connection->CreateTransaction().release();
out->_deletable = true;
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_delete_transaction(
caosdb_transaction_transaction *transaction),
{
if (transaction->_deletable) {
delete static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
}
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_retrieve_by_id(
caosdb_transaction_transaction *transaction,
const char *id),
{
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
return wrapped_transaction->RetrieveById(std::string(id));
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_retrieve_by_ids(
caosdb_transaction_transaction *transaction,
const char *ids[], int length),
{
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
return wrapped_transaction->RetrieveById(ids, ids + length);
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_query(
caosdb_transaction_transaction *transaction,
const char *query),
{
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
return wrapped_transaction->Query(std::string(query));
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_execute(
caosdb_transaction_transaction *transaction),
{
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
wrapped_transaction->ExecuteAsynchronously();
auto status = wrapped_transaction->WaitForIt();
return status.GetCode();
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_get_result_set(
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;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_transaction_get_count_result(
caosdb_transaction_transaction *transaction, long *out),
{
auto *wrapped_transaction =
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
long cr(wrapped_transaction->GetCountResult());
*out = cr;
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_result_set_at(
caosdb_transaction_result_set *result_set,
caosdb_entity_entity *entity, int index),
{
auto *wrapped_result_set =
static_cast<caosdb::transaction::MultiResultSet *>(
result_set->wrapped_result_set);
entity->wrapped_entity =
wrapped_result_set->mutable_at(index);
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_transaction_result_set_size(
caosdb_transaction_result_set *result_set, int *out),
{
auto *wrapped_result_set =
static_cast<caosdb::transaction::MultiResultSet *>(
result_set->wrapped_result_set);
int size(wrapped_result_set->size());
*out = size;
return 0;
})
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;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_delete_entity(caosdb_entity_entity *out), {
if (out->_deletable) {
delete static_cast<caosdb::entity::Entity *>(
out->wrapped_entity);
}
out->_deletable = false;
return 0;
})
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;
})
ERROR_RETURN_CODE(
GENERIC_ERROR, int caosdb_entity_delete_property(caosdb_entity_property *out),
{
if (out->_deletable) {
delete static_cast<caosdb::entity::Property *>(out->wrapped_property);
}
out->_deletable = false;
return 0;
})
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;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_delete_parent(caosdb_entity_parent *out), {
if (out->_deletable) {
delete static_cast<caosdb::entity::Parent *>(
out->wrapped_parent);
}
out->_deletable = false;
return 0;
})
CAOSDB_ENTITY_GET(id, strcpy(out, wrapped_entity->GetId().c_str());)
CAOSDB_ENTITY_GET(role, strcpy(out, wrapped_entity->GetRole().c_str());)
CAOSDB_ENTITY_GET(name, strcpy(out, wrapped_entity->GetName().c_str());)
CAOSDB_ENTITY_GET(description,
strcpy(out, wrapped_entity->GetDescription().c_str());)
CAOSDB_ENTITY_GET(datatype, strcpy(out, wrapped_entity->GetDatatype().c_str());)
CAOSDB_ENTITY_GET(value, strcpy(out, wrapped_entity->GetValue().c_str());)
CAOSDB_ENTITY_GET(unit, strcpy(out, wrapped_entity->GetUnit().c_str());)
CAOSDB_ENTITY_GET(version_id,
strcpy(out, wrapped_entity->GetVersionId().c_str());)
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_get_errors_size(caosdb_entity_entity *entity,
int *out),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
*out = wrapped_entity->GetErrors().size();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
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);
out->_deletable = false;
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_get_warnings_size(caosdb_entity_entity *entity,
int *out),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
*out = wrapped_entity->GetWarnings().size();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
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);
out->_deletable = false;
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_get_infos_size(caosdb_entity_entity *entity,
int *out),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
*out = wrapped_entity->GetInfos().size();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
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);
out->_deletable = false;
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_get_properties_size(caosdb_entity_entity *entity,
int *out),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
*out = wrapped_entity->GetProperties().size();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
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);
out->_deletable = false;
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_get_parents_size(caosdb_entity_entity *entity,
int *out),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
*out = wrapped_entity->GetParents().size();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
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);
out->_deletable = false;
return 0;
})
CAOSDB_PARENT_GET(id, strcpy(out, wrapped_parent->GetId().c_str());)
CAOSDB_PARENT_GET(name, strcpy(out, wrapped_parent->GetName().c_str());)
CAOSDB_PARENT_GET(description,
strcpy(out, wrapped_parent->GetDescription().c_str());)
CAOSDB_PROPERTY_GET(id, strcpy(out, wrapped_property->GetId().c_str());)
CAOSDB_PROPERTY_GET(name, strcpy(out, wrapped_property->GetName().c_str());)
CAOSDB_PROPERTY_GET(description,
strcpy(out, wrapped_property->GetDescription().c_str());)
CAOSDB_PROPERTY_GET(importance,
strcpy(out, wrapped_property->GetImportance().c_str());)
CAOSDB_PROPERTY_GET(datatype,
strcpy(out, wrapped_property->GetDatatype().c_str());)
CAOSDB_PROPERTY_GET(unit, strcpy(out, wrapped_property->GetUnit().c_str());)
CAOSDB_PROPERTY_GET(value, strcpy(out, wrapped_property->GetValue().c_str());)
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_message_get_code(caosdb_entity_message *message, int *out),
{
auto *wrapped_message =
static_cast<caosdb::entity::Message *>(message->wrapped_message);
*out = wrapped_message->GetCode();
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_message_get_description(caosdb_entity_message *message,
char *out),
{
auto *wrapped_message =
static_cast<caosdb::entity::Message *>(message->wrapped_message);
strcpy(out, wrapped_message->GetDescription().c_str());
return 0;
})
CAOSDB_ENTITY_SET(role, role, wrapped_entity->SetRole(std::string(role));)
CAOSDB_ENTITY_SET(name, name, wrapped_entity->SetName(std::string(name));)
CAOSDB_ENTITY_SET(description, description,
wrapped_entity->SetDescription(std::string(description));)
CAOSDB_ENTITY_SET(datatype, datatype,
wrapped_entity->SetDatatype(std::string(datatype));)
CAOSDB_ENTITY_SET(unit, unit, wrapped_entity->SetUnit(std::string(unit));)
CAOSDB_ENTITY_SET(value, value, wrapped_entity->SetValue(std::string(value));)
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_append_parent(caosdb_entity_entity *entity,
caosdb_entity_parent *parent),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
auto *wrapped_parent =
static_cast<caosdb::entity::Parent *>(parent->wrapped_parent);
wrapped_entity->AppendParent(*wrapped_parent);
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_remove_parent(caosdb_entity_entity *entity,
int index),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
wrapped_entity->RemoveParent(index);
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_append_property(caosdb_entity_entity *entity,
caosdb_entity_property *property),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
auto *wrapped_property =
static_cast<caosdb::entity::Property *>(property->wrapped_property);
wrapped_entity->AppendProperty(*wrapped_property);
return 0;
})
ERROR_RETURN_CODE(
GENERIC_ERROR,
int caosdb_entity_entity_remove_property(caosdb_entity_entity *entity,
int index),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
wrapped_entity->RemoveProperty(index);
return 0;
})
CAOSDB_PARENT_SET(id, id, wrapped_parent->SetId(std::string(id));)
CAOSDB_PARENT_SET(name, name, wrapped_parent->SetName(std::string(name));)
CAOSDB_PROPERTY_SET(name, name, wrapped_property->SetName(std::string(name));)
CAOSDB_PROPERTY_SET(id, id, wrapped_property->SetId(std::string(id));)
CAOSDB_PROPERTY_SET(datatype, datatype,
wrapped_property->SetDatatype(std::string(datatype));)
CAOSDB_PROPERTY_SET(importance, importance,
wrapped_property->SetImportance(std::string(importance));)
CAOSDB_PROPERTY_SET(unit, unit, wrapped_property->SetUnit(std::string(unit));)
CAOSDB_PROPERTY_SET(value, value,
wrapped_property->SetValue(std::string(value));)
}
Loading