diff --git a/include/opendht/default_types.h b/include/opendht/default_types.h index 8b55a6de2c44e6562283485a20f1bf9638efd62f..1b02d67fae81fed939f3129fb611fd28580755b6 100644 --- a/include/opendht/default_types.h +++ b/include/opendht/default_types.h @@ -21,8 +21,6 @@ #include "value.h" -MSGPACK_ADD_ENUM(dht::Value::Field) - namespace dht { enum class ImStatus : uint8_t { NONE = 0, diff --git a/include/opendht/value.h b/include/opendht/value.h index c498a7ae14976377363da52b2117ffcb52fb8eb4..cb9e4433cc10b2ee0ca6b4ce9a5d942be18278ef 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -630,30 +630,6 @@ private: Blob blobValue {}; }; - -/** - * @struct FieldSelectorDescription - * @brief Describes a selection. - * @details - * This is meant to narrow data to a set of specified fields. This structure is - * used to construct a Select structure. - */ -struct OPENDHT_PUBLIC FieldSelectorDescription -{ - FieldSelectorDescription() {} - FieldSelectorDescription(Value::Field f) : field(f) {} - - Value::Field getField() const { return field; } - - bool operator==(const FieldSelectorDescription& fd) const { return field == fd.field; } - - template <typename Packer> - void msgpack_pack(Packer& p) const { p.pack(static_cast<uint8_t>(field)); } - void msgpack_unpack(msgpack::object msg) { field = static_cast<Value::Field>(msg.as<int>()); } -private: - Value::Field field {Value::Field::None}; -}; - /** * @class Select * @brief Serializable Value field selection. @@ -686,11 +662,7 @@ struct OPENDHT_PUBLIC Select * @return the set of fields. */ std::set<Value::Field> getSelection() const { - std::set<Value::Field> fields {}; - for (const auto& f : fieldSelection_) { - fields.insert(f.getField()); - } - return fields; + return std::set<Value::Field>(fieldSelection_.begin(), fieldSelection_.end()); } template <typename Packer> @@ -702,7 +674,7 @@ struct OPENDHT_PUBLIC Select OPENDHT_PUBLIC friend std::ostream& operator<<(std::ostream& s, const dht::Select& q); private: - std::vector<FieldSelectorDescription> fieldSelection_ {}; + std::vector<Value::Field> fieldSelection_ {}; }; /** @@ -953,3 +925,5 @@ unpackVector(const std::vector<std::shared_ptr<Value>>& vals) { } } + +MSGPACK_ADD_ENUM(dht::Value::Field) diff --git a/src/value.cpp b/src/value.cpp index fac0e63fc0942190f3e37a44260c457d9e73a72c..68ee10fb6572c941f20a341f6e875a7df59e60f8 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -427,7 +427,7 @@ bool Query::isSatisfiedBy(const Query& q) const { std::ostream& operator<<(std::ostream& s, const dht::Select& select) { s << "SELECT " << (select.fieldSelection_.empty() ? "*" : ""); for (auto fs = select.fieldSelection_.begin() ; fs != select.fieldSelection_.end() ; ++fs) { - switch (fs->getField()) { + switch (*fs) { case Value::Field::Id: s << "id"; break;