当前位置: 首页>>代码示例>>C++>>正文


C++ ObExprObj::set_decimal方法代码示例

本文整理汇总了C++中ObExprObj::set_decimal方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::set_decimal方法的具体用法?C++ ObExprObj::set_decimal怎么用?C++ ObExprObj::set_decimal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObExprObj的用法示例。


在下文中一共展示了ObExprObj::set_decimal方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST_F(ObObjCastTest, decimal_to_xxx)
{
    ObExprObj in;
    const char * cases_str[] = {"0", "123.456", "-789.012"};
    ObNumber cases[ARRAYSIZEOF(cases_str)];
    int64_t int_expected[ARRAYSIZEOF(cases)] = {0, 123, -789};
    float float_expected[ARRAYSIZEOF(cases)] = {0.0f, 123.456f, -789.012f};
    double double_expected[ARRAYSIZEOF(cases)] = {0.0, 123.456, -789.012};
    for (int64_t i = 0; i < static_cast<int64_t>(ARRAYSIZEOF(cases)); ++i)
    {
        //printf("case %ld: %s\n", i, cases_str[i]);
        cases[i].from(cases_str[i]);
        in.set_decimal(cases[i]);
        int64_t v = int_expected[i];

        MY_EXPECT(ObDecimalType, in, ObNullType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObIntType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObFloatType, float_expected[i], cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObDoubleType, double_expected[i], cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObDateTimeType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObPreciseDateTimeType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObVarcharType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObSeqType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObCreateTimeType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObModifyTimeType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObExtendType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObBoolType, v, cases_str[i]);
        MY_EXPECT(ObDecimalType, in, ObDecimalType, v, cases_str[i]);
    }
}
开发者ID:sharpglasses,项目名称:oceanbase,代码行数:30,代码来源:ob_obj_cast_test.cpp

示例2: mtime_decimal

 static int mtime_decimal(const ObObjCastParams &params, const ObExprObj &in, ObExprObj &out)
 {
     UNUSED(params);
     OB_ASSERT(in.get_type() == ObModifyTimeType);
     ObNumber num;
     num.from(static_cast<int64_t> (in.get_mtime()));
     out.set_decimal(num);
     return OB_SUCCESS;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:9,代码来源:ob_obj_cast.cpp

示例3: int_decimal

 static int int_decimal(const ObObjCastParams &params, const ObExprObj &in, ObExprObj &out)
 {
     UNUSED(params);
     OB_ASSERT(in.get_type() == ObIntType);
     ObNumber num;
     num.from(in.get_int());
     out.set_decimal(num); // @todo optimize
     return OB_SUCCESS;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:9,代码来源:ob_obj_cast.cpp

示例4: varchar_decimal

 static int varchar_decimal(const ObObjCastParams &params, 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;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:18,代码来源:ob_obj_cast.cpp

示例5: double_decimal

 static int double_decimal(const ObObjCastParams &params, const ObExprObj &in, ObExprObj &out)
 {
     int ret = OB_SUCCESS;
     UNUSED(params);
     OB_ASSERT(in.get_type() == ObDoubleType);
     static const int64_t MAX_DOUBLE_PRINT_SIZE = 64;
     char buf[MAX_DOUBLE_PRINT_SIZE];
     snprintf(buf, MAX_DOUBLE_PRINT_SIZE, "%f", in.get_double());
     ObNumber num;
     if (OB_SUCCESS != (ret = num.from(buf)))
     {
         jlog(WARNING, "failed to convert float to decimal, err=%d", ret);
     }
     else
     {
         out.set_decimal(num);
     }
     return ret;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:19,代码来源:ob_obj_cast.cpp


注:本文中的ObExprObj::set_decimal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。