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
3ffd3f51
Commit
3ffd3f51
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Better cli and documentation.
parent
13b955a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#12594
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/README_SETUP.md
+3
-1
3 additions, 1 deletion
doc/README_SETUP.md
src/cxxcaosdbcli.cpp
+28
-10
28 additions, 10 deletions
src/cxxcaosdbcli.cpp
with
31 additions
and
11 deletions
doc/README_SETUP.md
+
3
−
1
View file @
3ffd3f51
...
...
@@ -79,7 +79,9 @@ For the tests there is a slightly different setup required (with option `-D CMAK
3.
`cmake -B . -D CMAKE_BUILD_TYPE=Debug ..`
*
If your clang-format version is too old, formatting, linting etc. can be skipped:
`cmake -B . -D CMAKE_BUILD_TYPE=Debug -D SKIP_LINTING=ON ..`
4.
`cmake --build .`
*
Depending on the clang version it might be necessary to also add
`-DCMAKE_CXX_FLAGS="-Wno-unused-parameter"`
5.
`cmake --build .`
### Run
...
...
This diff is collapsed.
Click to expand it.
src/cxxcaosdbcli.cpp
+
28
−
10
View file @
3ffd3f51
...
...
@@ -26,11 +26,14 @@
#include
"caosdb/entity.h"
// for Entity
#include
"caosdb/exceptions.h"
// for ConfigurationError
#include
"caosdb/info.h"
// for VersionInfo
#include
"caosdb/logging.h"
// for CAOSDB_LOG_TRACE
#include
"caosdb/transaction.h"
// for Transaction, ResultSet
#include
<iostream>
// for operator<<, basic_ostream, basic_ost...
#include
<memory>
// for unique_ptr, allocator, __shared_ptr_...
#include
<string>
// for operator<<, char_traits
auto
logger_name
=
"libcaosdb"
;
auto
main
()
->
int
{
std
::
cout
<<
"CaosDB C++ client (libcaosdb "
<<
caosdb
::
LIBCAOSDB_VERSION_MINOR
<<
"."
...
...
@@ -51,19 +54,34 @@ auto main() -> int {
// retrieve an entity
auto
transaction
(
connection
->
CreateTransaction
());
transaction
->
RetrieveById
(
"120"
);
transaction
->
Execute
();
transaction
->
ExecuteAsynchronously
();
auto
t_stat
=
transaction
->
WaitForIt
();
CAOSDB_LOG_INFO
(
logger_name
)
<<
"status: "
<<
t_stat
.
GetCode
()
<<
" // "
<<
t_stat
.
GetDescription
();
const
auto
&
result_set
=
transaction
->
GetResultSet
();
// print information
const
auto
&
ent
=
result_set
.
at
(
0
);
const
auto
&
props
=
ent
.
GetProperties
();
std
::
cout
<<
"Entity Name: "
<<
ent
.
GetName
()
<<
std
::
endl
;
std
::
cout
<<
"Entity Description: "
<<
ent
.
GetDescription
()
<<
std
::
endl
;
std
::
cout
<<
"Entity Properties: "
<<
std
::
endl
;
for
(
const
auto
&
prop
:
props
)
{
std
::
cout
<<
"----------
\n
"
<<
prop
.
ToString
()
<<
std
::
endl
;
if
(
result_set
.
size
()
>
0
)
{
// print information
const
auto
&
ent
=
result_set
.
at
(
0
);
const
auto
&
props
=
ent
.
GetProperties
();
std
::
cout
<<
"Entity Name: "
<<
ent
.
GetName
()
<<
std
::
endl
;
std
::
cout
<<
"Entity Description: "
<<
ent
.
GetDescription
()
<<
std
::
endl
;
std
::
cout
<<
"Entity Properties: "
<<
std
::
endl
;
for
(
const
auto
&
prop
:
props
)
{
std
::
cout
<<
"----------
\n
"
<<
prop
.
ToString
()
<<
std
::
endl
;
}
}
else
{
std
::
cout
<<
"No entity
\"
120
\"
retrieved, maybe it does not exist?
\n
"
<<
std
::
endl
;
}
// execute a query
std
::
string
query
(
"FIND Property
\"
Prop *
\"
"
);
std
::
cout
<<
"Trying to execute a query:
\n
"
<<
query
<<
std
::
endl
;
auto
q_transaction
(
connection
->
CreateTransaction
());
q_transaction
->
Query
(
query
);
q_transaction
->
ExecuteAsynchronously
();
t_stat
=
q_transaction
->
WaitForIt
();
CAOSDB_LOG_INFO
(
logger_name
)
<<
"status: "
<<
t_stat
.
GetCode
()
<<
" // "
<<
t_stat
.
GetDescription
();
return
0
;
}
catch
(
const
caosdb
::
exceptions
::
ConfigurationError
&
exc
)
{
std
::
cout
<<
"ConfigurationError: "
<<
exc
.
what
()
<<
std
::
endl
;
...
...
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