示例#1
0
文件: field.cpp 项目: Begun/libslave
const char* Field_set::unpack(const char* from) {
	
    ulonglong tmp;

    switch(pack_length()) {
    case 1:
        tmp = ulonglong(*((unsigned char*)(from)));
        break;
    case 2:
        tmp = ulonglong(uint2korr(from));
        break;
    case 3:
        tmp = ulonglong(uint3korr(from));
        break;
    case 4:
        tmp = ulonglong(uint4korr(from));
        break;
    case 8:
        tmp = uint8korr(from);
        break;
    default:
        tmp = uint8korr(from);
        break;				
    }

    field_data = tmp;

    LOG_TRACE(log, "  set: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#2
0
文件: field.cpp 项目: Begun/libslave
const char* Field_longlong::unpack(const char* from) {

    ulonglong tmp = uint8korr(from);
    field_data = tmp;

    LOG_TRACE(log, "  longlong: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#3
0
文件: field.cpp 项目: Begun/libslave
const char* Field_medium::unpack(const char* from) {

    uint32 tmp = uint3korr(from);
    field_data = tmp;

    LOG_TRACE(log, "  medium: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#4
0
文件: field.cpp 项目: Begun/libslave
const char* Field_short::unpack(const char* from) {

    uint16 tmp = uint2korr(from);
    field_data = tmp;

    LOG_TRACE(log, "  short: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#5
0
文件: field.cpp 项目: Begun/libslave
const char* Field_tiny::unpack(const char* from) {

    char tmp = *((char*)(from));
    field_data = tmp;

    LOG_TRACE(log, "  tiny: " << (int)(tmp) << " // " << pack_length());
    
    return from + pack_length();
}
示例#6
0
文件: field.cpp 项目: Begun/libslave
const char* Field_float::unpack(const char* from) {

    float tmp = *((float*)(from));
    field_data = tmp;

    LOG_TRACE(log, "  float: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#7
0
文件: field.cpp 项目: Begun/libslave
const char* Field_timestamp::unpack(const char* from) {

    uint32 tmp = uint4korr(from);
    field_data = tmp;

    LOG_TRACE(log, "  timestamp: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#8
0
文件: field.cpp 项目: Begun/libslave
const char* Field_double::unpack(const char* from) {

    double tmp = *((double*)(from));
    field_data = tmp;

    LOG_TRACE(log, "  double: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#9
0
文件: field.cpp 项目: vozbu/libslave
const char* Field_datetime::unpack(const char* from)
{
    ulonglong tmp;
    if (is_old_storage)
    {
        tmp = uint8korr(from);
    }
    else
    {
        // !! we ignore fractional part
        // 5 bytes + fractional-seconds storage, big endian
        // ---------------------------
        //  1 bit  sign           (1= non-negative, 0= negative)
        // 17 bits year*13+month  (year 0-9999, month 0-12)
        //  5 bits day            (0-31)
        //  5 bits hour           (0-23)
        //  6 bits minute         (0-59)
        //  6 bits second         (0-59)
        // ---------------------------
        // 40 bits = 5 bytes

        ulonglong data;
        for (unsigned int i = 0; i < 5; ++i)
            *((unsigned char *)&data + 4 - i) = *(from + i);

        tmp = data & 63;
        data >>= 6;
        tmp += (data & 63) * 100;
        data >>= 6;
        tmp += (data & 31) * 10000;
        data >>= 5;
        tmp += (data & 31) * 1000000;
        data >>= 5;

        ulonglong year_month = data & ((1 << 17) - 1);
        tmp += year_month % 13 * 100000000;
        tmp += year_month / 13 * 10000000000;
    }

    field_data = tmp;

    LOG_TRACE(log, "  datetime: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#10
0
文件: field.cpp 项目: Begun/libslave
const char* Field_enum::unpack(const char* from) {

    int tmp;

    if (pack_length() == 1) {

        tmp = int(*((char*)(from)));

    } else {
        tmp = int(*((short*)(from)));
    }

    field_data = tmp;

    LOG_TRACE(log, "  enum: " << tmp << " // " << pack_length());
		
    return from + pack_length();
}
示例#11
0
文件: field.cpp 项目: vozbu/libslave
const char* Field_time::unpack(const char* from) {

    int32 tmp;
    if (is_old_storage)
    {
        tmp = sint3korr(from);
    }
    else
    {
        // !! we ignore fractional part
        // 3 bytes + fractional-seconds storage, big endian
        // ---------------------
        //  1 bit sign    (1= non-negative, 0= negative)
        //  1 bit unused  (reserved for future extensions)
        // 10 bits hour   (0-838)
        //  6 bits minute (0-59)
        //  6 bits second (0-59)
        // ---------------------
        // 24 bits = 3 bytes

        uint32 data = 0;
        for (unsigned int i = 0; i < 3; ++i)
            *((unsigned char *)&data + 2 - i) = *(from + i);

        uint32 sign = (uint32)((data & (1 << 23)) >> 23);
        if (sign == 0)
            data = (1 << 23) - data;
        tmp = data & 63;
        data >>= 6;
        tmp += (data & 63) * 100;
        data >>= 6;
        tmp += (data & 1023) * 10000;
        if (sign == 0)
            tmp = -tmp;
    }

    field_data = tmp;

    LOG_TRACE(log, "  time: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#12
0
文件: field.cpp 项目: vozbu/libslave
const char* Field_timestamp::unpack(const char* from) {

    uint32 tmp;
    if (is_old_storage)
    {
        tmp = uint4korr(from);
    }
    else
    {
        // !! we ignore fractional part
        // 4 bytes + fractional-seconds storage, big endian
        // same as before 5.6.4, except big endian rather than little endian

        tmp = 0;
        for (unsigned int i = 0; i < 4; ++i)
            *((unsigned char *)&tmp + 3 - i) = *(from + i);
    }

    field_data = tmp;

    LOG_TRACE(log, "  timestamp: " << tmp << " // " << pack_length());

    return from + pack_length();
}
示例#13
0
文件: ipu.c 项目: cjxgm/ipu
int ipu_stack_length()
{
	return pack_length(_S);
}
示例#14
0
文件: ipu.c 项目: cjxgm/ipu
int ipu_stack_is_empty()
{
	return (pack_length(_S) == 0);
}
示例#15
0
文件: field.cpp 项目: vozbu/libslave
const char* Field_decimal::unpack(const char *from)
{
    double result = dec2double(from);
    field_data = result;
    return from + pack_length();
}