Update StarDirectives.cpp

This commit is contained in:
Kae 2024-01-03 19:17:19 +11:00
parent 9e605b182d
commit 98b27f5f65
2 changed files with 36 additions and 10 deletions

View File

@ -50,6 +50,7 @@ Directives::Shared::Shared(List<Entry>&& givenEntries, String&& givenString, Str
} }
Directives::Directives() {} Directives::Directives() {}
Directives::Directives(String const& directives) { Directives::Directives(String const& directives) {
parse(String(directives)); parse(String(directives));
} }
@ -62,29 +63,49 @@ Directives::Directives(const char* directives) {
parse(directives); parse(directives);
} }
Directives& Directives::operator=(String const& directives) { Directives::Directives(Directives&& directives) {
if (shared && shared->string == directives) *this = move(directives);
}
Directives::Directives(Directives const& directives) {
*this = directives;
}
Directives::~Directives() {}
Directives& Directives::operator=(String const& s) {
if (shared && shared->string == s)
return *this; return *this;
parse(String(directives)); parse(String(s));
return *this; return *this;
} }
Directives& Directives::operator=(String&& directives) { Directives& Directives::operator=(String&& s) {
if (shared && shared->string == directives) { if (shared && shared->string == s) {
directives.clear(); s.clear();
return *this; return *this;
} }
parse(move(directives)); parse(move(s));
return *this; return *this;
} }
Directives& Directives::operator=(const char* directives) { Directives& Directives::operator=(const char* s) {
if (shared && shared->string.utf8().compare(directives) == 0) if (shared && shared->string.utf8().compare(s) == 0)
return *this; return *this;
parse(directives); parse(s);
return *this;
}
Directives& Directives::operator=(Directives&& other) {
shared = move(other.shared);
return *this;
}
Directives& Directives::operator=(Directives const& other) {
shared = other.shared;
return *this; return *this;
} }

View File

@ -44,10 +44,15 @@ public:
Directives(String const& directives); Directives(String const& directives);
Directives(String&& directives); Directives(String&& directives);
Directives(const char* directives); Directives(const char* directives);
Directives(Directives const& directives);
Directives(Directives&& directives);
~Directives();
Directives& operator=(String const& s); Directives& operator=(String const& s);
Directives& operator=(String&& s); Directives& operator=(String&& s);
Directives& operator=(const char* s); Directives& operator=(const char* s);
Directives& operator=(Directives&& other);
Directives& operator=(Directives const& other);
void loadOperations() const; void loadOperations() const;
void parse(String&& directives); void parse(String&& directives);