Class sh::filesystem::Eurl

class sh::filesystem::Eurl : public std::enable_shared_from_this<Eurl>

Filesystem paths.

A Extended Uniform Resource Locator is something like a URL.

It is more general since it can also be nested. It is something like zip:/[]//zippedfolder/zippedfile.

You get Eurl instances only from the factory methods. There will never be two instances with the same textual value.

Please note: Instances can be associated with any kind of elements in the filesystem (files, directories, links, …). It might also point to something which does not exist at all. The documentation sometimes explicitly makes a difference between those kinds (files, directories, links, …; often called ‘node type’). But it often uses the term ‘file’ implicitly while meaning all kinds of elements; assuming that e.g. a directory is just a special kind of a file. It should be clear from the particular context which meaning applies.

Public Functions

QString asString() const

Returns the textual value. This is what Eurl.fromString would expect as parameter.

QString hostname() const

Returns the hostname part (from the outer url of this Eurl). Examples: "livingroom-pc" for smb://livingroom-pc/foo/bar/baz. "" for .

QString path() const

Returns the path part (from the outer url of this Eurl). Examples: "/foo/bar/baz" for smb://livingroom-pc/foo/bar/baz. "/foo/bar/baz" for . "/" for .

QString basename() const

Returns the last path segment. This is the text behind the last slash. Examples: "baz" for . "" for .

QString scheme() const

Returns the scheme (from the outer url of this shallot.Eurl). This is what comes before the ://. Example: "file" for .

std::shared_ptr<const Eurl> outerUrl() const

Returns a new Eurl containing only the outer part of this one (strips the embeddings). Example: foobar://host/foo/bar/baz for foobar:/[zip:/[]//d/e]//foo/bar/baz.

std::shared_ptr<const Eurl> outermostInnerEurl() const

Returns a new Eurl containing only the embedding of this one. Example: zip:/[]//d/e for foobar:/[zip:/[]//d/e]//foo/bar/baz.

std::shared_ptr<const Eurl> withAppendedSegment(QString basename) const

Returns a new Eurl from this one with “/basename” appended. The parameter is assumed to be a single path segment.

std::shared_ptr<const Eurl> withAppendedSegments(QString path) const

Returns a new Eurl with path segments “/pa/t/h/” appended. The parameter may contain "/"s for dividing path segments.

std::shared_ptr<const Eurl> root() const

Returns the root Eurl from this one. Example: zip:/[]// for zip:/[]//foo/bar/baz.

std::shared_ptr<const Eurl> enwrapWithOuterUrl(QString scheme, QString hostname, QString path) const

Returns a new Eurl containing this one packed as embedding and new outer parts scheme, hostname and path. Example: scheme:/[]/hostname/p/a/t/h for .

std::shared_ptr<const Eurl> parentSegment() const

Returns the parent Eurl. At first, this traverses path segments. For a root path eurl with embeddings, it returns the embedding. If none are available, it returns 0. Examples: foo://host/foo for foo://host/foo/bar. foo://host/ for foo://host/boo. foo:/[bar://host/goo]/anotherhost/ for foo:/[bar://host/goo]/anotherhost/boo. bar://host/foo for foo:/[bar://host/foo]/host/. 0 for foo://host/.

bool hasInnerUrls() const

Checks if this Eurl has embeddings. Examples: true for foo:/[bar:///foo]/host/. false for foo://host/.

bool outerUrlIsRootDirectory() const

Checks if this Eurl is a root path (with or without embeddings). Examples: true for foo://host/. false for foo://host/a. true for foo:/[bar:///goo]/host/. false for foo:/[bar:///goo]/host/a. true for foo:/[bar:///goo]//. false for foo:/[bar:///goo]//a.

bool hasParentSegment() const

Checks if this Eurl has a parent segment. This indicates if Eurl.parentSegment would return 0.

bool isPrefixOf(std::shared_ptr<const Eurl> longer) const

Checks if this Eurl is a prefix of another one. This is not an equivalent to a string comparison but it checks parent relationships according to Eurl.parentSegment.

Eurl(QString eurlstring)

Constructed only by the infrastructure and made available otherwise.

~Eurl()

Public Static Functions

std::shared_ptr<const Eurl> fromString(QString eurlstring)

Constructs a new Eurl by string (what Eurl.asString would return).

std::shared_ptr<const Eurl> create(QString scheme, QString hostname, QString path)

Constructs a new Eurl by scheme name, hostname and a path.

std::shared_ptr<const Eurl> create(QString scheme, const Eurl *inner, QString hostname, QString path)

Constructs a new Eurl by scheme name, an inner eurl, a hostname and a path.

void filenameCheck(QString filename)

Checks if a name is a valid filename. If not, EurlMisformattedException is thrown.

void doInitialize()
void doShutdown()

Public Static Attributes

const QChar WRAPPER_BEGIN = '['

The character marking the begin of an embedding.

const QChar WRAPPER_END = ']'

The character marking the end of an embedding.

const QString FORBIDDEN_FILENAME_CHARACTERS = QString("/")

Characters which are forbidden in filenames.

Private Members

const QString _eurlstring
std::shared_ptr<const Eurl> _cache_parentsegment = 0
std::shared_ptr<const Eurl> _cache_outerurl = 0
bool _cache_outerurl_isthis = false
std::shared_ptr<const Eurl> _cache_outermostinnereurl = 0
std::shared_ptr<const Eurl> _cache_root = 0
bool _cache_root_isthis = false
QString _cache_basename
QString _cache_hostname
QString _cache_path
QString _cache_scheme

Private Static Functions

QString check_scheme(QString scheme)
QString check_inner(QString inner)
QString check_hostname(QString hostname)
QString check_path(QString path)
QString check_filename(QString filename)
QString _escape(QString s)
QString _unescape(QString s)
std::shared_ptr<const Eurl> createNOCHECK(QString scheme, const Eurl *inner, QString hostname, QString path)
std::shared_ptr<const Eurl> fromStringNOCHECK(QString eurlstring)

Private Static Attributes

QHash<QChar, QString> _escapemap
QMutex _escapemapmutex
QMutex _mutex
QHash<QString, std::weak_ptr<const Eurl>> _eurluniverse