String manipulation and test functions. More...

Collaboration diagram for String name/path Functions:

Enumerations

enum  Murl::Util::MatchOptions {
  Murl::Util::MATCH_DEFAULT , Murl::Util::MATCH_NOESCAPE , Murl::Util::MATCH_PATHNAME , Murl::Util::MATCH_PERIOD ,
  Murl::Util::MATCH_CASEFOLD , Murl::Util::MATCH_LEADING_DIR
}
 Match option flags, can be combined using bitwise OR. More...
 

Functions

String Murl::Util::GetFilePath (const String &filePathAndName)
 Get the file path substring of a file path and name. More...
 
String Murl::Util::GetFileName (const String &filePathAndName)
 Get the file name substring of a file path and name. More...
 
String Murl::Util::GetFileExtension (const String &fileName)
 Get the file extension substring of a file name. More...
 
String Murl::Util::StripExtension (const String &fileName)
 Strip the file extension from a file name. More...
 
String Murl::Util::StripPathAndExtension (const String &filePathAndName)
 Strip the file path and extension from a file path and name. More...
 
String Murl::Util::JoinPaths (const String &leftPath, const String &rightPath)
 Join two path strings. More...
 
String Murl::Util::GetUnixPath (const String &windowsPath)
 Exchange all '\' with '/' characters. More...
 
String Murl::Util::GetWindowsPath (const String &unixPath)
 Exchange all '/' with '\' characters. More...
 
String Murl::Util::GetNormalizedPath (const String &path)
 Get a normalized path. More...
 
String Murl::Util::GetRelativePath (const String &absolutePath, const String &absoluteBasePath)
 Get a relative path from an absolute one. More...
 
String Murl::Util::GetAbsolutePath (const String &relativePath, const String &absoluteBasePath)
 Get an absolute path from a relative one. More...
 
Bool Murl::Util::HasMatchPattern (const String &name, UInt32 matchOption=MATCH_DEFAULT)
 Check if a name contains pattern matching statements. More...
 
Bool Murl::Util::IsNameMatching (const String &pattern, const String &name, UInt32 matchOptions=MATCH_DEFAULT)
 Check if a name matches a specified pattern. More...
 

Detailed Description

String manipulation and test functions.

Enumeration Type Documentation

◆ MatchOptions

Match option flags, can be combined using bitwise OR.

Enumerator
MATCH_DEFAULT 

Default matching * ? [0-z].

MATCH_NOESCAPE 

Disable backslash escaping.

MATCH_PATHNAME 

Slash must be matched by slash.

MATCH_PERIOD 

Period must be matched by period.

MATCH_CASEFOLD 

Pattern is matched case-insensitive.

MATCH_LEADING_DIR 

Ignore / tail after match.

Function Documentation

◆ GetFilePath()

String Murl::Util::GetFilePath ( const String filePathAndName)

Get the file path substring of a file path and name.

Returns the substring before the last '/' character.

Parameters
filePathAndNameThe file path and name.
Returns
The file path substring of the file name. If the '/' character is not found an empty string is returned.

◆ GetFileName()

String Murl::Util::GetFileName ( const String filePathAndName)

Get the file name substring of a file path and name.

Returns the substring behind the last '/' character.

Parameters
filePathAndNameThe file path and name.
Returns
The file name substring of the file name. If the '/' character is not found the input string is returned.

◆ GetFileExtension()

String Murl::Util::GetFileExtension ( const String fileName)

Get the file extension substring of a file name.

Returns the substring behind the last '.' character.

Parameters
fileNameThe file name.
Returns
The file extension substring of the file name. If the '.' character is not found an empty string is returned.

◆ StripExtension()

String Murl::Util::StripExtension ( const String fileName)

Strip the file extension from a file name.

Returns the substring before the last '.' character.

Parameters
fileNameThe file name.
Returns
The file name substring excluding the file extension. If the '.' character is not found the input string is returned.

◆ StripPathAndExtension()

String Murl::Util::StripPathAndExtension ( const String filePathAndName)

Strip the file path and extension from a file path and name.

Returns the substring from the last '/' to the last '.' character.

Parameters
filePathAndNameThe file path and name.
Returns
The file name substring excluding the file path and extension. If the '.' and '/' character is not found the input string is returned.

◆ JoinPaths()

String Murl::Util::JoinPaths ( const String leftPath,
const String rightPath 
)

Join two path strings.

Ensures exactly one '/' character between the left and the right part.

Parameters
leftPathThe left path string.
rightPathThe right path string.
Returns
The left plus the right path string.

◆ GetUnixPath()

String Murl::Util::GetUnixPath ( const String windowsPath)

Exchange all '\' with '/' characters.

Parameters
windowsPathThe path string to convert.
Returns
The Unix path string.

◆ GetWindowsPath()

String Murl::Util::GetWindowsPath ( const String unixPath)

Exchange all '/' with '\' characters.

Parameters
unixPathThe path string to convert.
Returns
The Windows path string.

◆ GetNormalizedPath()

String Murl::Util::GetNormalizedPath ( const String path)

Get a normalized path.

Returns the given path, with all occurrences of "." removed, and any occurrences of ".." recursively joined with the previous sub-path.

Parameters
pathThe path to normalize.
Returns
The normalized Unix-style path.

◆ GetRelativePath()

String Murl::Util::GetRelativePath ( const String absolutePath,
const String absoluteBasePath 
)

Get a relative path from an absolute one.

When the relative path cannot be resolved, the given absolute path is returned. This may happen e.g. when both given paths are located on different volumes.

Parameters
absolutePathThe absolute path to convert.
absoluteBasePathThe absolute base path relative to which the path is converted.
Returns
The relative path if it can be resolved, or absolutePath if not.

◆ GetAbsolutePath()

String Murl::Util::GetAbsolutePath ( const String relativePath,
const String absoluteBasePath 
)

Get an absolute path from a relative one.

When the given relative path is actually representing an absolute location (i.e. starting with "/"), it is directly returned. Otherwise, the base path and relative path are concatenated and normalized.

Parameters
relativePathThe relative path to convert.
absoluteBasePathThe absolute base path relative to which the path is converted.
Returns
The absolute path if it can be resolved, or relativePath if not.

◆ HasMatchPattern()

Bool Murl::Util::HasMatchPattern ( const String name,
UInt32  matchOption = MATCH_DEFAULT 
)

Check if a name contains pattern matching statements.

Pattern matching is supported by IsNameMatching().

Parameters
nameThe name string to check.
matchOptionThe option for checking, either MATCH_DEFAULT or MATCH_NOESCAPE.
Returns
true if the name contains pattern matching statements, otherwise false.

◆ IsNameMatching()

Bool Murl::Util::IsNameMatching ( const String pattern,
const String name,
UInt32  matchOptions = MATCH_DEFAULT 
)

Check if a name matches a specified pattern.

Matches patterns according to the Unix-like globbing rules * ? [0-z]. See HasMatchPattern() to check a name for patterns.

Parameters
patternThe pattern string.
nameThe name string to check.
matchOptionsThe options for checking, any MatchOptions can be combined using bitwise OR.
Returns
true if the name matches the pattern, otherwise false.


Copyright © 2011-2024 Spraylight GmbH.