Ejemplo n.º 1
0
/*
 * Produce a debugging string describing an NValue.
 */
std::string NValue::debug() const {
    const ValueType type = getValueType();
    if (isNull()) {
        return "<NULL>";
    }
    std::ostringstream buffer;
    std::string out_val;
    const char* ptr;
    int64_t addr;
    buffer << getTypeName(type) << "::";
    switch (type) {
    case VALUE_TYPE_BOOLEAN:
        buffer << (getBoolean() ? "true" : "false");
        break;
    case VALUE_TYPE_TINYINT:
        buffer << static_cast<int32_t>(getTinyInt());
        break;
    case VALUE_TYPE_SMALLINT:
        buffer << getSmallInt();
        break;
    case VALUE_TYPE_INTEGER:
        buffer << getInteger();
        break;
    case VALUE_TYPE_BIGINT:
    case VALUE_TYPE_TIMESTAMP:
        buffer << getBigInt();
        break;
    case VALUE_TYPE_DOUBLE:
        buffer << getDouble();
        break;
    case VALUE_TYPE_VARCHAR:
        ptr = reinterpret_cast<const char*>(getObjectValue_withoutNull());
        addr = reinterpret_cast<int64_t>(ptr);
        out_val = std::string(ptr, getObjectLength_withoutNull());
        buffer << "[" << getObjectLength_withoutNull() << "]";
        buffer << "\"" << out_val << "\"[@" << addr << "]";
        break;
    case VALUE_TYPE_VARBINARY:
        ptr = reinterpret_cast<const char*>(getObjectValue_withoutNull());
        addr = reinterpret_cast<int64_t>(ptr);
        out_val = std::string(ptr, getObjectLength_withoutNull());
        buffer << "[" << getObjectLength_withoutNull() << "]";
        buffer << "-bin[@" << addr << "]";
        break;
    case VALUE_TYPE_DECIMAL:
        buffer << createStringFromDecimal();
        break;
    default:
        buffer << "(no details)";
        break;
    }
    std::string ret(buffer.str());
    return (ret);
}
Ejemplo n.º 2
0
/*
 * Produce a debugging string describing an NValue.
 */
std::string NValue::debug() const {
    const ValueType type = getValueType();
    if (isNull()) {
        return "<NULL>";
    }
    std::ostringstream buffer;
    std::string out_val;
    const char* ptr;
    int64_t addr;
    buffer << getTypeName(type) << "::";
    switch (type) {
    case VALUE_TYPE_BOOLEAN:
        buffer << (getBoolean() ? "true" : "false");
        break;
    case VALUE_TYPE_TINYINT:
        buffer << static_cast<int32_t>(getTinyInt());
        break;
    case VALUE_TYPE_SMALLINT:
        buffer << getSmallInt();
        break;
    case VALUE_TYPE_INTEGER:
        buffer << getInteger();
        break;
    case VALUE_TYPE_BIGINT:
        buffer << getBigInt();
        break;
    case VALUE_TYPE_DOUBLE:
        buffer << getDouble();
        break;
    case VALUE_TYPE_VARCHAR:
    {
        int32_t length;
        ptr = getObject_withoutNull(&length);
        addr = reinterpret_cast<int64_t>(ptr);
        out_val = std::string(ptr, length);
        buffer << "[" << length << "]";
        buffer << "\"" << out_val << "\"[@" << addr << "]";
        break;
    }
    case VALUE_TYPE_VARBINARY:
    {
        int32_t length;
        ptr = getObject_withoutNull(&length);
        addr = reinterpret_cast<int64_t>(ptr);
        out_val = std::string(ptr, length);
        buffer << "[" << length << "]";
        buffer << "-bin[@" << addr << "]";
        break;
    }
    case VALUE_TYPE_DECIMAL:
        buffer << createStringFromDecimal();
        break;
    case VALUE_TYPE_TIMESTAMP: {
        try {
            std::stringstream ss;
            streamTimestamp(ss);
            buffer << ss.str();
        }
        catch (const SQLException &) {
            buffer << "<out of range timestamp:" << getBigInt() << ">";
        }
        catch (...) {
            buffer << "<exception when converting timestamp:" << getBigInt() << ">";
        }
        break;
    }
    case VALUE_TYPE_POINT:
        buffer << getGeographyPointValue().toString();
        break;
    case VALUE_TYPE_GEOGRAPHY:
        buffer << getGeographyValue().toString();
        break;
    default:
        buffer << "(no details)";
        break;
    }
    std::string ret(buffer.str());
    return (ret);
}