Deleting Particular repeated field data from Google protocol buffer
-
wrote on 4 Sept 2014, 11:30 last edited by
Hi,
I am working on Google Protocol Buffers for serializing and de-serializing , I searched through google protocol buffer library but couldn't find a way to delete a particular field from a message,
.proto file structure
@message repetedMSG
{
required string data = 1;
}message mainMSG
{
required repetedMSG_id = 1;
repeated repetedMSG rptMSG = 2;
}@I have one mainMSG and in it too many (suppose 10) repetedMSG are present. Now i want to delete any particular repetedMSG (suppose 5th repetedMSG )from mainMSG. For this i tried 2 ways but none of them worked.
@for (int j = 0; j<mainMSG->repetedMSG_size(); j++)
{
repetedMSG reptMsg = mainMsg->mutable_repetedMSG(j);if (QString::fromStdString(reptMsg->data).compare("deleteMe") == 0)
{
reptMsg->Clear(); // <-- First tried way
delete reptMsg; // <-- Second tried Way
break;
}
}@Any help will be higly appreciated.
Regards
1/1