I have just come accross Google's Protocol buffers. It seems to be the solution for a C++ backend application I am writing. Problem is I cant seem to find anything regarding vector types. The documentation mentions repeated_types, but I cant seem to find anything.
Supposing I have these set of classes:
class UnifiedBinaryHeader
{
public:
UnifiedBinaryHeader();
void Serialize(std::ostream& output) const;
void Deserialize(std::istream& input);
private:
wxString m_name;
wxDateTime m_time;
};
struct UnifiedBinaryRow
{
wxDateTime date;
float value;
UnifiedBinaryRow()
{
value= 0;
}
void Serialize(std::ostream& output) const;
void Deserialize(std::istream& input);
};
class UnifiedBinaryRowCollection
{
private:
typedef std::vector<UnifiedBinaryRow> UnifiedBinaryRowVector;
public:
typedef UnifiedBinaryRowVector::iterator iterator;
typedef UnifiedBinaryRowVector::const_iterator const_iterator;
UnifiedBinaryRowCollection();
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
UnifiedBinaryRowCollection& AddRow(const UnifiedBinaryRow& row);
size_t NumRows() const;
private:
UnifiedBinaryRowVector m_rows;
};
class UnifiedBinaryFormat
{
public:
UnifiedBinaryFormat();
UnifiedBinaryHeader& Header();
const UnifiedBinaryHeader& Header() const;
UnifiedBinaryFormat& Header(UnifiedBinaryHeader& header);
UnifiedBinaryRowCollection& Rows();
const UnifiedBinaryRowCollection& Rows() const;
UnifiedBinaryFormat& Rows(const UnifiedBinaryRowCollection& rows);
void Serialize(std::ostream& output) const;
void Deserialize(std::istream& input);
private:
UnifiedBinaryHeader m_header;
UnifiedBinaryRowCollection m_rows;
};
How may I write a .proto file for these classes, seeing as I am using a lot of members that are vectors. Any help in "porting" these classes to a .proto file I can use will be much appreciated.