1.1 --- a/core/UserMessagePBHelpers.h Fri Mar 21 13:10:44 2014 -0400
1.2 +++ b/core/UserMessagePBHelpers.h Fri Mar 21 13:23:48 2014 -0400
1.3 @@ -1093,6 +1093,24 @@
1.4 return msg->GetReflection()->FieldSize(*msg, field);
1.5 }
1.6
1.7 + inline bool RemoveRepeatedFieldValue(const char *pszFieldName, int index)
1.8 + {
1.9 + GETCHECK_FIELD();
1.10 + CHECK_FIELD_REPEATED();
1.11 + CHECK_REPEATED_ELEMENT(index);
1.12 +
1.13 + // Protobuf guarantees that repeated field values will stay in order and so must we.
1.14 + const protobuf::Reflection *pReflection = msg->GetReflection();
1.15 + for (int i = index; i < elemCount - 1; ++i)
1.16 + {
1.17 + pReflection->SwapElements(msg, field, i, i + 1);
1.18 + }
1.19 +
1.20 + pReflection->RemoveLast(msg, field);
1.21 +
1.22 + return true;
1.23 + }
1.24 +
1.25 private:
1.26 protobuf::Message *msg;
1.27 PBHandleList childHandles;