NIM PC Cross Platform SDK
载入中...
搜索中...
未找到
nim_cpp_wrapper_util::Json 命名空间参考

struct  BuiltStyledStreamWriter
 
class  CharReader
 
class  CharReaderBuilder
 Build a CharReader implementation. 更多...
 
struct  CommentStyle
 Scoped enums are not available until C++11. 更多...
 
class  Exception
 
class  FastWriter
 Outputs a Value in JSON format without formatting (not human friendly). 更多...
 
class  Features
 Configuration passed to reader and writer. This configuration object can be used to force the Reader or Writer to behave in a standard conforming way. 更多...
 
class  LogicError
 
class  OurCharReader
 
class  OurFeatures
 
class  OurReader
 
class  Path
 Experimental and untested: represents a "path" to access a node. 更多...
 
class  PathArgument
 Experimental and untested: represents an element of the "path" to access a node. 更多...
 
class  Reader
 Unserialize a JSON document into a Value. 更多...
 
class  RuntimeError
 
class  SecureAllocator
 
class  StaticString
 Lightweight wrapper to tag static string. 更多...
 
class  StreamWriter
 
class  StreamWriterBuilder
 Build a StreamWriter implementation. 更多...
 
class  StyledStreamWriter
 Writes a Value in JSON format in a human friendly way, to a stream rather than to a string. 更多...
 
class  StyledWriter
 Writes a Value in JSON format in a human friendly way. 更多...
 
class  Value
 Represents a JSON value. 更多...
 
class  ValueConstIterator
 const iterator for object and array value. 更多...
 
class  ValueIterator
 Iterator for object and array value. 更多...
 
class  ValueIteratorBase
 base class for Value iterators. 更多...
 
class  Writer
 Abstract class for writers. 更多...
 

类型定义

using Int = int
 
using UInt = unsigned int
 
using Int64 = int64_t
 
using UInt64 = uint64_t
 
using LargestInt = Int64
 
using LargestUInt = UInt64
 
template<typename T >
using Allocator = typename std::conditional< JSONCPP_USING_SECURE_MEMORY, SecureAllocator< T >, std::allocator< T > >::type
 
using String = std::basic_string< char, std::char_traits< char >, Allocator< char > >
 
using IStringStream = std::basic_istringstream< String::value_type, String::traits_type, String::allocator_type >
 
using OStringStream = std::basic_ostringstream< String::value_type, String::traits_type, String::allocator_type >
 
using IStream = std::istream
 
using OStream = std::ostream
 
using ArrayIndex = unsigned int
 
using CharReaderPtr = std::auto_ptr< CharReader >
 
using UIntToStringBuffer = char[uintToStringBufferSize]
 
using StreamWriterPtr = std::auto_ptr< StreamWriter >
 

枚举

enum  ValueType {
  nullValue = 0 , intValue , uintValue , realValue ,
  stringValue , booleanValue , arrayValue , objectValue
}
 Type of the value held by a Value object. 更多...
 
enum  CommentPlacement { commentBefore = 0 , commentAfterOnSameLine , commentAfter , numberOfCommentPlacement }
 
enum  PrecisionType { significantDigits = 0 , decimalPlaces }
 Type of precision for formatting of real values. 更多...
 
enum  { uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1 }
 

函数

template<typename T , typename U >
bool operator== (const SecureAllocator< T > &, const SecureAllocator< U > &)
 
template<typename T , typename U >
bool operator!= (const SecureAllocator< T > &, const SecureAllocator< U > &)
 
bool JSON_API parseFromStream (CharReader::Factory const &, IStream &, Value *root, String *errs)
 
JSON_API IStreamoperator>> (IStream &, Value &)
 Read from 'sin' into 'root'.
 
JSONCPP_NORETURN void throwRuntimeError (String const &msg)
 used internally
 
JSONCPP_NORETURN void throwLogicError (String const &msg)
 used internally
 
void swap (Value &a, Value &b)
 
String JSON_API writeString (StreamWriter::Factory const &factory, Value const &root)
 Write into stringstream, then return string, for convenience. A StreamWriter will be created from the factory, used, and then deleted.
 
String JSON_API valueToString (Int value)
 
String JSON_API valueToString (UInt value)
 
String JSON_API valueToString (LargestInt value)
 
String JSON_API valueToString (LargestUInt value)
 
String JSON_API valueToString (double value, unsigned int precision=Value::defaultRealPrecision, PrecisionType precisionType=PrecisionType::significantDigits)
 
String JSON_API valueToString (bool value)
 
String JSON_API valueToQuotedString (const char *value)
 
JSON_API OStreamoperator<< (OStream &, const Value &root)
 Output using the StyledStreamWriter.
 
static char getDecimalPoint ()
 
static String codePointToUTF8 (unsigned int cp)
 Converts a unicode code-point to UTF-8.
 
static void uintToString (LargestUInt value, char *&current)
 
template<typename Iter >
Iter fixNumericLocale (Iter begin, Iter end)
 
template<typename Iter >
void fixNumericLocaleInput (Iter begin, Iter end)
 
template<typename Iter >
Iter fixZerosInTheEnd (Iter begin, Iter end)
 
template<typename T >
static std::unique_ptr< T > cloneUnique (const std::unique_ptr< T > &p)
 
template<typename T , typename U >
static bool InRange (double d, T min, U max)
 
static char * duplicateStringValue (const char *value, size_t length)
 
static char * duplicateAndPrefixStringValue (const char *value, unsigned int length)
 
static void decodePrefixedString (bool isPrefixed, char const *prefixed, unsigned *length, char const **value)
 
static void releasePrefixedStringValue (char *value)
 
static void releaseStringValue (char *value, unsigned)
 
static bool IsIntegral (double d)
 
static bool doesAnyCharRequireEscaping (char const *s, size_t n)
 
static unsigned int utf8ToCodepoint (const char *&s, const char *e)
 
static String toHex16Bit (unsigned int x)
 
static void appendRaw (String &result, unsigned ch)
 
static void appendHex (String &result, unsigned ch)
 
static String valueToQuotedStringN (const char *value, unsigned length, bool emitUTF8=false)
 

变量

static const char hex2 []
 

类型定义说明

◆ Allocator

template<typename T >
using nim_cpp_wrapper_util::Json::Allocator = typedef typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>, std::allocator<T> >::type

◆ ArrayIndex

using nim_cpp_wrapper_util::Json::ArrayIndex = typedef unsigned int

◆ CharReaderPtr

using nim_cpp_wrapper_util::Json::CharReaderPtr = typedef std::auto_ptr<CharReader>

◆ Int

using nim_cpp_wrapper_util::Json::Int = typedef int

◆ Int64

using nim_cpp_wrapper_util::Json::Int64 = typedef int64_t

◆ IStream

using nim_cpp_wrapper_util::Json::IStream = typedef std::istream

◆ IStringStream

using nim_cpp_wrapper_util::Json::IStringStream = typedef std::basic_istringstream<String::value_type, String::traits_type, String::allocator_type>

◆ LargestInt

◆ LargestUInt

◆ OStream

using nim_cpp_wrapper_util::Json::OStream = typedef std::ostream

◆ OStringStream

using nim_cpp_wrapper_util::Json::OStringStream = typedef std::basic_ostringstream<String::value_type, String::traits_type, String::allocator_type>

◆ StreamWriterPtr

◆ String

using nim_cpp_wrapper_util::Json::String = typedef std::basic_string<char, std::char_traits<char>, Allocator<char> >

◆ UInt

using nim_cpp_wrapper_util::Json::UInt = typedef unsigned int

◆ UInt64

using nim_cpp_wrapper_util::Json::UInt64 = typedef uint64_t

◆ UIntToStringBuffer

枚举类型说明

◆ anonymous enum

anonymous enum
枚举值
uintToStringBufferSize 

Constant that specify the size of the buffer that must be passed to uintToString.

◆ CommentPlacement

枚举值
commentBefore 

a comment placed on the line before a value

commentAfterOnSameLine 

a comment just after a value on the same line

commentAfter 

a comment on the line after a value (only make sense for

numberOfCommentPlacement 

root value)

◆ PrecisionType

Type of precision for formatting of real values.

枚举值
significantDigits 

we set max number of significant digits in string

decimalPlaces 

we set max number of digits after "." in string

◆ ValueType

Type of the value held by a Value object.

枚举值
nullValue 

'null' value

intValue 

signed integer value

uintValue 

unsigned integer value

realValue 

double value

stringValue 

UTF-8 string value

booleanValue 

bool value

arrayValue 

array value (ordered list)

objectValue 

object value (collection of name/value pairs).

函数说明

◆ appendHex()

static void nim_cpp_wrapper_util::Json::appendHex ( String result,
unsigned  ch 
)
static

◆ appendRaw()

static void nim_cpp_wrapper_util::Json::appendRaw ( String result,
unsigned  ch 
)
static

◆ cloneUnique()

template<typename T >
static std::unique_ptr< T > nim_cpp_wrapper_util::Json::cloneUnique ( const std::unique_ptr< T > &  p)
static

◆ codePointToUTF8()

static String nim_cpp_wrapper_util::Json::codePointToUTF8 ( unsigned int  cp)
inlinestatic

Converts a unicode code-point to UTF-8.

◆ decodePrefixedString()

static void nim_cpp_wrapper_util::Json::decodePrefixedString ( bool  isPrefixed,
char const *  prefixed,
unsigned *  length,
char const **  value 
)
inlinestatic

◆ doesAnyCharRequireEscaping()

static bool nim_cpp_wrapper_util::Json::doesAnyCharRequireEscaping ( char const *  s,
size_t  n 
)
static

◆ duplicateAndPrefixStringValue()

static char * nim_cpp_wrapper_util::Json::duplicateAndPrefixStringValue ( const char *  value,
unsigned int  length 
)
inlinestatic

◆ duplicateStringValue()

static char * nim_cpp_wrapper_util::Json::duplicateStringValue ( const char *  value,
size_t  length 
)
inlinestatic

Duplicates the specified string value.

参数
valuePointer to the string to duplicate. Must be zero-terminated if length is "unknown".
lengthLength of the value. if equals to unknown, then it will be computed using strlen(value).
返回
Pointer on the duplicate instance of string.

◆ fixNumericLocale()

template<typename Iter >
Iter nim_cpp_wrapper_util::Json::fixNumericLocale ( Iter  begin,
Iter  end 
)

Change ',' to '.' everywhere in buffer.

We had a sophisticated way, but it did not work in WinCE.

参见
https://github.com/open-source-parsers/jsoncpp/pull/9

◆ fixNumericLocaleInput()

template<typename Iter >
void nim_cpp_wrapper_util::Json::fixNumericLocaleInput ( Iter  begin,
Iter  end 
)

◆ fixZerosInTheEnd()

template<typename Iter >
Iter nim_cpp_wrapper_util::Json::fixZerosInTheEnd ( Iter  begin,
Iter  end 
)

Return iterator that would be the new end of the range [begin,end), if we were to delete zeros in the end of string, but not the last zero before '.'.

◆ getDecimalPoint()

static char nim_cpp_wrapper_util::Json::getDecimalPoint ( )
inlinestatic

◆ InRange()

template<typename T , typename U >
static bool nim_cpp_wrapper_util::Json::InRange ( double  d,
min,
max 
)
inlinestatic

◆ IsIntegral()

static bool nim_cpp_wrapper_util::Json::IsIntegral ( double  d)
static

◆ operator!=()

template<typename T , typename U >
bool nim_cpp_wrapper_util::Json::operator!= ( const SecureAllocator< T > &  ,
const SecureAllocator< U > &   
)

◆ operator<<()

OStream & nim_cpp_wrapper_util::Json::operator<< ( OStream sout,
const Value root 
)

◆ operator==()

template<typename T , typename U >
bool nim_cpp_wrapper_util::Json::operator== ( const SecureAllocator< T > &  ,
const SecureAllocator< U > &   
)

◆ operator>>()

IStream & nim_cpp_wrapper_util::Json::operator>> ( IStream sin,
Value root 
)

Read from 'sin' into 'root'.

Always keep comments from the input JSON.

This can be used to read a file into a particular sub-object. For example:

cin >> root["dir"]["file"];
cout << root;
Represents a JSON value.
Definition: value.h:196

Result:

* {
* "dir": {
*    "file": {
*    // The input stream JSON would be nested here.
*    }
* }
* }
* 
异常
std::exceptionon parse error.
参见
nim_cpp_wrapper_util::Json::operator<<()

◆ parseFromStream()

bool nim_cpp_wrapper_util::Json::parseFromStream ( CharReader::Factory const &  fact,
IStream sin,
Value root,
String errs 
)

Consume entire stream and use its begin/end. Someday we might have a real StreamReader, but for now this is convenient.

◆ releasePrefixedStringValue()

static void nim_cpp_wrapper_util::Json::releasePrefixedStringValue ( char *  value)
inlinestatic

Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().

◆ releaseStringValue()

static void nim_cpp_wrapper_util::Json::releaseStringValue ( char *  value,
unsigned   
)
inlinestatic

◆ swap()

void nim_cpp_wrapper_util::Json::swap ( Value a,
Value b 
)
inline

◆ throwLogicError()

JSONCPP_NORETURN void nim_cpp_wrapper_util::Json::throwLogicError ( String const &  msg)

used internally

◆ throwRuntimeError()

JSONCPP_NORETURN void nim_cpp_wrapper_util::Json::throwRuntimeError ( String const &  msg)

used internally

◆ toHex16Bit()

static String nim_cpp_wrapper_util::Json::toHex16Bit ( unsigned int  x)
static

◆ uintToString()

static void nim_cpp_wrapper_util::Json::uintToString ( LargestUInt  value,
char *&  current 
)
inlinestatic

Converts an unsigned integer to string.

参数
valueUnsigned integer to convert to string
currentInput/Output string buffer. Must have at least uintToStringBufferSize chars free.

◆ utf8ToCodepoint()

static unsigned int nim_cpp_wrapper_util::Json::utf8ToCodepoint ( const char *&  s,
const char *  e 
)
static

◆ valueToQuotedString()

String nim_cpp_wrapper_util::Json::valueToQuotedString ( const char *  value)

◆ valueToQuotedStringN()

static String nim_cpp_wrapper_util::Json::valueToQuotedStringN ( const char *  value,
unsigned  length,
bool  emitUTF8 = false 
)
static

◆ valueToString() [1/6]

String nim_cpp_wrapper_util::Json::valueToString ( bool  value)

◆ valueToString() [2/6]

String nim_cpp_wrapper_util::Json::valueToString ( double  value,
unsigned int  precision = Value::defaultRealPrecision,
PrecisionType  precisionType = PrecisionType::significantDigits 
)

◆ valueToString() [3/6]

String JSON_API nim_cpp_wrapper_util::Json::valueToString ( Int  value)

◆ valueToString() [4/6]

String nim_cpp_wrapper_util::Json::valueToString ( LargestInt  value)

◆ valueToString() [5/6]

String nim_cpp_wrapper_util::Json::valueToString ( LargestUInt  value)

◆ valueToString() [6/6]

String JSON_API nim_cpp_wrapper_util::Json::valueToString ( UInt  value)

◆ writeString()

String nim_cpp_wrapper_util::Json::writeString ( StreamWriter::Factory const &  factory,
Value const &  root 
)

Write into stringstream, then return string, for convenience. A StreamWriter will be created from the factory, used, and then deleted.

变量说明

◆ hex2

const char nim_cpp_wrapper_util::Json::hex2[]
static
初始值:
=
"000102030405060708090a0b0c0d0e0f"
"101112131415161718191a1b1c1d1e1f"
"202122232425262728292a2b2c2d2e2f"
"303132333435363738393a3b3c3d3e3f"
"404142434445464748494a4b4c4d4e4f"
"505152535455565758595a5b5c5d5e5f"
"606162636465666768696a6b6c6d6e6f"
"707172737475767778797a7b7c7d7e7f"
"808182838485868788898a8b8c8d8e8f"
"909192939495969798999a9b9c9d9e9f"
"a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
"b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
"c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
"d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
"e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"