Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new to Google protobuf. I have a vector of 3D integers. For the 3D integers, I have created a struct "RawValues". I then push this struct into the vector "Value".

Here is how I have done it:

//to save 3d values in vector 
 struct RawValues
    {
        int32_t rawX ,rawY ,rawZ;
    }; 
	
//a vector of 3D values
std::vector<RawValues> Value; 

//setter for the 3d Vector 
void setValue(const std::vector<RawValues>& set) {Value= set;} 

//getter for the 3d Vector 
const std::vector<RawValues>& getValue() const {return Value;}


I need to define this in my Google protobuf.

What I have tried:

This is my protobuf file:

message RawData
{
	required int32 rawX 						=1;
	required int32 rawY 						=2;
	required int32 rawZ 						=3;	
}

message DataItem
{
     repeated RawData Value					=1;	
}



I have defined rawData as "message" that resembles a struct. Then I defined Value as "repeated" to resemble a vector of struct.
I am unsure if what i have done is correct.
Posted
Updated 4-Apr-19 22:50pm
v3
Comments
KarstenK 5-Apr-19 12:52pm    
You should use the struct of that protocol or library and not redefine them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900