Refactor: move RNAPath == operator implementation to a free function
This is to follow C++ core guidelines. Based on this discussion: https://projects.blender.org/blender/blender/pulls/123998#issuecomment-1229591 Pull Request: https://projects.blender.org/blender/blender/pulls/124394
This commit is contained in:
committed by
Nathan Vegdahl
parent
d4ae97fc3d
commit
45c489396f
@@ -64,29 +64,18 @@ struct RNAPath {
|
||||
*/
|
||||
std::optional<std::string> key = std::nullopt;
|
||||
std::optional<int> index = std::nullopt;
|
||||
|
||||
/**
|
||||
* NOTE: equality is defined in a specific way here to reflect the semantic
|
||||
* meaning of `RNAPath`. Since the key existing indicates a key-based array
|
||||
* element, with the index then only serving as a fallback, the index only
|
||||
* affects the equality result if *neither* `RNAPath` has a key specified.
|
||||
* (See the main `RNAPath` documentation above for the specific semantics of
|
||||
* key and index.)
|
||||
*/
|
||||
bool operator==(const RNAPath &other) const
|
||||
{
|
||||
if (this->path != other.path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->key.has_value() || other.key.has_value()) {
|
||||
return this->key == other.key;
|
||||
}
|
||||
|
||||
return this->index == other.index;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* NOTE: equality is defined in a specific way here to reflect the semantic
|
||||
* meaning of `RNAPath`. Since the key existing indicates a key-based array
|
||||
* element, with the index then only serving as a fallback, the index only
|
||||
* affects the equality result if *neither* `RNAPath` has a key specified.
|
||||
* (See the main `RNAPath` documentation above for the specific semantics of
|
||||
* key and index.)
|
||||
*/
|
||||
bool operator==(const RNAPath &left, const RNAPath &right);
|
||||
|
||||
char *RNA_path_append(
|
||||
const char *path, const PointerRNA *ptr, PropertyRNA *prop, int intkey, const char *strkey);
|
||||
#if 0 /* UNUSED. */
|
||||
|
||||
@@ -34,6 +34,19 @@
|
||||
#include "rna_access_internal.h"
|
||||
#include "rna_internal.hh"
|
||||
|
||||
bool operator==(const RNAPath &left, const RNAPath &right)
|
||||
{
|
||||
if (left.path != right.path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (left.key.has_value() || right.key.has_value()) {
|
||||
return left.key == right.key;
|
||||
}
|
||||
|
||||
return left.index == right.index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the first token from `path`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user