Skip to content
Snippets Groups Projects

ENH: Add retrieval and queries to Extern C interface

Merged Florian Spreckelsen requested to merge f-extended-c into f-files
2 files
+ 49
4
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 35
3
@@ -50,6 +50,34 @@ extern "C" {
@@ -50,6 +50,34 @@ extern "C" {
} \
} \
}
}
 
/**
 
* Macro for entity getters
 
*/
 
#define CAOSDB_ENTITY_GET(element, body_part) \
 
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; \
 
})
 
int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() {
int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() {
return caosdb::LIBCAOSDB_VERSION_MAJOR;
return caosdb::LIBCAOSDB_VERSION_MAJOR;
}
}
@@ -334,7 +362,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
@@ -334,7 +362,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
static_cast<caosdb::transaction::Transaction *>(
static_cast<caosdb::transaction::Transaction *>(
transaction->wrapped_transaction);
transaction->wrapped_transaction);
wrapped_transaction->ExecuteAsynchronously();
wrapped_transaction->ExecuteAsynchronously();
auto status = wrapped_transaction->WaitForIt();
auto status = wrapped_transaction->WaitForIt();
return status.GetCode();
return status.GetCode();
})
})
@@ -394,8 +422,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
@@ -394,8 +422,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
ERROR_RETURN_CODE(GENERIC_ERROR,
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_entity(caosdb_entity_entity *out), {
int caosdb_entity_create_entity(caosdb_entity_entity *out), {
auto entity = caosdb::entity::Entity();
out->wrapped_entity = new caosdb::entity::Entity();
out->wrapped_entity = (void *)(&entity);
return 0;
return 0;
})
})
@@ -405,4 +432,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
@@ -405,4 +432,9 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
out->wrapped_entity);
out->wrapped_entity);
return 0;
return 0;
})
})
 
 
CAOSDB_ENTITY_GET(id, strcpy(out, wrapped_entity->GetId().c_str());)
 
CAOSDB_ENTITY_GET(name, strcpy(out, wrapped_entity->GetName().c_str());)
 
 
CAOSDB_ENTITY_SET(name, name, wrapped_entity->SetName(std::string(name));)
}
}
Loading