Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Compare revisions
dev to f-to-string
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
caosdb/src/caosdb-cpplib
Select target project
No results found
f-to-string
Select Git revision
Loading items
Swap
Target
caosdb/src/caosdb-cpplib
Select target project
caosdb/src/caosdb-cpplib
1 result
dev
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
ENH: add to_string for extern C
· 49dc812f
Henrik tom Wörden
authored
3 years ago
49dc812f
Merge branch 'dev' into f-to-string
· e61826ef
Henrik tom Wörden
authored
1 year ago
e61826ef
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ccaosdb.h
+18
-0
18 additions, 0 deletions
include/ccaosdb.h
src/ccaosdb.cpp
+30
-0
30 additions, 0 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+11
-0
11 additions, 0 deletions
test/test_ccaosdb.cpp
with
59 additions
and
0 deletions
include/ccaosdb.h
View file @
e61826ef
...
...
@@ -376,6 +376,7 @@ typedef struct caosdb_entity_datatype {
}
caosdb_entity_datatype
;
// GETTERS FOR EVERYTHING
int
caosdb_entity_entity_to_string
(
caosdb_entity_entity
*
entity
,
char
**
out
);
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
);
...
...
@@ -401,6 +402,7 @@ 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_to_string
(
caosdb_entity_property
*
entity
,
char
**
out
);
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
);
...
...
@@ -408,6 +410,22 @@ int caosdb_entity_property_get_importance(caosdb_entity_property *property, char
int
caosdb_entity_property_get_datatype
(
caosdb_entity_property
*
property
,
caosdb_entity_datatype
*
out
);
int
caosdb_entity_property_get_unit
(
caosdb_entity_property
*
property
,
char
**
out
);
int
caosdb_entity_property_get_int_value
(
caosdb_entity_property
*
property
,
int32_t
*
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_at
(
caosdb_entity_property
*
property
,
int32_t
*
out
,
const
int
index
);
int
caosdb_entity_property_get_double_list_value_at
(
caosdb_entity_property
*
property
,
double
*
out
,
const
int
index
);
int
caosdb_entity_property_get_boolean_list_value_at
(
caosdb_entity_property
*
property
,
bool
*
out
,
const
int
index
);
int
caosdb_entity_property_get_string_list_value_at
(
caosdb_entity_property
*
property
,
char
**
out
,
const
int
index
);
int
caosdb_entity_property_get_value_list_length
(
caosdb_entity_property
*
property
,
int
*
out
);
int
caosdb_entity_parent_to_string
(
caosdb_entity_parent
*
entity
,
char
**
out
);
int
caosdb_entity_property_get_value
(
caosdb_entity_property
*
property
,
caosdb_entity_value
*
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
);
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
View file @
e61826ef
...
...
@@ -723,6 +723,16 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_delete_value(caosdb_entity_va
})
CAOSDB_ENTITY_GET
(
id
,
GetId
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_to_string
(
caosdb_entity_entity
*
entity
,
char
**
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
std
::
string
role_str
=
wrapped_entity
->
ToString
();
auto
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
role_str
.
length
()
+
1
);
strcpy
(
tmp
,
role_str
.
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_role
(
caosdb_entity_entity
*
entity
,
char
**
out
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
...
...
@@ -871,10 +881,30 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
})
CAOSDB_PARENT_GET
(
id
,
GetId
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_parent_to_string
(
caosdb_entity_parent
*
entity
,
char
**
out
),
{
auto
*
wrapped_entity
=
WRAPPED_PARENT_CAST
(
entity
);
std
::
string
role_str
=
wrapped_entity
->
ToString
();
auto
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
role_str
.
length
()
+
1
);
strcpy
(
tmp
,
role_str
.
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
CAOSDB_PARENT_GET
(
name
,
GetName
())
CAOSDB_PARENT_GET
(
description
,
GetDescription
())
CAOSDB_PROPERTY_GET
(
id
,
GetId
())
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_to_string
(
caosdb_entity_property
*
entity
,
char
**
out
),
{
auto
*
wrapped_entity
=
WRAPPED_PROPERTY_CAST
(
entity
);
std
::
string
role_str
=
wrapped_entity
->
ToString
();
auto
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
role_str
.
length
()
+
1
);
strcpy
(
tmp
,
role_str
.
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
CAOSDB_PROPERTY_GET
(
name
,
GetName
())
CAOSDB_PROPERTY_GET
(
description
,
GetDescription
())
...
...
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
View file @
e61826ef
...
...
@@ -404,6 +404,9 @@ TEST_F(test_ccaosdb, test_entity) {
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
out
,
"length"
),
0
);
return_code
=
caosdb_entity_entity_to_string
(
&
entity
,
&
out
);
EXPECT_EQ
(
return_code
,
0
);
// test call without validation of result
return_code
=
caosdb_entity_entity_set_role
(
&
entity
,
"FILE"
);
EXPECT_EQ
(
return_code
,
0
);
...
...
@@ -422,6 +425,7 @@ TEST_F(test_ccaosdb, test_entity) {
caosdb_entity_entity_get_role
(
&
entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"PROPERTY"
),
0
);
caosdb_entity_entity_set_description
(
&
entity
,
"The length of an object"
);
caosdb_entity_entity_get_description
(
&
entity
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"The length of an object"
),
0
);
...
...
@@ -559,6 +563,9 @@ TEST_F(test_ccaosdb, test_property) {
caosdb_entity_property_get_id
(
&
property
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"some_id"
),
0
);
return_code
=
caosdb_entity_property_to_string
(
&
property
,
&
out
);
EXPECT_EQ
(
return_code
,
0
);
caosdb_entity_property_get_name
(
&
property
,
&
out
);
EXPECT_EQ
(
strcmp
(
out
,
"some_name"
),
0
);
...
...
@@ -826,6 +833,7 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
char
*
in
=
nullptr
;
// NOLINT
char
*
out
=
nullptr
;
// NOLINT
// cannot assign an already assigned property
// return_code = caosdb_entity_entity_get_property(&entity, &input_property, 0);
// EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR);
...
...
@@ -885,6 +893,9 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) {
caosdb_entity_parent_get_name
(
&
output_parent
,
&
out
);
EXPECT_EQ
(
strcmp
(
in
,
out
),
0
);
return_code
=
caosdb_entity_parent_to_string
(
&
input_parent
,
&
out
);
EXPECT_EQ
(
return_code
,
0
);
// Delete everything
return_code
=
caosdb_entity_delete_parent
(
&
input_parent
);
EXPECT_EQ
(
return_code
,
0
);
...
...
This diff is collapsed.
Click to expand it.