|
HDK
|
#include "UT_API.h"#include "UT_StringView.h"#include <SYS/SYS_Compiler.h>#include <SYS/SYS_Inline.h>#include <SYS/SYS_ParseNumber.h>#include <SYS/SYS_String.h>#include <SYS/SYS_Types.h>#include <tuple>#include <string.h>
Include dependency graph for UT_StringUtils.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| SYS_FORCE_INLINE bool | UTisstring (const char *s) |
| template<typename T , bool HasFastLength = true> | |
| SYS_NO_DISCARD_RESULT bool | UTstringStartsWith (const T &str, const char *prefix, bool case_sensitive=true, exint len=-1) |
| template<typename T > | |
| SYS_NO_DISCARD_RESULT bool | UTstringEndsWith (const T &str, const char *suffix, bool case_sensitive=true, exint len=-1) |
| template<typename T > | |
| SYS_NO_DISCARD_RESULT const char * | UTstringNumericSuffix (const T &str) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT UT_StringView | UTstringFileName (const StringT &str) |
| template<> | |
| SYS_NO_DISCARD_RESULT UT_StringView | UTstringFileName (const UT_StringView &str) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT std::tuple< UT_StringView, UT_StringView, UT_StringView > | UTstringSplitPath (const StringT &str) |
| Split the given path into the directory, filename, and file extension. More... | |
| template<> | |
| SYS_NO_DISCARD_RESULT std::tuple< UT_StringView, UT_StringView, UT_StringView > | UTstringSplitPath (const UT_StringView &str) |
| Split the given path into the directory, filename, and file extension. More... | |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT UT_StringView | UTstringFileExtension (const StringT &str) |
| template<> | |
| SYS_NO_DISCARD_RESULT UT_StringView | UTstringFileExtension< UT_StringView > (const UT_StringView &str) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT bool | UTstringMatchFileExtension (const StringT &str, const char *extension) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT int | UTstringCountChar (const StringT &str, int c) |
| template<> | |
| SYS_NO_DISCARD_RESULT int | UTstringCountChar< UT_StringView > (const UT_StringView &str, int c) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT bool | UTstringIsFloat (const StringT &str, bool skip_spaces=false, bool loose=false, bool allow_underscore=false) |
| template<> | |
| SYS_NO_DISCARD_RESULT bool | UTstringIsFloat< UT_StringView > (const UT_StringView &str, bool skip_spaces, bool loose, bool allow_underscore) |
| template<typename StringT > | |
| SYS_NO_DISCARD_RESULT bool | UTstringIsInteger (const StringT &str, bool skip_spaces=false) |
| template<> | |
| SYS_NO_DISCARD_RESULT bool | UTstringIsInteger< UT_StringView > (const UT_StringView &str, bool skip_spaces) |
| template<typename StringT > | |
| bool | UTstringParseNumberedFilename (const StringT &str, UT_StringView &prefix, UT_StringView &frame, UT_StringView &suffix, bool negative, bool fractional) |
| template<typename StringT > | |
| bool | UTstringParseNumberedFilename (const StringT &str, UT_StringHolder &prefix, UT_StringHolder &frame, UT_StringHolder &suffix, bool negative, bool fractional) |
| template<typename StringT > | |
| bool | UTstringIsQuoted (const StringT &str, char delimiter) |
| template<typename StringT , typename IntT > | |
| SYS_ParseStatus | UTstringToInt (const StringT &str, IntT &number, int base=0, SYS_ParseFlags flags=SYS_ParseFlags::None) |
| template<typename IntT , typename StringT > | |
| SYS_NO_DISCARD_RESULT IntT | UTstringToInt (const StringT &str, int base=0, SYS_ParseFlags flags=SYS_ParseFlags::None) |
| template<typename StringT > | |
| void | UTstringGetRelativePath (StringT &result, const char *src_fullpath, const char *dest_fullpath, bool file_path=false, bool allow_relative_path_from_root=true) |
| UT_API bool | UTspinNumericText (const UT_StringView &text, int cursor, bool is_float, int direction, UT_StringHolder &out_text, int &out_cursor, int max_precision=-1, fpreal64 min_value=-SYS_FP64_MAX, fpreal64 max_value=SYS_FP64_MAX) |
| SYS_FORCE_INLINE bool UTisstring | ( | const char * | s | ) |
Definition at line 29 of file UT_StringUtils.h.
| UT_API bool UTspinNumericText | ( | const UT_StringView & | text, |
| int | cursor, | ||
| bool | is_float, | ||
| int | direction, | ||
| UT_StringHolder & | out_text, | ||
| int & | out_cursor, | ||
| int | max_precision = -1, |
||
| fpreal64 | min_value = -SYS_FP64_MAX, |
||
| fpreal64 | max_value = SYS_FP64_MAX |
||
| ) |
Step the numeric value at the cursor by one unit. The place value stepped is determined by the cursor position relative to the digit immediately to its right.
Briefly: Rule 1: cursor before a digit -> step that digit's place. Rule 2: cursor before '.' (float field) -> step the first digit past the '.' (always tenths). Rule 3: cursor at end of a numeric token (float field) -> step one place finer than the rightmost digit (precision extension). Otherwise: returns false; caller should fall back to default text-input behavior.
On success (returns true), out_text and out_cursor are written. On failure (returns false), out parameters are left unchanged.
| text | Input text (a numeric or expression field). |
| cursor | Cursor position [0, text.length()]. |
| is_float | True for float fields (enables rules 2 and 3). |
| direction | +1 to increase value (Up), -1 to decrease (Down). |
| out_text | Resulting text on success. |
| out_cursor | Resulting cursor index on success. |
| max_precision | Max decimal places for rule 3. -1 means unlimited. |
| min_value | Min legal value (clamped silently). |
| max_value | Max legal value (clamped silently). |
| SYS_NO_DISCARD_RESULT int UTstringCountChar | ( | const StringT & | str, |
| int | c | ||
| ) |
Definition at line 208 of file UT_StringUtils.h.
|
inline |
Definition at line 216 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT bool UTstringEndsWith | ( | const T & | str, |
| const char * | suffix, | ||
| bool | case_sensitive = true, |
||
| exint | len = -1 |
||
| ) |
Definition at line 59 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT UT_StringView UTstringFileExtension | ( | const StringT & | str | ) |
Definition at line 170 of file UT_StringUtils.h.
|
inline |
Definition at line 179 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT UT_StringView UTstringFileName | ( | const StringT & | str | ) |
Definition at line 100 of file UT_StringUtils.h.
|
inline |
Definition at line 109 of file UT_StringUtils.h.
| void UTstringGetRelativePath | ( | StringT & | result, |
| const char * | src_fullpath, | ||
| const char * | dest_fullpath, | ||
| bool | file_path = false, |
||
| bool | allow_relative_path_from_root = true |
||
| ) |
This function will calculate the relative path to get from src to dest. If file_path is false, this method assume it is dealing with node paths. If file_path is true, it will also deal with Windows drive letters and UNC paths.
If we are doing file path comparisons then the source and dest are treated as files. So getting from /a/b to /a/c is just "c". But "/a/b/" to "/a/c" is "../c", using the trailing slash on the source path to indicate it specifies a directory instead of a file.
| SYS_NO_DISCARD_RESULT bool UTstringIsFloat | ( | const StringT & | str, |
| bool | skip_spaces = false, |
||
| bool | loose = false, |
||
| bool | allow_underscore = false |
||
| ) |
Definition at line 239 of file UT_StringUtils.h.
|
inline |
Definition at line 337 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT bool UTstringIsInteger | ( | const StringT & | str, |
| bool | skip_spaces = false |
||
| ) |
Definition at line 350 of file UT_StringUtils.h.
|
inline |
Definition at line 387 of file UT_StringUtils.h.
| bool UTstringIsQuoted | ( | const StringT & | str, |
| char | delimiter | ||
| ) |
Definition at line 487 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT bool UTstringMatchFileExtension | ( | const StringT & | str, |
| const char * | extension | ||
| ) |
Definition at line 200 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT const char* UTstringNumericSuffix | ( | const T & | str | ) |
Definition at line 82 of file UT_StringUtils.h.
| bool UTstringParseNumberedFilename | ( | const StringT & | str, |
| UT_StringView & | prefix, | ||
| UT_StringView & | frame, | ||
| UT_StringView & | suffix, | ||
| bool | negative, | ||
| bool | fractional | ||
| ) |
Decompose a filename into various parts
parseNumberedFileName will breakup a filename into its various parts: file = prefix$Fsuffix (note: suffix is not the same as file extension.) 0 is returned if there is no frame number. 'negative' allows -[frame] to be interpreted as a negative number. 'fractional' allows [frame].[number] to be interpreted as a fractional frame.
WARNING: Make sure to take care of lifetimes when the input string is UT_StringView.
Definition at line 407 of file UT_StringUtils.h.
| bool UTstringParseNumberedFilename | ( | const StringT & | str, |
| UT_StringHolder & | prefix, | ||
| UT_StringHolder & | frame, | ||
| UT_StringHolder & | suffix, | ||
| bool | negative, | ||
| bool | fractional | ||
| ) |
Decompose a filename into various parts
parseNumberedFileName will breakup a filename into its various parts: file = prefix$Fsuffix (note: suffix is not the same as file extension.) 0 is returned if there is no frame number. 'negative' allows -[frame] to be interpreted as a negative number. 'fractional' allows [frame].[number] to be interpreted as a fractional frame.
| SYS_NO_DISCARD_RESULT std::tuple<UT_StringView, UT_StringView, UT_StringView> UTstringSplitPath | ( | const StringT & | str | ) |
Split the given path into the directory, filename, and file extension.
Definition at line 127 of file UT_StringUtils.h.
|
inline |
Split the given path into the directory, filename, and file extension.
Definition at line 137 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT bool UTstringStartsWith | ( | const T & | str, |
| const char * | prefix, | ||
| bool | case_sensitive = true, |
||
| exint | len = -1 |
||
| ) |
Definition at line 33 of file UT_StringUtils.h.
| SYS_ParseStatus UTstringToInt | ( | const StringT & | str, |
| IntT & | number, | ||
| int | base = 0, |
||
| SYS_ParseFlags | flags = SYS_ParseFlags::None |
||
| ) |
Definition at line 498 of file UT_StringUtils.h.
| SYS_NO_DISCARD_RESULT IntT UTstringToInt | ( | const StringT & | str, |
| int | base = 0, |
||
| SYS_ParseFlags | flags = SYS_ParseFlags::None |
||
| ) |
Definition at line 511 of file UT_StringUtils.h.