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,13 +22,9 @@ ...@@ -22,13 +22,9 @@
    #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 <google/protobuf/generated_message_util.h> // for Arena
    #include <google/protobuf/util/json_util.h> // IWYU pragma: keep
    #include <memory> // for unique_ptr #include <memory> // for unique_ptr
    #include <string> // for string, operator== #include <string> // for string, operator==
    #include <utility> // for move #include <utility> // for move
    ...@@ -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;
    ......
    ...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
    #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 {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment