Beispiel #1
0
        void ParseValues(PacketParser parser, FieldPacket fieldInfo, ref MyStructData myData)
        {
            Types fieldType = (Types)fieldInfo.type;

            switch (fieldType)
            {
            case Types.TIMESTAMP: //
            case Types.DATE:      //
            case Types.DATETIME:  //
            case Types.NEWDATE:   //
                myData.myDateTime = parser.ParseLengthCodedDateTime();
                myData.type       = fieldType;
                break;

            case Types.TINY:    //length = 1;
                myData.myInt32 = parser.ParseUnsigned1();
                myData.type    = fieldType;
                break;

            case Types.SHORT:   //length = 2;
            case Types.YEAR:    //length = 2;
                myData.myInt32 = (int)parser.ParseUnsigned2();
                myData.type    = fieldType;
                break;

            case Types.INT24:
            case Types.LONG:    //length = 4;
                myData.myInt32 = (int)parser.ParseUnsigned4();
                myData.type    = fieldType;
                break;

            case Types.FLOAT:
                myData.myDouble = parser.ParseFloat();
                myData.type     = fieldType;
                break;

            case Types.DOUBLE:
                myData.myDouble = parser.ParseDouble();
                myData.type     = fieldType;
                break;

            case Types.NEWDECIMAL:
                myData.myDecimal = parser.ParseDecimal();
                myData.type      = fieldType;
                break;

            case Types.LONGLONG:
                myData.myInt64 = parser.ParseInt64();
                myData.type    = fieldType;
                break;

            case Types.STRING:
            case Types.VARCHAR:
            case Types.VAR_STRING:
                myData.myString = parser.ParseLengthCodedString();
                myData.type     = fieldType;
                break;

            case Types.TINY_BLOB:
            case Types.MEDIUM_BLOB:
            case Types.LONG_BLOB:
            case Types.BLOB:
            case Types.BIT:
                myData.myBuffer = parser.ParseLengthCodedBuffer();
                myData.type     = fieldType;
                break;

            case Types.GEOMETRY:

            default:
                myData.myBuffer = parser.ParseLengthCodedBuffer();
                myData.type     = Types.NULL;
                break;
            }
        }