Skip to content

Commit c1a511c

Browse files
committed
Add code to compara two enums values and add copy_from methode
1 parent b4f4376 commit c1a511c

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/mfast/coder/encoder_v2/fast_encoder_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "../mfast_coder_export.h"
44
#include "../../sequence_ref.h"
5+
#include "../../enum_ref.h"
56
#include "../../nested_message_ref.h"
67
#include "../../malloc_allocator.h"
78
#include "../common/template_repo.h"
@@ -31,6 +32,11 @@ inline bool equivalent(const decimal_cref &v, const value_storage &prev) {
3132
v.exponent() == prev.of_decimal.exponent_;
3233
}
3334

35+
inline bool equivalent(const enum_cref &v, const value_storage &prev) {
36+
return v.absent() == prev.is_empty() &&
37+
v.value() == prev.of_uint64.content_;
38+
}
39+
3440
template <typename T>
3541
inline bool equivalent(const vector_cref<T> &v, const value_storage &prev) {
3642
return v.size() == prev.of_array.len_ - 1 &&

src/mfast/enum_ref.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ class enum_mref : public make_field_mref<enum_cref> {
9797
*this->storage() = this->instruction()->initial_value();
9898
}
9999
value_type value() const { return this->storage()->get<value_type>(); }
100+
101+
protected:
102+
friend class mfast::detail::codec_helper;
103+
104+
void copy_from(value_storage v) const { *this->storage() = v; }
100105
};
101106

102107
template <> struct mref_of<enum_cref> { typedef enum_mref type; };

0 commit comments

Comments
 (0)