mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Move overloaded symmetric operators out of classes
This follows the advice of C++ Core Guidelines C.161 and C.168. The File equality and less than comparison operators have not been moved because File::GetDisplayName() is not a trivial accessor.
This commit is contained in:
@@ -62,20 +62,6 @@ public:
|
||||
const std::vector<std::string>& afterGroups = {},
|
||||
const std::string& description = "");
|
||||
|
||||
/**
|
||||
* Check if two Group objects are equal by comparing their names.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Group& rhs) const;
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Group objects
|
||||
* can be stored in sets.
|
||||
* @returns True if this Group is less than the given Group, false
|
||||
* otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Group& rhs) const;
|
||||
|
||||
/**
|
||||
* Get the name of the group.
|
||||
* @return The group's name.
|
||||
@@ -100,12 +86,26 @@ private:
|
||||
std::vector<std::string> afterGroups_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two Group objects are equal by comparing their names.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Group& lhs, const Group& rhs);
|
||||
|
||||
/**
|
||||
* Check if two Group objects are not equal.
|
||||
* @returns True if the Group objects are not equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator!=(const Group& lhs, const Group& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Group objects
|
||||
* can be stored in sets.
|
||||
* @returns True if the first Group is less than the second Group, false
|
||||
* otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Group& lhs, const Group& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first Group object is greater than the second Group
|
||||
* object.
|
||||
|
||||
@@ -52,20 +52,6 @@ public:
|
||||
LOOT_API explicit Location(const std::string& url,
|
||||
const std::string& name = "");
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Location objects
|
||||
* can be stored in sets.
|
||||
* @returns True if this Location is less than the given Location, false
|
||||
* otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Location& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if two Location objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Location& rhs) const;
|
||||
|
||||
/**
|
||||
* Get the object's URL.
|
||||
* @return A URL string.
|
||||
@@ -83,12 +69,26 @@ private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two Location objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Location& lhs, const Location& rhs);
|
||||
|
||||
/**
|
||||
* Check if two Location objects are not equal.
|
||||
* @returns True if the Location objects are not equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator!=(const Location& lhs, const Location& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Location objects
|
||||
* can be stored in sets.
|
||||
* @returns True if the first Location is less than the second Location, false
|
||||
* otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Location& lhs, const Location& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first Location object is greater than the second Location
|
||||
* object.
|
||||
|
||||
@@ -84,20 +84,6 @@ public:
|
||||
*/
|
||||
LOOT_API explicit Message(const SimpleMessage& message);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Message objects
|
||||
* can be stored in sets.
|
||||
* @returns Returns true if this Message is less than the given Message, and
|
||||
* false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Message& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if two Message objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Message& rhs) const;
|
||||
|
||||
/**
|
||||
* Get the message type.
|
||||
* @return The message type.
|
||||
@@ -125,12 +111,26 @@ private:
|
||||
std::vector<MessageContent> content_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two Message objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Message& lhs, const Message& rhs);
|
||||
|
||||
/**
|
||||
* Check if two Message objects are not equal.
|
||||
* @returns True if the Message objects are not equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator!=(const Message& lhs, const Message& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Message objects
|
||||
* can be stored in sets.
|
||||
* @returns Returns true if the first Message is less than the second Message,
|
||||
* and false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Message& lhs, const Message& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first Message object is greater than the second Message object.
|
||||
* @returns True if the second Message object is less than the first Message
|
||||
|
||||
@@ -72,31 +72,31 @@ public:
|
||||
*/
|
||||
LOOT_API std::string GetLanguage() const;
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that MessageContent
|
||||
* objects can be stored in sets.
|
||||
* @returns True if this MessageContent is less than the given
|
||||
* MessageContent, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const MessageContent& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if two MessageContent objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const MessageContent& rhs) const;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
std::string language_{DEFAULT_LANGUAGE};
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two MessageContent objects are equal by comparing their fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const MessageContent& lhs, const MessageContent& rhs);
|
||||
|
||||
/**
|
||||
* Check if two MessageContent objects are not equal.
|
||||
* @returns True if the MessageContent objects are not equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator!=(const MessageContent& lhs, const MessageContent& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that MessageContent
|
||||
* objects can be stored in sets.
|
||||
* @returns True if the first MessageContent is less than the second
|
||||
* MessageContent, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const MessageContent& lhs, const MessageContent& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first MessageContent object is greater than the second
|
||||
* MessageContent object.
|
||||
|
||||
@@ -83,20 +83,6 @@ public:
|
||||
unsigned int itm,
|
||||
unsigned int ref,
|
||||
unsigned int nav);
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that
|
||||
* PluginCleaningData objects can be stored in sets.
|
||||
* @returns True if this PluginCleaningData is less than the given
|
||||
* PluginCleaningData, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const PluginCleaningData& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if two PluginCleaningData objects are equal by comparing their
|
||||
* fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const PluginCleaningData& rhs) const;
|
||||
|
||||
/**
|
||||
* Get the CRC that identifies the plugin that the cleaning data is for.
|
||||
@@ -147,6 +133,14 @@ private:
|
||||
std::vector<MessageContent> detail_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two PluginCleaningData objects are equal by comparing their
|
||||
* fields.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const PluginCleaningData& lhs,
|
||||
const PluginCleaningData& rhs);
|
||||
|
||||
/**
|
||||
* Check if two MessageContent objects are not equal.
|
||||
* @returns True if the MessageContent objects are not equal, false otherwise.
|
||||
@@ -154,6 +148,15 @@ private:
|
||||
LOOT_API bool operator!=(const PluginCleaningData& lhs,
|
||||
const PluginCleaningData& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that
|
||||
* PluginCleaningData objects can be stored in sets.
|
||||
* @returns True if the first PluginCleaningData is less than the second
|
||||
* PluginCleaningData, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const PluginCleaningData& lhs,
|
||||
const PluginCleaningData& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first PluginCleaningData object is greater than the second
|
||||
* PluginCleaningData object.
|
||||
|
||||
+13
-13
@@ -57,19 +57,6 @@ public:
|
||||
const bool isAddition = true,
|
||||
const std::string& condition = "");
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Tag objects
|
||||
* can be stored in sets.
|
||||
* @returns True if this Tag is less than the given Tag, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Tag& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if two Tag objects are equal.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Tag& rhs) const;
|
||||
|
||||
/**
|
||||
* Check if the tag should be added.
|
||||
* @return True if the tag should be added, false if it should be removed.
|
||||
@@ -87,12 +74,25 @@ private:
|
||||
bool addTag_{true};
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two Tag objects are equal.
|
||||
* @returns True if the objects' fields are equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator==(const Tag& lhs, const Tag& rhs);
|
||||
|
||||
/**
|
||||
* Check if two Tag objects are not equal.
|
||||
* @returns True if the Tag objects are not equal, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator!=(const Tag& lhs, const Tag& rhs);
|
||||
|
||||
/**
|
||||
* A less-than operator implemented with no semantics so that Tag objects
|
||||
* can be stored in sets.
|
||||
* @returns True if the first Tag is less than the second Tag, false otherwise.
|
||||
*/
|
||||
LOOT_API bool operator<(const Tag& lhs, const Tag& rhs);
|
||||
|
||||
/**
|
||||
* Check if the first Tag object is greater than the second Tag object.
|
||||
* @returns True if the second Tag object is less than the first Tag object,
|
||||
|
||||
Reference in New Issue
Block a user