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
3ce3fae9
Commit
3ce3fae9
authored
3 years ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
STY: adding a few consts
parent
4df5b416
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!14
ENH: New functions getEnumNameFromValue() and getEnumValueFromName()
,
!12
F consolidation
Pipeline
#12246
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/utility.cpp
+4
-3
4 additions, 3 deletions
src/caosdb/utility.cpp
with
4 additions
and
3 deletions
src/caosdb/utility.cpp
+
4
−
3
View file @
3ce3fae9
...
...
@@ -63,7 +63,7 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
// caosdb::entity::importance_names.cend(),
// [name](const auto& entry){ return entry.second == name; });
// Workaround: plaint old iteration:
for
(
auto
entry
:
caosdb
::
entity
::
importance_names
)
{
for
(
auto
const
&
entry
:
caosdb
::
entity
::
importance_names
)
{
if
(
entry
.
second
==
name
)
{
return
entry
.
first
;
}
...
...
@@ -73,16 +73,17 @@ auto getEnumValueFromName<Importance>(const std::string &name) -> Importance {
template
<
>
auto
getEnumValueFromName
<
AtomicDataType
>
(
const
std
::
string
&
name
)
->
AtomicDataType
{
for
(
auto
entry
:
caosdb
::
entity
::
atomicdatatype_names
)
{
for
(
auto
const
&
entry
:
caosdb
::
entity
::
atomicdatatype_names
)
{
if
(
entry
.
second
==
name
)
{
return
entry
.
first
;
}
}
throw
std
::
out_of_range
(
std
::
string
(
"Could not find enum value for string '"
)
+
name
+
"'."
);
}
template
<
>
auto
getEnumValueFromName
<
Role
>
(
const
std
::
string
&
name
)
->
Role
{
for
(
auto
entry
:
caosdb
::
entity
::
role_names
)
{
for
(
auto
const
&
entry
:
caosdb
::
entity
::
role_names
)
{
if
(
entry
.
second
==
name
)
{
return
entry
.
first
;
}
...
...
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