本文整理汇总了C++中ObExprObj::get_varchar方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::get_varchar方法的具体用法?C++ ObExprObj::get_varchar怎么用?C++ ObExprObj::get_varchar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObExprObj
的用法示例。
在下文中一共展示了ObExprObj::get_varchar方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: varchar_datetime
static int varchar_datetime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
int year = 0;
int month = 0;
int day = 0;
int hour = 0;
int minute = 0;
int second = 0;
ret = varchar_scanf(in, 6, "%4d-%2d-%2d %2d:%2d:%2d",
&year, &month, &day,
&hour, &minute, &second);
if (OB_SUCCESS != ret)
{
year = month = day = hour = minute = second = 0;
ret = varchar_scanf(in, 3, "%4d-%2d-%2d",
&year, &month, &day);
}
if (OB_SUCCESS != ret)
{
year = month = day = hour = minute = second = 0;
ret = varchar_scanf(in, 3, "%2d:%2d:%2d",
&hour, &minute, &second);
}
if (OB_SUCCESS == ret)
{
struct tm gtm;
memset(>m, 0, sizeof (gtm));
gtm.tm_year = year - 1900;
gtm.tm_mon = month - 1;
gtm.tm_mday = day;
gtm.tm_hour = hour;
gtm.tm_min = minute;
gtm.tm_sec = second;
time_t t = mktime(>m);
out.set_datetime(static_cast<ObDateTime> (t));
}
else
{
const string& varchar = in.get_varchar();
jlog(WARNING, "failed to convert string `%.*s' to datetime type",
varchar.length(), varchar.data());
out.set_datetime(static_cast<ObDateTime> (0));
ret = OB_SUCCESS;
}
return ret;
}
示例2: varchar_decimal
static int varchar_decimal(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
const string &varchar = in.get_varchar();
ObNumber num;
if (OB_SUCCESS != (ret = num.from(varchar.data(), varchar.length())))
{
jlog(WARNING, "failed to convert varchar to decimal, err=%d varchar=%.*s",
ret, varchar.length(), varchar.data());
}
else
{
out.set_decimal(num); // @todo optimize
}
return OB_SUCCESS;
}
示例3: decimal_varchar
static int decimal_varchar(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObDecimalType);
string varchar = out.get_varchar();
if (varchar.length() < ObNumber::MAX_PRINTABLE_SIZE)
{
jlog(WARNING, "output buffer for varchar not enough, buf_len=%d", varchar.length());
ret = OB_INVALID_ARGUMENT;
}
else
{
int64_t length = in.get_decimal().to_string((char*) varchar.data(), varchar.length());
string varchar2(varchar);
out.set_varchar(varchar2);
}
return ret;
}
示例4: varchar_mtime
static int varchar_mtime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
int64_t timestamp = 0;
ret = varchar_timestamp(in, timestamp);
if (OB_SUCCESS == ret)
{
out.set_mtime(static_cast<ObModifyTime> (timestamp));
}
else
{
const string& varchar = in.get_varchar();
jlog(WARNING, "failed to convert string `%.*s' to modifytime type",
varchar.length(), varchar.data());
out.set_mtime(static_cast<ObModifyTime> (0));
ret = OB_SUCCESS;
}
return ret;
}
示例5: varchar_printf
static int varchar_printf(ObExprObj &out, const char* format, ...)
{
int ret = OB_SUCCESS;
string varchar = out.get_varchar();
if (NULL == varchar.data() || varchar.length() <= 0)
{
jlog(WARNING, "output buffer for varchar not enough, buf_len=%u", varchar.length());
ret = OB_INVALID_ARGUMENT;
}
else
{
va_list args;
va_start(args, format);
int length = vsnprintf((char*) varchar.data(), varchar.length(), format, args);
va_end(args);
/*qinbo*/
//string varchar2(varchar.length(), length, varchar.data());
string varchar2(varchar);
out.set_varchar(varchar2);
}
return ret;
}
示例6: varchar_scanf
static int varchar_scanf(const ObExprObj &in, const int items, const char* format, ...)
{
int ret = OB_SUCCESS;
const string& varchar = in.get_varchar();
char* str = strndupa(varchar.data(), varchar.length()); // alloc from the stack, no need to free
if (NULL == str)
{
jlog(ERROR, "no memory");
ret = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
va_list args;
va_start(args, format);
int matched = vsscanf(str, format, args);
va_end(args);
if (items != matched)
{
ret = OB_INVALID_ARGUMENT;
}
}
return ret;
}
示例7: varchar_bool
static int varchar_bool(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
const string &varchar = in.get_varchar();
bool value = false;
if (varchar.data() != NULL && varchar.length() > 0)
{
static const int64_t len_true = strlen("true");
static const int64_t len_t = strlen("T");
static const int64_t len_yes = strlen("yes");
static const int64_t len_y = strlen("y");
if (varchar.length() == len_true
&& 0 == strncasecmp(varchar.data(), "true", len_true))
{
value = true;
}
else if (varchar.length() == len_t
&& 0 == strncasecmp(varchar.data(), "T", len_t))
{
value = true;
}
else if (varchar.length() == len_yes
&& 0 == strncasecmp(varchar.data(), "yes", len_yes))
{
value = true;
}
else if (varchar.length() == len_y
&& 0 == strncasecmp(varchar.data(), "y", len_y))
{
value = true;
}
}
out.set_bool(value);
return OB_SUCCESS;
}