ADTF
3.18.2
|
File name class. More...
Public Member Functions | |
cFilename () | |
Constructor that initializes an empty cFilename object. | |
cFilename (const cFilename &oFilename) | |
Constructor that initializes the object with an existing cFilename object. More... | |
cFilename & | operator= (const cFilename &i_oOther) |
Copy assignment operator. More... | |
cFilename (const cString &strString) | |
Constructor that initializes the filename with an existing cString object. More... | |
cFilename (const tChar *pString) | |
Constructor that initializes the filename with a null-terminated string. More... | |
cFilename (char cChar) | |
Constructor that initializes the filename with a single character. More... | |
cFilename (cFilename &&i_oOther) | |
Implements move construction. More... | |
cFilename & | operator= (cFilename &&i_oOther) |
Implements move assignment. More... | |
virtual | ~cFilename () |
Destructor. | |
cFilename & | operator= (tChar cChar) |
assigns a given string More... | |
cFilename & | operator= (const tChar *pString) |
assigns a given string More... | |
cFilename & | operator= (const cString &sString) |
assigns a given string More... | |
cFilename | GetRoot () const |
This function extract the root component of a filename (without double point). More... | |
cFilename | GetPath () const |
This function extract the path of the parent folder and/or the root component of a file/folder. More... | |
cString | GetName () const |
This function extracts the name component of a filename. More... | |
cString | GetNameWithoutExtension () const |
This function extract the name component of a filename. More... | |
cString | GetExtension () const |
This function extract the extension of a filename. More... | |
cString | GetDrive () const |
This function extracts the drive name of a filename (e.g. More... | |
tChar | GetDriveLetter () const |
cFilename & | SetExtension (const cString &strExtension) |
This function changes the extension of a filename. More... | |
cFilename & | AppendTrailingSlash () |
This function appends a trailing slash to the filename if there isn't one, yet. More... | |
cFilename & | RemoveTrailingSlash () |
This function removes a trailing slash from the filename if there is one. More... | |
cFilename & | MakeNativeSlashes () |
This function changes all slashes to OS specific slashes. More... | |
cFilename & | MakeBackwardSlashes () |
This function changes all forward slashes to backslashes. More... | |
cFilename & | MakeForwardSlashes () |
This function changes all backslashes to forward slashes. More... | |
cFilename | CreateRelativePath (const cFilename &strParent) const |
This function creates a relative path for this file regarding the given parent (Only works with native slashes!). More... | |
cFilename | CreateAbsolutePath (const cFilename &strParent) const |
This function creates an absolute path for this file regarding the given parent (Only works with native slashes!). More... | |
tBool | IsRelative () const |
This function checks the filename if it is relative. More... | |
tBool | IsAbsolute () const |
This function checks the filename if it is absolute. More... | |
cFilename & | AppendPath (const cFilename &strPath) |
Append a path string to current string. More... | |
cFilename & | CleanPath () |
This function resolves relative components ("." or "..") within an absolute path. More... | |
tVoid | SplitPath (cStringList &List) const |
Split path into a string list. More... | |
Public Member Functions inherited from string_base< cStackString > | |
string_base () | |
Constructor that initializes an empty cStringA object. | |
string_base (const _myType &strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (_myType &&strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (const string_base< T2 > &strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (const _StorageType &strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (const tChar &strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (const tChar *strValue) | |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base (const tChar *strValue, tSize szLength) | |
Constructor that initalizes an existing cString object with the spezified string value. More... | |
string_base & | operator= (const _myType &strValue) |
The cString assignment (=) operator assigns a new value to the existing cString object. More... | |
string_base & | operator= (_myType &&strValue) |
The cString assignment (=) operator assigns a new value to the existing cString object. More... | |
string_base & | operator= (const string_base< T2 > &strValue) |
Constructor that initalizes an existing cString object with the spezified string value. | |
string_base & | operator= (const _StorageType &strValue) |
The cString assignment (=) operator assigns a new value to the existing cString object. More... | |
string_base & | operator= (const tChar &strValue) |
The cString assignment (=) operator assigns a new value to the existing cString object. More... | |
string_base & | operator= (const tChar *strValue) |
The cString assignment (=) operator assigns a new value to the existing cString object. More... | |
virtual | ~string_base () |
Destructor. | |
iterator | begin () |
Iterator to beginning. | |
iterator | end () |
Iterator to end. | |
reverse_iterator | rbegin () |
Reverse iterator to beginning. | |
reverse_iterator | rend () |
Reverse iterator to end. | |
const_iterator | cbegin () const |
Iterator to beginning. | |
const_iterator | cend () const |
Iterator to end. | |
const_reverse_iterator | crbegin () const |
Reverse iterator to beginning. | |
const_reverse_iterator | crend () const |
Reverse iterator to end. | |
tVoid | Clear () |
Makes this cStringA object an empty string and frees memory as appropriate. | |
_myType & | Set (const _myType &strStringToSet, tSize nLength=InvalidPos) |
Assigns a new value to a cStringA object. More... | |
_myType & | Set (const tChar *pString, tSize nLength=InvalidPos) |
Assigns a new value to a cStringA object. More... | |
_myType & | Set (tChar c, tSize nCount) |
Assigns a new value to a cStringA object. More... | |
tSize | GetLength () const |
This function returns the number of characters in a cStringA object. More... | |
tSize | SetBuffer (tSize szSize) |
Sets or resizes the internal string buffer. More... | |
tSize | GetBufferSize () const |
Get the size of the internal allocated string buffer. More... | |
tChar | GetAt (tSize nIdx) const |
You can think of a cStringA object as an array of characters. More... | |
tVoid | SetAt (tSize nIdx, tChar c) |
The SetAt member function sets a single character at a specified position. More... | |
const tChar & | operator[] (tSize nIdx) const |
array access operator More... | |
tChar & | operator[] (tSize nIdx) |
array access operator More... | |
tBool | IsEmpty () const |
This function checks if the string object is empty. More... | |
tBool | IsNotEmpty () const |
This function checks if the string object is not empty. More... | |
const tChar * | GetPtr () const |
This function returns the current string as an array of characters (c-style) More... | |
tChar * | GetBuffer () |
This function returns the pointer to the data. More... | |
_myType & | Append (const _myType &strString, tSize nLength=InvalidPos) |
This function appends a string to the end of the cStringA object. More... | |
_myType & | Append (tChar c) |
This function appends one character to the end of the cStringA object. More... | |
_myType & | Delete (tSize nPos, tSize nLength=InvalidPos) |
This function deletes a substring of length nLength characters from the cStringA object, starting at position nPos (zero-based). More... | |
_myType & | Insert (const _myType &strToInsertString, tSize nPos, tSize nLength=InvalidPos) |
This function inserts a string into the cStringA object. More... | |
_myType & | Insert (const tChar *pToInsertString, tSize nPos, tSize nLength=InvalidPos) |
This function inserts a string into the cStringA object. More... | |
tInt | Compare (const _myType &strString, tSize nPos=0, tSize nLength=InvalidPos) const |
This function compares a cStringA object with another string using the generic-text function _tcscmp. More... | |
tInt | Compare (const tChar *strString, tSize nPos=0, tSize nLength=InvalidPos) const |
This function compares a cStringA object with another string using the generic-text function _tcscmp. More... | |
tInt | CompareNoCase (const _myType &strString, tSize nPos=0, tSize nLength=InvalidPos) const |
This function compares a cStringA object with another string using the generic-text function _tcsicmp. More... | |
tBool | IsEqual (const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const |
This function checks if the two strings are equal (case sensitive) More... | |
tBool | IsEqualNoCase (const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const |
This function checks if the two strings are equal (case insensitive) More... | |
tBool | IsNotEqual (const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const |
This function checks if the two strings are not equal (case sensitive) More... | |
tBool | IsNotEqualNoCase (const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const |
This function checks if the two strings are not equal (case insensitive) More... | |
tSize | Find (const _myType &strStringToFind, tSize nStart=0, const tBool bNoCase=tFalse) const |
This function searches the cStringA object for the first match of a substring. More... | |
tSize | Find (tChar cToFind, tSize nStart=0) const |
This function searches the cStringA object for the first match of the specified character. More... | |
tSize | RFind (tChar cChar, tSize nStart=0) const |
This function searches the cStringA object for the last match of the specified character. More... | |
tSize | FindToken (const _myType &strTokenList, tSize nStart=0) const |
This function searches a string for the first character that matches any character contained in a token list. More... | |
tSize | FindNotToken (const _myType &strTokenList, tSize nStart=0) const |
This function searches a string for the first character that matches none of the characters contained in a token list. More... | |
tSize | CountString (const _myType &strFind, tSize nStart=0) const |
This counts the occurrences of a given substring in a string. More... | |
tSize | Replace (const _myType &strOld, const _myType &strNew, tBool bReplaceAll=tTrue) |
This function replaces one substring by another. More... | |
tSize | Replace (tChar cOld, tChar cNew, tBool bReplaceAll=tTrue) |
This function replaces one character by another. More... | |
tSize | Filter (tChar cChar) |
This function removes all occurrences of a given character from a string. More... | |
tSize | Filter (const _myType &strCharList) |
This function removes all occurrences of each character given in a token list. More... | |
tBool | StartsWith (const _myType &strStartsWith, const tBool bNoCase=tFalse) const |
This function checks if the string starts with a given prefix. More... | |
tSize | RSplitByToken (const tChar cToken, _myType &strFirst, _myType &strSecond) const |
tSize | SplitByToken (const tChar cToken, _myType &strFirst, _myType &strSecond) const |
tBool | EndsWith (const _myType &strEndsWith, const tBool bNoCase=tFalse) const |
This function checks if the string ends with a given postfix. More... | |
operator const tChar * () const | |
This useful casting operator provides an efficient method to access the null- terminated C string contained in a cStringA object. More... | |
const _myType & | operator+= (const _myType &strString) |
The += concatenation operator joins characters to the end of this string. More... | |
tBool | operator== (const tChar *pString) const |
Checks if a string equals the cStringA object. More... | |
tBool | operator== (const _myType &strString) const |
Checks if a string equals the cStringA object. More... | |
tBool | operator!= (const tChar *pString) const |
Checks if a string does not equal the cStringA object. More... | |
tBool | operator!= (const _myType &strString) const |
Checks if a string not equals the cStringA object. More... | |
tBool | operator< (const tChar *pString) const |
Checks if a string is lexicographically greater than the cStringA object. More... | |
tBool | operator< (const _myType &strString) const |
Checks if a string is lexicographically greater than the cStringA object. More... | |
tBool | operator> (const tChar *pString) const |
Checks if a string is lexicographically smaller than the cStringA object. More... | |
tBool | operator> (const _myType &strString) const |
Checks if a string is lexicographically smaller than the cStringA object. More... | |
tBool | operator<= (const tChar *pString) const |
Checks if a string is lexicographically greater than or equal to the cStringA object. More... | |
tBool | operator<= (const _myType &strString) const |
Checks if a string is lexicographically greater than or equal to the cStringA object. More... | |
tBool | operator>= (const tChar *pString) const |
Checks if a string is lexicographically smaller than or equal to the cStringA object. More... | |
tBool | operator>= (const _myType &strString) const |
Checks if a string is lexicographically smaller than or equal to the cStringA object. More... | |
_myType | SubString (tSize nPos, tSize nLength=InvalidPos) const |
This function extracts a substring of length nLength characters from the cStringA object, starting at position nPos (zero-based). More... | |
_myType | Mid (tSize nPos, tSize nLength=InvalidPos) const |
This function extracts a substring of length nLength characters from the cStringA object, starting at position nPos (zero-based). More... | |
_myType | Left (tSize nLength) const |
Extracts the first (that is, leftmost) nLength characters from the cStringA object and returns a copy of the extracted substring. More... | |
_myType | Right (tSize nLength) const |
Extracts the last (that is, rightmost) nLength characters from the cStringA object and returns a copy of the extracted substring. More... | |
tVoid | Split (string_list_base< _myType > &lstSplittedResult, tChar cToken) const |
This function splits up a single cStringA object into several parts using a token character. More... | |
tVoid | Split (string_list_base< _myType > &lstSplittedResult, const _myType &strToken) const |
This function splits up a single cStringA object into several parts using a token string. More... | |
tVoid | SplitToken (string_list_base< _myType > &lstList, const _myType &strTokenList) const |
Split string using a token list. More... | |
tVoid | Trim () |
This function removes leading and trailing whitespace characters from a cStringA object. More... | |
tVoid | LeftTrim (tBool bNumTrim=tFalse) |
This function removes leading whitespace characters or leading zero characters from a cStringA object. More... | |
tVoid | RightTrim () |
This function removes trailing whitespace characters from a cStringA object. | |
tVoid | NumTrim () |
This function removes whitespace and redundant zero characters from a cStringA object. More... | |
tVoid | DropQuotes () |
This function removes quotes from a cStringA object. More... | |
tVoid | ToLower () |
This function converts a cStringA object to a lowercase string. More... | |
tVoid | ToUpper () |
This function converts a cStringA object to an uppercase string. More... | |
_myType & | Escape () |
Escape control characters. More... | |
_myType & | Unescape () |
Escape control characters. More... | |
tBool | IsInteger () const |
Check if string content represents an integer value. More... | |
tBool | IsFloat () const |
Check if string content represents a floating point value. More... | |
tBool | IsNumeric () const |
Check if string content represents a numeric value. More... | |
tInt32 | AsInt32 () const |
This function converts the string to an integer value. More... | |
tVoid | ToType (tInt32 &i32Value) const |
This function converts the string to an integer value. More... | |
tVoid | ToType (tUInt32 &ui32Value) const |
This function converts the string to an integer value. More... | |
tVoid | ToType (tInt64 &i64Value) const |
This function converts the string to an integer value. More... | |
tVoid | ToType (tUInt64 &ui64Value) const |
This function converts the string to an integer value. More... | |
tVoid | ToType (tFloat64 &f64Value) const |
This function converts the string to a floating-point value. More... | |
tVoid | ToType (tFloat32 &f32Value) const |
This function converts the string to a floating-point value. More... | |
tVoid | ToType (tBool &bValue) const |
This function converts the string to a boolean value. More... | |
tUInt32 | AsUInt32 () const |
This function converts the string to an integer value. More... | |
tInt64 | AsInt64 () const |
This function converts the string to an integer value. More... | |
tUInt64 | AsUInt64 () const |
This function converts the string to an integer value. More... | |
tFloat64 | AsFloat64 () const |
This function converts the string to a floating-point value. More... | |
tFloat32 | AsFloat32 () const |
This function converts the string to a floating-point value. More... | |
tBool | AsBool () const |
This function converts the string to a boolean value. More... | |
tInt64 | HexToInt64 () const |
This function converts a hexadecimal string representation to an integer value. More... | |
tSize | GetMaxBufferSize () const |
Return maximum size of string buffer. More... | |
tVoid | HexToType (tInt64 &i64Value) const |
This function converts a hexadecimal string representation to an integer value. More... | |
Static Public Member Functions | |
static cFilename | JoinPath (const cFilename &strPath1, const cFilename &strPath2) |
This function joins two subpaths (strPath1 and strPath2) to a new one. More... | |
static tBool | IsSlash (tChar c) |
This function checks if a character is a slash. More... | |
Static Public Member Functions inherited from string_base< cStackString > | |
static _myType | Repeat (tChar c, tSize nCount) |
Creates a string from a repeated character. More... | |
static _myType | FromType (tInt32 i32Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tUInt32 ui32Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tInt64 i64Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tUInt64 ui64Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tFloat64 f64Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tFloat32 f32Value, const _myType &strFormat=Empty) |
This function creates a new cString object from a numeric value. More... | |
static _myType | FromType (tBool bValue, const _myType &strFormat=Empty) |
This function creates a new cString object from a boolean value. More... | |
static _myType | Format (const value_type *strFormat,...) |
Write formatted data to a string. More... | |
static _myType | ToStringFromType (T oValue, const _myType &strFormat) |
This function creates a new cString object from a numeric value. More... | |
static _myType & | Copy (_myType &strDestination, const _myType &strSource, tSize szLength=InvalidPos) |
Copies the value of one StringObject to another Stringobject. More... | |
Static Public Attributes | |
static constexpr const tChar | WINDOWS_SLASH = '\\' |
the windows slash is '\' | |
static constexpr const tChar | UNIX_SLASH = '/' |
the unis slash is '/' | |
static constexpr const tChar *const | WINDOWS_DOUBLE_SLASH = "\\\\" |
the windows slash is "\\\\" | |
static constexpr const tChar *const | UNIX_DOUBLE_SLASH = "//" |
the unis slash is "//" | |
static constexpr const tChar | NATIVE_SLASH = UNIX_SLASH |
the native slash of the system will be defined | |
static constexpr const tChar | ALTERNATIVE_SLASH = WINDOWS_SLASH |
the alternative slash will be defined (is the counterpart of NATIVE_DOUBLE_SLASH) | |
static constexpr const tChar *const | NATIVE_DOUBLE_SLASH = UNIX_DOUBLE_SLASH |
the native double slash of the system will be defined | |
static constexpr const tChar *const | ALTERNATIVE_DOUBLE_SLASH = WINDOWS_DOUBLE_SLASH |
the alternative double slash will be defined (is the counterpart of NATIVE_DOUBLE_SLASH) | |
static const cFilename | Empty |
Static Public Attributes inherited from string_base< cStackString > | |
static const _myType | Empty |
Internally used empty string. | |
static const tSize | InvalidPos |
used to identicate out of range, invalidpos or default length | |
Additional Inherited Members | |
Public Types inherited from string_base< cStackString > | |
typedef string_base< cStackString > | _myType |
definition my type | |
typedef cStackString | _StorageType |
definition storage type | |
typedef _StorageType::value_type | value_type |
definition of value type | |
typedef _StorageType::iterator | iterator |
short typedefinition for cString iterators | |
typedef _StorageType::const_iterator | const_iterator |
short typedefinition for cString iterators | |
typedef _StorageType::reverse_iterator | reverse_iterator |
short typedefinition for cString reverse iterators | |
typedef _StorageType::const_reverse_iterator | const_reverse_iterator |
short typedefinition for cString reverse iterators | |
File name class.
Mind that this does not support any multi-byte encodings (UTF-8) but ANSI charsets only.
Name | Description |
root | Using windows this is a drive letter i.e. "C" or \\servername Using linux this is always "/" |
drive | Using windows this is a drive letter i.e. "C" detected by the ":" Using linux this is alwas "/" |
folder / directory | A folder is a combination of several names separated by the native slash If the last element of this combination is a filename with extension it is called a path. i.e. C:\temp\myfolder\ \etc\bin\ |
name | The name and the extension of a filename. The last part of a filename which is detected by the last native slash i.e. C:\temp\myfolder -> myfolder C:\temp\myfolder\myfile.txt -> myfile.txt /etc/bin/bla.txt -> bla.txt |
extension | The last part of a filename detected by a "." |
path | The combination of root + folder + name |
Definition at line 58 of file filename.h.
Constructor that initializes the filename with an existing cString object.
strString | [in] An existing cString object to be copied into this cFilename object. |
Constructor that initializes the filename with a null-terminated string.
pString | [in] A null-terminated string to be copied into this cFilename object. |
cFilename | ( | char | cChar | ) |
Constructor that initializes the filename with a single character.
cChar | [in] A single character. |
Implements move construction.
[in] | i_oOther | rValue reference of another cFilename object to be moved into this. |
Append a path string to current string.
This function does not check if a cFilename contains a filename. I.e. C:\foo.txt -> AppendPath (bar) ==> C:\foo.txt\bar. This function uses the native slashes to concatenate the paths
strPath | [in] Path to be appended |
cFilename& AppendTrailingSlash | ( | ) |
This function appends a trailing slash to the filename if there isn't one, yet.
cFilename& CleanPath | ( | ) |
This function resolves relative components ("." or "..") within an absolute path.
It also removes slashes that follow slashes. When it is not possible to resolve all ".." elements because the root directory has already been reached then the string is cleared. If it is a relative path no modifications are performed.
This function creates an absolute path for this file regarding the given parent (Only works with native slashes!).
The parent can also be set to "", "./" or ".". The function then uses the current directory as parent.
strParent | [in] This is taken as relation for this path to create the absolute one |
This function creates a relative path for this file regarding the given parent (Only works with native slashes!).
strParent | [in] This is taken as relation for this path to create the relative one |
cString GetDrive | ( | ) | const |
This function extracts the drive name of a filename (e.g.
"c:") Using linux a "/" will be returned if the filename is not empty.
tChar GetDriveLetter | ( | ) | const |
cString GetExtension | ( | ) | const |
This function extract the extension of a filename.
The extension is detected by a ".". If no "." is found then empty will be returned.
cString GetName | ( | ) | const |
This function extracts the name component of a filename.
If the given filename is only a folder then the last folder name will be returned.
cString GetNameWithoutExtension | ( | ) | const |
This function extract the name component of a filename.
No extension is appended to the name. If the given filename is a folder name then the last folder name will be returned
cFilename GetPath | ( | ) | const |
This function extract the path of the parent folder and/or the root component of a file/folder.
If the given filename is a folder then its parent folder will be extracted.
cFilename GetRoot | ( | ) | const |
This function extract the root component of a filename (without double point).
tBool IsAbsolute | ( | ) | const |
This function checks the filename if it is absolute.
tBool IsRelative | ( | ) | const |
This function checks the filename if it is relative.
This function checks if a character is a slash.
c | [in] Character to be checked. |
This function joins two subpaths (strPath1 and strPath2) to a new one.
strPath1 | [in] First path to be joined |
strPath2 | [in] Second path to be joined |
cFilename& MakeBackwardSlashes | ( | ) |
This function changes all forward slashes to backslashes.
cFilename& MakeForwardSlashes | ( | ) |
This function changes all backslashes to forward slashes.
cFilename& MakeNativeSlashes | ( | ) |
This function changes all slashes to OS specific slashes.
Implements move assignment.
[in] | i_oOther | rValue reference of another cFilename object to be moved into this. |
Copy assignment operator.
[in] | i_oOther | Object to copy assign this from |
assigns a given string
[in] | sString | given string containing a filename /path |
assigns a given string
[in] | pString | given string containing a filename / path |
assigns a given string
[in] | cChar | given string containing a filename / path |
cFilename& RemoveTrailingSlash | ( | ) |
This function removes a trailing slash from the filename if there is one.
This function changes the extension of a filename.
strExtension | [in] cString object that specifies the new extension. |
tVoid SplitPath | ( | cStringList & | List | ) | const |
Split path into a string list.
This function splits up a path into several parts.
List | [inout] Reference to cStringList object that is filled. The list is cleaned first. |