Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GeoModel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Insights
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
GeoModelDev
GeoModel
Commits
e648c514
Commit
e648c514
authored
11 months ago
by
Riccardo Maria Bianchi
Committed by
Johannes Junggeburth
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Set precision to all conversions from double to string in DBManager
parent
00e5195c
No related branches found
No related tags found
1 merge request
!327
New schema for the GeoModel SQLite database and updated I/O
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp
+15
-16
15 additions, 16 deletions
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp
with
15 additions
and
16 deletions
GeoModelIO/GeoModelDBManager/src/GMDBManager.cpp
+
15
−
16
View file @
e648c514
/*
Copyright (C) 2002-202
3
CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-202
4
CERN for the benefit of the ATLAS collaboration
*/
/*
...
...
@@ -14,6 +14,9 @@
* - Jul 2023 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>,
* Populate the caches in the constructor, so all print methods are
* available as soon as the input file is opened by the GMDBManager
* - Apr 2024 - Riccardo Maria Bianchi, <riccardo.maria.bianchi@cern.ch>,
* New DB format to extend the storage of numbers as REAL instead of TEXT,
* New methods to handle vector<variants> as input of records
*/
#include
<GeoModelDBManager/GMDBManager.h>
...
...
@@ -437,7 +440,7 @@ bool GMDBManager::addListOfRecordsToTable(
// do for the std::variant version!
}
std
::
string
values
=
GeoModelIO
::
CppHelper
::
joinVectorStrings
(
items
,
","
);
sql
+=
" ("
+
std
::
to_string
(
id
)
+
","
+
values
+
")"
;
sql
+=
" ("
+
std
::
to_string
(
id
)
+
","
+
values
+
")"
;
// INT
if
(
id
!=
nRecords
)
{
sql
+=
","
;
}
else
{
...
...
@@ -484,15 +487,13 @@ bool GMDBManager::addListOfRecordsToTable(
for
(
const
std
::
variant
<
int
,
long
,
float
,
double
,
std
::
string
>&
item
:
rec
)
{
if
(
std
::
holds_alternative
<
int
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
int
>
(
item
)));
// we need to encapsulate records' values into
// quotes for the SQL query string
items
.
push_back
(
std
::
to_string
(
std
::
get
<
int
>
(
item
)));
// INT
else
if
(
std
::
holds_alternative
<
long
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
long
>
(
item
)));
items
.
push_back
(
std
::
to_string
(
std
::
get
<
long
>
(
item
)));
// INT
else
if
(
std
::
holds_alternative
<
float
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
float
>
(
item
)));
items
.
push_back
(
GeoModelIO
::
CppHelper
::
to_string_with_precision
(
std
::
get
<
float
>
(
item
)));
else
if
(
std
::
holds_alternative
<
double
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
double
>
(
item
)));
items
.
push_back
(
GeoModelIO
::
CppHelper
::
to_string_with_precision
(
std
::
get
<
double
>
(
item
)));
else
if
(
std
::
holds_alternative
<
std
::
string
>
(
item
))
{
std
::
string
str
=
std
::
get
<
std
::
string
>
(
item
);
// NOTE: if item is a "NULL" string, we don't encapsulate it
...
...
@@ -509,7 +510,7 @@ bool GMDBManager::addListOfRecordsToTable(
}
// we build the long string containing all values
std
::
string
values
=
GeoModelIO
::
CppHelper
::
joinVectorStrings
(
items
,
","
);
sql
+=
" ("
+
std
::
to_string
(
id
)
+
","
+
values
+
")"
;
sql
+=
" ("
+
std
::
to_string
(
id
)
+
","
+
values
+
")"
;
// INT
if
(
id
!=
nRecords
)
{
sql
+=
","
;
}
else
{
...
...
@@ -555,19 +556,17 @@ bool GMDBManager::addRecordsToTable(
{
++
id
;
std
::
string
startRow
=
"("
+
std
::
to_string
(
id
)
+
", "
;
std
::
string
startRow
=
"("
+
std
::
to_string
(
id
)
+
", "
;
// INT
items
.
push_back
(
startRow
);
if
(
std
::
holds_alternative
<
int
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
int
>
(
item
)));
// we need to encapsulate records' values into
// quotes for the SQL query string
items
.
push_back
(
std
::
to_string
(
std
::
get
<
int
>
(
item
)));
// INT
else
if
(
std
::
holds_alternative
<
long
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
long
>
(
item
)));
items
.
push_back
(
std
::
to_string
(
std
::
get
<
long
>
(
item
)));
// INT
else
if
(
std
::
holds_alternative
<
float
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
float
>
(
item
)));
items
.
push_back
(
GeoModelIO
::
CppHelper
::
to_string_with_precision
(
std
::
get
<
float
>
(
item
)));
else
if
(
std
::
holds_alternative
<
double
>
(
item
))
items
.
push_back
(
std
::
to_string
(
std
::
get
<
double
>
(
item
)));
items
.
push_back
(
GeoModelIO
::
CppHelper
::
to_string_with_precision
(
std
::
get
<
double
>
(
item
)));
else
if
(
std
::
holds_alternative
<
std
::
string
>
(
item
))
{
std
::
string
str
=
std
::
get
<
std
::
string
>
(
item
);
...
...
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