template<> NValue NValue::callUnary<FUNC_VOLT_POINT_LONGITUDE>() const { if (isNull()) { return NValue::getNullValue(VALUE_TYPE_DOUBLE); } const GeographyPointValue point = getGeographyPointValue(); NValue retVal(VALUE_TYPE_DOUBLE); retVal.getDouble() = point.getLongitude(); return retVal; }
template<> NValue NValue::callUnary<FUNC_VOLT_ASTEXT_GEOGRAPHY_POINT>() const { assert(getValueType() == VALUE_TYPE_POINT); if (isNull()) { return NValue::getNullValue(VALUE_TYPE_VARCHAR); } const std::string pointAsText = getGeographyPointValue().toWKT(); return getTempStringValue(pointAsText.c_str(), pointAsText.length()); }
/* * 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); }