source: cpp/common/util-string.h @ 1303

Last change on this file since 1303 was 1288, checked in by Maciej Komosinski, 13 months ago

Added helper functions

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