AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
strings.h
1
#ifndef UTILS_STRINGS_H
2
#define UTILS_STRINGS_H
3
4
#include "downward/utils/exceptions.h"
5
6
#include <sstream>
7
#include <string>
8
#include <vector>
9
10
namespace
utils {
11
extern
void
lstrip(std::string& s);
12
extern
void
rstrip(std::string& s);
13
extern
void
strip(std::string& s);
14
15
/*
16
Split a given string at the first max_splits occurrence of separator. Use
17
the default of -1 for an unlimited amount of splits.
18
*/
19
extern
std::vector<std::string>
20
split(
const
std::string& s,
const
std::string& separator,
int
max_splits = -1);
21
22
extern
bool
startswith(
const
std::string& s,
const
std::string& prefix);
23
24
extern
std::string tolower(std::string s);
25
26
template
<
typename
Collection>
27
std::string join(
const
Collection& collection,
const
std::string& delimiter)
28
{
29
std::ostringstream oss;
30
bool
first_item =
true
;
31
32
for
(
const
auto
& item : collection) {
33
if
(first_item)
34
first_item =
false
;
35
else
36
oss << delimiter;
37
oss << item;
38
}
39
return
oss.str();
40
}
41
42
extern
bool
is_alpha_numeric(
const
std::string& s);
43
}
// namespace utils
44
#endif
downward
utils
strings.h
Generated on Tue Jan 7 2025 for AI 24/25 Project Software by
1.12.0