cesium-native 0.52.0
Loading...
Searching...
No Matches
StringHelpers.h
1#pragma once
2
3#include <string>
4#include <string_view>
5#include <vector>
6
7namespace CesiumUtility {
8
13public:
21 static std::string toStringUtf8(const std::u8string& s);
22
27 static std::string_view trimWhitespace(const std::string_view& s);
28
32 struct SplitOptions {
37 bool trimWhitespace{true};
38
47 bool omitEmptyParts{true};
48 };
49
59 static std::vector<std::string_view> splitOnCharacter(
60 const std::string_view& s,
61 char separator,
62 const SplitOptions& options =
63 SplitOptions{.trimWhitespace = true, .omitEmptyParts = true});
64};
65
66} // namespace CesiumUtility
Helper functions for working with strings.
static std::vector< std::string_view > splitOnCharacter(const std::string_view &s, char separator, const SplitOptions &options=SplitOptions{.trimWhitespace=true,.omitEmptyParts=true})
Splits a string view on a specified character.
static std::string_view trimWhitespace(const std::string_view &s)
Trims whitespace (spaces and tabs) from the start and end of a string view.
static std::string toStringUtf8(const std::u8string &s)
Converts a u8string to a string without changing its encoding. The output string is encoded in UTF-8,...
Utility classes for Cesium.
Options that control the behavior of splitOnCharacter.
bool omitEmptyParts
If this option is specified, empty parts will be omitted from the result.
bool trimWhitespace
If this option is specified, whitespace (spaces and tabs) will be trimmed from each part before it is...