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
26b3d9e5
Verified
Commit
26b3d9e5
authored
2 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: replace char[] with string
parent
ec5732e2
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!42
Release 0.2.0
,
!39
F remove boost rdep
Pipeline
#24629
passed
2 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#24630
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
include/caosdb/utility.h
+0
-5
0 additions, 5 deletions
include/caosdb/utility.h
src/caosdb/configuration.cpp
+6
-5
6 additions, 5 deletions
src/caosdb/configuration.cpp
src/caosdb/utility.cpp
+17
-16
17 additions, 16 deletions
src/caosdb/utility.cpp
with
24 additions
and
27 deletions
CMakeLists.txt
+
1
−
1
View file @
26b3d9e5
...
...
@@ -323,7 +323,7 @@ if(_LINTING)
else
()
message
(
STATUS
"clang-tidy:
${
clang_tidy
}
"
)
set
(
_CMAKE_CXX_CLANG_TIDY_CHECKS
"--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type,-bugprone-branch-clone,-altera-*,-cppcoreguidelines-macro-usage
,-*-avoid-c-arrays
"
)
"--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type,-bugprone-branch-clone,-altera-*,-cppcoreguidelines-macro-usage"
)
set
(
_CMAKE_C_CLANG_TIDY_CHECKS
"
${
_CMAKE_CXX_CLANG_TIDY_CHECKS
}
"
)
set
(
_CMAKE_CXX_CLANG_TIDY
"
${
clang_tidy
}
"
"--header-filter=caosdb/.*[^
\(
\.pb\.h
\)
]$"
...
...
This diff is collapsed.
Click to expand it.
include/caosdb/utility.h
+
0
−
5
View file @
26b3d9e5
...
...
@@ -147,11 +147,6 @@ public:
*/
auto
operator
=
(
JsonValue
&&
other
)
noexcept
->
JsonValue
&
;
/**
* Return true if the `wrapped` object is the nullptr.
*/
inline
auto
IsNull
()
const
->
bool
{
return
this
->
wrapped
==
nullptr
;
}
/**
* Reset this object.
*
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/configuration.cpp
+
6
−
5
View file @
26b3d9e5
...
...
@@ -45,10 +45,11 @@
#include
<string>
// for string, operator+
#include
<utility>
// for move
#define WRAPPED_JSON_CONFIGURATION(obj) (static_cast<value *>((obj)->json_configuration.wrapped.get()))
#define WRAPPED_JSON_CONFIGURATION(obj) \
(static_cast<value *>((obj)->json_configuration.wrapped.get()))
#define GET_CONNECTIONS \
if (this->json_configuration.
IsNull()
) { \
if (
!
this->json_configuration.
wrapped
) { \
throw ConfigurationError("This CaosDB client has not been configured."); \
} \
assert(WRAPPED_JSON_CONFIGURATION(this)->is_object()); \
...
...
@@ -379,7 +380,7 @@ auto ConfigurationManager::mClear() noexcept -> int {
}
auto
ConfigurationManager
::
mLoadSingleJSONConfiguration
(
const
path
&
json_file
)
->
void
{
if
(
!
json_configuration
.
IsNull
()
)
{
if
(
json_configuration
.
wrapped
)
{
throw
ConfigurationError
(
"This CaosDB client has already been configured."
);
}
if
(
!
exists
(
json_file
))
{
...
...
@@ -468,7 +469,7 @@ auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT
}
// Logging in the configuration leads to additional content.
if
(
!
this
->
json_configuration
.
IsNull
()
&&
WRAPPED_JSON_CONFIGURATION
(
this
)
->
is_object
()
&&
if
(
this
->
json_configuration
.
wrapped
&&
WRAPPED_JSON_CONFIGURATION
(
this
)
->
is_object
()
&&
WRAPPED_JSON_CONFIGURATION
(
this
)
->
as_object
().
contains
(
"logging"
))
{
LoggingConfiguration
logging_configuration
=
CreateLoggingConfiguration
(
WRAPPED_JSON_CONFIGURATION
(
this
)
->
at
(
"logging"
).
as_object
());
...
...
@@ -479,7 +480,7 @@ auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT
"We are using the default configuration"
;
}
if
(
configuration_file_path
!=
nullptr
&&
!
this
->
json_configuration
.
IsNull
()
&&
if
(
configuration_file_path
!=
nullptr
&&
this
->
json_configuration
.
wrapped
&&
WRAPPED_JSON_CONFIGURATION
(
this
)
->
is_object
())
{
CAOSDB_LOG_INFO
(
logger_name
)
<<
"Loaded configuration from "
<<
*
(
configuration_file_path
)
<<
"."
;
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/utility.cpp
+
17
−
16
View file @
26b3d9e5
...
...
@@ -114,11 +114,10 @@ auto base64_encode(const std::string &plain) -> std::string {
auto
size_plain
=
plain
.
size
();
auto
size_encoded
=
boost
::
beast
::
detail
::
base64
::
encoded_size
(
size_plain
);
std
::
unique_ptr
<
char
[]
>
encoded
(
new
char
[
size_encoded
]
);
boost
::
beast
::
detail
::
base64
::
encode
(
encoded
.
get
()
,
plain
.
c_str
(),
size_plain
);
std
::
string
result
=
std
::
string
(
size_encoded
,
'\0'
);
boost
::
beast
::
detail
::
base64
::
encode
(
&
result
[
0
]
,
plain
.
c_str
(),
size_plain
);
// the encoded char[] is not null terminated, so explicitely set the length
return
{
encoded
.
get
(),
encoded
.
get
()
+
size_encoded
};
return
result
;
}
auto
_load_json_file
(
const
path
&
json_file
)
->
value
{
...
...
@@ -144,38 +143,40 @@ auto load_json_file(const path &json_file) -> JsonValue {
return
{
new
value
(
_load_json_file
(
json_file
))};
}
JsonValue
::
JsonValue
(
void
*
wrapped
)
{
this
->
wrapped
=
std
::
make_shared
<
value
>
(
*
static_cast
<
value
*>
(
wrapped
));
}
JsonValue
::
JsonValue
(
void
*
wrapped
)
{
this
->
wrapped
.
reset
(
static_cast
<
value
*>
(
wrapped
));
}
JsonValue
::~
JsonValue
()
{
this
->
Reset
();
}
JsonValue
::~
JsonValue
()
=
default
;
auto
JsonValue
::
Reset
()
->
void
{
this
->
wrapped
.
reset
();
}
auto
JsonValue
::
Reset
()
->
void
{
if
(
this
->
wrapped
)
{
this
->
wrapped
.
reset
();
}
}
JsonValue
::
JsonValue
(
const
JsonValue
&
other
)
{
if
(
!
other
.
IsNull
()
)
{
this
->
wrapped
=
std
::
make_shared
<
value
>
(
*
static_cast
<
value
*>
(
other
.
wrapped
.
get
()));
if
(
other
.
wrapped
)
{
this
->
wrapped
.
reset
(
static_cast
<
value
*>
(
other
.
wrapped
.
get
()));
}
}
auto
JsonValue
::
operator
=
(
const
JsonValue
&
other
)
->
JsonValue
&
{
if
(
this
!=
&
other
)
{
Reset
();
if
(
!
other
.
IsNull
())
{
this
->
wrapped
=
std
::
make_shared
<
value
>
(
*
static_cast
<
value
*>
(
other
.
wrapped
.
get
()));
if
(
other
.
wrapped
)
{
this
->
wrapped
=
std
::
make_shared
<
value
>
(
*
(
static_cast
<
value
*>
(
other
.
wrapped
.
get
())));
}
}
return
*
this
;
}
JsonValue
::
JsonValue
(
JsonValue
&&
other
)
noexcept
:
wrapped
(
nullptr
)
{
if
(
!
other
.
IsNull
()
)
{
JsonValue
::
JsonValue
(
JsonValue
&&
other
)
noexcept
{
if
(
other
.
wrapped
)
{
this
->
wrapped
=
std
::
move
(
other
.
wrapped
);
}
}
auto
JsonValue
::
operator
=
(
JsonValue
&&
other
)
noexcept
->
JsonValue
&
{
if
(
this
!=
&
other
)
{
Reset
();
this
->
wrapped
=
std
::
move
(
other
.
wrapped
);
}
return
*
this
;
...
...
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