CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
StringUtil.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include <boost/algorithm/string.hpp>
10
11
namespace
carla
{
12
13
class
StringUtil
{
14
public
:
15
16
static
const
char
*
ToConstCharPtr
(
const
char
*str) {
17
return
str;
18
}
19
20
template
<
typename
StringT>
21
static
const
char
*
ToConstCharPtr
(
const
StringT &str) {
22
return
str.c_str();
23
}
24
25
template
<
typename
Range1T,
typename
Range2T>
26
static
bool
StartsWith
(
const
Range1T &input,
const
Range2T &test) {
27
return
boost::algorithm::istarts_with(input, test);
28
}
29
30
template
<
typename
Range1T,
typename
Range2T>
31
static
bool
EndsWith
(
const
Range1T &input,
const
Range2T &test) {
32
return
boost::algorithm::iends_with(input, test);
33
}
34
35
template
<
typename
WritableRangeT>
36
static
void
ToLower
(WritableRangeT &str) {
37
boost::algorithm::to_lower(str);
38
}
39
40
template
<
typename
SequenceT>
41
static
auto
ToLowerCopy
(
const
SequenceT &str) {
42
return
boost::algorithm::to_lower_copy(str);
43
}
44
45
template
<
typename
WritableRangeT>
46
static
void
ToUpper
(WritableRangeT &str) {
47
boost::algorithm::to_upper(str);
48
}
49
50
template
<
typename
SequenceT>
51
static
auto
ToUpperCopy
(
const
SequenceT &str) {
52
return
boost::algorithm::to_upper_copy(str);
53
}
54
55
template
<
typename
WritableRangeT>
56
static
void
Trim
(WritableRangeT &str) {
57
boost::algorithm::trim(str);
58
}
59
60
template
<
typename
SequenceT>
61
static
auto
TrimCopy
(
const
SequenceT &str) {
62
return
boost::algorithm::trim_copy(str);
63
}
64
65
template
<
typename
Container,
typename
Range1T,
typename
Range2T>
66
static
void
Split
(Container &destination,
const
Range1T &str,
const
Range2T &separators) {
67
boost::split(destination, str, boost::is_any_of(separators));
68
}
69
70
/// Match @a str with the Unix shell-style @a wildcard_pattern.
71
static
bool
Match
(
const
char
*str,
const
char
*wildcard_pattern);
72
73
/// Match @a str with the Unix shell-style @a wildcard_pattern.
74
template
<
typename
String1T,
typename
String2T>
75
static
bool
Match
(
const
String1T &str,
const
String2T &wildcard_pattern) {
76
return
Match
(
ToConstCharPtr
(str),
ToConstCharPtr
(wildcard_pattern));
77
}
78
};
79
80
}
// namespace carla
carla::StringUtil
Definition
StringUtil.h:13
carla::StringUtil::ToUpper
static void ToUpper(WritableRangeT &str)
Definition
StringUtil.h:46
carla::StringUtil::Match
static bool Match(const char *str, const char *wildcard_pattern)
Match str with the Unix shell-style wildcard_pattern.
Definition
StringUtil.cpp:20
carla::StringUtil::Split
static void Split(Container &destination, const Range1T &str, const Range2T &separators)
Definition
StringUtil.h:66
carla::StringUtil::Match
static bool Match(const String1T &str, const String2T &wildcard_pattern)
Match str with the Unix shell-style wildcard_pattern.
Definition
StringUtil.h:75
carla::StringUtil::ToConstCharPtr
static const char * ToConstCharPtr(const char *str)
Definition
StringUtil.h:16
carla::StringUtil::ToLowerCopy
static auto ToLowerCopy(const SequenceT &str)
Definition
StringUtil.h:41
carla::StringUtil::ToUpperCopy
static auto ToUpperCopy(const SequenceT &str)
Definition
StringUtil.h:51
carla::StringUtil::TrimCopy
static auto TrimCopy(const SequenceT &str)
Definition
StringUtil.h:61
carla::StringUtil::ToConstCharPtr
static const char * ToConstCharPtr(const StringT &str)
Definition
StringUtil.h:21
carla::StringUtil::EndsWith
static bool EndsWith(const Range1T &input, const Range2T &test)
Definition
StringUtil.h:31
carla::StringUtil::Trim
static void Trim(WritableRangeT &str)
Definition
StringUtil.h:56
carla::StringUtil::ToLower
static void ToLower(WritableRangeT &str)
Definition
StringUtil.h:36
carla::StringUtil::StartsWith
static bool StartsWith(const Range1T &input, const Range2T &test)
Definition
StringUtil.h:26
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0