21 #ifndef GF_STRING_UTILS_H 22 #define GF_STRING_UTILS_H 30 #include "Portability.h" 31 #include "StringRef.h" 34 #ifndef DOXYGEN_SHOULD_SKIP_THIS 48 GF_API std::string
niceNum(
float num,
float precision);
56 GF_API std::string
formatString(
const char *fmt, ...) GF_FORMAT(1, 2);
123 std::swap(current, other.current);
172 return current != other.current;
182 return current == other.current;
188 constexpr char32_t decode() const noexcept {
189 char32_t codepoint = 0;
190 uint8_t c = current[0];
192 if ((c & 0b10000000) == 0b00000000) {
193 codepoint = c & 0b01111111;
194 }
else if ((c & 0b11100000) == 0b11000000) {
195 codepoint = c & 0b00011111;
196 codepoint = (codepoint << 6) + (current[1] & 0b00111111);
197 }
else if ((c & 0b11110000) == 0b11100000) {
198 codepoint = c & 0b00001111;
199 codepoint = (codepoint << 6) + (current[1] & 0b00111111);
200 codepoint = (codepoint << 6) + (current[2] & 0b00111111);
202 assert((c & 0b11111000) == 0b11110000);
203 codepoint = c & 0b00000111;
204 codepoint = (codepoint << 6) + (current[1] & 0b00111111);
205 codepoint = (codepoint << 6) + (current[2] & 0b00111111);
206 codepoint = (codepoint << 6) + (current[3] & 0b00111111);
212 constexpr
void step() noexcept {
213 uint8_t c = current[0];
215 if ((c & 0b10000000) == 0b00000000) {
217 }
else if ((c & 0b11100000) == 0b11000000) {
219 }
else if ((c & 0b11110000) == 0b11100000) {
222 assert((c & 0b11111000) == 0b11110000);
247 #ifndef DOXYGEN_SHOULD_SKIP_THIS 252 #endif // GF_STRING_UTILS_H std::vector< StringRef > splitInParagraphs(StringRef str)
Split a string in multiples paragraphs.
constexpr Iterator & operator++() noexcept
Increment operator (prefix)
Definition: StringUtils.h:149
constexpr bool operator==(const Iterator &other) const noexcept
Equality operator.
Definition: StringUtils.h:181
constexpr const_iterator begin() const noexcept
Get an iterator to the beginning of the string.
Definition: StringRef.h:167
constexpr Iterator end() const noexcept
Definition: StringUtils.h:232
std::forward_iterator_tag iterator_category
Definition: StringUtils.h:117
std::string formatString(const char *fmt,...)
Format a string like printf.
constexpr Iterator operator++(int) noexcept
Increment operator (postfix)
Definition: StringUtils.h:159
std::string escapeString(StringRef str)
Escape a string.
A range over a sequence of codepoints in UTF-8.
Definition: StringUtils.h:109
value_type reference
Definition: StringUtils.h:116
char32_t value_type
Definition: StringUtils.h:114
constexpr const_iterator end() const noexcept
Get an iterator past the end of the string.
Definition: StringRef.h:178
constexpr CodepointRange codepoints(StringRef ref)
Create a range over codepoints from a string.
Definition: StringUtils.h:243
constexpr pointer operator->() const noexcept
Pointer operator.
Definition: StringUtils.h:140
value_type pointer
Definition: StringUtils.h:115
constexpr reference operator*() const noexcept
Dereference operator.
Definition: StringUtils.h:131
std::vector< StringRef > splitInWords(StringRef str)
Split a string in multiples words.
std::ptrdiff_t difference_type
Definition: StringUtils.h:113
StringRef ref
Definition: StringUtils.h:110
constexpr Iterator begin() const noexcept
Definition: StringUtils.h:228
The namespace for gf classes.
Definition: Action.h:35
void swap(Iterator &other) noexcept
Swap the iterator with another iterator.
Definition: StringUtils.h:122
const char * current
Definition: StringUtils.h:185
Definition: StringUtils.h:112
std::string niceNum(float num, float precision)
Create a string representation of a floating point number.
constexpr bool operator!=(const Iterator &other) const noexcept
Inequality operator.
Definition: StringUtils.h:171
A constant reference to a string and its size.
Definition: StringRef.h:41