Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEP
HEPnOS
Commits
b77d842b
Commit
b77d842b
authored
Jan 24, 2020
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using binary format numbers instead of hexadecimal in keys
parent
300b1d0f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
20 deletions
+123
-20
src/Event.cpp
src/Event.cpp
+2
-6
src/Run.cpp
src/Run.cpp
+2
-6
src/SubRun.cpp
src/SubRun.cpp
+2
-6
src/private/EventImpl.hpp
src/private/EventImpl.hpp
+39
-0
src/private/RunImpl.hpp
src/private/RunImpl.hpp
+40
-2
src/private/SubRunImpl.hpp
src/private/SubRunImpl.hpp
+38
-0
No files found.
src/Event.cpp
View file @
b77d842b
...
...
@@ -51,12 +51,8 @@ Event Event::next() const {
if
(
s
==
0
)
return
Event
();
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
Event
();
if
(
keys
[
0
][
i
]
!=
'%'
)
return
Event
();
std
::
stringstream
strEventNumber
;
strEventNumber
<<
std
::
hex
<<
keys
[
0
].
substr
(
i
+
1
);
EventNumber
n
;
strEventNumber
>>
n
;
EventNumber
n
=
Impl
::
parseEventNumberFromKeyString
(
&
keys
[
0
][
i
]);
if
(
n
==
InvalidEventNumber
)
return
Event
();
return
Event
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
n
);
}
...
...
src/Run.cpp
View file @
b77d842b
...
...
@@ -53,12 +53,8 @@ Run Run::next() const {
if
(
s
==
0
)
return
Run
();
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
Run
();
if
(
keys
[
0
][
i
]
!=
'%'
)
return
Run
();
std
::
stringstream
strRunNumber
;
strRunNumber
<<
std
::
hex
<<
keys
[
0
].
substr
(
i
+
1
);
RunNumber
rn
;
strRunNumber
>>
rn
;
RunNumber
rn
=
Impl
::
parseRunNumberFromKeyString
(
&
keys
[
0
][
i
]);
if
(
rn
==
InvalidRunNumber
)
return
Run
();
return
Run
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
rn
);
}
...
...
src/SubRun.cpp
View file @
b77d842b
...
...
@@ -56,12 +56,8 @@ SubRun SubRun::next() const {
if
(
s
==
0
)
return
SubRun
();
size_t
i
=
m_impl
->
m_container
->
size
()
+
1
;
if
(
keys
[
0
].
size
()
<=
i
)
return
SubRun
();
if
(
keys
[
0
][
i
]
!=
'%'
)
return
SubRun
();
std
::
stringstream
strSubRunNumber
;
strSubRunNumber
<<
std
::
hex
<<
keys
[
0
].
substr
(
i
+
1
);
SubRunNumber
rn
;
strSubRunNumber
>>
rn
;
SubRunNumber
rn
=
Impl
::
parseSubRunNumberFromKeyString
(
&
keys
[
0
][
i
]);
if
(
rn
==
InvalidSubRunNumber
)
return
SubRun
();
return
SubRun
(
m_impl
->
m_datastore
,
m_impl
->
m_level
,
m_impl
->
m_container
,
rn
);
}
...
...
src/private/EventImpl.hpp
View file @
b77d842b
...
...
@@ -6,6 +6,7 @@
#ifndef __HEPNOS_PRIVATE_EVENT_IMPL_H
#define __HEPNOS_PRIVATE_EVENT_IMPL_H
#include <boost/predef/other/endian.h>
#include <sstream>
#include <iomanip>
#include <memory>
...
...
@@ -29,9 +30,47 @@ class Event::Impl {
,
m_event_nr
(
n
)
{}
static
std
::
string
makeKeyStringFromEventNumber
(
const
EventNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
EventNumber
parseEventNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidEventNumber
;
EventNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strEventNumber
;
strEventNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strEventNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromEventNumber
()
const
{
...
...
src/private/RunImpl.hpp
View file @
b77d842b
...
...
@@ -29,10 +29,48 @@ class Run::Impl {
,
m_container
(
container
)
,
m_run_nr
(
rn
)
{}
static
std
::
string
makeKeyStringFromRunNumber
(
const
RunNumber
&
nr
)
{
static
std
::
string
makeKeyStringFromRunNumber
(
const
RunNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
r
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
RunNumber
parseRunNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidRunNumber
;
RunNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strRunNumber
;
strRunNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strRunNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromRunNumber
()
const
{
...
...
src/private/SubRunImpl.hpp
View file @
b77d842b
...
...
@@ -30,9 +30,47 @@ class SubRun::Impl {
,
m_subrun_nr
(
rn
)
{}
static
std
::
string
makeKeyStringFromSubRunNumber
(
const
SubRunNumber
&
n
)
{
std
::
string
str
(
1
+
sizeof
(
n
),
'\0'
);
str
[
0
]
=
'%'
;
#ifndef HEPNOS_READABLE_NUMBERS
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
str
[
1
],
&
n
,
sizeof
(
n
));
return
str
;
#else
unsigned
i
=
sizeof
(
n
);
auto
n2
=
n
;
while
(
n2
!=
0
)
{
str
[
i
]
=
n2
&
0xff
;
n2
=
n2
>>
8
;
i
-=
1
;
}
return
str
;
#endif
#else
std
::
stringstream
strstr
;
strstr
<<
"%"
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
std
::
hex
<<
n
;
return
strstr
.
str
();
#endif
}
static
SubRunNumber
parseSubRunNumberFromKeyString
(
const
char
*
str
)
{
if
(
str
[
0
]
!=
'%'
)
return
InvalidSubRunNumber
;
SubRunNumber
n
;
#ifdef HEPNOS_READABLE_NUMBERS
std
::
stringstream
strSubRunNumber
;
strSubRunNumber
<<
std
::
hex
<<
std
::
string
(
str
+
1
,
16
);
strSubRunNumber
>>
n
;
#else
#if BOOST_ENDIAN_BIG_BYTE
std
::
memcpy
(
&
n
,
&
str
[
1
],
sizeof
(
n
));
#else
n
=
0
;
for
(
unsigned
i
=
0
;
i
<
sizeof
(
n
);
i
++
)
{
n
=
256
*
n
+
str
[
i
+
1
];
}
#endif
#endif
return
n
;
}
std
::
string
makeKeyStringFromSubRunNumber
()
const
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment