Protocol Buffer - Static Initialization of array's

131 views
Skip to first unread message

Kavali Naresh

unread,
Jan 28, 2015, 9:43:47 AM1/28/15
to prot...@googlegroups.com
Hi All,
 
Our project is build using VC++(MFC) and few files have structures declared, few arrays of integers and char's and they are initialized statically. We have few static member variables initialized with data as below,
char* class::m_psz[] = {
   "COL",
   "FAC",
   "MAS",
   "NOL",
   "SET"
};
 
TYPE_20 class::m_Defaults[] = {
    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}
};
 
And have few typedefs as below,
typedef unsigned char TYPE_20[20];
 
My requirement is to use Protocol Buffer concept and achieve the above. So How can i write the *.proto file (or the schema) to declare the static array of integers and initialize values to it. And finally i need to generate the *.cs (cshar file) out of it.
 
Below are my Basic knowledge on PB:
1) I created the classes, used "optional", "repeated" concepts.
2) created the code to declare 2d array.
3) how do I initialize the array at declaration time as it is done in C++?
Below is code of PB schema for 2d array without initialization(at static time)
 
repeated DefaultsForTYPE_20 m_DefaultsForTYPE_20 = 1;
    message DefaultsForTYPE_20{
        optional bytes m_DefaultsForTYPE_20 = 1;
    }
but how can i initialize data to it here?
 
Please provide me your suggestions, it's kind of Urgent for me.
 
Thanks in Advance
Reply all
Reply to author
Forward
0 new messages