Deleting Particular repeated field data from Google protocol buffer

  • 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

    Any help will be higly appreciated.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.