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


C++ Value::asLargestUInt方法代码示例

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


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

示例1: switch

static void
printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." )
{
   switch ( value.type() )
   {
   case Json::nullValue:
      fprintf( fout, "%s=null\n", path.c_str() );
      break;
   case Json::intValue:
      fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asLargestInt() ).c_str() );
      break;
   case Json::uintValue:
      fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asLargestUInt() ).c_str() );
      break;
   case Json::realValue:
       fprintf( fout, "%s=%s\n", path.c_str(), normalizeFloatingPointStr(value.asDouble()).c_str() );
      break;
   case Json::stringValue:
      fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() );
      break;
   case Json::booleanValue:
      fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" );
      break;
   case Json::arrayValue:
      {
         fprintf( fout, "%s=[]\n", path.c_str() );
         int size = value.size();
         for ( int index =0; index < size; ++index )
         {
            static char buffer[16];
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
            sprintf_s( buffer, sizeof(buffer), "[%d]", index );
#else
            snprintf( buffer, sizeof(buffer), "[%d]", index );
#endif
            printValueTree( fout, value[index], path + buffer );
         }
      }
      break;
   case Json::objectValue:
      {
         fprintf( fout, "%s={}\n", path.c_str() );
         Json::Value::Members members( value.getMemberNames() );
         std::sort( members.begin(), members.end() );
         std::string suffix = *(path.end()-1) == '.' ? "" : ".";
         for ( Json::Value::Members::iterator it = members.begin(); 
               it != members.end(); 
               ++it )
         {
            const std::string &name = *it;
            printValueTree( fout, value[name], path + suffix + name );
         }
      }
      break;
   default:
      break;
   }
}
开发者ID:cdunn2001,项目名称:jsoncpp-old,代码行数:58,代码来源:main.cpp

示例2: init

void JsonTree::init( const string &key, const Json::Value &value, bool setType, NodeType nodeType, ValueType valueType )
{
    mKey = key;
    mNodeType = nodeType;
    mParent = 0;
    mValue = "";
    mValueType = valueType;

    if( ! value.isNull() && ( value.isArray() || value.isObject() ) ) {
        if( value.isArray() ) {
            mNodeType = NODE_ARRAY;
            for ( uint32_t i = 0; i < value.size(); i++ ) {
                pushBack( JsonTree( "", value[ i ] ) );
            }
        }
        else if( value.isObject() ) {
            mNodeType = NODE_OBJECT;
            Json::Value::Members members = value.getMemberNames();
            for( Json::Value::Members::const_iterator memberIt = members.begin(); memberIt != members.end(); ++memberIt ) {
                string key = *memberIt;
                pushBack( JsonTree( key, value[ key ] ) );
            }
        }
    }
    else {
        if( value.isBool() ) {
            mValue = toString( value.asBool() );
            if( setType ) {
                mValueType = VALUE_BOOL;
            }
        }
        else if ( value.isDouble() ) {
            mValue = toString( value.asDouble() );
            if ( setType ) {
                mValueType = VALUE_DOUBLE;
            }
        }
        else if ( value.isInt() ) {
            mValue = toString( value.asLargestInt() );
            if ( setType ) {
                mValueType = VALUE_INT;
            }
        }
        else if ( value.isString() ) {
            mValue = toString( value.asString() );
            if ( setType ) {
                mValueType = VALUE_STRING;
            }
        }
        else if ( value.isUInt() ) {
            mValue = toString( value.asLargestUInt() );
            if ( setType ) {
                mValueType = VALUE_UINT;
            }
        }
    }
}
开发者ID:rfpuyana,项目名称:Cinder,代码行数:57,代码来源:Json.cpp

示例3: pack

    static inline
    void
    pack(msgpack::packer<Stream>& packer, const Json::Value& source) {
        switch(source.type()) {
        case Json::objectValue: {
            packer.pack_map(source.size());

            const Json::Value::Members keys(source.getMemberNames());

            for(auto it = keys.begin(); it != keys.end(); ++it) {
                packer << *it;
                pack(packer, source[*it]);
            }
        } break;

        case Json::arrayValue: {
            packer.pack_array(source.size());

            for(auto it = source.begin(); it != source.end(); ++it) {
                pack(packer, *it);
            }
        } break;

        case Json::booleanValue: {
            packer << source.asBool();
        } break;

        case Json::stringValue: {
            packer << source.asString();
        } break;

        case Json::realValue: {
            packer << source.asDouble();
        } break;

        case Json::intValue: {
            packer << source.asLargestInt();
        } break;

        case Json::uintValue: {
            packer << source.asLargestUInt();
        } break;

        case Json::nullValue: {
            packer << msgpack::type::nil();
        }}
    }
开发者ID:andrewpsp,项目名称:cocaine-core,代码行数:47,代码来源:json.hpp

示例4: pj_convert

  py::object pj_convert(Json::Value const & node)
  {

    switch (node.type())
      {

      case Json::ValueType::nullValue:
      {
        //return py::object();
        return py::object(Py_None, true);
      }

      case Json::ValueType::intValue:
      {
        //node.asInt();
        //node.asInt64();
        return py::int_(node.asLargestInt());
      }

      case Json::ValueType::uintValue:
      {
        //node.asUInt();
        //node.asUInt64();
        return py::int_(node.asLargestUInt());
      }

      case Json::ValueType::realValue:
      {
        //node.asFloat();
        return py::float_(node.asDouble());
      }

      case Json::ValueType::stringValue:
      {
        return py::str(node.asString());
      }

      case Json::ValueType::booleanValue:
      {
        return py::bool_(node.asBool());
      }

      case Json::ValueType::arrayValue:
      {
        py::list result;

        for (auto it = node.begin(); it != node.end(); ++it)
          {
            result.append(pj_convert(*it));
          }

        return result;
      }

      case Json::ValueType::objectValue:
      {
        py::dict result;

        for (auto it = node.begin(); it != node.end(); ++it)
          {
            result[pj_convert(it.key())] = pj_convert(*it);
          }

        return result;
      }

      default:
      {
        throw std::runtime_error("undefined json value");
      }

      }
  }
开发者ID:mdcb,项目名称:python-jsoncpp11,代码行数:73,代码来源:extension.cpp


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