userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
text_light.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <string>
8
#include <string_view>
9
#include <vector>
10
11
USERVER_NAMESPACE_BEGIN
12
14
namespace
utils::text
{
15
17
[[nodiscard]]
18
std::string
Trim
(std::string_view str);
19
21
[[nodiscard]]
22
std::string
Trim
(std::string&& str);
23
25
[[nodiscard]]
26
std::string_view
TrimView
(std::string_view str);
27
28
enum class
SplitFlags {
29
kNone = 0,
30
kCompressAdjacentSeparators = 1 << 0,
31
};
32
36
std::vector<std::string>
Split
(
37
std::string_view str,
38
std::string_view separators,
39
SplitFlags split_flags = SplitFlags::kCompressAdjacentSeparators
40
);
41
47
std::vector<std::string_view>
SplitIntoStringViewVector
(std::string_view str, std::string_view separators);
48
50
std::string
Join
(
const
std::vector<std::string>& strs, std::string_view sep);
51
53
std::string
Format
(
double
value,
int
ndigits);
54
57
constexpr
bool
StartsWith
(std::string_view hay, std::string_view needle)
noexcept
{
return
hay.starts_with(needle); }
58
61
constexpr
bool
EndsWith
(std::string_view hay, std::string_view needle)
noexcept
{
return
hay.ends_with(needle); }
62
64
bool
ICaseStartsWith
(std::string_view hay, std::string_view needle)
noexcept
;
65
67
bool
ICaseEndsWith
(std::string_view hay, std::string_view needle)
noexcept
;
68
78
std::string
RemoveQuotes
(std::string_view str);
79
81
bool
IsAscii
(
char
ch)
noexcept
;
82
84
bool
IsAsciiSpace
(
char
ch)
noexcept
;
85
87
bool
IsAscii
(std::string_view
text
)
noexcept
;
88
90
namespace
utf8
{
91
93
std::size_t
CodePointLengthByFirstByte
(
char
c)
noexcept
;
94
96
bool
IsWellFormedCodePoint
(std::string_view
text
)
noexcept
;
97
99
bool
IsValid
(std::string_view
text
)
noexcept
;
100
103
std::size_t
GetCodePointsCount
(std::string_view
text
);
104
108
void
TrimTruncatedEnding
(std::string& str);
109
112
void
TrimViewTruncatedEnding
(std::string_view& view);
113
117
std::size_t
GetTextPosByCodePointPos
(std::string_view
text
, std::size_t pos)
noexcept
;
118
121
void
RemovePrefix
(std::string&
text
, std::size_t count)
noexcept
;
122
125
void
RemoveViewPrefix
(std::string_view&
text
, std::size_t count)
noexcept
;
126
129
void
TakePrefix
(std::string&
text
, std::size_t count)
noexcept
;
130
133
void
TakeViewPrefix
(std::string_view&
text
, std::size_t count)
noexcept
;
134
135
}
// namespace utf8
136
138
bool
IsUtf8
(std::string_view
text
)
noexcept
;
139
144
bool
IsPrintable
(std::string_view
text
,
bool
ascii_only =
true
) noexcept;
145
147
bool
IsCString
(
std
::string_view
text
) noexcept;
148
150
std
::
string
CamelCaseToSnake
(
std
::string_view camel);
151
153
std
::
string
SnakeCaseToCamel
(
std
::string_view snake);
154
155
}
// namespace utils::text
156
157
USERVER_NAMESPACE_END
userver
utils
text_light.hpp
Generated on
for userver by
Doxygen
1.17.0