userver
C++ Async Framework
Loading...
Searching...
No Matches
bytes_per_second.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/bytes_per_second.hpp
4
/// @brief @copybrief utils::BytesPerSecond
5
/// @ingroup userver_universal
6
7
#
include
<
string
>
8
9
#
include
<
userver
/
formats
/
parse
/
to
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
utils
{
14
15
/// @ingroup userver_universal userver_containers
16
///
17
/// @brief Data type that represents `bytes per second` unit
18
enum
class
BytesPerSecond
:
long
long
{};
19
20
constexpr
long
long
ToLongLong(
BytesPerSecond
x) {
return
static_cast
<
long
long
>(x); }
21
22
constexpr
bool
operator==(
BytesPerSecond
lhs,
BytesPerSecond
rhs) {
return
ToLongLong(lhs) == ToLongLong(rhs); }
23
24
constexpr
bool
operator!=(
BytesPerSecond
lhs,
BytesPerSecond
rhs) {
return
!(lhs == rhs); }
25
26
/// Understands all the date-rate unit suffixes from
27
/// https://en.wikipedia.org/wiki/Data-rate_units#Conversion_table
28
BytesPerSecond
StringToBytesPerSecond
(
const
std::string& data);
29
30
template
<
class
Value>
31
BytesPerSecond
Parse(
const
Value& v, formats::
parse
::
To
<
BytesPerSecond
>) {
32
return
StringToBytesPerSecond(v.
template
As<std::string>());
33
}
34
35
}
// namespace utils
36
37
USERVER_NAMESPACE_END
userver
utils
bytes_per_second.hpp
Generated on Tue Nov 19 2024 11:34:19 for userver by
Doxygen
1.10.0