LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
pretty.h
Go to the documentation of this file.
1
// Copyright 2021 CEA LIST
2
// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3
//
4
// SPDX-License-Identifier: MIT
5
6
#ifndef DEEPLIMA_SRC_INCLUDE_PRETTY_H
7
#define DEEPLIMA_SRC_INCLUDE_PRETTY_H
8
9
#include <string>
10
#include <sstream>
11
#include <cstdint>
12
13
namespace
deeplima
14
{
15
16
inline
std::string
pretty_bits_to_string_one_byte
(
const
uint8_t arg)
17
{
18
std::stringstream s;
19
for
(
size_t
i = 7; i > 0; i--)
20
{
21
s << ((arg & (0x01 << i)) >> i);
22
}
23
s << (arg & 0x01);
24
return
s.str();
25
}
26
27
template
<
class
T>
28
inline
std::string
pretty_bits_to_string
(
const
T arg)
29
{
30
std::stringstream s;
31
for
(
size_t
i =
sizeof
(T) - 1; i > 0; i--)
32
{
33
if
(i <
sizeof
(T) - 1)
34
{
35
s <<
" "
;
36
}
37
s <<
pretty_bits_to_string_one_byte
(uint8_t(arg >> (i * 8)));
38
}
39
s <<
" "
<<
pretty_bits_to_string_one_byte
(uint8_t(arg));
40
return
s.str();
41
}
42
43
}
// namespace deeplima
44
45
#endif
deeplima
Definition
dependency_parser.h:28
deeplima::pretty_bits_to_string_one_byte
std::string pretty_bits_to_string_one_byte(const uint8_t arg)
Definition
pretty.h:16
deeplima::pretty_bits_to_string
std::string pretty_bits_to_string(const T arg)
Definition
pretty.h:28
deeplima
include
deeplima
utils
pretty.h
Generated by
1.9.8