@@ -174,6 +174,18 @@ ViewFactory::parse_prefixlen_field(const std::string &def)
174174 return field;
175175}
176176
177+ std::string
178+ ViewFactory::parse_inout_prefix (std::string &def)
179+ {
180+ std::string dir = " " ;
181+ if (check_strip_prefix (def, " in " ) || check_strip_prefix (def, " in" )) {
182+ dir = " in" ;
183+ } else if (check_strip_prefix (def, " out " ) || check_strip_prefix (def, " out" )) {
184+ dir = " out" ;
185+ }
186+ return dir;
187+ }
188+
177189std::unique_ptr<Field>
178190ViewFactory::parse_dir_field (const std::string &def)
179191{
@@ -238,6 +250,12 @@ ViewFactory::create_value_field(const std::string& def)
238250 throw std::invalid_argument (" invalid aggregation function " + func);
239251 }
240252
253+ if (prefix == " in" ) {
254+ field.reset (new InOutValueField (std::move (field), ViewDirection::In));
255+ } else if (prefix == " out" ) {
256+ field.reset (new InOutValueField (std::move (field), ViewDirection::Out));
257+ }
258+
241259 field->set_name (def);
242260 return field;
243261}
@@ -301,9 +319,24 @@ ViewFactory::create_view(
301319 view.m_value_size += field->size ();
302320 view.m_value_count ++;
303321
322+ if (field->is_of_type <InOutValueField>()) {
323+ view.m_has_inout_fields = true ;
324+ }
325+
304326 view.m_fields .push_back (std::move (field));
305327 }
306328
329+ if (view.m_has_inout_fields ) {
330+ for (size_t i = 0 ; i < view.m_key_count ; i++) {
331+ auto &field = view.m_fields [i];
332+ if (auto new_field = InOutKeyField::create_from (*field.get ())) {
333+ new_field->set_name (field->name ());
334+ new_field->set_offset (field->offset ());
335+ field = std::move (new_field);
336+ }
337+ }
338+ }
339+
307340 if (!order_def.empty ()) {
308341 for (auto def : split_args (order_def)) {
309342 string_trim (def);
0 commit comments