From f2a82f4f58a7922d2151414228b605bb8345d61d Mon Sep 17 00:00:00 2001 From: florijan Date: Thu, 21 Sep 2017 15:56:52 +0200 Subject: [PATCH] Decoded value - returning non-const primitives by ref Reviewers: mferencevic, mislav.bradac Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D820 --- src/communication/bolt/v1/decoder/decoded_value.cpp | 4 ++++ src/communication/bolt/v1/decoder/decoded_value.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/communication/bolt/v1/decoder/decoded_value.cpp b/src/communication/bolt/v1/decoder/decoded_value.cpp index 12a0e298e..8bfdcc3dd 100644 --- a/src/communication/bolt/v1/decoder/decoded_value.cpp +++ b/src/communication/bolt/v1/decoder/decoded_value.cpp @@ -3,6 +3,10 @@ namespace communication::bolt { #define DEF_GETTER_BY_VAL(type, value_type, field) \ + value_type &DecodedValue::Value##type() { \ + if (type_ != Type::type) throw DecodedValueException(); \ + return field; \ + } \ value_type DecodedValue::Value##type() const { \ if (type_ != Type::type) throw DecodedValueException(); \ return field; \ diff --git a/src/communication/bolt/v1/decoder/decoded_value.hpp b/src/communication/bolt/v1/decoder/decoded_value.hpp index 3edef6b19..ff320e955 100644 --- a/src/communication/bolt/v1/decoder/decoded_value.hpp +++ b/src/communication/bolt/v1/decoder/decoded_value.hpp @@ -122,6 +122,7 @@ class DecodedValue { Type type() const { return type_; } #define DECL_GETTER_BY_VALUE(type, value_type) \ + value_type &Value##type(); \ value_type Value##type() const; DECL_GETTER_BY_VALUE(Bool, bool)