diff --git a/include/ccaosdb.h b/include/ccaosdb.h index 70a12840b4139ff3795af45ee337e85be02ce826..fdda0b1de407569195f9c794f40c31620248975e 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -137,8 +137,7 @@ int caosdb_connection_create_pem_file_certificate_provider( * * EXPERT USE ONLY. Only use it when you know what you are doing. */ -int caosdb_connection_delete_certificate_provider( - caosdb_connection_certificate_provider *provider); +int caosdb_connection_delete_certificate_provider(caosdb_connection_certificate_provider *provider); /** * Create a tls-secured connection configuration. @@ -153,8 +152,8 @@ int caosdb_connection_delete_certificate_provider( * Only use it when you know what you are doing. */ int caosdb_connection_create_tls_connection_configuration( - caosdb_connection_connection_configuration *out, const char *host, - const int port, caosdb_authentication_authenticator *authenticator, + caosdb_connection_connection_configuration *out, const char *host, const int port, + caosdb_authentication_authenticator *authenticator, caosdb_connection_certificate_provider *provider); /** @@ -173,8 +172,7 @@ int caosdb_connection_create_tls_connection_configuration( * Only use it when you know what you are doing. */ int caosdb_connection_create_insecure_connection_configuration( - caosdb_connection_connection_configuration *out, const char *host, - const int port); + caosdb_connection_connection_configuration *out, const char *host, const int port); /** * Destructor function for the caosdb_connection_connection_configuration @@ -192,8 +190,7 @@ int caosdb_connection_delete_connection_configuration( * @param cacert path to a pem-file. */ int caosdb_connection_configuration_add_cacert( - caosdb_connection_connection_configuration *configuration, - const char *cacert); + caosdb_connection_connection_configuration *configuration, const char *cacert); /** * Create a plain password authenticator. @@ -206,16 +203,14 @@ int caosdb_connection_configuration_add_cacert( * Only use it when you know what you are doing. */ int caosdb_authentication_create_plain_password_authenticator( - caosdb_authentication_authenticator *out, const char *username, - const char *password); + caosdb_authentication_authenticator *out, const char *username, const char *password); /** * Destructor function for the caosdb_authentication_authenticator struct. * * EXPERT USE ONLY. Only use it when you know what you are doing. */ -int caosdb_authentication_delete_authenticator( - caosdb_authentication_authenticator *authenticator); +int caosdb_authentication_delete_authenticator(caosdb_authentication_authenticator *authenticator); /** * Create a connection instance. @@ -239,31 +234,28 @@ int caosdb_connection_create_connection( * * EXPERT USE ONLY. Only use it when you know what you are doing. */ -int caosdb_connection_delete_connection( - caosdb_connection_connection *connection); +int caosdb_connection_delete_connection(caosdb_connection_connection *connection); /** * Request the version of the server. */ -int caosdb_connection_get_version_info( - caosdb_info_version_info *out, - const caosdb_connection_connection *connection); +int caosdb_connection_get_version_info(caosdb_info_version_info *out, + const caosdb_connection_connection *connection); /** * Get the default connection from the ConnectionManager. * * The default connection is to be specified in a configuration file. */ -int caosdb_connection_connection_manager_get_default_connection( - caosdb_connection_connection *out); +int caosdb_connection_connection_manager_get_default_connection(caosdb_connection_connection *out); /** * Get a named connection from the ConnectionManager. * * The named connection is to be specified in a configuration file. */ -int caosdb_connection_connection_manager_get_connection( - caosdb_connection_connection *out, const char *name); +int caosdb_connection_connection_manager_get_connection(caosdb_connection_connection *out, + const char *name); /**************************************************************************** * ENTITY STUFF AND TRANSACTIONS @@ -282,19 +274,16 @@ typedef struct { * This transaction has to be deleted manually by * caosdb_transaction_delete_transaction() later on. */ -int caosdb_connection_connection_create_transaction( - caosdb_connection_connection *connection, - caosdb_transaction_transaction *out); -int caosdb_transaction_delete_transaction( - caosdb_transaction_transaction *transaction); -int caosdb_transaction_transaction_retrieve_by_id( - caosdb_transaction_transaction *transaction, const char *id); -int caosdb_transaction_transaction_retrieve_by_ids( - caosdb_transaction_transaction *transaction, const char *ids[], int length); -int caosdb_transaction_transaction_query( - caosdb_transaction_transaction *transaction, const char *query); -int caosdb_transaction_transaction_execute( - caosdb_transaction_transaction *transaction); +int caosdb_connection_connection_create_transaction(caosdb_connection_connection *connection, + caosdb_transaction_transaction *out); +int caosdb_transaction_delete_transaction(caosdb_transaction_transaction *transaction); +int caosdb_transaction_transaction_retrieve_by_id(caosdb_transaction_transaction *transaction, + const char *id); +int caosdb_transaction_transaction_retrieve_by_ids(caosdb_transaction_transaction *transaction, + const char *ids[], int length); +int caosdb_transaction_transaction_query(caosdb_transaction_transaction *transaction, + const char *query); +int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *transaction); // TODO(fspreck) execute_asynchronously may be added as a separate // function once we actually support asynchronous execution. @@ -303,12 +292,11 @@ typedef struct { bool _deletable = false; } caosdb_transaction_result_set; -int caosdb_transaction_transaction_get_result_set( - caosdb_transaction_transaction *transaction, - caosdb_transaction_result_set *out); +int caosdb_transaction_transaction_get_result_set(caosdb_transaction_transaction *transaction, + caosdb_transaction_result_set *out); -int caosdb_transaction_transaction_get_count_result( - caosdb_transaction_transaction *transaction, long *out); +int caosdb_transaction_transaction_get_count_result(caosdb_transaction_transaction *transaction, + long *out); typedef struct { void *wrapped_entity; @@ -317,8 +305,7 @@ typedef struct { int caosdb_transaction_result_set_at(caosdb_transaction_result_set *result_set, caosdb_entity_entity *entity, int index); -int caosdb_transaction_result_set_size( - caosdb_transaction_result_set *result_set, int *out); +int caosdb_transaction_result_set_size(caosdb_transaction_result_set *result_set, int *out); typedef struct { void *wrapped_property; @@ -337,90 +324,60 @@ typedef struct { int caosdb_entity_entity_get_id(caosdb_entity_entity *entity, char **out); int caosdb_entity_entity_get_role(caosdb_entity_entity *entity, char **out); int caosdb_entity_entity_get_name(caosdb_entity_entity *entity, char **out); -int caosdb_entity_entity_get_description(caosdb_entity_entity *entity, - char **out); +int caosdb_entity_entity_get_description(caosdb_entity_entity *entity, char **out); int caosdb_entity_entity_get_datatype(caosdb_entity_entity *entity, char **out); int caosdb_entity_entity_get_unit(caosdb_entity_entity *entity, char **out); int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, long *out); -int caosdb_entity_entity_get_double_value(caosdb_entity_entity *entity, - double *out); -int caosdb_entity_entity_get_boolean_value(caosdb_entity_entity *entity, - bool *out); -int caosdb_entity_entity_get_string_value(caosdb_entity_entity *entity, - char **out); -int caosdb_entity_entity_get_int_list_value(caosdb_entity_entity *entity, - long *out); -int caosdb_entity_entity_get_double_list_value(caosdb_entity_entity *entity, - double *out); -int caosdb_entity_entity_get_boolean_list_value(caosdb_entity_entity *entity, - bool *out); -int caosdb_entity_entity_get_string_list_value(caosdb_entity_entity *entity, - char **out); -int caosdb_entity_entity_get_value_list_length(caosdb_entity_entity *entity, - int *out); - -int caosdb_entity_entity_get_version_id(caosdb_entity_entity *entity, - char **out); -int caosdb_entity_entity_get_errors_size(caosdb_entity_entity *entity, - int *out); -int caosdb_entity_entity_get_error(caosdb_entity_entity *entity, - caosdb_entity_message *out, int index); -int caosdb_entity_entity_get_warnings_size(caosdb_entity_entity *entity, - int *out); -int caosdb_entity_entity_get_warning(caosdb_entity_entity *entity, - caosdb_entity_message *out, int index); +int caosdb_entity_entity_get_double_value(caosdb_entity_entity *entity, double *out); +int caosdb_entity_entity_get_boolean_value(caosdb_entity_entity *entity, bool *out); +int caosdb_entity_entity_get_string_value(caosdb_entity_entity *entity, char **out); +int caosdb_entity_entity_get_int_list_value(caosdb_entity_entity *entity, long *out); +int caosdb_entity_entity_get_double_list_value(caosdb_entity_entity *entity, double *out); +int caosdb_entity_entity_get_boolean_list_value(caosdb_entity_entity *entity, bool *out); +int caosdb_entity_entity_get_string_list_value(caosdb_entity_entity *entity, char **out); +int caosdb_entity_entity_get_value_list_length(caosdb_entity_entity *entity, int *out); + +int caosdb_entity_entity_get_version_id(caosdb_entity_entity *entity, char **out); +int caosdb_entity_entity_get_errors_size(caosdb_entity_entity *entity, int *out); +int caosdb_entity_entity_get_error(caosdb_entity_entity *entity, caosdb_entity_message *out, + int index); +int caosdb_entity_entity_get_warnings_size(caosdb_entity_entity *entity, int *out); +int caosdb_entity_entity_get_warning(caosdb_entity_entity *entity, caosdb_entity_message *out, + int index); int caosdb_entity_entity_get_infos_size(caosdb_entity_entity *entity, int *out); -int caosdb_entity_entity_get_info(caosdb_entity_entity *entity, - caosdb_entity_message *out, int index); -int caosdb_entity_entity_get_properties_size(caosdb_entity_entity *entity, - int *out); -int caosdb_entity_entity_get_property(caosdb_entity_entity *entity, - caosdb_entity_property *out, int index); -int caosdb_entity_entity_get_parents_size(caosdb_entity_entity *entity, - int *out); -int caosdb_entity_entity_get_parent(caosdb_entity_entity *entity, - caosdb_entity_parent *out, int index); +int caosdb_entity_entity_get_info(caosdb_entity_entity *entity, caosdb_entity_message *out, + int index); +int caosdb_entity_entity_get_properties_size(caosdb_entity_entity *entity, int *out); +int caosdb_entity_entity_get_property(caosdb_entity_entity *entity, caosdb_entity_property *out, + int index); +int caosdb_entity_entity_get_parents_size(caosdb_entity_entity *entity, int *out); +int caosdb_entity_entity_get_parent(caosdb_entity_entity *entity, caosdb_entity_parent *out, + int index); int caosdb_entity_property_get_id(caosdb_entity_property *property, char **out); -int caosdb_entity_property_get_name(caosdb_entity_property *property, - char **out); -int caosdb_entity_property_get_description(caosdb_entity_property *property, - char **out); -int caosdb_entity_property_get_importance(caosdb_entity_property *property, - char **out); -int caosdb_entity_property_get_datatype(caosdb_entity_property *property, - char **out); -int caosdb_entity_property_get_unit(caosdb_entity_property *property, - char **out); - -int caosdb_entity_property_get_int_value(caosdb_entity_property *property, - long *out); -int caosdb_entity_property_get_double_value(caosdb_entity_property *property, - double *out); -int caosdb_entity_property_get_boolean_value(caosdb_entity_property *property, - bool *out); -int caosdb_entity_property_get_string_value(caosdb_entity_property *property, - char **out); -int caosdb_entity_property_get_int_list_value(caosdb_entity_property *property, - long **out); -int caosdb_entity_property_get_double_list_value( - caosdb_entity_property *property, double *out); -int caosdb_entity_property_get_boolean_list_value( - caosdb_entity_property *property, bool *out); -int caosdb_entity_property_get_string_list_value( - caosdb_entity_property *property, char ***out); -int caosdb_entity_property_get_value_list_length( - caosdb_entity_property *property, int *out); +int caosdb_entity_property_get_name(caosdb_entity_property *property, char **out); +int caosdb_entity_property_get_description(caosdb_entity_property *property, char **out); +int caosdb_entity_property_get_importance(caosdb_entity_property *property, char **out); +int caosdb_entity_property_get_datatype(caosdb_entity_property *property, char **out); +int caosdb_entity_property_get_unit(caosdb_entity_property *property, char **out); + +int caosdb_entity_property_get_int_value(caosdb_entity_property *property, long *out); +int caosdb_entity_property_get_double_value(caosdb_entity_property *property, double *out); +int caosdb_entity_property_get_boolean_value(caosdb_entity_property *property, bool *out); +int caosdb_entity_property_get_string_value(caosdb_entity_property *property, char **out); +int caosdb_entity_property_get_int_list_value(caosdb_entity_property *property, long **out); +int caosdb_entity_property_get_double_list_value(caosdb_entity_property *property, double *out); +int caosdb_entity_property_get_boolean_list_value(caosdb_entity_property *property, bool *out); +int caosdb_entity_property_get_string_list_value(caosdb_entity_property *property, char ***out); +int caosdb_entity_property_get_value_list_length(caosdb_entity_property *property, int *out); int caosdb_entity_parent_get_id(caosdb_entity_parent *parent, char **out); int caosdb_entity_parent_get_name(caosdb_entity_parent *parent, char **out); -int caosdb_entity_parent_get_description(caosdb_entity_parent *parent, - char **out); +int caosdb_entity_parent_get_description(caosdb_entity_parent *parent, char **out); int caosdb_entity_message_get_code(caosdb_entity_message *message, int *out); -int caosdb_entity_message_get_description(caosdb_entity_message *message, - char **out); +int caosdb_entity_message_get_description(caosdb_entity_message *message, char **out); // CONSTRUCTORS AND DESTRUCTORS int caosdb_entity_create_entity(caosdb_entity_entity *out); @@ -431,78 +388,52 @@ int caosdb_entity_create_parent(caosdb_entity_parent *out); int caosdb_entity_delete_parent(caosdb_entity_parent *out); // SETTERS FOR EVERYTHING THAT MAY BE SET -int caosdb_entity_entity_set_role(caosdb_entity_entity *entity, - const char *role); -int caosdb_entity_entity_set_name(caosdb_entity_entity *entity, - const char *name); -int caosdb_entity_entity_set_description(caosdb_entity_entity *entity, - const char *description); -int caosdb_entity_entity_set_datatype(caosdb_entity_entity *entity, - const char *datatype); -int caosdb_entity_entity_set_unit(caosdb_entity_entity *entity, - const char *unit); +int caosdb_entity_entity_set_role(caosdb_entity_entity *entity, const char *role); +int caosdb_entity_entity_set_name(caosdb_entity_entity *entity, const char *name); +int caosdb_entity_entity_set_description(caosdb_entity_entity *entity, const char *description); +int caosdb_entity_entity_set_datatype(caosdb_entity_entity *entity, const char *datatype); +int caosdb_entity_entity_set_unit(caosdb_entity_entity *entity, const char *unit); // TODO(fspreck) replace by more specific setters -int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, - const long value); -int caosdb_entity_entity_set_double_value(caosdb_entity_entity *entity, - const double value); -int caosdb_entity_entity_set_boolean_value(caosdb_entity_entity *entity, - const bool value); -int caosdb_entity_entity_set_string_value(caosdb_entity_entity *entity, - const char *value); -int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, - const long *value, +int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, const long value); +int caosdb_entity_entity_set_double_value(caosdb_entity_entity *entity, const double value); +int caosdb_entity_entity_set_boolean_value(caosdb_entity_entity *entity, const bool value); +int caosdb_entity_entity_set_string_value(caosdb_entity_entity *entity, const char *value); +int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, const long *value, const int length); -int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, - const double *value, +int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, const double *value, const int length); -int caosdb_entity_entity_set_boolean_list_value(caosdb_entity_entity *entity, - const bool *value, +int caosdb_entity_entity_set_boolean_list_value(caosdb_entity_entity *entity, const bool *value, const int length); -int caosdb_entity_entity_set_string_list_value(caosdb_entity_entity *entity, - const char **value, +int caosdb_entity_entity_set_string_list_value(caosdb_entity_entity *entity, const char **value, const int length); -int caosdb_entity_entity_append_parent(caosdb_entity_entity *entity, - caosdb_entity_parent *parent); +int caosdb_entity_entity_append_parent(caosdb_entity_entity *entity, caosdb_entity_parent *parent); int caosdb_entity_entity_remove_parent(caosdb_entity_entity *entity, int index); int caosdb_entity_entity_append_property(caosdb_entity_entity *entity, caosdb_entity_property *property); -int caosdb_entity_entity_remove_property(caosdb_entity_entity *entity, - int index); - -int caosdb_entity_property_set_id(caosdb_entity_property *property, - const char *id); -int caosdb_entity_property_set_name(caosdb_entity_property *property, - const char *name); -int caosdb_entity_property_set_datatype(caosdb_entity_property *property, - const char *datatype); -int caosdb_entity_property_set_importance(caosdb_entity_property *property, - const char *importance); -int caosdb_entity_property_set_unit(caosdb_entity_property *property, - const char *unit); - -int caosdb_entity_property_set_int_value(caosdb_entity_property *property, - const long value); -int caosdb_entity_property_set_double_value(caosdb_entity_property *property, - const double value); -int caosdb_entity_property_set_boolean_value(caosdb_entity_property *property, - const bool value); -int caosdb_entity_property_set_string_value(caosdb_entity_property *property, - const char *value); -int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, - const long *value, +int caosdb_entity_entity_remove_property(caosdb_entity_entity *entity, int index); + +int caosdb_entity_property_set_id(caosdb_entity_property *property, const char *id); +int caosdb_entity_property_set_name(caosdb_entity_property *property, const char *name); +int caosdb_entity_property_set_datatype(caosdb_entity_property *property, const char *datatype); +int caosdb_entity_property_set_importance(caosdb_entity_property *property, const char *importance); +int caosdb_entity_property_set_unit(caosdb_entity_property *property, const char *unit); + +int caosdb_entity_property_set_int_value(caosdb_entity_property *property, const long value); +int caosdb_entity_property_set_double_value(caosdb_entity_property *property, const double value); +int caosdb_entity_property_set_boolean_value(caosdb_entity_property *property, const bool value); +int caosdb_entity_property_set_string_value(caosdb_entity_property *property, const char *value); +int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, const long *value, const int length); -int caosdb_entity_property_set_double_list_value( - caosdb_entity_property *property, const double *value, const int length); -int caosdb_entity_property_set_boolean_list_value( - caosdb_entity_property *property, const bool *value, const int length); -int caosdb_entity_property_set_string_list_value( - caosdb_entity_property *property, const char **value, const int length); +int caosdb_entity_property_set_double_list_value(caosdb_entity_property *property, + const double *value, const int length); +int caosdb_entity_property_set_boolean_list_value(caosdb_entity_property *property, + const bool *value, const int length); +int caosdb_entity_property_set_string_list_value(caosdb_entity_property *property, + const char **value, const int length); int caosdb_entity_parent_set_id(caosdb_entity_parent *parent, const char *id); -int caosdb_entity_parent_set_name(caosdb_entity_parent *parent, - const char *name); +int caosdb_entity_parent_set_name(caosdb_entity_parent *parent, const char *name); #ifdef __cplusplus } diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index 1443141ae0f0705debd359c74898170268ae8f84..9d08cc0bdc1261c66cd4c7175230195bbd2a9eca 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -38,135 +38,113 @@ extern "C" { #define CCAOSDB_LOGGER_NAME "ccaosdb" -#define WRAPPED_ENTITY_CAST(name) \ - static_cast<caosdb::entity::Entity *>(name->wrapped_entity) +#define WRAPPED_ENTITY_CAST(name) static_cast<caosdb::entity::Entity *>(name->wrapped_entity) -#define WRAPPED_PROPERTY_CAST(name) \ - static_cast<caosdb::entity::Property *>(name->wrapped_property) +#define WRAPPED_PROPERTY_CAST(name) static_cast<caosdb::entity::Property *>(name->wrapped_property) -#define WRAPPED_PARENT_CAST(name) \ - static_cast<caosdb::entity::Parent *>(name->wrapped_parent) +#define WRAPPED_PARENT_CAST(name) static_cast<caosdb::entity::Parent *>(name->wrapped_parent) -#define WRAPPED_MESSAGE_CAST(name) \ - static_cast<caosdb::entity::Message *>(name->wrapped_message) +#define WRAPPED_MESSAGE_CAST(name) static_cast<caosdb::entity::Message *>(name->wrapped_message) /* * Macro for wrapping every function into a try-catch clause. If an exception * occurs, the given StatusCode is being returned. */ -#define ERROR_RETURN_CODE(code, fun, body) \ - fun { \ - CAOSDB_LOG_TRACE(CCAOSDB_LOGGER_NAME) << "Enter " << #fun; \ - try { \ - body \ - } catch (const std::exception &exc) { \ - caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what()); \ - return caosdb::StatusCode::code; \ - } \ +#define ERROR_RETURN_CODE(code, fun, body) \ + fun { \ + CAOSDB_LOG_TRACE(CCAOSDB_LOGGER_NAME) << "Enter " << #fun; \ + try { \ + body \ + } catch (const std::exception &exc) { \ + caosdb::logging::caosdb_log_fatal(CCAOSDB_LOGGER_NAME, exc.what()); \ + return caosdb::StatusCode::code; \ + } \ } /** * Macro for entity getters */ -#define CAOSDB_ENTITY_GET(element, GetFunction) \ - ERROR_RETURN_CODE( \ - GENERIC_ERROR, \ - int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, \ - char **out), \ - { \ - auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); \ - char *tmp = (char *)malloc( \ - sizeof(char) * wrapped_entity->GetFunction().length() + 1); \ - strcpy(tmp, wrapped_entity->GetFunction().c_str()); \ - delete[] * out; \ - *out = tmp; \ - return 0; \ +#define CAOSDB_ENTITY_GET(element, GetFunction) \ + ERROR_RETURN_CODE( \ + GENERIC_ERROR, \ + int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, char **out), { \ + auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); \ + char *tmp = (char *)malloc(sizeof(char) * wrapped_entity->GetFunction().length() + 1); \ + strcpy(tmp, wrapped_entity->GetFunction().c_str()); \ + delete[] * out; \ + *out = tmp; \ + 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 = WRAPPED_ENTITY_CAST(entity); \ - body_part return 0; \ - }) +#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 = WRAPPED_ENTITY_CAST(entity); \ + body_part return 0; \ + }) /** * Macro for property getters */ -#define CAOSDB_PROPERTY_GET(element, GetFunction) \ - ERROR_RETURN_CODE( \ - GENERIC_ERROR, \ - int caosdb_entity_property_get_##element(caosdb_entity_property *property, \ - char **out), \ - { \ - auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); \ - char *tmp = (char *)malloc( \ - sizeof(char) * wrapped_property->GetFunction().length() + 1); \ - strcpy(tmp, wrapped_property->GetFunction().c_str()); \ - delete[] * out; \ - *out = tmp; \ - return 0; \ +#define CAOSDB_PROPERTY_GET(element, GetFunction) \ + ERROR_RETURN_CODE( \ + GENERIC_ERROR, \ + int caosdb_entity_property_get_##element(caosdb_entity_property *property, char **out), { \ + auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); \ + char *tmp = (char *)malloc(sizeof(char) * wrapped_property->GetFunction().length() + 1); \ + strcpy(tmp, wrapped_property->GetFunction().c_str()); \ + delete[] * out; \ + *out = tmp; \ + 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 = \ - WRAPPED_PROPERTY_CAST(property); \ - body_part return 0; \ - }) +#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 = WRAPPED_PROPERTY_CAST(property); \ + body_part return 0; \ + }) /** * Macro for parent getters */ -#define CAOSDB_PARENT_GET(element, GetFunction) \ - ERROR_RETURN_CODE( \ - GENERIC_ERROR, \ - int caosdb_entity_parent_get_##element(caosdb_entity_parent *parent, \ - char **out), \ - { \ - auto *wrapped_parent = WRAPPED_PARENT_CAST(parent); \ - char *tmp = (char *)malloc( \ - sizeof(char) * wrapped_parent->GetFunction().length() + 1); \ - strcpy(tmp, wrapped_parent->GetFunction().c_str()); \ - delete[] * out; \ - *out = tmp; \ - return 0; \ +#define CAOSDB_PARENT_GET(element, GetFunction) \ + ERROR_RETURN_CODE( \ + GENERIC_ERROR, \ + int caosdb_entity_parent_get_##element(caosdb_entity_parent *parent, char **out), { \ + auto *wrapped_parent = WRAPPED_PARENT_CAST(parent); \ + char *tmp = (char *)malloc(sizeof(char) * wrapped_parent->GetFunction().length() + 1); \ + strcpy(tmp, wrapped_parent->GetFunction().c_str()); \ + delete[] * out; \ + *out = tmp; \ + 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 = WRAPPED_PARENT_CAST(parent); \ - body_part return 0; \ - }) - -int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() { - return caosdb::LIBCAOSDB_VERSION_MAJOR; -} +#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 = WRAPPED_PARENT_CAST(parent); \ + body_part return 0; \ + }) -int caosdb_constants_LIBCAOSDB_VERSION_MINOR() { - return caosdb::LIBCAOSDB_VERSION_MINOR; -} +int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() { return caosdb::LIBCAOSDB_VERSION_MAJOR; } -int caosdb_constants_LIBCAOSDB_VERSION_PATCH() { - return caosdb::LIBCAOSDB_VERSION_PATCH; -} +int caosdb_constants_LIBCAOSDB_VERSION_MINOR() { return caosdb::LIBCAOSDB_VERSION_MINOR; } + +int caosdb_constants_LIBCAOSDB_VERSION_PATCH() { return caosdb::LIBCAOSDB_VERSION_PATCH; } int caosdb_constants_COMPATIBLE_SERVER_VERSION_MAJOR() { return caosdb::COMPATIBLE_SERVER_VERSION_MAJOR; @@ -184,9 +162,7 @@ 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; -} +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); @@ -198,65 +174,61 @@ const char *caosdb_get_status_description(int code) { ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_create_pem_file_certificate_provider( - caosdb_connection_certificate_provider *out, - const char *path), + 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)); + new caosdb::configuration::PemFileCertificateProvider(std::string(path)); out->_deletable = true; return 0; }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_connection_delete_certificate_provider( - caosdb_connection_certificate_provider *provider), - { - if (provider->_deletable) { - delete static_cast<caosdb::configuration::CertificateProvider *>( - provider->wrapped_certificate_provider); - } - provider->_deletable = false; - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_connection_delete_certificate_provider( + caosdb_connection_certificate_provider *provider), + { + if (provider->_deletable) { + delete static_cast<caosdb::configuration::CertificateProvider *>( + provider->wrapped_certificate_provider); + } + provider->_deletable = false; + return 0; + }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_authentication_create_plain_password_authenticator( - caosdb_authentication_authenticator *out, - const char *username, const char *password), + 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)); + 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), - { - if (authenticator->_deletable) { - delete static_cast<caosdb::authentication::Authenticator *>( - authenticator->wrapped_authenticator); - } - authenticator->_deletable = false; - 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, int caosdb_connection_create_tls_connection_configuration( - caosdb_connection_connection_configuration *out, const char *host, - const int port, caosdb_authentication_authenticator *authenticator, + caosdb_connection_connection_configuration *out, const char *host, const int port, + caosdb_authentication_authenticator *authenticator, caosdb_connection_certificate_provider *provider), { if (out->_deletable) { @@ -264,29 +236,22 @@ ERROR_RETURN_CODE( } auto host_str = std::string(host); if (authenticator != nullptr && provider != nullptr) { - auto wrapped_provider = - static_cast<caosdb::configuration::CertificateProvider *>( - provider->wrapped_certificate_provider); + auto wrapped_provider = static_cast<caosdb::configuration::CertificateProvider *>( + provider->wrapped_certificate_provider); auto wrapped_authenticator = - static_cast<caosdb::authentication::Authenticator *>( - authenticator->wrapped_authenticator); - out->wrapped_connection_configuration = - new caosdb::configuration::TlsConnectionConfiguration( - host_str, port, *wrapped_provider, *wrapped_authenticator); + static_cast<caosdb::authentication::Authenticator *>(authenticator->wrapped_authenticator); + out->wrapped_connection_configuration = new caosdb::configuration::TlsConnectionConfiguration( + host_str, port, *wrapped_provider, *wrapped_authenticator); } else if (authenticator != nullptr) { auto wrapped_authenticator = - static_cast<caosdb::authentication::Authenticator *>( - authenticator->wrapped_authenticator); - out->wrapped_connection_configuration = - new caosdb::configuration::TlsConnectionConfiguration( - host_str, port, *wrapped_authenticator); + static_cast<caosdb::authentication::Authenticator *>(authenticator->wrapped_authenticator); + out->wrapped_connection_configuration = new caosdb::configuration::TlsConnectionConfiguration( + host_str, port, *wrapped_authenticator); } else if (provider != nullptr) { - auto wrapped_provider = - static_cast<caosdb::configuration::CertificateProvider *>( - provider->wrapped_certificate_provider); + auto wrapped_provider = static_cast<caosdb::configuration::CertificateProvider *>( + provider->wrapped_certificate_provider); out->wrapped_connection_configuration = - new caosdb::configuration::TlsConnectionConfiguration( - host_str, port, *wrapped_provider); + new caosdb::configuration::TlsConnectionConfiguration(host_str, port, *wrapped_provider); } else { out->wrapped_connection_configuration = new caosdb::configuration::TlsConnectionConfiguration(host_str, port); @@ -295,54 +260,50 @@ ERROR_RETURN_CODE( return 0; }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_connection_create_insecure_connection_configuration( - 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; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_connection_create_insecure_connection_configuration( + 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; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_connection_delete_connection_configuration( - caosdb_connection_connection_configuration *configuration), - { - if (configuration->_deletable) { - delete static_cast<caosdb::configuration::ConnectionConfiguration *>( - configuration->wrapped_connection_configuration); - } - configuration->_deletable = false; - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_connection_delete_connection_configuration( + caosdb_connection_connection_configuration *configuration), + { + if (configuration->_deletable) { + delete static_cast<caosdb::configuration::ConnectionConfiguration *>( + configuration->wrapped_connection_configuration); + } + configuration->_deletable = false; + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_connection_create_connection( - 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; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_connection_create_connection( + 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; + }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_connection_delete_connection( - caosdb_connection_connection *connection), + int caosdb_connection_delete_connection(caosdb_connection_connection *connection), { if (connection->_deletable) { delete static_cast<caosdb::connection::Connection *>( @@ -354,12 +315,11 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE( GENERIC_ERROR, - int caosdb_connection_get_version_info( - caosdb_info_version_info *out, - const caosdb_connection_connection *connection), + int caosdb_connection_get_version_info(caosdb_info_version_info *out, + const caosdb_connection_connection *connection), { - auto *wrapped_connection = static_cast<caosdb::connection::Connection *>( - connection->wrapped_connection); + auto *wrapped_connection = + static_cast<caosdb::connection::Connection *>(connection->wrapped_connection); auto status = wrapped_connection->RetrieveVersionInfoNoExceptions(); if (status.IsError()) { @@ -372,33 +332,30 @@ ERROR_RETURN_CODE( out->patch = (int)version_info->GetPatch(); // copy pre_release, needs local variable because out->pre_release is const - char *pre_release = (char *)malloc( - sizeof(char) * (version_info->GetPreRelease().length() + 1)); + char *pre_release = (char *)malloc(sizeof(char) * (version_info->GetPreRelease().length() + 1)); strcpy(pre_release, version_info->GetPreRelease().c_str()); out->pre_release = pre_release; // copy build, needs local variable because out->build is const - char *build = - (char *)malloc(sizeof(char) * (version_info->GetBuild().length() + 1)); + char *build = (char *)malloc(sizeof(char) * (version_info->GetBuild().length() + 1)); strcpy(build, version_info->GetBuild().c_str()); out->build = build; return 0; }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - 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; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + 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; + }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_connection_manager_get_connection( @@ -408,9 +365,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; } out->wrapped_connection = - caosdb::connection::ConnectionManager::GetConnection( - std::string(name)) - .get(); + caosdb::connection::ConnectionManager::GetConnection(std::string(name)).get(); // managed by the connection manager now, so not // to be deleted manually out->_deletable = false; @@ -422,191 +377,161 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ****************************************************************************/ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_connection_create_transaction( - caosdb_connection_connection *connection, - caosdb_transaction_transaction *out), + 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(); + 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_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), + caosdb_transaction_transaction *transaction, const char *id), { - auto *wrapped_transaction = - static_cast<caosdb::transaction::Transaction *>( - transaction->wrapped_transaction); + 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), + caosdb_transaction_transaction *transaction, const char *ids[], int length), { - auto *wrapped_transaction = - static_cast<caosdb::transaction::Transaction *>( - transaction->wrapped_transaction); + 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), + caosdb_transaction_transaction *transaction, const char *query), { - auto *wrapped_transaction = - static_cast<caosdb::transaction::Transaction *>( - transaction->wrapped_transaction); + 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_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_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); + 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), + 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); + 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), + 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); + 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_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_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_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_delete_parent(caosdb_entity_parent *out), { - if (out->_deletable) { - delete static_cast<caosdb::entity::Parent *>( - out->wrapped_parent); - } - 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, GetId) // TODO(fspreck) @@ -619,24 +544,22 @@ CAOSDB_ENTITY_GET(description, GetDescription) // TODO(fspreck) // CAOSDB_ENTITY_GET(value, strcpy(out, wrapped_entity->GetValue().c_str());) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_int_value( - caosdb_entity_entity *entity, long *out), - { + int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, long *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); *out = wrapped_entity->GetValue().AsInteger(); return 0; }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_double_value( - caosdb_entity_entity *entity, double *out), + int caosdb_entity_entity_get_double_value(caosdb_entity_entity *entity, + double *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); *out = wrapped_entity->GetValue().AsDouble(); return 0; }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_boolean_value( - caosdb_entity_entity *entity, bool *out), + int caosdb_entity_entity_get_boolean_value(caosdb_entity_entity *entity, + bool *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); *out = wrapped_entity->GetValue().AsBool(); @@ -644,8 +567,8 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) CAOSDB_ENTITY_GET(string_value, GetValue().AsString) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_int_list_value( - caosdb_entity_entity *entity, long *out), + int caosdb_entity_entity_get_int_list_value(caosdb_entity_entity *entity, + long *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); auto value_list = wrapped_entity->GetValue().AsList(); @@ -657,8 +580,8 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_value_list_length( - caosdb_entity_entity *entity, int *out), + int caosdb_entity_entity_get_value_list_length(caosdb_entity_entity *entity, + int *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); if (wrapped_entity->GetValue().IsList()) { @@ -672,135 +595,121 @@ ERROR_RETURN_CODE(GENERIC_ERROR, CAOSDB_ENTITY_GET(unit, GetUnit) CAOSDB_ENTITY_GET(version_id, GetVersionId) -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_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_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_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_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_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_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_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_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_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; - }) +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, GetId) CAOSDB_PARENT_GET(name, GetName) @@ -820,24 +729,24 @@ CAOSDB_PROPERTY_GET(unit, GetUnit) // CAOSDB_PROPERTY_GET(value, strcpy(out, // wrapped_property->GetValue().c_str());) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_get_int_value( - caosdb_entity_property *property, long *out), + int caosdb_entity_property_get_int_value(caosdb_entity_property *property, + long *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); *out = wrapped_property->GetValue().AsInteger(); return 0; }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_get_double_value( - caosdb_entity_property *property, double *out), + int caosdb_entity_property_get_double_value(caosdb_entity_property *property, + double *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); *out = wrapped_property->GetValue().AsDouble(); return 0; }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_get_boolean_value( - caosdb_entity_property *property, bool *out), + int caosdb_entity_property_get_boolean_value(caosdb_entity_property *property, + bool *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); *out = wrapped_property->GetValue().AsBool(); @@ -866,8 +775,8 @@ CAOSDB_PROPERTY_GET(string_value, GetValue().AsString) // }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_get_value_list_length( - caosdb_entity_property *property, int *out), + int caosdb_entity_property_get_value_list_length(caosdb_entity_property *property, + int *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); if (wrapped_property->GetValue().IsList()) { @@ -878,25 +787,19 @@ ERROR_RETURN_CODE(GENERIC_ERROR, return 0; }) -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_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); - char *tmp = (char *)malloc( - sizeof(char) * wrapped_message->GetDescription().length() + 1); + int caosdb_entity_message_get_description(caosdb_entity_message *message, char **out), { + auto *wrapped_message = static_cast<caosdb::entity::Message *>(message->wrapped_message); + char *tmp = (char *)malloc(sizeof(char) * wrapped_message->GetDescription().length() + 1); strcpy(tmp, wrapped_message->GetDescription().c_str()); delete[] * out; *out = tmp; @@ -913,160 +816,144 @@ CAOSDB_ENTITY_SET(description, description, // wrapped_entity->SetDataType(std::string(datatype));) CAOSDB_ENTITY_SET(unit, unit, wrapped_entity->SetUnit(std::string(unit));) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, - const long value), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - wrapped_entity->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, + const long value), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + wrapped_entity->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_double_value(caosdb_entity_entity *entity, - const double value), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - wrapped_entity->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_double_value(caosdb_entity_entity *entity, + const double value), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + wrapped_entity->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_boolean_value(caosdb_entity_entity *entity, - const bool value), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - wrapped_entity->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_boolean_value(caosdb_entity_entity *entity, + const bool value), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + wrapped_entity->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_string_value(caosdb_entity_entity *entity, - const char *value), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - wrapped_entity->SetValue(std::string(value)); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_string_value(caosdb_entity_entity *entity, + const char *value), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + wrapped_entity->SetValue(std::string(value)); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, - const long *value, - const int length), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<long> value_list; - for (int i = 0; i < length; i++) { - value_list.push_back(value[i]); - } - wrapped_entity->SetValue(value_list); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, + const long *value, const int length), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + std::vector<long> value_list; + for (int i = 0; i < length; i++) { + value_list.push_back(value[i]); + } + wrapped_entity->SetValue(value_list); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, - const double *value, - const int length), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<double> value_list; - for (int i = 0; i < length; i++) { - value_list.push_back(value[i]); - } - wrapped_entity->SetValue(value_list); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, + const double *value, + const int length), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + std::vector<double> value_list; + for (int i = 0; i < length; i++) { + value_list.push_back(value[i]); + } + wrapped_entity->SetValue(value_list); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_boolean_list_value(caosdb_entity_entity *entity, - const bool *value, - const int length), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<bool> value_list; - for (int i = 0; i < length; i++) { - value_list.push_back(value[i]); - } - wrapped_entity->SetValue(value_list); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_boolean_list_value(caosdb_entity_entity *entity, + const bool *value, + const int length), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + std::vector<bool> value_list; + for (int i = 0; i < length; i++) { + value_list.push_back(value[i]); + } + wrapped_entity->SetValue(value_list); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_entity_set_string_list_value(caosdb_entity_entity *entity, - const char **value, - const int length), - { - auto *wrapped_entity = - static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<std::string> value_list; - for (int i = 0; i < length; i++) { - value_list.push_back(std::string(value[i])); - } - wrapped_entity->SetValue(value_list); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_entity_set_string_list_value(caosdb_entity_entity *entity, + const char **value, + const int length), + { + auto *wrapped_entity = + static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); + std::vector<std::string> value_list; + for (int i = 0; i < length; i++) { + value_list.push_back(std::string(value[i])); + } + wrapped_entity->SetValue(value_list); + return 0; + }) -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_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_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; - }) +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));) @@ -1081,58 +968,53 @@ CAOSDB_PROPERTY_SET(id, id, wrapped_property->SetId(std::string(id));) // wrapped_property->SetImportance(std::string(importance));) CAOSDB_PROPERTY_SET(unit, unit, wrapped_property->SetUnit(std::string(unit));) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_property_set_int_value(caosdb_entity_property *property, - const long value), - { - auto *wrapped_property = - static_cast<caosdb::entity::Property *>(property->wrapped_property); - wrapped_property->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_property_set_int_value(caosdb_entity_property *property, + const long value), + { + auto *wrapped_property = + static_cast<caosdb::entity::Property *>(property->wrapped_property); + wrapped_property->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_property_set_double_value(caosdb_entity_property *property, - const double value), - { - auto *wrapped_property = - static_cast<caosdb::entity::Property *>(property->wrapped_property); - wrapped_property->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_property_set_double_value(caosdb_entity_property *property, + const double value), + { + auto *wrapped_property = + static_cast<caosdb::entity::Property *>(property->wrapped_property); + wrapped_property->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_property_set_boolean_value(caosdb_entity_property *property, - const bool value), - { - auto *wrapped_property = - static_cast<caosdb::entity::Property *>(property->wrapped_property); - wrapped_property->SetValue(value); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_property_set_boolean_value(caosdb_entity_property *property, + const bool value), + { + auto *wrapped_property = + static_cast<caosdb::entity::Property *>(property->wrapped_property); + wrapped_property->SetValue(value); + return 0; + }) -ERROR_RETURN_CODE( - GENERIC_ERROR, - int caosdb_entity_property_set_string_value(caosdb_entity_property *property, - const char *value), - { - auto *wrapped_property = - static_cast<caosdb::entity::Property *>(property->wrapped_property); - wrapped_property->SetValue(std::string(value)); - return 0; - }) +ERROR_RETURN_CODE(GENERIC_ERROR, + int caosdb_entity_property_set_string_value(caosdb_entity_property *property, + const char *value), + { + auto *wrapped_property = + static_cast<caosdb::entity::Property *>(property->wrapped_property); + wrapped_property->SetValue(std::string(value)); + return 0; + }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_set_int_list_value( - caosdb_entity_property *property, const long *value, - const int length), + int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, + const long *value, + const int length), { auto *wrapped_property = - static_cast<caosdb::entity::Property *>( - property->wrapped_property); + static_cast<caosdb::entity::Property *>(property->wrapped_property); std::vector<long> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); @@ -1142,13 +1024,12 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_set_double_list_value( - caosdb_entity_property *property, const double *value, - const int length), + int caosdb_entity_property_set_double_list_value(caosdb_entity_property *property, + const double *value, + const int length), { auto *wrapped_property = - static_cast<caosdb::entity::Property *>( - property->wrapped_property); + static_cast<caosdb::entity::Property *>(property->wrapped_property); std::vector<double> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); @@ -1159,12 +1040,10 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_set_boolean_list_value( - caosdb_entity_property *property, const bool *value, - const int length), + caosdb_entity_property *property, const bool *value, const int length), { auto *wrapped_property = - static_cast<caosdb::entity::Property *>( - property->wrapped_property); + static_cast<caosdb::entity::Property *>(property->wrapped_property); std::vector<bool> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); @@ -1174,13 +1053,12 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_property_set_string_list_value( - caosdb_entity_property *property, const char **value, - const int length), + int caosdb_entity_property_set_string_list_value(caosdb_entity_property *property, + const char **value, + const int length), { auto *wrapped_property = - static_cast<caosdb::entity::Property *>( - property->wrapped_property); + static_cast<caosdb::entity::Property *>(property->wrapped_property); std::vector<std::string> value_list; for (int i = 0; i < length; i++) { value_list.push_back(std::string(value[i])); diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp index a8a53317d26df70da1651eb3479e3f39a969d319..294c8aa355b56647775934c77ecc696b91a5ce06 100644 --- a/test/test_ccaosdb.cpp +++ b/test/test_ccaosdb.cpp @@ -262,8 +262,7 @@ TEST_F(test_ccaosdb, test_list_property) { // EXPECT_EQ(return_code, 0); const char *value_list[] = {"val0", "val1", "val2"}; // NOLINT - return_code = - caosdb_entity_property_set_string_list_value(&property, value_list, 3); + return_code = caosdb_entity_property_set_string_list_value(&property, value_list, 3); EXPECT_EQ(return_code, 0); // TODO(fspreck)