Regarding Handling Repeated Fields in schema

214 views
Skip to first unread message

Yogesh Fulsunge

unread,
Jun 9, 2016, 8:53:17 AM6/9/16
to Protocol Buffers
Dear Team,

I have a schema which handles repeated fields as shown below, i am facing problems for Initialising the repeated fields.

In my schema, i have one Rack inside that i have multiple Shelf and inside one shelf i have multiple Cards and Slots.

how to handle this kind of scenario in C++ APIs?  

I generated the C++ code and for handling repeated fields it makes use of google::protobuf::RepeatedPtrField  which i am not able to Initialise in code.

can you help me with some sample C++ code to understand the usage? whether i am using correct approach?? please let me know.

is there a way i can generate JSON data structure instead of Templates i guess it will be easier can you please help me in this??


message RackRequest {
required ReqType req_type = 1;
required float rheight = 2;
required float rwidth = 3;
repeated Shelf shelf_in = 4;
enum ReqType {
SEARCH = 0;
ADD = 1;
MODIFY = 2;
DELETE = 3;
}
}

message RackResponse {
required RespType resp_type = 1;
required float rheight = 2;
required float rwidth = 3;
repeated Shelf shelf_in = 4;
enum RespType {
SEARCH = 0;
ADD = 1;
MODIFY = 2;
DELETE = 3;
}
required int32 result_code = 7;

}
message Shelf {
    required float sxaxis = 1;
    required float syaxis = 2;
    required float sheight = 3;
    required float swidth = 4;
    required bool sconfigurable = 5;
repeated Card card_in = 6;
repeated Slot slot_in = 7;
}
message Card {
    required float cxaxis = 1;
    required float cyaxis = 2;
    required float cheight = 3;
    required float cwidth = 4;
    required bool cconfigurable = 5;
    repeated int32 port = 6;
    }
message Slot {
    required float cxaxis = 1;
    required float cyaxis = 2;
    required float cheight = 3;
    required float cwidth = 4;
    required bool cconfigurable = 5;
    repeated int32 port = 6;
    }

Feng Xiao

unread,
Jun 10, 2016, 1:13:29 PM6/10/16
to Yogesh Fulsunge, Protocol Buffers
On Thu, Jun 9, 2016 at 5:53 AM, Yogesh Fulsunge <yogesh.t...@gmail.com> wrote:
Dear Team,

I have a schema which handles repeated fields as shown below, i am facing problems for Initialising the repeated fields.

In my schema, i have one Rack inside that i have multiple Shelf and inside one shelf i have multiple Cards and Slots.

how to handle this kind of scenario in C++ APIs?  

I generated the C++ code and for handling repeated fields it makes use of google::protobuf::RepeatedPtrField  which i am not able to Initialise in code.

can you help me with some sample C++ code to understand the usage? whether i am using correct approach?? please let me know.
Please refer to the generated code guide for repeated message fields:
 

is there a way i can generate JSON data structure instead of Templates i guess it will be easier can you please help me in this??

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Yogesh Fulsunge

unread,
Jun 11, 2016, 3:31:28 PM6/11/16
to Feng Xiao, Protocol Buffers
Dear Feng,

I have seen the links, but i am not able to understand how to use them thats why i am asking again.

can you please send me some sample examples for inserting and extracting of a repeated field from its parent message class object?

Regards,
Yogesh
Reply all
Reply to author
Forward
0 new messages