struct CCL::IUrl

Overview

URL interface <> More…

#include <iurl.h>

struct IUrl: public CCL::IUnknown
{
    // enums

    enum NormalizationFlags;
    enum StringTypes;
    enum Types;

    // methods

    virtual void CCL_API clone (IUrl*& url) const = 0;
    virtual void CCL_API assign (UrlRef url) = 0;
    virtual tbool CCL_API isEqualUrl (UrlRef url, tbool withParameters = true) const = 0;
    virtual tbool CCL_API isEmpty () const = 0;
    virtual int CCL_API getType () const = 0;
    virtual void CCL_API getUrl (String& url, tbool withParameters = false) const = 0;
    virtual void CCL_API setUrl (StringRef url, int type = kFile) = 0;
    virtual StringRef CCL_API getProtocol () const = 0;
    virtual void CCL_API setProtocol (StringRef protocol) = 0;
    virtual StringRef CCL_API getHostName () const = 0;
    virtual void CCL_API setHostName (StringRef name) = 0;
    virtual StringRef CCL_API getPath () const = 0;
    virtual void CCL_API setPath (StringRef path, int type = kIgnore) = 0;
    virtual void CCL_API getPathName (String& pathName) const = 0;
    virtual void CCL_API getName (String& name, tbool withExtension = true) const = 0;
    virtual void CCL_API setName (StringRef name, int type = kIgnore) = 0;
    virtual tbool CCL_API getExtension (String& ext) const = 0;
    virtual void CCL_API setExtension (StringRef ext, tbool replace = true) = 0;
    virtual const FileType&CCL_API getFileType () const = 0;

    virtual void CCL_API setFileType (
        const FileType& type,
        tbool replaceExtension = true
    ) = 0;

    virtual tbool CCL_API isRootPath () const = 0;
    virtual tbool CCL_API isNativePath () const = 0;
    virtual tbool CCL_API toNativePath (uchar* pathBuffer, int bufferSize) const = 0;
    virtual tbool CCL_API fromNativePath (const uchar* pathBuffer, int type = kFile) = 0;
    virtual tbool CCL_API toPOSIXPath (char* pathBuffer, int bufferSize) const = 0;
    virtual tbool CCL_API fromPOSIXPath (const char* pathBuffer, int type = kFile) = 0;

    virtual tbool CCL_API toDisplayString (
        String& displayString,
        int which = kStringNativePath
    ) const = 0;

    virtual tbool CCL_API fromDisplayString (
        StringRef displayString,
        int type = kFile
    ) = 0;

    virtual tbool CCL_API isAbsolute () const = 0;
    virtual tbool CCL_API isRelative () const = 0;
    virtual tbool CCL_API makeAbsolute (UrlRef baseUrl) = 0;
    virtual tbool CCL_API makeRelative (UrlRef baseUrl) = 0;
    virtual tbool CCL_API ascend () = 0;
    virtual tbool CCL_API descend (StringRef name, int type = kFile) = 0;
    virtual void CCL_API normalize (int flags) = 0;
    virtual IStringDictionary&CCL_API getParameters () const = 0;
    virtual void CCL_API getParameters (String& params) const = 0;
    virtual void CCL_API setParameters (StringRef params) = 0;
    virtual tbool CCL_API hasParameters () const = 0;
    IUrl bool isFile () const;
    bool isFolder () const;
    IUrl& operator = (UrlRef url);
};

Inherited Members

public:
    // methods

    virtual tresult CCL_API queryInterface (UIDRef iid, void** ptr) = 0;
    virtual unsigned int CCL_API retain () = 0;
    virtual unsigned int CCL_API release () = 0;

Detailed Documentation

URL interface <>

Methods

virtual void CCL_API clone (IUrl*& url) const = 0

Clone URL object.

virtual void CCL_API assign (UrlRef url) = 0

Assign from other URL reference.

virtual tbool CCL_API isEqualUrl (UrlRef url, tbool withParameters = true) const = 0

Check two URLs for equality.

virtual tbool CCL_API isEmpty () const = 0

Check if URL is empty.

virtual int CCL_API getType () const = 0

Get URL type (file or folder).

virtual void CCL_API getUrl (String& url, tbool withParameters = false) const = 0

Get full URL string (e.g.

file://localhost/folder1/folder2/file.ext”).

virtual void CCL_API setUrl (StringRef url, int type = kFile) = 0

Set full URL string and type.

virtual StringRef CCL_API getProtocol () const = 0

Get protocol string (e.g.

“file”).

virtual void CCL_API setProtocol (StringRef protocol) = 0

Set protocol string.

virtual StringRef CCL_API getHostName () const = 0

Get host string (e.g.

“localhost”).

virtual void CCL_API setHostName (StringRef name) = 0

Set host string.

virtual StringRef CCL_API getPath () const = 0

Get path string (folder + file name, e.g.

“folder1/folder2/file.ext”).

virtual void CCL_API setPath (StringRef path, int type = kIgnore) = 0

Set path string (folder + file name).

virtual void CCL_API getPathName (String& pathName) const = 0

Get path name without file name (e.g.

“folder1/folder2”).

virtual void CCL_API getName (String& name, tbool withExtension = true) const = 0

Get file name with or without extension (e.g.

“file” or “file.ext”).

virtual void CCL_API setName (StringRef name, int type = kIgnore) = 0

Set file name and extension.

virtual tbool CCL_API getExtension (String& ext) const = 0

Get extension string (e.g.

“ext”)

virtual void CCL_API setExtension (StringRef ext, tbool replace = true) = 0

Set extension string, either by appending or replacing the existing one (e.g.

“file.new” or “file.old.new”).

virtual const FileType&CCL_API getFileType () const = 0

Get file type (extension + description + MIME type).

Not all fields are guaranteed to be valid.

virtual void CCL_API setFileType (
    const FileType& type,
    tbool replaceExtension = true
) = 0

Set extension with file type, either by appending or replacing the existing one.

virtual tbool CCL_API isRootPath () const = 0

Check if URL is a root path (e.g.

path is empty or “/” or “C:”).

virtual tbool CCL_API isNativePath () const = 0

Check if URL is a native path using “file” protocol (e.g.

file:///C:/folder/file.ext”).

virtual tbool CCL_API toNativePath (uchar* pathBuffer, int bufferSize) const = 0

Convert to native path string in UTF-16 enconding (e.g.

“C:folderfile.ext” or “Volumes/folder/file.ext”).

virtual tbool CCL_API fromNativePath (const uchar* pathBuffer, int type = kFile) = 0

Assign native path.

On Windows a path string like “C:...” will be mapped to “file:///C:/…”.

virtual tbool CCL_API toPOSIXPath (char* pathBuffer, int bufferSize) const = 0

Convert to POSIX-style path (‘/’ as separator) in UTF-8 encoding.

virtual tbool CCL_API fromPOSIXPath (const char* pathBuffer, int type = kFile) = 0

Assign from POSIX-style path.

virtual tbool CCL_API toDisplayString (
    String& displayString,
    int which = kStringNativePath
) const = 0

Get beautified string for display respecting the platform conventions.

virtual tbool CCL_API fromDisplayString (
    StringRef displayString,
    int type = kFile
) = 0

Assign path from native display string, following platform conventions.

virtual tbool CCL_API isAbsolute () const = 0

Check if it is an absolute path.

virtual tbool CCL_API isRelative () const = 0

Check if it is a relative path.

virtual tbool CCL_API makeAbsolute (UrlRef baseUrl) = 0

Make relative URL absolute to base URL.

virtual tbool CCL_API makeRelative (UrlRef baseUrl) = 0

Make absolute URL relative to given base URL.

virtual tbool CCL_API ascend () = 0

Ascend one directory level (e.g.

“folder1/folder2” becomes “folder1”).

virtual tbool CCL_API descend (StringRef name, int type = kFile) = 0

Descend one directory level appending given name and type.

virtual void CCL_API normalize (int flags) = 0

Normalize URL with given options.

virtual IStringDictionary&CCL_API getParameters () const = 0

Access to dictionary with (decoded) parameters.

virtual void CCL_API getParameters (String& params) const = 0

Get parameters as URL-encoded string.

virtual void CCL_API setParameters (StringRef params) = 0

Set parameters from URL-encoded string.

virtual tbool CCL_API hasParameters () const = 0

Check if URL has parameters.