本文整理汇总了C++中ObExprObj::set_bool方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::set_bool方法的具体用法?C++ ObExprObj::set_bool怎么用?C++ ObExprObj::set_bool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObExprObj
的用法示例。
在下文中一共展示了ObExprObj::set_bool方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mtime_bool
static int mtime_bool(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObModifyTimeType);
out.set_bool(static_cast<bool> (in.get_mtime()));
return OB_SUCCESS;
}
示例2: pdatetime_bool
static int pdatetime_bool(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObPreciseDateTimeType);
out.set_bool(static_cast<bool> (in.get_precise_datetime()));
return OB_SUCCESS;
}
示例3: float_bool
static int float_bool(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObFloatType);
out.set_bool(static_cast<bool> (in.get_float()));
return OB_SUCCESS;
}
示例4: decimal_bool
static int decimal_bool(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObDecimalType);
out.set_bool(!in.get_decimal().is_zero());
return OB_SUCCESS;
}
示例5:
TEST_F(ObObjCastTest, bool_to_xxx)
{
ObExprObj in;
bool cases[] = {true, false};
const char *varchar_expected[] = {"true", "false"};
const char *dec_expected[] = {"1", "0"};
for (int64_t i = 0; i < static_cast<int64_t>(ARRAYSIZEOF(cases)); ++i)
{
bool v = cases[i];
in.set_bool(v);
MY_EXPECT(ObBoolType, in, ObNullType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObIntType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObFloatType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObDoubleType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObDateTimeType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObPreciseDateTimeType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObVarcharType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObSeqType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObCreateTimeType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObModifyTimeType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObExtendType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObBoolType, v, varchar_expected[i]);
MY_EXPECT(ObBoolType, in, ObDecimalType, v, dec_expected[i]);
}
}
示例6: 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;
}