AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
string.hpp
1// Copyright 2024 Robin Müller
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <string.h>
18
19#include <map>
20#include <vector>
21
22// Additionally include some string utils from rcpputils
23#include "rcpputils/join.hpp"
24
25namespace auto_apms_util
26{
29
30enum class TextColor
31{
32 GREEN,
33 RED,
34 YELLOW,
35 BLUE,
36 MAGENTA,
37 CYAN
38};
39
40using rcpputils::join;
41
55std::vector<std::string> splitString(const std::string & str, const std::string & delimiter, bool remove_empty = true);
56
64std::string printMap(
65 const std::map<std::string, std::string> & map, const std::string & key_val_sep = "=",
66 const std::string & entry_sep = ", ");
67
78std::string makeColoredText(const std::string & text, TextColor color);
79
85std::string trimWhitespaces(const std::string & str);
86
92std::string toCamelCase(const std::string & str);
93
99std::string toSnakeCase(const std::string & str);
100
102
103} // namespace auto_apms_util
std::string trimWhitespaces(const std::string &str)
Trim whitespaces from both ends of a string.
Definition string.cpp:84
std::string makeColoredText(const std::string &text, TextColor color)
Add ANSI color escape sequences to display the text in color when printed to console.
Definition string.cpp:65
std::vector< std::string > splitString(const std::string &str, const std::string &delimiter, bool remove_empty=true)
Split a string into multiple tokens using a specific delimiter string (Delimiter may consist of multi...
Definition string.cpp:24
std::string printMap(const std::map< std::string, std::string > &map, const std::string &key_val_sep="=", const std::string &entry_sep=", ")
Converts a map to a string representation that is suited for printing to console.
Definition string.cpp:50
std::string toCamelCase(const std::string &str)
Transform a string to camelCase.
Definition string.cpp:97
std::string toSnakeCase(const std::string &str)
Transform a string to snake_case.
Definition string.cpp:116
Fundamental helper classes and utility functions.