ansys::Project::URL Class Reference
Last update: 24.03.2026The address of a local or remote file, using the URI format. More...
#include "URL.hpp"
Public Member Functions | |
| URL () | |
| Default constructor. More... | |
| URL (const std::string &pStr) | |
| Constructor from string. More... | |
| URL (const std::string &pType, const std::string &pStr) | |
| Constructor from type and path/filename. More... | |
| URL (const char *pStr) | |
| Constructor from char*. More... | |
| ~URL () | |
| Destructor. More... | |
| std::string | getFilename () const |
| Returns the file component of the URL, path removed. More... | |
| std::string | getItemName () const |
| Returns the last name (directory or file) from the path. More... | |
| std::string | getFilenameRoot () const |
| Returns root (suffix removed) from the filename. More... | |
| std::string | getFilenamePath () const |
| Returns the path from a filename. More... | |
| std::string | getURLString () const |
| Returns the full type://path/filename for a URL. More... | |
| std::vector< std::string > | getURLComponents () const |
| URL | getURLSubset (int pComponentStart, int pEnd=-1) const |
| Return a subset of the URL components. More... | |
| bool | isValid () const |
| Indicate if URL is defined. More... | |
| bool | isNull () const |
| Indicate if URL path/filename is non null. More... | |
| bool | isLocalPath () const |
| Indicate if URL path/filename is a ./ path. More... | |
| bool | isRelativePath () const |
| Indicate if URL path/filename is a relative path. More... | |
| bool | isGlobalPath () const |
| Indicate if URL path/filename is a global path. More... | |
| bool | isInside (const URL &pURL) const |
| Indicate if URL is inside the specified folder URL. More... | |
| URLType | getType () const |
| Return the URL type. More... | |
| const std::string & | str () const |
| Returns the path/file component of the URL. More... | |
| const char * | c_str () const |
| void | toGlobal (const URL &pRootPath) |
| Convert URL to global path. More... | |
| void | toRelative (const URL &pRefDir) |
| Convert URL to relative path. More... | |
| void | simplifyURL () |
| Simplify URL by removing internal relative paths. More... | |
| bool | operator!= (const URL &pURL) const |
| Unequal operator. More... | |
| bool | operator== (const URL &pURL) const |
| Equal operator. More... | |
| bool | operator== (const std::string &pURLString) const |
| Equal operator - with string. More... | |
| URL | operator+ (const URL &p2) const |
| Concatenation operator. More... | |
| URL & | operator+= (const URL &p2) |
| Self concatenation operator. More... | |
| bool | normalizeToFolder () |
| Ensure the URL is a folder path, if trailing / was missing. More... | |
Detailed Description
The address of a local or remote file, using the URI format.
The URL objects contains the string for a URL path and provides string operations on it. A Project define an URL for each file or folder, the URL will indicate where to fetch the content.
A URL is a data location as
type://path file:///home/user/file http://host.com/folder/file
A special type of URL is also supported: relative paths
./filename
Relative paths infer their global location from their parent directory (PFolder)
Type
The type can be omitted, it is then assumed a "file://" type see URL::getType()
"filename" -> "file://filename"
The type is tied to a Storage interface, and some project operations ( file access, deletion, etc.) will require the matching Storage plug-in to access the remote file.
Note: (2020R2) only a "file://" interface is provided via StorageFilesystem
Differences with URI specs:
- a URL object can be initialized with a relative path ( starts with ./) but such an URL is only used for URL composision
- The single slash file:/path syntax is not supported, only file://...
Path/Filename component
str(), c_str() will return the URL content without the type "file:///path/filename" -> "/path/filename"
Type: file
The file paths are stored with the / separator (if \ windows separator are used, the are converted to /, except file sharing paths)
"/path/to/file" -> "/path/to/file" "./relative/file" -> "./relative/file" "d:\path\to\file" -> "d:/path/to/file" "\\filesystem\path\file" -> "\\filesystem\path\file"
Constructor & Destructor Documentation
◆ URL() [1/4]
| ansys::Project::URL::URL | ( | ) |
Default constructor.
◆ URL() [2/4]
| ansys::Project::URL::URL | ( | const std::string & | pURL | ) |
Constructor from string.
Builds URL from string. If type:// is omitted, the type "file" is assumed.
- Parameters
-
pURL String with a valid full URI
◆ URL() [3/4]
| ansys::Project::URL::URL | ( | const std::string & | pType, |
| const std::string & | pURL | ||
| ) |
◆ URL() [4/4]
| ansys::Project::URL::URL | ( | const char * | pStr | ) |
Constructor from char*.
Builds URL from string. If type:// is omitted, the type "file" is assumed.
- Parameters
-
pStr String with a valid full URI
◆ ~URL()
| ansys::Project::URL::~URL | ( | ) |
Destructor.
Member Function Documentation
◆ c_str()
|
inline |
◆ getFilename()
| std::string ansys::Project::URL::getFilename | ( | ) | const |
◆ getFilenamePath()
| std::string ansys::Project::URL::getFilenamePath | ( | ) | const |
Returns the path from a filename.
Return the path of a file /path/to/file.cas -> /path/to/ /path/folder/ -> /path/folder/
- Returns
- item name as string
◆ getFilenameRoot()
| std::string ansys::Project::URL::getFilenameRoot | ( | ) | const |
Returns root (suffix removed) from the filename.
This function can only be used on file URLs: /path/to/file.cas -> file /path/to/file_cas -> file_cas /path/folder/ -> (empty string)
- Returns
- item name as string
◆ getItemName()
| std::string ansys::Project::URL::getItemName | ( | ) | const |
Returns the last name (directory or file) from the path.
Only the last component of the path is returned, including / for folder name. /path/to/filename -> filename /path/folder/ -> folder/
- Returns
- item name as string
◆ getType()
◆ getURLComponents()
| std::vector< std::string > ansys::Project::URL::getURLComponents | ( | ) | const |
◆ getURLString()
| std::string ansys::Project::URL::getURLString | ( | ) | const |
Returns the full type://path/filename for a URL.
The type is always included, even if using implicit file:// ./file -> file://./file /path/file -> file:///path/file
- Returns
- Full URL as string
◆ getURLSubset()
| URL ansys::Project::URL::getURLSubset | ( | int | pComponentStart, |
| int | pEnd = -1 |
||
| ) | const |
Return a subset of the URL components.
The getURLComponents() returns an array of the URL items /path/file -> [ / , path/ , file] This function returns the URL forming the subset between indices in this array
- Parameters
-
pComponentStart start of the subset (starts at 0) pEnd end of the subset, not included. (omit, or -1 to include up to the end of the URL)
- Returns
- URL of the subset, if a folder will end by /
◆ isGlobalPath()
| bool ansys::Project::URL::isGlobalPath | ( | ) | const |
Indicate if URL path/filename is a global path.
A global path starts by / , \ (windows file share) or is a windows drive name (i.e. c:/ ...)
- Returns
- true if global
◆ isInside()
| bool ansys::Project::URL::isInside | ( | const URL & | pURL | ) | const |
◆ isLocalPath()
| bool ansys::Project::URL::isLocalPath | ( | ) | const |
Indicate if URL path/filename is a ./ path.
A local path starts by ./ and assumes inside local directory
- Returns
- true if relative
◆ isNull()
| bool ansys::Project::URL::isNull | ( | ) | const |
Indicate if URL path/filename is non null.
- Returns
- true if non null
◆ isRelativePath()
| bool ansys::Project::URL::isRelativePath | ( | ) | const |
Indicate if URL path/filename is a relative path.
A relative path starts by ./ or ../
- Returns
- true if relative
◆ isValid()
| bool ansys::Project::URL::isValid | ( | ) | const |
◆ normalizeToFolder()
| bool ansys::Project::URL::normalizeToFolder | ( | ) |
Ensure the URL is a folder path, if trailing / was missing.
- Returns
- false if error
◆ operator!=()
| bool ansys::Project::URL::operator!= | ( | const URL & | pURL | ) | const |
Unequal operator.
- Returns
- true if URL::operator==() is false
◆ operator+()
◆ operator+=()
◆ operator==() [1/2]
| bool ansys::Project::URL::operator== | ( | const std::string & | pURLString | ) | const |
Equal operator - with string.
- Returns
- true if both type and URL string are the same
◆ operator==() [2/2]
| bool ansys::Project::URL::operator== | ( | const URL & | pURL | ) | const |
Equal operator.
- Returns
- true if both type and URL string are the same
◆ simplifyURL()
| void ansys::Project::URL::simplifyURL | ( | ) |
◆ str()
| const std::string & ansys::Project::URL::str | ( | ) | const |
◆ toGlobal()
| void ansys::Project::URL::toGlobal | ( | const URL & | pRootPath | ) |