A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/writer_8h_source.html below:

NCBI C++ ToolKit: include/misc/jsonwrapp/rapidjson11/writer.h Source File

15 #ifndef RAPIDJSON_WRITER_H_ 16 #define RAPIDJSON_WRITER_H_ 26 #if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) 28 #pragma intrinsic(_BitScanForward) 30 #ifdef RAPIDJSON_SSE42 31 #include <nmmintrin.h> 32 #elif defined(RAPIDJSON_SSE2) 33 #include <emmintrin.h> 38

RAPIDJSON_DIAG_OFF(4127)

43

RAPIDJSON_DIAG_OFF(padded)

44

RAPIDJSON_DIAG_OFF(unreachable-

code

)

45

RAPIDJSON_DIAG_OFF(c++98-compat)

59 #ifndef RAPIDJSON_WRITE_DEFAULT_FLAGS 60 #define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags 87 template

<

typename

OutputStream,

typename

SourceEncoding = UTF8<>,

typename

TargetEncoding = UTF8<>,

typename

StackAllocator = CrtAllocator,

unsigned

writeFlags = kWriteDefaultFlags>

90  typedef typename

SourceEncoding::Ch

Ch

;

92  static const int

kDefaultMaxDecimalPlaces = 324;

100  Writer

(OutputStream& os, StackAllocator* stackAllocator = 0,

size_t

levelDepth = kDefaultLevelDepth) :

101

os_(&os), level_stack_(stackAllocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(

false

) {}

104  Writer

(StackAllocator* allocator = 0,

size_t

levelDepth = kDefaultLevelDepth) :

105

os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(

false

) {}

107 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 109

os_(rhs.os_), level_stack_(std::move(rhs.level_stack_)), maxDecimalPlaces_(rhs.maxDecimalPlaces_), hasRoot_(rhs.hasRoot_) {

135

level_stack_.Clear();

143  return

hasRoot_ && level_stack_.Empty();

147  return

maxDecimalPlaces_;

172

maxDecimalPlaces_ = maxDecimalPlaces;

198  return

EndValue(WriteString(

str

, length));

205  return

EndValue(WriteString(

str

, length));

208 #if RAPIDJSON_HAS_STDSTRING 209  bool

String(

const

std::basic_string<Ch>&

str

) {

216  new

(level_stack_.template Push<Level>()) Level(

false

);

217  return

WriteStartObject();

226

level_stack_.template Pop<Level>(1);

227  return

EndValue(WriteEndObject());

232  new

(level_stack_.template Push<Level>()) Level(

true

);

233  return

WriteStartArray();

240

level_stack_.template Pop<Level>(1);

241  return

EndValue(WriteEndArray());

265  return

EndValue(WriteRawValue(json, length));

271  Level

(

bool

inArray_) : valueCount(0), inArray(inArray_) {}

276  static const size_t

kDefaultLevelDepth = 32;

299  for

(

const char

* p =

buffer

; p != end; ++p)

300  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(*p));

308  for

(

const char

* p =

buffer

; p != end; ++p)

309  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(*p));

317  for

(

const char

* p =

buffer

; p != end; ++p)

318  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(*p));

326  for

(

char

* p =

buffer

; p != end; ++p)

327  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(*p));

354  for

(

char

* p =

buffer

; p != end; ++p)

355  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(*p));

360  static const typename

OutputStream::Ch hexDigits[16] = {

'0'

,

'1'

,

'2'

,

'3'

,

'4'

,

'5'

,

'6'

,

'7'

,

'8'

,

'9'

,

'A'

,

'B'

,

'C'

,

'D'

,

'E'

,

'F'

};

361  static const char

escape[256] = {

362 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 364  'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'b'

,

't'

,

'n'

,

'u'

,

'f'

,

'r'

,

'u'

,

'u'

,

365  'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

'u'

,

366

0, 0,

'"'

, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

368

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

'\\'

, 0, 0, 0,

373  if

(TargetEncoding::supportUnicode)

380  while

(ScanWriteUnescapedString(is, length)) {

382  if

(!TargetEncoding::supportUnicode &&

static_cast<unsigned>

(c) >= 0x80) {

389  if

(codepoint <= 0xD7FF || (codepoint >= 0xE000 && codepoint <= 0xFFFF)) {

390  PutUnsafe

(*os_, hexDigits[(codepoint >> 12) & 15]);

391  PutUnsafe

(*os_, hexDigits[(codepoint >> 8) & 15]);

392  PutUnsafe

(*os_, hexDigits[(codepoint >> 4) & 15]);

393  PutUnsafe

(*os_, hexDigits[(codepoint ) & 15]);

398  unsigned

s = codepoint - 0x010000;

399  unsigned

lead = (s >> 10) + 0xD800;

400  unsigned

trail = (s & 0x3FF) + 0xDC00;

401  PutUnsafe

(*os_, hexDigits[(lead >> 12) & 15]);

402  PutUnsafe

(*os_, hexDigits[(lead >> 8) & 15]);

403  PutUnsafe

(*os_, hexDigits[(lead >> 4) & 15]);

404  PutUnsafe

(*os_, hexDigits[(lead ) & 15]);

407  PutUnsafe

(*os_, hexDigits[(trail >> 12) & 15]);

408  PutUnsafe

(*os_, hexDigits[(trail >> 8) & 15]);

409  PutUnsafe

(*os_, hexDigits[(trail >> 4) & 15]);

410  PutUnsafe

(*os_, hexDigits[(trail ) & 15]);

413  else if

((

sizeof

(

Ch

) == 1 ||

static_cast<unsigned>

(c) < 256) &&

RAPIDJSON_UNLIKELY

(escape[

static_cast<unsigned char>

(c)])) {

416  PutUnsafe

(*os_,

static_cast<

typename OutputStream::Ch

>

(escape[

static_cast<unsigned char>

(c)]));

417  if

(escape[

static_cast<unsigned char>

(c)] ==

'u'

) {

420  PutUnsafe

(*os_, hexDigits[

static_cast<unsigned char>

(c) >> 4]);

421  PutUnsafe

(*os_, hexDigits[

static_cast<unsigned char>

(c) & 0xF]);

444  for

(

size_t i

= 0;

i

< length;

i

++) {

454

Level* level = level_stack_.template Top<Level>();

455  if

(level->valueCount > 0) {

459

os_->Put((level->valueCount % 2 == 0) ?

','

:

':'

);

461  if

(!level->inArray && level->valueCount % 2 == 0)

493  char

*

buffer

= os_->Push(11);

495

os_->Pop(

static_cast<size_t>

(11 - (end -

buffer

)));

501  char

*

buffer

= os_->Push(10);

503

os_->Pop(

static_cast<size_t>

(10 - (end -

buffer

)));

509  char

*

buffer

= os_->Push(21);

511

os_->Pop(

static_cast<size_t>

(21 - (end -

buffer

)));

517  char

*

buffer

= os_->Push(20);

519

os_->Pop(

static_cast<size_t>

(20 - (end -

buffer

)));

545  char

*

buffer

= os_->Push(25);

547

os_->Pop(

static_cast<size_t>

(25 - (end -

buffer

)));

551 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) 560  const char

* p = is.

src_

;

561  const char

* end = is.

head_

+ length;

562  const char

* nextAligned =

reinterpret_cast<const char

*

>

((

reinterpret_cast<size_t>

(p) + 15) &

static_cast<size_t>

(~15));

563  const char

* endAligned =

reinterpret_cast<const char

*

>

(

reinterpret_cast<size_t>

(end) &

static_cast<size_t>

(~15));

564  if

(nextAligned > end)

567  while

(p != nextAligned)

568  if

(*p < 0x20 || *p ==

'\"'

|| *p ==

'\\'

) {

573

os_->PutUnsafe(*p++);

576  static const char

dquote[16] = {

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

,

'\"'

};

577  static const char

bslash[16] = {

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

,

'\\'

};

578  static const char

space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };

583  for

(; p != endAligned; p += 16) {

594

_BitScanForward(&

offset

,

r

);

599  char

* q =

reinterpret_cast<char

*

>

(os_->PushUnsafe(

len

));

600  for

(

size_t i

= 0;

i

<

len

;

i

++)

bool EndArray(SizeType elementCount=0)

bool IsComplete() const

Checks whether the output is a complete JSON.

bool ScanWriteUnescapedString(GenericStringStream< SourceEncoding > &is, size_t length)

Writer(StackAllocator *allocator=0, size_t levelDepth=kDefaultLevelDepth)

bool WriteUint64(uint64_t u64)

bool String(const Ch *str, SizeType length, bool copy=false)

bool Key(const Ch *str, SizeType length, bool copy=false)

bool WriteRawValue(const Ch *json, size_t length)

bool RawNumber(const Ch *str, SizeType length, bool copy=false)

bool String(const Ch *str)

Simpler but slower overload.

bool Uint64(uint64_t u64)

Writer & operator=(const Writer &)

bool RawValue(const Ch *json, size_t length, Type type)

Write a raw JSON value.

bool WriteUint(unsigned u)

internal::Stack< StackAllocator > level_stack_

bool WriteString(const Ch *str, SizeType length)

Writer(OutputStream &os, StackAllocator *stackAllocator=0, size_t levelDepth=kDefaultLevelDepth)

Constructor.

int GetMaxDecimalPlaces() const

void SetMaxDecimalPlaces(int maxDecimalPlaces)

Sets the maximum number of decimal places for double output.

bool WriteInt64(int64_t i64)

void Reset(OutputStream &os)

Reset the writer with a new stream.

bool EndObject(SizeType memberCount=0)

bool WriteDouble(double d)

bool Double(double d)

Writes the given double value to the stream.

static const char * str(char *buf, int n)

#define RAPIDJSON_WRITE_DEFAULT_FLAGS

User-defined kWriteDefaultFlags definition.

#define RAPIDJSON_LIKELY(x)

Compiler branching hint for expression with high probability to be true.

#define RAPIDJSON_UNLIKELY(x)

Compiler branching hint for expression with low probability to be true.

#define RAPIDJSON_ASSERT(x)

Assertion.

#define RAPIDJSON_NAMESPACE_BEGIN

provide custom rapidjson namespace (opening expression)

#define RAPIDJSON_NAMESPACE_END

provide custom rapidjson namespace (closing expression)

char * dtoa(double value, char *buffer, int maxDecimalPlaces=324)

char * i64toa(int64_t value, char *buffer)

char * u32toa(uint32_t value, char *buffer)

char * i32toa(int32_t value, char *buffer)

char * u64toa(uint64_t value, char *buffer)

void PutUnsafe(Stream &stream, typename Stream::Ch c)

Write character to a stream, presuming buffer is reserved.

unsigned SizeType

Size type (for string lengths, array sizes, etc.)

void PutReserve(Stream &stream, size_t count)

Reserve n characters for writing to a stream.

WriteFlag

Combination of writeFlags.

@ kWriteNanAndInfFlag

Allow writing of Infinity, -Infinity and NaN.

@ kWriteDefaultFlags

Default write flags. Can be customized by defining RAPIDJSON_WRITE_DEFAULT_FLAGS.

@ kWriteValidateEncodingFlag

Validate encoding of JSON strings.

@ kWriteNoFlags

No flags are set.

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)

static __m128i _mm_max_epu8(__m128i a, __m128i b)

static int _mm_movemask_epi8(__m128i a)

static __m128i _mm_loadu_si128(const __m128i *p)

static __m128i _mm_cmpeq_epi8(__m128i a, __m128i b)

static __m128i _mm_load_si128(const __m128i *p)

static __m128i _mm_or_si128(__m128i, __m128i)

static void _mm_storeu_si128(__m128i *p, __m128i a)

const Ch * head_

Original head of the string.

const Ch * src_

Current read position.

Information for each nested level.

bool inArray

true if in array, otherwise in object

size_t valueCount

number of values in this level

void Decode(const vector< char > &, CRawScoreVector< Key, Score > &)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4