def protobuf_get_constant_type(proto_type) :
    """About protobuf write types see :
    https://developers.google.com/protocol-buffers/docs/encoding#structure

    +--------------------------------------+
    + Type + Meaning +       Used For      +
    +--------------------------------------+
    +      +         + int32, int64, uint32+
    +  0   + Varint  + uint64,sint32,sint64+
    +      +         + boolean, enum       +
    +--------------------------------------+
    +      +         +                     +
    +  1   + 64-bit  + fixed64, sfixed64,  +
    +      +         + double              +
    +--------------------------------------+
    +  2   + string  + string              +
    +--------------------------------------+
    +  5   + 32-bit  + float               +
    +--------------------------------------+
    """
    if 'uInt32' == proto_type or \
        'sInt32' == proto_type or \
        'int32' == proto_type :
            return 0
    elif 'double' == proto_type :
        return 1
    elif 'string' == proto_type :
        return 2
    elif 'float' == proto_type :
        return 5
    return 2