On Thu, Sep 15, 2016 at 1:48 PM, Виталий Андросенко <[email protected]>
wrote:
> Thank you for yours answers. It isn't really good. I think, that i can
> create user define type customize file compiler from protobuf to python and
> using custom options...
> P.S. I can use monkey patching to create oun compiler, but i don't think
> that it is good idea :(
>
You can actually extend the protocol compiler by writing a compiler plugin.
That allows you to generate additional code in the generated files. It can
take advantage of custom options. For example:
// foo.proto
syntax = "proto3";
import "google/protobuf/descriptor.proto";
extend google.protobuf.FieldOptions {
bool is_decimal = xxx;
}
message Foo {
string decimal_value = 1 [(is_decimal) = true];
}
And then your custom protoc plugin and add additional getter/setter for
that decimal_value field (to basically convert between decimal and string).
>
> 2016-09-15 23:14 GMT+03:00 Feng Xiao <[email protected]>:
>
>> Protobuf does not support defining custom field types. You need to
>> represent your data using some existing protobuf field types and probably
>> also write some helper functions to do translation between the proto type
>> and the actual type you want to store.
>>
>> On Thu, Sep 15, 2016 at 8:48 AM, 'Nathaniel Manista' via Protocol Buffers
>> <[email protected]> wrote:
>>
>>> [email protected] once more with feeling
>>>
>>> On Thu, Sep 15, 2016 at 8:41 AM, Nathaniel Manista <[email protected]
>>> > wrote:
>>>
>>>> [email protected]
>>>>
>>>> On Wed, Sep 14, 2016 at 10:10 PM, <[email protected]> wrote:
>>>>
>>>>> >>> gRPC Python sounds like a great fit for your use.
>>>>> I think the same.
>>>>>
>>>>> And another small question. A can't find mechanizm in documentation
>>>>> how can i create user-define type. I need something like decimal, but in
>>>>> "Scalar Value Types" i can get only python float type. A search in this
>>>>> group, but can find only this post
>>>>> <https://groups.google.com/forum/#!topic/protobuf/eFDUKVao6CU>. Maybe
>>>>> you have a small manual how can i create special type for my project?
>>>>>
>>>>
>>>> This is more of a "how do I design my Protocol Buffers messages"
>>>> question than a gRPC question; I certainly don't know the answer. Proto
>>>> party people, your thoughts?
>>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/protobuf.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.