Provides string utility functions that mimic string methods from Python.
More...
#include <Pythonesque.h>
|
| static std::string | Lstrip (const std::string &str, const std::string &chars=" \\\) |
| | Strips leading whitespace from the given string. More...
|
| |
| static std::string | Rstrip (const std::string &str, const std::string &chars=" \\\) |
| | Strips trailing whitespace from the given string. More...
|
| |
| static std::string | Strip (const std::string &str, const std::string &chars=" \\\) |
| | Strips both leading and trailing whitespace from the given string. More...
|
| |
| static std::string | Replace (const std::string &str, const std::string &oldstr, const std::string &newstr, int count=INT_MAX) |
| | Replaces occurrences of one substring with another within the given string. More...
|
| |
| static BasicStringList | Split (const std::string &str, const std::string &sep, int maxsplit=INT_MAX) |
| | Splits the given string into a list of string tokens. More...
|
| |
| static std::string | Join (const BasicStringList &vec, const std::string &sep) |
| | Joins a list of string tokens, concatenating them into a single string. More...
|
| |
| static bool | Startswith (const std::string &str, const std::string &prefix, int start=0, int end=INT_MAX) |
| | Determines if the given string starts with the specified prefix. More...
|
| |
| static bool | Endswith (const std::string &str, const std::string &suffix, int start=0, int end=INT_MAX) |
| | Determines if the given string ends with the specified suffix. More...
|
| |
| static std::string | Basename (const std::string &path) |
| | Gets the base name (the file name itself, without leading path components) from the given file path. More...
|
| |
|
|
| Pythonesque (void) |
| | Protected constructor; prevents class instantiation.
|
| |
Provides string utility functions that mimic string methods from Python.
- Note
- All methods of this class are static methods.
Definition at line 34 of file Pythonesque.h.
◆ Basename()
| std::string Basename |
( |
const std::string & |
path | ) |
|
|
static |
Gets the base name (the file name itself, without leading path components) from the given file path.
- Parameters
-
| path | The full path name of the given file. |
- Returns
- A string containing the base name.
Definition at line 133 of file Pythonesque.cpp.
◆ Endswith()
| bool Endswith |
( |
const std::string & |
str, |
|
|
const std::string & |
suffix, |
|
|
int |
start = 0, |
|
|
int |
end = INT_MAX |
|
) |
| |
|
static |
Determines if the given string ends with the specified suffix.
- Parameters
-
| str | The original string. |
| suffix | The suffix string to look for. |
| start | The position at which to start looking for the suffix. 0 indicates the beginning. If not given, 0 is assumed. |
| end | The position at which to stop looking for the suffix. If not given, the end of the string is assumed. |
- Returns
- True if the suffix is found, false otherwise.
Definition at line 121 of file Pythonesque.cpp.
◆ Join()
Joins a list of string tokens, concatenating them into a single string.
- Parameters
-
| vec | The list of string tokens to concatenate. |
| sep | The separator that delimits tokens within the string. |
- Returns
- A string with the tokens joined together.
Definition at line 98 of file Pythonesque.cpp.
◆ Lstrip()
| std::string Lstrip |
( |
const std::string & |
str, |
|
|
const std::string & |
chars = " \r\n\t\v\f" |
|
) |
| |
|
static |
Strips leading whitespace from the given string.
- Parameters
-
| str | The original string. |
| chars | The list of whitespace characters to strip. If not specified, strip all whitespace characters. |
- Returns
- A string with the leading whitespace stripped.
Definition at line 25 of file Pythonesque.cpp.
◆ Replace()
| std::string Replace |
( |
const std::string & |
str, |
|
|
const std::string & |
oldstr, |
|
|
const std::string & |
newstr, |
|
|
int |
count = INT_MAX |
|
) |
| |
|
static |
Replaces occurrences of one substring with another within the given string.
- Parameters
-
| str | The original string. |
| oldstr | The substring to be replaced. |
| newstr | The substring doing the replacing. |
| count | If specified, only replace the first <count> occurrences. If not specified, replace all occurrences. |
- Returns
- A string with the replacements made.
Definition at line 62 of file Pythonesque.cpp.
◆ Rstrip()
| std::string Rstrip |
( |
const std::string & |
str, |
|
|
const std::string & |
chars = " \r\n\t\v\f" |
|
) |
| |
|
static |
Strips trailing whitespace from the given string.
- Parameters
-
| str | The original string. |
| chars | The list of whitespace characters to strip. If not specified, strip all whitespace characters. |
- Returns
- A string with the trailing whitespace stripped.
Definition at line 41 of file Pythonesque.cpp.
◆ Split()
| BasicStringList Split |
( |
const std::string & |
str, |
|
|
const std::string & |
sep, |
|
|
int |
maxsplit = INT_MAX |
|
) |
| |
|
static |
Splits the given string into a list of string tokens.
- Parameters
-
| str | The original string. |
| sep | The separator that delimits tokens within the string. |
| maxsplit | If specified, perform only <maxsplit> splits. In this case, the resulting token list will contain at most <maxsplit+1> elements; the last element will be the unsplit portion of the string. If not specified, perform all possible splits. |
- Returns
- A vector of string tokens.
Definition at line 77 of file Pythonesque.cpp.
◆ Startswith()
| bool Startswith |
( |
const std::string & |
str, |
|
|
const std::string & |
prefix, |
|
|
int |
start = 0, |
|
|
int |
end = INT_MAX |
|
) |
| |
|
static |
Determines if the given string starts with the specified prefix.
- Parameters
-
| str | The original string. |
| prefix | The prefix string to look for. |
| start | The position at which to start looking for the prefix. 0 indicates the beginning. If not given, 0 is assumed. |
| end | The position at which to stop looking for the prefix. If not given, the end of the string is assumed. |
- Returns
- True if the prefix is found, false otherwise.
Definition at line 109 of file Pythonesque.cpp.
◆ Strip()
| std::string Strip |
( |
const std::string & |
str, |
|
|
const std::string & |
chars = " \r\n\t\v\f" |
|
) |
| |
|
static |
Strips both leading and trailing whitespace from the given string.
- Parameters
-
| str | The original string. |
| chars | The list of whitespace characters to strip. If not specified, strip all whitespace characters. |
- Returns
- A string with the leading and trailing whitespace stripped.
Definition at line 57 of file Pythonesque.cpp.
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/libcyberradio-24.10.14/libcyberradio/include/LibCyberRadio/Common/Pythonesque.h
- /home/abuild/rpmbuild/BUILD/libcyberradio-24.10.14/libcyberradio/libcyberradio/Common/Pythonesque.cpp