Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread sanjana gupta
Thanks Marc, I am gonna try fixed32. I will update on my findings. On Wed, Jul 18, 2018, 15:40 Marc Gravell wrote: > The first step, then, is to find how to get your ipv4 in a 4 byte > std::string rather than a 15 byte std::string - I can't advise on that, but > it should absolutely be

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread Marc Gravell
The first step, then, is to find how to get your ipv4 in a 4 byte std::string rather than a 15 byte std::string - I can't advise on that, but it should absolutely be possible. You don't need it as ASCII - you just want the bytes. As for will it be longer? No, especially when compared to uint32; a

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread sanjana gupta
I would like to understand from the protobuf generated API point of view: If I have, repeated bytes localEndpoint = 1; The generated file profile.pb.h shows me the following APIs to add+set values in it : // repeated bytes localEndpoint = 1; * inline void add_localendpoint(const

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread Marc Gravell
I would be amazed if there isn't a way of getting the raw underlying bytes from the IP address, rather than the text (ASCII). The address 111.111.111.111 is literally the 4 bytes with decimal values 111, 111, 111 and 111. No ASCII required. On Wed, 18 Jul 2018, 10:28 sanjana gupta, wrote: > Hey

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread sanjana gupta
Hey Marc, I am sorry if I am repeating my words. Please enlighten me on this thing : "bytes" requires me to give a std::string (c++) value as input. The problem with string for me is that a usual 4-byte ipv4 address like 111.111.111.111 becomes 15-bytes string "111.111.111.111" Having said

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread Marc Gravell
At that point I'd probably use "repeated bytes", then. It'll cost you an extra byte on v4 addresses, but it is simple. On Wed, 18 Jul 2018, 09:36 sanjana gupta, wrote: > Thanks Marc for your reply! By mistake I wrote 8-bytes for ipv4. I have > corrected it as 4-bytes in my question. Thanks for

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread sanjana gupta
Thanks Marc for your reply! By mistake I wrote 8-bytes for ipv4. I have corrected it as 4-bytes in my question. Thanks for that :) One thing I want to ask you is that can I use "oneof" if my field "localEndpoint" is repeated? I mean to say that my one "profile" message can have any among :

Re: [protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread Marc Gravell
You should be able to encode ipv4 in 4 bytes, making fixed32 ideal, since you can avoid the length prefix. For ipv6, you're going to need 16 bytes, so "bytes" is probably your best bet, since it will only require a single header. You can then create a union of those: oneof ip_addr {

[protobuf] What is the most efficient protobuf type (in C++) for storing ipv4 or ipv6 address? My address is a boost::asio::ip::address_v4 (or v6)

2018-07-18 Thread sanjana gupta
I read that protobuf has a type called "*bytes*" which can store arbitrary number of bytes and is the equivalent of "C++ string". The reason why I don't prefer to use "bytes" is that it expects input as a C++ string i.e., boost IP will need to be converted to a string. Now my concern lies