Ejemplo n.º 1
0
    public static PB_WireType PBTypeToWriteType(pb_type nType)
    {
        switch (nType)
        {
        case pb_type.pb_int32:
        case pb_type.pb_uint32:
        case pb_type.pb_bool:
        case pb_type.pb_enum:
        case pb_type.pb_int64:
        case pb_type.pb_uint64:
        case pb_type.pb_sint32:
        case pb_type.pb_sint64:
            return(PB_WireType.WIRETYPE_VARINT);

        case pb_type.pb_fixed64:
        case pb_type.pb_sfixed64:
        case pb_type.pb_double:
            return(PB_WireType.WIRETYPE_FIXED64);

        case pb_type.pb_fixed32:
        case pb_type.pb_sfixed32:
        case pb_type.pb_float:
            return(PB_WireType.WIRETYPE_FIXED32);

        case pb_type.pb_string:
        case pb_type.pb_object:
            return(PB_WireType.WIRETYPE_LENGTH_DELIMITED);

        default:
            break;
        }
        return(PB_WireType.WIRETYPE_LENGTH_DELIMITED);
    }
Ejemplo n.º 2
0
    public static string GetZipType(pb_type nType)
    {
        switch (nType)
        {
        case pb_type.pb_sint32:     // 压缩的变量, ZipFag压缩的
        case pb_type.pb_sint64:
            return("PB_Zip_ZigZag");

        case pb_type.pb_fixed64:      // 定长的变量
        case pb_type.pb_sfixed64:
        case pb_type.pb_double:
        case pb_type.pb_fixed32:
        case pb_type.pb_sfixed32:
        case pb_type.pb_float:
            return("PB_Zip_Fixed");

        case pb_type.pb_enum:
            return("PB_Zip_Varint");

        case pb_type.pb_string:
            return("PB_Zip_Varint");

        case pb_type.pb_object:
            return("PB_Zip_Varint");

        default:
            return("PB_Zip_Varint");
        }
    }
Ejemplo n.º 3
0
 public static int PB_GetWireType(pb_type nType, PBValueType nValueType)
 {
     if (PBValueType.Value_Array == nValueType ||
         PBValueType.Value_Map == nValueType)
     {
         return((int)PB_WireType.WIRETYPE_LENGTH_DELIMITED);
     }
     else
     {
         return((int)PBTypeToWriteType(nType));
     }
 }
Ejemplo n.º 4
0
 public static int PB_MakeTag(int nFiledIndex, pb_type nType, PBValueType nValueType)
 {
     if (PBValueType.Value_Array == nValueType ||
         PBValueType.Value_Map == nValueType)
     {
         return(MakeTag(nFiledIndex, PB_WireType.WIRETYPE_LENGTH_DELIMITED));
     }
     else
     {
         PB_WireType nWiretType = PBTypeToWriteType(nType);
         return(MakeTag(nFiledIndex, nWiretType));
     }
 }