Skip to content

Commit 1accd0b

Browse files
committed
Add the correction for the encoder and decoder
1 parent 389434d commit 1accd0b

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/mfast/aggregate_ref.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class aggregate_cref {
5757
this->instruction_ = other.instruction_;
5858
this->storage_array_ = other.storage_array_;
5959
}
60+
bool content() const { return storage_array_->of_group.content_ != nullptr; }
6061

6162
class iterator
6263
: public boost::iterator_facade<iterator, field_cref,

src/mfast/coder/encoder/fast_encoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ void fast_encoder_impl::visit(message_cref cref, bool force_reset) {
195195
aggregate_cref message(cref.field_storage(0), instruction);
196196

197197
for (auto &&field : message)
198+
{
198199
if (field.present() || field.instruction()->field_operator() == operator_none)
199200
apply_accessor(*this, field);
201+
else if (!field.present() && field.instruction()->pmap_size())
202+
current_pmap().set_next_bit(false);
203+
}
200204

201205
pmap.commit();
202206
}

src/mfast/ext_ref.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,23 @@ class ext_cref<BaseCRef, sequence_element_tag, Properties>
183183
aggregate_cref base_;
184184
};
185185

186+
template <typename BaseCRef, typename Properties>
187+
class ext_cref<BaseCRef, group_type_tag, Properties>
188+
: public ext_ref_properties<group_type_tag, Properties> {
189+
public:
190+
typedef BaseCRef cref_type;
191+
typedef typename cref_type::type_category type_category;
192+
typedef group_type_tag operator_category;
193+
194+
explicit ext_cref(const field_cref &base) : base_(base) {}
195+
explicit ext_cref(const aggregate_cref &base) : base_(base) {}
196+
cref_type get() const { return base_; }
197+
bool present() const { return !this->optional() || base_.content(); }
198+
199+
private:
200+
cref_type base_;
201+
};
202+
186203
template <typename Properties>
187204
class ext_cref<nested_message_cref, group_type_tag, Properties>
188205
: public ext_ref_properties<group_type_tag, Properties> {

0 commit comments

Comments
 (0)