[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
[1276] | 2 | // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. |
---|
[286] | 3 | // See LICENSE.txt for details. |
---|
[140] | 4 | |
---|
[840] | 5 | #ifndef _UTIL_STRINGS_H_ |
---|
| 6 | #define _UTIL_STRINGS_H_ |
---|
[140] | 7 | |
---|
| 8 | #include "nonstd_stl.h" |
---|
[180] | 9 | #include <stdarg.h> |
---|
[140] | 10 | |
---|
[1025] | 11 | string repr(const char *str); |
---|
| 12 | |
---|
[257] | 13 | char* strmove(char *a, char *b); //strcpy that works well for overlapping strings ("Source and destination overlap") |
---|
[913] | 14 | bool str_starts_with(const char *str, const char *prefix); |
---|
[1288] | 15 | inline bool starts_with(const string& str, const char *prefix) { return str_starts_with(str.c_str(), prefix); } //std::string.starts_with(...) since c++20 |
---|
[1276] | 16 | bool ends_with(std::string_view str, std::string_view suffix); |
---|
[1288] | 17 | bool strip_prefix(string& modify_me, const char* prefix); //@return true if the prefix is found and removed |
---|
[257] | 18 | |
---|
[140] | 19 | string ssprintf(const char* format, ...); |
---|
[180] | 20 | string ssprintf_va(const char* format, va_list ap); |
---|
[140] | 21 | |
---|
| 22 | string stripExt(const string& filename); // strip extension from filename |
---|
[180] | 23 | string getFileExt(const string& filename); // get extension (starting with ".") from filename |
---|
[246] | 24 | string getFileDir(const string& filename); // get path component excluding filename ("" if no dir in file) |
---|
[460] | 25 | string stripFileDir(const string& filename); // strip path component from filename |
---|
[1288] | 26 | string concatPath(const string& path, const string& other_path); // concatenate paths, adding PATH_SEPARATOR_CHAR if necessary |
---|
[140] | 27 | |
---|
[1016] | 28 | void ltrim_inplace(string &s); |
---|
| 29 | void rtrim_inplace(string &s); |
---|
| 30 | void trim_inplace(string &s); |
---|
| 31 | string ltrim(string s); |
---|
| 32 | string rtrim(string s); |
---|
| 33 | string trim(string s); |
---|
| 34 | |
---|
[140] | 35 | #endif |
---|