Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
std_string.cpp
Go to the documentation of this file.
1
#include "
std_string.hpp
"
2
#include <algorithm>
3
#include <cctype>
4
#include <iostream>
5
#include <locale>
6
#include <sstream>
7
#include <vector>
8
9
namespace
bb::detail
{
10
std::vector<std::string>
split
(
const
std::string& str,
char
delimiter)
11
{
12
std::vector<std::string> result;
13
std::istringstream iss(str);
14
std::string token;
15
16
while
(
std::getline
(iss, token, delimiter)) {
17
result.push_back(token);
18
}
19
20
return
result;
21
}
22
23
// trim from start (in place)
24
void
ltrim
(std::string& s)
25
{
26
s.erase(s.begin(),
std::find_if
(s.begin(), s.end(), [](
unsigned
char
ch) { return !std::isspace(ch); }));
27
}
28
29
// trim from end (in place)
30
void
rtrim
(std::string& s)
31
{
32
s.erase(
std::find_if
(s.rbegin(), s.rend(), [](
unsigned
char
ch) { return !std::isspace(ch); }).base(), s.end());
33
}
34
35
// trim from both ends (in place)
36
void
trim
(std::string& s)
37
{
38
rtrim
(s);
39
ltrim
(s);
40
}
41
std::vector<std::string>
split_and_trim
(
const
std::string& str,
char
delimiter)
42
{
43
std::vector<std::string> ret =
split
(str, delimiter);
44
for
(std::string& part : ret) {
45
trim
(part);
46
}
47
return
ret;
48
}
49
}
// namespace bb::detail
bb::detail
Definition
constexpr_utils.hpp:8
bb::detail::split
std::vector< std::string > split(const std::string &str, char delimiter)
Definition
std_string.cpp:10
bb::detail::ltrim
void ltrim(std::string &s)
Definition
std_string.cpp:24
bb::detail::trim
void trim(std::string &s)
Definition
std_string.cpp:36
bb::detail::split_and_trim
std::vector< std::string > split_and_trim(const std::string &str, char delimiter)
Definition
std_string.cpp:41
bb::detail::rtrim
void rtrim(std::string &s)
Definition
std_string.cpp:30
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
std_string.hpp
src
barretenberg
common
std_string.cpp
Generated by
1.9.8