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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
09f305f4
Commit
09f305f4
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add get_list_value_at getters
parent
4336c440
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!13
ENH: Add datatypes and value classes to Extern C interface
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/ccaosdb.h
+16
-8
16 additions, 8 deletions
include/ccaosdb.h
src/ccaosdb.cpp
+76
-6
76 additions, 6 deletions
src/ccaosdb.cpp
test/test_ccaosdb.cpp
+6
-8
6 additions, 8 deletions
test/test_ccaosdb.cpp
with
98 additions
and
22 deletions
include/ccaosdb.h
+
16
−
8
View file @
09f305f4
...
...
@@ -332,10 +332,14 @@ 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_int_list_value_at
(
caosdb_entity_entity
*
entity
,
long
*
out
,
const
int
index
);
int
caosdb_entity_entity_get_double_list_value_at
(
caosdb_entity_entity
*
entity
,
double
*
out
,
const
int
index
);
int
caosdb_entity_entity_get_boolean_list_value_at
(
caosdb_entity_entity
*
entity
,
bool
*
out
,
const
int
index
);
int
caosdb_entity_entity_get_string_list_value_at
(
caosdb_entity_entity
*
entity
,
char
**
out
,
const
int
index
);
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
);
...
...
@@ -366,10 +370,14 @@ int caosdb_entity_property_get_int_value(caosdb_entity_property *property, long
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_int_list_value_at
(
caosdb_entity_property
*
property
,
long
*
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_get_id
(
caosdb_entity_parent
*
parent
,
char
**
out
);
...
...
This diff is collapsed.
Click to expand it.
src/ccaosdb.cpp
+
76
−
6
View file @
09f305f4
...
...
@@ -566,16 +566,45 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
return
0
;
})
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
_at
(
caosdb_entity_entity
*
entity
,
long
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
int
i
=
0
;
for
(
const
auto
elt
:
value_list
)
{
out
[
i
++
]
=
elt
.
AsInteger
();
}
*
out
=
value_list
[
index
].
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_double_list_value_at
(
caosdb_entity_entity
*
entity
,
double
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_boolean_value_list_value_at
(
caosdb_entity_entity
*
entity
,
bool
*
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsBool
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_entity_get_string_list_value_at
(
caosdb_entity_entity
*
entity
,
char
**
out
,
const
int
index
),
{
auto
*
wrapped_entity
=
WRAPPED_ENTITY_CAST
(
entity
);
auto
value_list
=
wrapped_entity
->
GetValue
().
AsList
();
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
value_list
[
index
].
AsString
().
length
()
+
1
);
strcpy
(
tmp
,
value_list
[
index
].
AsString
().
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
...
...
@@ -754,6 +783,47 @@ ERROR_RETURN_CODE(GENERIC_ERROR,
})
CAOSDB_PROPERTY_GET
(
string_value
,
GetValue
().
AsString
)
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_int_list_value_at
(
caosdb_entity_property
*
property
,
long
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsInteger
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_double_list_value_at
(
caosdb_entity_property
*
property
,
double
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsDouble
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_boolean_value_list_value_at
(
caosdb_entity_property
*
property
,
bool
*
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
*
out
=
value_list
[
index
].
AsBool
();
return
0
;
})
ERROR_RETURN_CODE
(
GENERIC_ERROR
,
int
caosdb_entity_property_get_string_list_value_at
(
caosdb_entity_property
*
property
,
char
**
out
,
const
int
index
),
{
auto
*
wrapped_property
=
WRAPPED_PROPERTY_CAST
(
property
);
auto
value_list
=
wrapped_property
->
GetValue
().
AsList
();
char
*
tmp
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
value_list
[
index
].
AsString
().
length
()
+
1
);
strcpy
(
tmp
,
value_list
[
index
].
AsString
().
c_str
());
delete
[]
*
out
;
*
out
=
tmp
;
return
0
;
})
// TODO(fspreck) Fix this somehow. It segfaults. Bleh.
// ERROR_RETURN_CODE(GENERIC_ERROR,
// int caosdb_entity_property_get_string_list_value(
...
...
This diff is collapsed.
Click to expand it.
test/test_ccaosdb.cpp
+
6
−
8
View file @
09f305f4
...
...
@@ -277,14 +277,12 @@ TEST_F(test_ccaosdb, test_list_property) {
EXPECT_EQ
(
*
length
,
3
);
// TODO(fspreck) get and compare values in list. Segfaults as it is right now.
// char **out_list = nullptr; // NOLINT
// std::cout << "Getting list values" << std::endl;
// return_code =
// caosdb_entity_property_get_string_list_value(&property, &out_list);
// EXPECT_EQ(return_code, 0);
// for (int i = 0; i < *length; i++) {
// EXPECT_EQ(strcmp(value_list[i], out_list[i]), 0); // NOLINT
// }
char
*
out
=
nullptr
;
// NOLINT
for
(
int
i
=
0
;
i
<
*
length
;
i
++
)
{
return_code
=
caosdb_entity_property_get_string_list_value_at
(
&
property
,
&
out
,
i
);
EXPECT_EQ
(
return_code
,
0
);
EXPECT_EQ
(
strcmp
(
value_list
[
i
],
out
),
0
);
// NOLINT
}
return_code
=
caosdb_entity_delete_property
(
&
property
);
EXPECT_EQ
(
return_code
,
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment