RAPIDJSON_DIAG_OFF(4127)
43RAPIDJSON_DIAG_OFF(padded)
44RAPIDJSON_DIAG_OFF(unreachable-
code)
45RAPIDJSON_DIAG_OFF(c++98-compat)
59 #ifndef RAPIDJSON_WRITE_DEFAULT_FLAGS 60 #define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags 87 template<
typenameOutputStream,
typenameSourceEncoding = UTF8<>,
typenameTargetEncoding = UTF8<>,
typenameStackAllocator = CrtAllocator,
unsignedwriteFlags = kWriteDefaultFlags>
90 typedef typenameSourceEncoding::Ch
Ch;
92 static const intkDefaultMaxDecimalPlaces = 324;
100 Writer(OutputStream& os, StackAllocator* stackAllocator = 0,
size_tlevelDepth = kDefaultLevelDepth) :
101os_(&os), level_stack_(stackAllocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(
false) {}
104 Writer(StackAllocator* allocator = 0,
size_tlevelDepth = kDefaultLevelDepth) :
105os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(
false) {}
107 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 109os_(rhs.os_), level_stack_(std::move(rhs.level_stack_)), maxDecimalPlaces_(rhs.maxDecimalPlaces_), hasRoot_(rhs.hasRoot_) {
135level_stack_.Clear();
143 returnhasRoot_ && level_stack_.Empty();
147 returnmaxDecimalPlaces_;
172maxDecimalPlaces_ = maxDecimalPlaces;
198 returnEndValue(WriteString(
str, length));
205 returnEndValue(WriteString(
str, length));
208 #if RAPIDJSON_HAS_STDSTRING 209 boolString(
conststd::basic_string<Ch>&
str) {
216 new(level_stack_.template Push<Level>()) Level(
false);
217 returnWriteStartObject();
226level_stack_.template Pop<Level>(1);
227 returnEndValue(WriteEndObject());
232 new(level_stack_.template Push<Level>()) Level(
true);
233 returnWriteStartArray();
240level_stack_.template Pop<Level>(1);
241 returnEndValue(WriteEndArray());
265 returnEndValue(WriteRawValue(json, length));
271 Level(
boolinArray_) : valueCount(0), inArray(inArray_) {}
276 static const size_tkDefaultLevelDepth = 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 typenameOutputStream::Ch hexDigits[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'};
361 static const charescape[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',
3660, 0,
'"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3680, 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 unsigneds = codepoint - 0x010000;
399 unsignedlead = (s >> 10) + 0xD800;
400 unsignedtrail = (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++) {
454Level* level = level_stack_.template Top<Level>();
455 if(level->valueCount > 0) {
459os_->Put((level->valueCount % 2 == 0) ?
',':
':');
461 if(!level->inArray && level->valueCount % 2 == 0)
493 char*
buffer= os_->Push(11);
495os_->Pop(
static_cast<size_t>(11 - (end -
buffer)));
501 char*
buffer= os_->Push(10);
503os_->Pop(
static_cast<size_t>(10 - (end -
buffer)));
509 char*
buffer= os_->Push(21);
511os_->Pop(
static_cast<size_t>(21 - (end -
buffer)));
517 char*
buffer= os_->Push(20);
519os_->Pop(
static_cast<size_t>(20 - (end -
buffer)));
545 char*
buffer= os_->Push(25);
547os_->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 ==
'\\') {
573os_->PutUnsafe(*p++);
576 static const chardquote[16] = {
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"'};
577 static const charbslash[16] = {
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\'};
578 static const charspace[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