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


C++ ObObj::get_double方法代码示例

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


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

示例1: apply

    int ObObj::apply(const ObObj &mutation)
    {
      int64_t org_type = get_type();
      int64_t org_ext = get_ext();
      int err = OB_SUCCESS;
      ObCreateTime create_time = 0;
      ObModifyTime modify_time = 0;
      bool is_add = false;
      bool org_is_add = false;
      if (ObSeqType == mutation.get_type()
        || ObMinType >= mutation.get_type()
        || ObMaxType <= mutation.get_type())
      {
        TBSYS_LOG(WARN,"unsupported type [type:%d]", static_cast<int32_t>(mutation.get_type()));
        err = OB_INVALID_ARGUMENT;
      }
      if (OB_SUCCESS == err 
        && ObExtendType != get_type()
        && ObNullType != get_type()
        && ObExtendType != mutation.get_type()
        && ObNullType != mutation.get_type()
        && get_type() != mutation.get_type())
      {
        TBSYS_LOG(WARN,"type not coincident [this->type:%d,mutation.type:%d]", 
          static_cast<int>(get_type()), static_cast<int>(mutation.get_type()));
        err = OB_INVALID_ARGUMENT;
      }
      _ObjValue value, mutation_value;
      if (OB_SUCCESS == err)
      {
        bool ext_val_can_change =  (ObActionFlag::OP_ROW_DOES_NOT_EXIST == get_ext())  ||  (ObNullType == get_type());
        bool org_is_nop = (ObActionFlag::OP_NOP == get_ext());
        switch (mutation.get_type())
        {
        case ObNullType: 
          set_null();
          break;
        case ObVarcharType:
          *this = mutation;
          break;
        case ObIntType:
          if (ext_val_can_change || org_is_nop)
          {
            set_int(0);
          }
          err = get_int(value.int_val,org_is_add);
          if (OB_SUCCESS == err)
          {
            err = mutation.get_int(mutation_value.int_val,is_add);
          }
          if (OB_SUCCESS == err)
          {
            if (is_add)
            {
              value.int_val += mutation_value.int_val;
            }
            else
            {
              value.int_val = mutation_value.int_val;
            }
            set_int(value.int_val, (org_is_add || org_is_nop) && is_add);
          }
          break;
        case ObFloatType:
          if (ext_val_can_change || org_is_nop)
          {
            set_float(0);
          }
          err = get_float(value.float_val,org_is_add);
          if (OB_SUCCESS == err)
          {
            err = mutation.get_float(mutation_value.float_val, is_add);
          }
          if (OB_SUCCESS == err)
          {
            if (is_add)
            {
              value.float_val += mutation_value.float_val;
            }
            else
            {
              value.float_val = mutation_value.float_val;
            }
            set_float(value.float_val,is_add && (org_is_add || org_is_nop));
          }
          break;
        case ObDoubleType:
          if (ext_val_can_change || org_is_nop)
          {
            set_double(0);
          }
          err = get_double(value.double_val,org_is_add);
          if (OB_SUCCESS == err)
          {
            err = mutation.get_double(mutation_value.double_val,is_add);
          }
          if (OB_SUCCESS == err)
          {
            if (is_add)
            {
//.........这里部分代码省略.........
开发者ID:CCoder123,项目名称:pproj,代码行数:101,代码来源:ob_object.cpp

示例2: if

 bool ObObj::operator==(const ObObj &that_obj) const
 {
   bool result = false;
   int err = OB_SUCCESS;
   if ((get_type() == ObNullType) && (that_obj.get_type() == ObNullType))
   {
     result = true;
   }
   else if ((get_type() == ObNullType) || (that_obj.get_type() == ObNullType))
   {
     result = false;
   }
   else if (!can_compare(that_obj))
   {
     result = false;
     TBSYS_LOG(ERROR, "logic error, cann't compare two obj with different type [this.type:%d,"
       "that.type:%d]", get_type(), that_obj.get_type());
   }
   else
   {
     _ObjValue this_value;
     _ObjValue that_value;
     int64_t this_timestamp = 0;
     int64_t that_timestamp = 0;
     ObObjType type = get_type();
     switch (type)
     {
     case ObIntType:
       err = get_int(this_value.int_val);
       if (OB_SUCCESS == err)
       {
         err = that_obj.get_int(that_value.int_val);
         if (OB_SUCCESS == err)
         {
           result = this_value.int_val == that_value.int_val;
         }
       }
       break;
     case ObVarcharType:
       err = get_varchar(this_value.varchar_val);
       if (OB_SUCCESS == err)
       {
         err = that_obj.get_varchar(that_value.varchar_val);
         if (OB_SUCCESS == err)
         {
           result = this_value.varchar_val == that_value.varchar_val;
         }
       }
       break;
     case ObFloatType:
       err = get_float(this_value.float_val);
       if (OB_SUCCESS == err)
       {
         err = that_obj.get_float(that_value.float_val);
         if (OB_SUCCESS == err)
         {
           result = fabsf(this_value.float_val - that_value.float_val) < FLOAT_EPSINON;
         }
       }
       break;
     case ObDoubleType:
       err = get_double(this_value.double_val);
       if (OB_SUCCESS == err)
       {
         err = that_obj.get_double(that_value.double_val);
         if (OB_SUCCESS == err)
         {
           result = fabs(this_value.double_val - that_value.double_val) < DOUBLE_EPSINON;
         }
       }
       break;
     case ObDateTimeType:
     case ObPreciseDateTimeType:
     case ObCreateTimeType:
     case ObModifyTimeType:
       err = get_timestamp(this_timestamp);
       if (OB_SUCCESS == err)
       {
         err = that_obj.get_timestamp(that_timestamp);
         if (OB_SUCCESS == err)
         {
           result = this_timestamp == that_timestamp;
         }
       }
       break;
       /*case ObSeqType:
         /// @todo (wushi [email protected]) sequence
         break;*/
     default:
       result = OB_ERR_UNEXPECTED;
       TBSYS_LOG(ERROR,"unexpected obj type [obj.type:%d]", type);
       break;
     }
   }
   return result;
 }
开发者ID:CCoder123,项目名称:pproj,代码行数:96,代码来源:ob_object.cpp


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