Project
Loading...
Searching...
No Matches
strtag.h
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
14
15
#ifndef STRTAG_H
16
#define STRTAG_H
17
18
#include <cstring>
19
#include <cstdint>
20
#include <string>
21
#include <type_traits>
22
23
template
<
class
T = u
int
64_t, std::
size_t
N>
24
constexpr
T
qStr2Tag
(
const
char
(&
str
)[N])
25
{
26
static_assert
(std::is_trivially_copyable_v<T>);
27
static_assert
(N - 1 ==
sizeof
(T),
"Invalid tag length"
);
28
T
value
{};
29
for
(std::size_t
i
= 0;
i
<
sizeof
(T); ++
i
) {
30
value
|= T(
static_cast<
unsigned
char
>
(
str
[
i
])) << (
i
* 8);
31
}
32
return
value
;
33
}
34
35
template
<
class
T>
36
std::string
qTag2Str
(
const
T tag)
37
{
38
T
str
[2];
39
str
[0] = tag;
40
str
[1] = 0;
41
return
std::string((
const
char
*)
str
);
42
}
43
44
#endif
i
int32_t i
Definition
GPUCommonAlgorithm.h:436
value
GLsizei const GLfloat * value
Definition
glcorearb.h:819
qStr2Tag
constexpr T qStr2Tag(const char(&str)[N])
Definition
strtag.h:24
qTag2Str
std::string qTag2Str(const T tag)
Definition
strtag.h:36
str
const std::string str
Definition
test_ransEncodeDecode.cxx:37
GPU
GPUTracking
utils
strtag.h
Generated on Sat Jan 31 2026 18:02:29 for Project by
1.9.8