Skip to content
Snippets Groups Projects
Verified Commit 4625ad87 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

EHN: Add ToString to ProtoMessageWrapper

parent b0d5af32
No related branches found
No related tags found
1 merge request!25F cpp to string
Pipeline #13624 passed
Pipeline: caosdb-cppinttest

#13626

    ...@@ -22,9 +22,11 @@ ...@@ -22,9 +22,11 @@
    #ifndef CAOSDB_PROTOBUF_HELPER_H #ifndef CAOSDB_PROTOBUF_HELPER_H
    #define CAOSDB_PROTOBUF_HELPER_H #define CAOSDB_PROTOBUF_HELPER_H
    #include "caosdb/status_code.h" #include "caosdb/status_code.h" // for StatusCode, SUCCESS
    #include <google/protobuf/arena.h> // for Arena #include <google/protobuf/arena.h> // for Arena
    #include <google/protobuf/extension_set.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) \ #define CAOSDB_DEBUG_MESSAGE_STRING(message, out) \
    std::string out; \ std::string out; \
    ...@@ -47,6 +49,14 @@ public: ...@@ -47,6 +49,14 @@ public:
    return StatusCode::SUCCESS; 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: protected:
    ProtoMessageWrapper() : ProtoMessageWrapper(Arena::CreateMessage<P>(get_arena())) {} ProtoMessageWrapper() : ProtoMessageWrapper(Arena::CreateMessage<P>(get_arena())) {}
    ProtoMessageWrapper(P *wrapped) : wrapped(wrapped) {} ProtoMessageWrapper(P *wrapped) : wrapped(wrapped) {}
    ......
    ...@@ -22,17 +22,13 @@ ...@@ -22,17 +22,13 @@
    #ifndef CAOSDB_VALUE_H #ifndef CAOSDB_VALUE_H
    #define CAOSDB_VALUE_H #define CAOSDB_VALUE_H
    #include "caosdb/protobuf_helper.h" // for ProtoMessageWrapper #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 "caosdb/entity/v1alpha1/main.pb.h" // for RepeatedPtrField, Message
    #include <cstdint> // for int64_t
    #include <cstdint> // for int64_t #include <google/protobuf/arena.h> // for Arena
    #include <google/protobuf/arena.h> // for Arena #include <memory> // for unique_ptr
    #include <google/protobuf/generated_message_util.h> // for Arena #include <string> // for string, operator==
    #include <google/protobuf/util/json_util.h> // IWYU pragma: keep #include <utility> // for move
    #include <memory> // for unique_ptr #include <vector> // for vector
    #include <string> // for string, operator==
    #include <utility> // for move
    #include <vector> // for vector
    #define LIST_VALUE_CONSTRUCTOR(TYPE, SETTER) \ #define LIST_VALUE_CONSTRUCTOR(TYPE, SETTER) \
    explicit inline Value(const std::vector<TYPE> &values) : ProtoMessageWrapper<ProtoValue>() { \ explicit inline Value(const std::vector<TYPE> &values) : ProtoMessageWrapper<ProtoValue>() { \
    ...@@ -412,11 +408,6 @@ public: ...@@ -412,11 +408,6 @@ public:
    return *this; return *this;
    } }
    inline auto ToString() const noexcept -> const std::string {
    CAOSDB_DEBUG_MESSAGE_STRING(*wrapped, out)
    return out;
    }
    friend class Entity; friend class Entity;
    friend class Property; friend class Property;
    ......
    ...@@ -20,13 +20,12 @@ ...@@ -20,13 +20,12 @@
    * *
    */ */
    #include "caosdb/entity.h" #include "caosdb/entity.h"
    #include "caosdb/data_type.h" // for DataType #include "caosdb/data_type.h" // for DataType
    #include "caosdb/entity/v1alpha1/main.pb.h" // for Messages #include "caosdb/entity/v1alpha1/main.pb.h" // for Messages
    #include "caosdb/protobuf_helper.h" // for get_arena #include "caosdb/protobuf_helper.h" // for get_arena
    #include "caosdb/value.h" // for Value #include "caosdb/value.h" // for Value
    #include <google/protobuf/arena.h> // for Arena #include <google/protobuf/arena.h> // for Arena
    #include <google/protobuf/generated_message_util.h> // for Arena::Create... #include <new> // for operator new
    #include <new> // for operator new
    namespace caosdb::entity { namespace caosdb::entity {
    using ProtoParent = caosdb::entity::v1alpha1::Parent; using ProtoParent = caosdb::entity::v1alpha1::Parent;
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment