diff --git a/include/caosdb/protobuf_helper.h b/include/caosdb/protobuf_helper.h index 3cfa3d433d540c545fd3d96789e9cec9166022ee..9a73c0d726b25a792232530d0e01852d9c0b2e99 100644 --- a/include/caosdb/protobuf_helper.h +++ b/include/caosdb/protobuf_helper.h @@ -22,9 +22,11 @@ #ifndef CAOSDB_PROTOBUF_HELPER_H #define CAOSDB_PROTOBUF_HELPER_H -#include "caosdb/status_code.h" -#include <google/protobuf/arena.h> // for Arena -#include <google/protobuf/extension_set.h> // for Arena +#include "caosdb/status_code.h" // for StatusCode, SUCCESS +#include <google/protobuf/arena.h> // for Arena +#include <google/protobuf/extension_set.h> // for Arena +#include <google/protobuf/util/json_util.h> // for JsonOptions, MessageToJs... +#include <string> // for string #define CAOSDB_DEBUG_MESSAGE_STRING(message, out) \ std::string out; \ @@ -47,6 +49,14 @@ public: return StatusCode::SUCCESS; } + /** + * Return a json representation of this object. + */ + inline auto ToString() const noexcept -> const std::string { + CAOSDB_DEBUG_MESSAGE_STRING(*wrapped, out) + return out; + } + protected: ProtoMessageWrapper() : ProtoMessageWrapper(Arena::CreateMessage<P>(get_arena())) {} ProtoMessageWrapper(P *wrapped) : wrapped(wrapped) {} diff --git a/include/caosdb/value.h b/include/caosdb/value.h index 20bbead6afee5c1e9f2e2a9a86c2705600bf4411..f6de040dcf02fb1600f170f2e18817ed4e2db883 100644 --- a/include/caosdb/value.h +++ b/include/caosdb/value.h @@ -22,17 +22,13 @@ #ifndef CAOSDB_VALUE_H #define CAOSDB_VALUE_H #include "caosdb/protobuf_helper.h" // for ProtoMessageWrapper -#include "caosdb/logging.h" // IWYU pragma: keep #include "caosdb/entity/v1alpha1/main.pb.h" // for RepeatedPtrField, Message - -#include <cstdint> // for int64_t -#include <google/protobuf/arena.h> // for Arena -#include <google/protobuf/generated_message_util.h> // for Arena -#include <google/protobuf/util/json_util.h> // IWYU pragma: keep -#include <memory> // for unique_ptr -#include <string> // for string, operator== -#include <utility> // for move -#include <vector> // for vector +#include <cstdint> // for int64_t +#include <google/protobuf/arena.h> // for Arena +#include <memory> // for unique_ptr +#include <string> // for string, operator== +#include <utility> // for move +#include <vector> // for vector #define LIST_VALUE_CONSTRUCTOR(TYPE, SETTER) \ explicit inline Value(const std::vector<TYPE> &values) : ProtoMessageWrapper<ProtoValue>() { \ @@ -412,11 +408,6 @@ public: return *this; } - inline auto ToString() const noexcept -> const std::string { - CAOSDB_DEBUG_MESSAGE_STRING(*wrapped, out) - return out; - } - friend class Entity; friend class Property; diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 977fb69e63a9741705506b08a9366a41dafcf7ad..8f737602bbda62bbae8e8dcf8f287e95fd82aa09 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -20,13 +20,12 @@ * */ #include "caosdb/entity.h" -#include "caosdb/data_type.h" // for DataType -#include "caosdb/entity/v1alpha1/main.pb.h" // for Messages -#include "caosdb/protobuf_helper.h" // for get_arena -#include "caosdb/value.h" // for Value -#include <google/protobuf/arena.h> // for Arena -#include <google/protobuf/generated_message_util.h> // for Arena::Create... -#include <new> // for operator new +#include "caosdb/data_type.h" // for DataType +#include "caosdb/entity/v1alpha1/main.pb.h" // for Messages +#include "caosdb/protobuf_helper.h" // for get_arena +#include "caosdb/value.h" // for Value +#include <google/protobuf/arena.h> // for Arena +#include <new> // for operator new namespace caosdb::entity { using ProtoParent = caosdb::entity::v1alpha1::Parent;