PixelLightAPI  .
Public Member Functions
PLCore::Url Class Reference

Contains a path or URL (Uniform Resource Locator) More...

#include <Url.h>

List of all members.

Public Member Functions

 Url ()
 Constructor.
 Url (const Url &cUrl)
 Copy constructor.
 Url (const String &sUrl)
 Constructor.
 ~Url ()
 Destructor.
Urloperator= (const Url &cUrl)
 Copy an URL.
Urloperator= (const String &sUrl)
 Copy an URL (passed as a string)
Url operator+ (const Url &cUrl) const
 Concatenate an URL.
Urloperator+= (const Url &cUrl)
 Concatenate an URL.
String GetUrl () const
 Get value in URL notation.
String GetNativePath () const
 Get value in native notation.
String GetWindowsPath () const
 Get value in Windows notation.
String GetUnixPath () const
 Get value in Unix notation.
bool IsValid () const
 Returns if the URL is valid.
bool IsValidNativePath () const
 Check if the URL is a valid native file path.
bool IsValidWindowsPath () const
 Check if the URL is valid as a Windows file path.
bool IsValidUnixPath () const
 Check if the URL is valid as a Unix file path.
bool IsEmpty () const
 Returns if the URL is empty.
bool IsAbsolute () const
 Returns if the URL is absolute.
bool IsRelative () const
 Returns if the URL is relative.
bool IsDirectory () const
 Returns if the URL targets a directory.
String GetProtocol () const
 Returns the protocol part.
String GetRoot () const
 Returns the root part.
String GetPath () const
 Returns the path (without root and filename)
String GetFilename () const
 Returns the filename (including it's extension)
String CutFilename () const
 Returns the path without the filename.
String GetTitle () const
 Returns the filename without it's complete extension (one may also call the result "basename)
String GetCompleteTitle () const
 Returns the filename without it's extension (one may also call the result "basename)
String GetExtension () const
 Returns the file extension (aka "suffix")
String CutExtension () const
 Returns the path and filename without extension.
String GetCompleteExtension () const
 Returns the complete file extension (aka "suffix")
String CutCompleteExtension () const
 Returns the path and filename without complete extension.
String GetFirstPath (uint32 &nPathPos) const
 Returns the first part of the path.
String GetFirstPath () const
 Returns the first part of the path.
PLCORE_API String GetNextPath (uint32 &nPathPos) const
 Returns the next part of the path.
PLCORE_API UrlCollapse ()
 Collapses the URL.

Detailed Description

Contains a path or URL (Uniform Resource Locator)

Note:
  • An URL is always stored using a protocol ("file://" for a local path) and "/" as the delimiter.
  • For getting the URL in native style, use the specific functions (GetWindowsPath(), GetUnixPath(), GetNativePath())
  • If there's a "/" at the end of a given path it will be kept, but no "/" is added automatically

Constructor & Destructor Documentation

PLCore::Url::Url ( ) [inline]
PLCore::Url::Url ( const Url cUrl) [inline]

Copy constructor.

Parameters:
[in]cUrlURL to copy
PLCore::Url::Url ( const String sUrl) [inline]

Constructor.

Parameters:
[in]sUrlURL as string
PLCore::Url::~Url ( ) [inline]

Destructor.


Member Function Documentation

Url & PLCore::Url::operator= ( const Url cUrl) [inline]

Copy an URL.

Parameters:
[in]cUrlURL to copy
Returns:
Reference to this URL
Url & PLCore::Url::operator= ( const String sUrl) [inline]

Copy an URL (passed as a string)

Parameters:
[in]sUrlString containing URL to copy
Returns:
Reference to this URL
Url PLCore::Url::operator+ ( const Url cUrl) const [inline]

Concatenate an URL.

Parameters:
[in]cUrlURL to add
Returns:
Resulting URL
Note:
  • Both URLs must be valid
  • The second URL must be relative
  • The protocol of the second URL must match the first one or be empty
Url & PLCore::Url::operator+= ( const Url cUrl) [inline]

Concatenate an URL.

Parameters:
[in]cUrlURL to add
Returns:
Reference to this URL
See also:
  • operator +
String PLCore::Url::GetUrl ( ) const [inline]

Get value in URL notation.

Returns:
Path in URL style
Note:
  • If the value contains a local file path, a file:// URL is returned
  • Any other URL (e.g. http://) is returned directly
  • For example "Url("C:\Programs\App\App.exe")" will result in "file://C:/Programs/App/App.exe"
  • For example "Url("C:\Programs\App\")" will result in "file://C:/Programs/App/"
  • For example "Url("C:\Programs\App")" will result in "file://C:/Programs/App"
String PLCore::Url::GetNativePath ( ) const [inline]

Get value in native notation.

Returns:
Path in native path format style
Note:
  • Returns the URL in native (Windows/Unix) notation, if it is a local path
  • If it is another URL (e.g. http://), the URL is returned
  • On Windows for example "Url("C:\Programs\App\App.exe")" will result in "C:\Programs\App\App.exe"
  • On Windows for example "Url("C:\Programs\App\")" will result in "C:\Programs\App\"
  • On Windows for example "Url("C:\Programs\App")" will result in "C:\Programs\App"
  • On Linux for example "Url("C:\Programs\App\App.exe")" will result in "C:/Programs/App/App.exe"
  • On Linux for example "Url("C:\Programs\App\")" will result in "C:/Programs/App/"
  • On Linux for example "Url("C:\Programs\App")" will result in "C:/Programs/App"
String PLCore::Url::GetWindowsPath ( ) const [inline]

Get value in Windows notation.

Returns:
Path in Windows format style
Note:
  • If the value contains a valid Windows or Unix file path or an file:// URL, it is returned in Windows style
  • If the value contains another URL (e.g. http://), the URL is returned without being converted
  • For example "Url("C:\Programs\App\App.exe")" will result in "C:\Programs\App\App.exe"
  • For example "Url("C:\Programs\App\")" will result in "C:\Programs\App\"
  • For example "Url("C:\Programs\App")" will result in "C:\Programs\App"
String PLCore::Url::GetUnixPath ( ) const [inline]

Get value in Unix notation.

Returns:
Path in Unix format style
Note:
  • If the value contains a valid Windows or Unix file path or an file:// URL, it is returned in Unix style
  • If the value contains another URL (e.g. http://), the URL is returned without being converted
  • For example "Url("C:\Programs\App\App.exe")" will result in "C:/Programs/App/App.exe"
  • For example "Url("C:\Programs\App\")" will result in "C:/Programs/App/"
  • For example "Url("C:\Programs\App")" will result in "C:/Programs/App"
bool PLCore::Url::IsValid ( ) const [inline]

Returns if the URL is valid.

Returns:
'true' if the value is valid, else 'false'
bool PLCore::Url::IsValidNativePath ( ) const [inline]

Check if the URL is a valid native file path.

Returns:
'true', if the path is valid in the native path format style
Note:
bool PLCore::Url::IsValidWindowsPath ( ) const [inline]

Check if the URL is valid as a Windows file path.

Returns:
'true', if the path is valid in Windows format style
Note:
  • 'false', if the protocol is any other than "file://" or empty
  • 'false', if the file root is any other than "X:/" or empty ("/" is invalid!)
bool PLCore::Url::IsValidUnixPath ( ) const [inline]

Check if the URL is valid as a Unix file path.

Returns:
'true', if the path is valid in Unix format style
Note:
  • 'false', if the protocol is any other than "file://" or empty
  • 'false', if the file root is any other than "/" or empty ("X:/" is invalid!)
bool PLCore::Url::IsEmpty ( ) const [inline]

Returns if the URL is empty.

Returns:
'true' if the path is empty, else 'false'
Note:
  • The protocol is ignored
bool PLCore::Url::IsAbsolute ( ) const [inline]

Returns if the URL is absolute.

Returns:
'true' if the path is absolute, else 'false'
bool PLCore::Url::IsRelative ( ) const [inline]

Returns if the URL is relative.

Returns:
'true' if the path is relative, else 'false'
bool PLCore::Url::IsDirectory ( ) const [inline]

Returns if the URL targets a directory.

Returns:
'true' if the path targets a directory, else 'false'
Note:
  • Returns true, if the URL ends with "/" which indicates a directory
  • This is a consideration on pure syntax level - it does not mean that the path pointed to is really a directory or that it even exists!
String PLCore::Url::GetProtocol ( ) const [inline]

Returns the protocol part.

Returns:
Protocol part (e.g. "file://" or "http://")
String PLCore::Url::GetRoot ( ) const [inline]

Returns the root part.

Returns:
Root part (e.g. "C:/" or "/")
String PLCore::Url::GetPath ( ) const [inline]

Returns the path (without root and filename)

Returns:
Path (e.g. "Programs/")
String PLCore::Url::GetFilename ( ) const [inline]

Returns the filename (including it's extension)

Returns:
Filename (e.g. "readme.txt")
String PLCore::Url::CutFilename ( ) const [inline]

Returns the path without the filename.

Returns:
Path without filename (e.g. "C:/Programs/App/App.exe"->"C:/Programs/App/")
Note:
  • The protocol is omitted for a local path (e.g. the result will not be "file://C:/Programs/App/")
String PLCore::Url::GetTitle ( ) const [inline]

Returns the filename without it's complete extension (one may also call the result "basename)

Remarks:
		*   Example showing the difference between "GetTitle()", "GetCompleteTitle()", "GetExtension()", "CutExtension()", "GetCompleteExtension()" and "CutCompleteExtension()":
		*     Url cUrl("C:\\Programs\\App\\archive.tar.gz");
		*     String sTitle                = cUrl.GetTitle();              // Result is "archive"
		*     String sCompleteTitle        = cUrl.GetCompleteTitle();      // Result is "archive.tar"
		*     String sExtension            = cUrl.GetExtension();          // Result is "gz"
		*     String sCutExtension         = cUrl.CutExtension();          // Result is "C:\Programs\App\archive.tar"
		*     String sCompleteExtension    = cUrl.GetCompleteExtension();  // Result is "tar.gz"
		*     String sCutCompleteExtension = cUrl.CutCompleteExtension();  // Result is "C:\Programs\App\archive"
		*  
Returns:
Filename without complete extension (e.g. "readme" if the filename was "readme.txt", "archive" if the filename was "archive.tar.gz")

Returns the filename without it's extension (one may also call the result "basename)

Returns:
Filename without extension (e.g. "readme" if the filename was "readme.txt", "archive.tar" if the filename was "archive.tar.gz")
See also:
  • "GetTitle()" for an usage example
String PLCore::Url::GetExtension ( ) const [inline]

Returns the file extension (aka "suffix")

Returns:
File extension (e.g. "txt" if the filename was "readme.txt", "gz" if the filename was "archive.tar.gz")
See also:
  • "GetTitle()" for an usage example
String PLCore::Url::CutExtension ( ) const [inline]

Returns the path and filename without extension.

Returns:
Path and filename without extension (e.g. "C:\Programs\App\App.exe"->"C:\Programs\App\App" or "C:\Programs\App\archive.tar.gz"->"C:\Programs\App\archive.tar")
See also:
  • "GetTitle()" for an usage example

Returns the complete file extension (aka "suffix")

Returns:
File extension (e.g. "txt" if the filename was "readme.txt", "tar.gz" if the filename was "archive.tar.gz")
See also:
  • "GetTitle()" for an usage example

Returns the path and filename without complete extension.

Returns:
Path and filename without complete extension (e.g. "C:\Programs\App\App.exe"->"C:\Programs\App\App" or "C:\Programs\App\archive.tar.gz"->"C:\Programs\App\archive")
See also:
  • "GetTitle()" for an usage example
String PLCore::Url::GetFirstPath ( uint32 &  nPathPos) const [inline]

Returns the first part of the path.

Parameters:
[out]nPathPosWill receive the new position within the path
Returns:
First path
Note:
  • Ignores the root (e.g. "C:/" or "/")
  • Example: "test/foo.bar"->"test"
String PLCore::Url::GetFirstPath ( ) const [inline]

Returns the first part of the path.

Returns:
First path
Note:
  • Ignores the root (e.g. "C:/" or "/")
  • Example: "test/foo.bar"->"test"
PLCORE_API String PLCore::Url::GetNextPath ( uint32 &  nPathPos) const

Returns the next part of the path.

Parameters:
[in,out]nPathPosPosition within the path
Returns:
First path
Note:
PLCORE_API Url& PLCore::Url::Collapse ( )

Collapses the URL.

Returns:
Reference to this object
Note:
  • Collapsing means, '..' and '.' inside the path will be resolved (on a syntactical level only!)
  • If the URL is invalid, the function will fail

The documentation for this class was generated from the following files:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:14
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported