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)
58 #ifndef RAPIDJSON_WRITE_DEFAULT_FLAGS 59 #define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags 86 template<
typename OutputStream,
typename SourceEncoding = UTF8<>,
typename TargetEncoding = UTF8<>,
typename StackAllocator = CrtAllocator,
unsigned writeFlags = kWriteDefaultFlags>
89 typedef typename SourceEncoding::Ch
Ch;
198 #if RAPIDJSON_HAS_STDSTRING 199 bool String(
const std::basic_string<Ch>&
str) {
286 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(*
p));
295 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(*
p));
304 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(*
p));
313 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(*
p));
341 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(*
p));
346 static const typename TargetEncoding::Ch hexDigits[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
347 static const char escape[256] = {
348 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 350 'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'b',
't',
'n',
'u',
'f',
'r',
'u',
'u',
351 'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
352 0, 0,
'"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
354 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'\\', 0, 0, 0,
359 if (TargetEncoding::supportUnicode)
368 if (!TargetEncoding::supportUnicode && static_cast<unsigned>(
c) >= 0x80) {
385 unsigned lead = (
s >> 10) + 0xD800;
386 unsigned trail = (
s & 0x3FF) + 0xDC00;
399 else if ((
sizeof(
Ch) == 1 || static_cast<unsigned>(
c) < 256) &&
RAPIDJSON_UNLIKELY(escape[static_cast<unsigned char>(
c)])) {
402 PutUnsafe(*
os_, static_cast<typename TargetEncoding::Ch>(escape[static_cast<unsigned char>(
c)]));
403 if (escape[static_cast<unsigned char>(
c)] ==
'u') {
406 PutUnsafe(*
os_, hexDigits[static_cast<unsigned char>(
c) >> 4]);
407 PutUnsafe(*
os_, hexDigits[static_cast<unsigned char>(
c) & 0xF]);
430 for (
size_t i = 0; i <
length; i++) {
441 if (
level->valueCount > 0) {
445 os_->Put((
level->valueCount % 2 == 0) ?
',' :
':');
447 if (!
level->inArray &&
level->valueCount % 2 == 0)
479 char *
buffer = os_->Push(11);
481 os_->Pop(static_cast<size_t>(11 - (
end -
buffer)));
487 char *
buffer = os_->Push(10);
489 os_->Pop(static_cast<size_t>(10 - (
end -
buffer)));
495 char *
buffer = os_->Push(21);
497 os_->Pop(static_cast<size_t>(21 - (
end -
buffer)));
503 char *
buffer = os_->Push(20);
505 os_->Pop(static_cast<size_t>(20 - (
end -
buffer)));
531 char *
buffer = os_->Push(25);
533 os_->Pop(static_cast<size_t>(25 - (
end -
buffer)));
537 #if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) 546 const char*
p = is.
src_;
548 const char* nextAligned =
reinterpret_cast<const char*
>((
reinterpret_cast<size_t>(
p) + 15) &
static_cast<size_t>(~15));
549 const char* endAligned =
reinterpret_cast<const char*
>(
reinterpret_cast<size_t>(
end) & static_cast<size_t>(~15));
550 if (nextAligned >
end)
553 while (
p != nextAligned)
554 if (*
p < 0x20 || *
p ==
'\"' || *
p ==
'\\') {
559 os_->PutUnsafe(*
p++);
562 static const char dquote[16] = {
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"',
'\"' };
563 static const char bslash[16] = {
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\',
'\\' };
564 static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };
565 const __m128i dq = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&dquote[0]));
566 const __m128i bs = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&bslash[0]));
567 const __m128i sp = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&space[0]));
569 for (;
p != endAligned;
p += 16) {
570 const __m128i
s = _mm_load_si128(reinterpret_cast<const __m128i *>(
p));
571 const __m128i t1 = _mm_cmpeq_epi8(
s, dq);
572 const __m128i t2 = _mm_cmpeq_epi8(
s, bs);
573 const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(
s, sp), sp);
574 const __m128i
x = _mm_or_si128(_mm_or_si128(t1, t2), t3);
575 unsigned short r =
static_cast<unsigned short>(_mm_movemask_epi8(
x));
578 #ifdef _MSC_VER // Find the index of first escaped 585 char*
q =
reinterpret_cast<char*
>(os_->PushUnsafe(
len));
586 for (
size_t i = 0; i <
len; i++)
592 _mm_storeu_si128(reinterpret_cast<__m128i *>(os_->PushUnsafe(16)),
s);
598 #endif // defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) 610 #endif // RAPIDJSON_RAPIDJSON_H_ bool WriteInt64(int64_t i64)
Definition: writer.h:299
char * dtoa(double value, char *buffer, int maxDecimalPlaces=324)
Definition: dtoa.h:216
WriteFlag
Combination of writeFlags.
Definition: writer.h:63
true
Definition: rapidjson.h:606
int GetMaxDecimalPlaces() const
Definition: writer.h:138
const Ch * head_
Original head of the string.
Definition: stream.h:125
void PutUnsafe(Stream &stream, typename Stream::Ch c)
Write character to a stream, presuming buffer is reserved.
Definition: stream.h:91
bool Key(const Ch *str, SizeType length, bool copy=false)
Definition: writer.h:210
Allow writing of Infinity, -Infinity and NaN.
Definition: writer.h:66
bool inArray
true if in array, otherwise in object
Definition: writer.h:259
Ch Peek() const
Definition: stream.h:115
array
Definition: rapidjson.h:608
No flags are set.
Definition: writer.h:64
void Prefix(Type type)
Definition: writer.h:437
OutputStream * os_
Definition: writer.h:464
string
Definition: rapidjson.h:609
bool Key(const Ch *str)
Definition: writer.h:240
static int codepoint(lua_State *L)
Definition: lutf8lib.c:100
#define RAPIDJSON_WRITE_DEFAULT_FLAGS
Definition: writer.h:59
bool WriteDouble(double d)
Definition: writer.h:317
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
char * i64toa(int64_t value, char *buffer)
Definition: itoa.h:291
bool StartArray()
Definition: writer.h:220
bool WriteEndObject()
Definition: writer.h:424
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:455
GLenum GLsizei len
Definition: glext.h:7389
false
Definition: rapidjson.h:605
object
Definition: rapidjson.h:607
static const char json[]
Definition: namespacetest.cpp:32
size_t GetSize() const
Definition: stack.h:176
Encoding conversion.
Definition: encodings.h:658
bool Double(double d)
Writes the given double value to the stream.
Definition: writer.h:184
char * u64toa(uint64_t value, char *buffer)
Definition: itoa.h:123
const Ch * src_
Current read position.
Definition: stream.h:124
GLdouble s
Definition: glext.h:6390
char * u32toa(uint32_t value, char *buffer)
Definition: itoa.h:39
SizeType StrLen(const Ch *s)
Custom strlen() which works on different character types.
Definition: strfunc.h:30
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
bool StartObject()
Definition: writer.h:204
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
Read-only string stream.
Definition: fwd.h:47
bool EndObject(SizeType memberCount=0)
Definition: writer.h:212
bool Bool(bool b)
Definition: writer.h:173
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
Writer & operator=(const Writer &)
size_t Tell() const
Definition: stream.h:117
bool String(const Ch *str, SizeType length, bool copy=false)
Definition: writer.h:192
bool ScanWriteUnescapedString(GenericStringStream< SourceEncoding > &is, size_t length)
Definition: writer.h:419
null
Definition: rapidjson.h:604
bool Null()
Definition: writer.h:172
GLenum type
Definition: glext.h:6233
bool hasRoot_
Definition: writer.h:467
Writer(StackAllocator *allocator=0, size_t levelDepth=kDefaultLevelDepth)
Definition: writer.h:103
void Clear()
Definition: stack.h:98
bool EndArray(SizeType elementCount=0)
Definition: writer.h:226
Level(bool inArray_)
Definition: writer.h:257
bool WriteString(const Ch *str, SizeType length)
Definition: writer.h:345
GLint level
Definition: glext.h:6293
number
Definition: rapidjson.h:610
bool IsComplete() const
Checks whether the output is a complete JSON.
Definition: writer.h:134
internal::Stack< StackAllocator > level_stack_
Definition: writer.h:465
bool WriteStartArray()
Definition: writer.h:425
void Reset(OutputStream &os)
Reset the writer with a new stream.
Definition: writer.h:124
bool Uint(unsigned u)
Definition: writer.h:175
SourceEncoding::Ch Ch
Definition: writer.h:89
bool String(const Ch *str)
Simpler but slower overload.
Definition: writer.h:239
void SetMaxDecimalPlaces(int maxDecimalPlaces)
Sets the maximum number of decimal places for double output.
Definition: writer.h:163
size_t valueCount
number of values in this level
Definition: writer.h:258
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
bool WriteBool(bool b)
Definition: writer.h:269
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:6414
bool RawValue(const Ch *json, size_t length, Type type)
Write a raw JSON value.
Definition: writer.h:252
Unknown compiler Device disconnected from port File already exists Saving to backup buffer Got connection Public address Setting disk in tray You have left the game You have joined with input devices *s *s has joined as player u A netplay connection attempt failed because the peer is not running or is running an old version of RetroArch use the same version use the same version This core does not support inter architecture netplay Incorrect password A netplay client has disconnected You do not have permission to play The input devices requested are not available Netplay peer s paused Give hardware rendered cores their own private context Avoids having to assume hardware state changes inbetween frames Adjusts menu screen appearance settings Improves performance at the cost of latency and more video stuttering Use only if you cannot obtain full speed otherwise Autodetect Capabilities Connecting to port Password Username Accounts List Endpoint Achievements Scan Content Import content Ask Block Frames نظام تشغيل الصوت Audio Enable Turbo Deadzone Audio Maximum Timing Skew Audio Output Dynamic Audio Rate Control الصوت Audio Volume Level(dB)" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_EXCLUSIVE_MODE
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:468
bool Empty() const
Definition: stack.h:175
Definition: inftrees.h:27
Default write flags. Can be customized by defining RAPIDJSON_WRITE_DEFAULT_FLAGS.
Definition: writer.h:67
GLfloat GLfloat p
Definition: glext.h:9809
bool Uint64(uint64_t u64)
Definition: writer.h:177
bool WriteNull()
Definition: writer.h:264
Ch Take()
Definition: stream.h:116
bool EndValue(bool ret)
Definition: writer.h:458
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
bool WriteEndArray()
Definition: writer.h:426
bool WriteInt(int i)
Definition: writer.h:281
Validate encoding of JSON strings.
Definition: writer.h:65
void PutReserve(Stream &stream, size_t count)
Reserve n characters for writing to a stream.
Definition: stream.h:84
JSON writer.
Definition: fwd.h:95
signed __int64 int64_t
Definition: stdint.h:135
char * i32toa(int32_t value, char *buffer)
Definition: itoa.h:113
Type
Type of JSON value.
Definition: rapidjson.h:603
bool WriteUint(unsigned u)
Definition: writer.h:290
int maxDecimalPlaces_
Definition: writer.h:466
bool Int64(int64_t i64)
Definition: writer.h:176
GLuint GLuint end
Definition: glext.h:6292
static const size_t kDefaultLevelDepth
Definition: writer.h:262
#define false
Definition: ordinals.h:83
bool WriteRawValue(const Ch *json, size_t length)
Definition: writer.h:428
Definition: video4linux2.c:51
Writer(OutputStream &os, StackAllocator *stackAllocator=0, size_t levelDepth=kDefaultLevelDepth)
Constructor.
Definition: writer.h:99
GLintptr offset
Definition: glext.h:6560
Information for each nested level.
Definition: writer.h:256
static const int kDefaultMaxDecimalPlaces
Definition: writer.h:91
bool WriteUint64(uint64_t u64)
Definition: writer.h:308
unsigned __int64 uint64_t
Definition: stdint.h:136
GLenum GLuint GLenum GLsizei length
Definition: glext.h:6233
bool Int(int i)
Definition: writer.h:174
const char *const str
Definition: portlistingparse.c:18
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:380
bool WriteStartObject()
Definition: writer.h:423
bool RawNumber(const Ch *str, SizeType length, bool copy=false)
Definition: writer.h:186