Skip to content
Snippets Groups Projects
Commit f9147bbd authored by florian's avatar florian
Browse files

DRAFT: Begin datatype creators and destructors

parent b0d5af32
No related branches found
No related tags found
1 merge request!24API: Introduce value and datatype structs to Extern C
......@@ -441,7 +441,11 @@ int caosdb_entity_delete_property(caosdb_entity_property *out);
int caosdb_entity_create_parent(caosdb_entity_parent *out);
int caosdb_entity_delete_parent(caosdb_entity_parent *out);
// TODO(fspreck) implementations, also list_datatypes, list_values...
int caosdb_entity_create_datatype(caosdb_entity_datatype *out);
// DATATYPE CONSTRUCTORS for atomic and reference datatypes and lists thereof
int caosdb_entity_create_atomic_datatype(caosdb_entity_datatype *out, const char *name);
int caosdb_entity_create_reference_datatype(caosdb_entity_datatype *out, const char *name);
int caosdb_entity_create_atomic_list_datatype(caosdb_entity_datatype *out, const char *name);
int caosdb_entity_create_reference_list_datatype(caosdb_entity_datatype *out, const char *name);
int caosdb_entity_delete_datatype(caosdb_entity_datatype *out);
// VALUE CONSTRUCTORS (resolve overloaded constructors)
int caosdb_entity_create_int_value(caosdb_entity_value *out, const int64_t value);
......
......@@ -48,6 +48,8 @@ extern "C" {
#define WRAPPED_MESSAGE_CAST(name) static_cast<caosdb::entity::Message *>(name->wrapped_message)
#define WRAPPED_DATATYPE_CAST(name) static_cast<caosdb::entity::Datatype *>(name->wrapped_datatype)
#define WRAPPED_VALUE_CAST(name) static_cast<caosdb::entity::AbstractValue *>(name->wrapped_value)
#define ENUM_NAME_FROM_VALUE(arg, etype) \
......@@ -56,6 +58,11 @@ extern "C" {
#define ENUM_VALUE_FROM_NAME(arg, etype) \
caosdb::utility::getEnumValueFromName<caosdb::entity::etype>(arg)
#define RETURN_ASSIGNEMENT_ERROR_IF_DELETABLE(name) \
if (name->_deletable) { \
return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; \
}
/*
* Macro for wrapping every function into a try-catch clause. If an exception
* occurs, the given StatusCode is being returned.
......@@ -683,6 +690,31 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_delete_parent(caosdb_entity_p
return 0;
})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_atomic_datatype(caosdb_entity_datatype *out,
const char *name),
{})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_reference_datatype(caosdb_entity_datatype *out,
const char *name),
{})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_atomic_list_datatype(caosdb_entity_datatype *out,
const char *name),
{})
ERROR_RETURN_CODE(GENERIC_ERROR,
int caosdb_entity_create_reference_list_datatype(caosdb_entity_datatype *out,
const char *name),
{})
ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_delete_datatype(caosdb_entity_datatype *out), {
if (out->_deletable) {
delete WRAPPED_DATATYPE_CAST(out);
}
out->_deletable = false;
return 0;
})
CREATE_VALUE(int_value, const int64_t value)
CREATE_VALUE(string_value, const char *value)
CREATE_VALUE(double_value, const double value)
......
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