Skip to content

Commit

Permalink
libcore|Path|NativePath: Added move constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 14, 2017
1 parent 45a6119 commit c4006bd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doomsday/sdk/libcore/include/de/data/path.h
Expand Up @@ -472,7 +472,35 @@ class DENG2_PUBLIC DotPath : public Path
DotPath(QString const &str) : Path(str, '.') {}
DotPath(char const *nullTerminatedCStr) : Path(nullTerminatedCStr, '.') {}
DotPath(Path const &other) : Path(other) {}
DotPath(Path &&moved) : Path(moved) {}
DotPath(DotPath const &other) : Path(other.toStringRef(), other.separator()) {}
DotPath(DotPath &&moved) : Path(moved) {}

DotPath &operator = (char const *nullTerminatedCStr) {
return *this = DotPath(nullTerminatedCStr);
}
DotPath &operator = (String const &str) {
return *this = DotPath(str);
}
DotPath &operator = (QString const &str) {
return *this = DotPath(str);
}
DotPath &operator = (Path const &other) {
Path::operator = (other);
return *this;
}
DotPath &operator = (DotPath const &other) {
Path::operator = (other);
return *this;
}
DotPath &operator = (Path &&moved) {
Path::operator = (moved);
return *this;
}
DotPath &operator = (DotPath &&moved) {
Path::operator = (moved);
return *this;
}

bool operator == (DotPath const &other) const {
return Path::operator == (other);
Expand Down
5 changes: 5 additions & 0 deletions doomsday/sdk/libcore/include/de/filesys/nativepath.h
Expand Up @@ -51,6 +51,9 @@ class DENG2_PUBLIC NativePath : public Path
*/
NativePath();

NativePath(NativePath const &other);
NativePath(NativePath &&moved);

/**
* Constructs a native path from any string.
*
Expand All @@ -72,6 +75,8 @@ class DENG2_PUBLIC NativePath : public Path
NativePath &operator = (String const &str);

NativePath &operator = (QString const &str);
NativePath &operator = (NativePath &&moved);
NativePath &operator = (NativePath const &other);
NativePath &operator = (char const *nullTerminatedCStr);

/**
Expand Down
20 changes: 20 additions & 0 deletions doomsday/sdk/libcore/src/filesys/nativepath.cpp
Expand Up @@ -65,6 +65,14 @@ static QString toNative(String const &s)
NativePath::NativePath() : Path()
{}

NativePath::NativePath(NativePath const &other)
: Path(other)
{}

NativePath::NativePath(NativePath &&moved)
: Path(moved)
{}

NativePath::NativePath(String const &str) : Path(toNative(str), DIR_SEPARATOR)
{}

Expand All @@ -91,6 +99,18 @@ NativePath &NativePath::operator = (QString const &str)
return *this;
}

NativePath &NativePath::operator = (NativePath &&moved)
{
Path::operator = (moved);
return *this;
}

NativePath &NativePath::operator = (NativePath const &other)
{
Path::operator = (other);
return *this;
}

NativePath &NativePath::operator = (char const *nullTerminatedCStr)
{
return (*this) = String(nullTerminatedCStr);
Expand Down

0 comments on commit c4006bd

Please sign in to comment.