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


C++ DynamicObject::getUInt64方法代码示例

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


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

示例1: isValid

bool Int::isValid(
   DynamicObject& obj,
   ValidatorContext* context)
{
   bool rval;
   DynamicObjectType objType;

   rval = !obj.isNull();

   if(rval)
   {
      objType = obj->getType();
      if(objType == String)
      {
         objType = DynamicObject::determineType(obj->getString());
      }

      // type check
      rval =
         objType == Int32 ||
         objType == UInt32 ||
         objType == Int64 ||
         objType == UInt64;
   }

   if(!rval)
   {
      DynamicObject detail =
         context->addError("monarch.validation.ValueError", &obj);
      detail["validator"] = "monarch.validator.Int";
      detail["message"] =
         mErrorMessage ? mErrorMessage :
            "The given value type is required to be an integer.";
   }

   // absolute value of dyno value
   uint64_t val = 0;
   // flag if val is negative
   bool valneg = false;

   // get value for min/max check
   if(rval)
   {
      // get value and sign
      switch(objType)
      {
         case Int32:
         case Int64:
         {
            int64_t raw = obj->getInt64();
            valneg = (raw < 0);
            val = (uint64_t)(valneg ? -raw : raw);
            break;
         }
         case UInt32:
         case UInt64:
         {
            valneg = false;
            val = obj->getUInt64();
            break;
         }
         default:
            // never get here
            break;
      }
   }

   // min check
   if(rval)
   {
      if(mMinNegative != valneg)
      {
         // signs are different
         // val meets the minimum unless val is negative
         rval = !valneg;
      }
      else
      {
         // signs are the same
         // val meets the minimum if:
         // 1. val is positive and larger than mMin
         // 2. val is negative and smaller than mMin
         rval = (!valneg ? val >= mMin : val <= mMin);
      }

      // set exception on failure
      if(!rval)
      {
         DynamicObject detail =
            context->addError("monarch.validation.ValueError", &obj);
         detail["validator"] = "monarch.validator.Int";
         detail["message"] = mErrorMessage ? mErrorMessage :
            "The given integer value is less than the required minimum "
            "integer value.";
         detail["expectedMin"] = mMin;
      }
   }

   // max check
   if(rval)
//.........这里部分代码省略.........
开发者ID:bsletten,项目名称:monarch,代码行数:101,代码来源:Int.cpp


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