Exemplo n.º 1
0
bool checkreturn pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type)
{
    switch (wire_type)
    {
        case PB_WT_VARINT: return pb_skip_varint(stream);
        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
        case PB_WT_STRING: return pb_skip_string(stream);
        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
        default: PB_RETURN_ERROR(stream, "invalid wire_type");
    }
}
Exemplo n.º 2
0
Arquivo: pbc.cpp Projeto: EFLql/conet
int  pb_skip_field(pb_field_t *f, pb_wire_type_t wire_type)
{
    switch (wire_type)
    {
        case PB_WT_VARINT: return pb_skip_varint(f);
        case PB_WT_FIXED64: return pb_get_ddword(f, NULL);
        case PB_WT_STRING: return pb_skip_string(f);
        case PB_WT_FIXED32: return pb_get_dword(f, NULL);
        default: PB_RETURN_ERROR(f, -1, "invalid wire_type");
    }
}
Exemplo n.º 3
0
 void decode(thinger_message&  message, size_t size){
     size_t start_read = bytes_read();
     while(size-(bytes_read()-start_read)>0) {
         protoson::pb_wire_type wire_type;
         uint32_t field_number;
         pb_decode_tag(wire_type, field_number);
         switch (wire_type) {
             case protoson::length_delimited:{
                 uint32_t size = pb_decode_varint32();
                 pb_skip(size);
             }
                 break;
             case protoson::varint: {
                 switch (field_number) {
                     case thinger_message::SIGNAL_FLAG:
                         message.set_signal_flag((thinger_message::signal_flag)pb_decode_varint32());
                         break;
                     case thinger_message::STREAM_ID:
                         message.set_stream_id(pb_decode_varint32());
                         break;
                     default:
                         pb_skip_varint();
                         break;
                 }
                 break;
             }
             case protoson::pson_type:
                 switch(field_number){
                     case thinger_message::RESOURCE:
                         protoson::pson_decoder::decode(message.get_resources());
                         break;
                     case thinger_message::PSON_PAYLOAD:
                         protoson::pson_decoder::decode(((protoson::pson&) message));
                         break;
                     default:
                         break;
                 }
                 break;
             case protoson::fixed_32:
                 pb_skip(4);
                 break;
             case protoson::fixed_64:
                 pb_skip(8);
                 break;
             default:
                 break;
         }
     }
 }