Skip to content
Snippets Groups Projects
Commit 14731539 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

STY: Style changes and docstrings.

parent 79af0a93
No related branches found
No related tags found
1 merge request!15ENH: Allow insert/update/delete and files in Extern C
Pipeline #12477 failed
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
...@@ -279,11 +279,13 @@ int caosdb_connection_connection_create_transaction(caosdb_connection_connection ...@@ -279,11 +279,13 @@ int caosdb_connection_connection_create_transaction(caosdb_connection_connection
int caosdb_transaction_delete_transaction(caosdb_transaction_transaction *transaction); int caosdb_transaction_delete_transaction(caosdb_transaction_transaction *transaction);
int caosdb_transaction_transaction_retrieve_by_id(caosdb_transaction_transaction *transaction, int caosdb_transaction_transaction_retrieve_by_id(caosdb_transaction_transaction *transaction,
const char *id); const char *id);
int caosdb_transaction_transaction_retrieve_and_download_file_by_id(caosdb_transaction_transaction *transaction, int caosdb_transaction_transaction_retrieve_and_download_file_by_id(
const char *id, caosdb_transaction_transaction *transaction,
const char *path); const char *id,
int caosdb_transaction_transaction_retrieve_by_ids(caosdb_transaction_transaction *transaction, const char *path);
const char *ids[], int length); 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, int caosdb_transaction_transaction_query(caosdb_transaction_transaction *transaction,
const char *query); const char *query);
int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *transaction); int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *transaction);
......
...@@ -75,7 +75,7 @@ extern "C" { ...@@ -75,7 +75,7 @@ extern "C" {
GENERIC_ERROR, \ GENERIC_ERROR, \
int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, char **out), { \ int caosdb_entity_entity_get_##element(caosdb_entity_entity *entity, char **out), { \
auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); \ auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); \
char *tmp = (char *)malloc(sizeof(char) * wrapped_entity->GetFunction.length() + 1); \ auto *tmp = (char *)malloc(sizeof(char) * wrapped_entity->GetFunction.length() + 1); \
strcpy(tmp, wrapped_entity->GetFunction.c_str()); \ strcpy(tmp, wrapped_entity->GetFunction.c_str()); \
delete[] * out; \ delete[] * out; \
*out = tmp; \ *out = tmp; \
...@@ -101,7 +101,7 @@ extern "C" { ...@@ -101,7 +101,7 @@ extern "C" {
GENERIC_ERROR, \ GENERIC_ERROR, \
int caosdb_entity_property_get_##element(caosdb_entity_property *property, char **out), { \ int caosdb_entity_property_get_##element(caosdb_entity_property *property, char **out), { \
auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); \ auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); \
char *tmp = (char *)malloc(sizeof(char) * wrapped_property->GetFunction.length() + 1); \ auto *tmp = (char *)malloc(sizeof(char) * wrapped_property->GetFunction.length() + 1); \
strcpy(tmp, wrapped_property->GetFunction.c_str()); \ strcpy(tmp, wrapped_property->GetFunction.c_str()); \
delete[] * out; \ delete[] * out; \
*out = tmp; \ *out = tmp; \
...@@ -128,7 +128,7 @@ extern "C" { ...@@ -128,7 +128,7 @@ extern "C" {
GENERIC_ERROR, \ GENERIC_ERROR, \
int caosdb_entity_parent_get_##element(caosdb_entity_parent *parent, char **out), { \ int caosdb_entity_parent_get_##element(caosdb_entity_parent *parent, char **out), { \
auto *wrapped_parent = WRAPPED_PARENT_CAST(parent); \ auto *wrapped_parent = WRAPPED_PARENT_CAST(parent); \
char *tmp = (char *)malloc(sizeof(char) * wrapped_parent->GetFunction.length() + 1); \ auto *tmp = (char *)malloc(sizeof(char) * wrapped_parent->GetFunction.length() + 1); \
strcpy(tmp, wrapped_parent->GetFunction.c_str()); \ strcpy(tmp, wrapped_parent->GetFunction.c_str()); \
delete[] * out; \ delete[] * out; \
*out = tmp; \ *out = tmp; \
...@@ -338,12 +338,12 @@ ERROR_RETURN_CODE( ...@@ -338,12 +338,12 @@ ERROR_RETURN_CODE(
out->patch = (int)version_info->GetPatch(); out->patch = (int)version_info->GetPatch();
// copy pre_release, needs local variable because out->pre_release is const // copy pre_release, needs local variable because out->pre_release is const
char *pre_release = (char *)malloc(sizeof(char) * (version_info->GetPreRelease().length() + 1)); auto *pre_release = (char *)malloc(sizeof(char) * (version_info->GetPreRelease().length() + 1));
strcpy(pre_release, version_info->GetPreRelease().c_str()); strcpy(pre_release, version_info->GetPreRelease().c_str());
out->pre_release = pre_release; out->pre_release = pre_release;
// copy build, needs local variable because out->build is const // copy build, needs local variable because out->build is const
char *build = (char *)malloc(sizeof(char) * (version_info->GetBuild().length() + 1)); auto *build = (char *)malloc(sizeof(char) * (version_info->GetBuild().length() + 1));
strcpy(build, version_info->GetBuild().c_str()); strcpy(build, version_info->GetBuild().c_str());
out->build = build; out->build = build;
...@@ -588,7 +588,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ...@@ -588,7 +588,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_entity_get_role(caosdb_entity_entity *entity, char **out), { int caosdb_entity_entity_get_role(caosdb_entity_entity *entity, char **out), {
auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
std::string role_str = ENUM_NAME_FROM_VALUE(wrapped_entity->GetRole(), Role); std::string role_str = ENUM_NAME_FROM_VALUE(wrapped_entity->GetRole(), Role);
char *tmp = (char *)malloc(sizeof(char) * role_str.length() + 1); auto *tmp = (char *)malloc(sizeof(char) * role_str.length() + 1);
strcpy(tmp, role_str.c_str()); strcpy(tmp, role_str.c_str());
delete[] * out; delete[] * out;
*out = tmp; *out = tmp;
...@@ -600,7 +600,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ...@@ -600,7 +600,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
{ {
auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity);
auto path = wrapped_entity->GetLocalPath().string(); auto path = wrapped_entity->GetLocalPath().string();
char *tmp = (char *)malloc(sizeof(char) * path.length() + 1); auto *tmp = (char *)(malloc(sizeof(char) * path.length() + 1));
strcpy(tmp, path.c_str()); strcpy(tmp, path.c_str());
delete[] * out; delete[] * out;
*out = tmp; *out = tmp;
...@@ -951,7 +951,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ...@@ -951,7 +951,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
{ {
auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); auto *wrapped_property = WRAPPED_PROPERTY_CAST(property);
auto value_list = wrapped_property->GetValue().AsList(); auto value_list = wrapped_property->GetValue().AsList();
char *tmp = auto *tmp =
(char *)malloc(sizeof(char) * value_list[index].AsString().length() + 1); (char *)malloc(sizeof(char) * value_list[index].AsString().length() + 1);
strcpy(tmp, value_list[index].AsString().c_str()); strcpy(tmp, value_list[index].AsString().c_str());
delete[] * out; delete[] * out;
...@@ -984,7 +984,7 @@ ERROR_RETURN_CODE( ...@@ -984,7 +984,7 @@ ERROR_RETURN_CODE(
GENERIC_ERROR, GENERIC_ERROR,
int caosdb_entity_message_get_description(caosdb_entity_message *message, char **out), { int caosdb_entity_message_get_description(caosdb_entity_message *message, char **out), {
auto *wrapped_message = static_cast<caosdb::entity::Message *>(message->wrapped_message); auto *wrapped_message = static_cast<caosdb::entity::Message *>(message->wrapped_message);
char *tmp = (char *)malloc(sizeof(char) * wrapped_message->GetDescription().length() + 1); auto *tmp = (char *)malloc(sizeof(char) * wrapped_message->GetDescription().length() + 1);
strcpy(tmp, wrapped_message->GetDescription().c_str()); strcpy(tmp, wrapped_message->GetDescription().c_str());
delete[] * out; delete[] * out;
*out = tmp; *out = tmp;
......
...@@ -465,7 +465,7 @@ TEST_F(test_ccaosdb, test_remove_property) { ...@@ -465,7 +465,7 @@ TEST_F(test_ccaosdb, test_remove_property) {
} }
TEST_F(test_ccaosdb, test_insert_update_delete) { TEST_F(test_ccaosdb, test_insert_update_delete) {
// Only test adding to a transaction, excution and results are // Only test adding to a transaction. Excution and results are
// tested in integration tests. // tested in integration tests.
caosdb_connection_connection connection; caosdb_connection_connection connection;
caosdb_connection_connection_manager_get_default_connection(&connection); caosdb_connection_connection_manager_get_default_connection(&connection);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment