join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
pack.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_DATA_PACK_HPP
26#define JOIN_DATA_PACK_HPP
27
28// libjoin.
29#include <join/utils.hpp>
30#include <join/sax.hpp>
31
32// C++.
33#include <stdexcept>
34
35namespace join
36{
40 class PackWriter : public StreamWriter
41 {
42 public:
47 PackWriter (std::ostream& document)
48 : StreamWriter (document)
49 {
50 }
51
56 PackWriter (const PackWriter& other) = delete;
57
63 PackWriter& operator= (const PackWriter& other) = delete;
64
69 PackWriter (PackWriter&& other) = delete;
70
76 PackWriter& operator= (PackWriter&& other) = delete;
77
81 virtual ~PackWriter () = default;
82
87 virtual int setNull () override
88 {
89 append (0xc0);
90 return 0;
91 }
92
98 virtual int setBool (bool value) override
99 {
100 if (value)
101 {
102 append (0xc3);
103 }
104 else
105 {
106 append (0xc2);
107 }
108 return 0;
109 }
110
116 virtual int setInt (int32_t value) override
117 {
118 if (value < -(1 << 15))
119 {
120 append (0xd2);
121 pack (static_cast<uint32_t> (value));
122 }
123 else if (value < -(1 << 7))
124 {
125 append (0xd1);
126 pack (static_cast<uint16_t> (value));
127 }
128 else if (value < -(1 << 5))
129 {
130 append (0xd0);
131 pack (static_cast<uint8_t> (value));
132 }
133 else if (value < (1 << 7))
134 {
135 append (static_cast<uint8_t> (value));
136 }
137 else if (value < (1 << 8))
138 {
139 append (0xcc);
140 pack (static_cast<uint8_t> (value));
141 }
142 else if (value < (1 << 16))
143 {
144 append (0xcd);
145 pack (static_cast<uint16_t> (value));
146 }
147 else
148 {
149 append (0xce);
150 pack (static_cast<uint32_t> (value));
151 }
152 return 0;
153 }
154
160 virtual int setUint (uint32_t value) override
161 {
162 if (value < (1 << 7))
163 {
164 append (static_cast<uint8_t> (value));
165 }
166 else if (value < (1 << 8))
167 {
168 append (0xcc);
169 pack (static_cast<uint8_t> (value));
170 }
171 else if (value < (1 << 16))
172 {
173 append (0xcd);
174 pack (static_cast<uint16_t> (value));
175 }
176 else
177 {
178 append (0xce);
179 pack (value);
180 }
181 return 0;
182 }
183
189 virtual int setInt64 (int64_t value) override
190 {
191 if (value < -(1LL << 31))
192 {
193 append (0xd3);
194 pack (static_cast<uint64_t> (value));
195 }
196 else if (value < -(1LL << 15))
197 {
198 append (0xd2);
199 pack (static_cast<uint32_t> (value));
200 }
201 else if (value < -(1LL << 7))
202 {
203 append (0xd1);
204 pack (static_cast<uint16_t> (value));
205 }
206 else if (value < -(1LL << 5))
207 {
208 append (0xd0);
209 pack (static_cast<uint8_t> (value));
210 }
211 else if (value < (1LL << 7))
212 {
213 append (static_cast<uint8_t> (value));
214 }
215 else if (value < (1LL << 8))
216 {
217 append (0xcc);
218 pack (static_cast<uint8_t> (value));
219 }
220 else if (value < (1LL << 16))
221 {
222 append (0xcd);
223 pack (static_cast<uint16_t> (value));
224 }
225 else if (value < (1LL << 32))
226 {
227 append (0xce);
228 pack (static_cast<uint32_t> (value));
229 }
230 else
231 {
232 append (0xcf);
233 pack (static_cast<uint64_t> (value));
234 }
235 return 0;
236 }
237
243 virtual int setUint64 (uint64_t value) override
244 {
245 if (value < (1ULL << 7))
246 {
247 append (static_cast<uint8_t> (value));
248 }
249 else if (value < (1ULL << 8))
250 {
251 append (0xcc);
252 pack (static_cast<uint8_t> (value));
253 }
254 else if (value < (1ULL << 16))
255 {
256 append (0xcd);
257 pack (static_cast<uint16_t> (value));
258 }
259 else if (value < (1ULL << 32))
260 {
261 append (0xce);
262 pack (static_cast<uint32_t> (value));
263 }
264 else
265 {
266 append (0xcf);
267 pack (value);
268 }
269 return 0;
270 }
271
277 virtual int setDouble (double value) override
278 {
279 float f = static_cast<float> (value);
280 if (std::isfinite (value) && static_cast<double> (f) == value)
281 {
282 append (0xca);
283 pack (f);
284 }
285 else
286 {
287 append (0xcb);
288 pack (value);
289 }
290 return 0;
291 }
292
298 virtual int setString (const std::string& value) override
299 {
300 if (value.size () < 32)
301 {
302 append (static_cast<char> (0xa0 | value.size ()));
303 }
304 else if (value.size () < 256)
305 {
306 append (0xd9);
307 pack (static_cast<uint8_t> (value.size ()));
308 }
309 else if (value.size () < 65536)
310 {
311 append (0xda);
312 pack (static_cast<uint16_t> (value.size ()));
313 }
314 else
315 {
316 append (0xdb);
317 pack (static_cast<uint32_t> (value.size ()));
318 }
319 append (value.c_str (), static_cast<uint32_t> (value.size ()));
320 return 0;
321 }
322
328 virtual int startArray (uint32_t size = 0) override
329 {
330 if (size < 16)
331 {
332 append (static_cast<char> (0x90 | size));
333 }
334 else if (size < 65536)
335 {
336 append (0xdc);
337 pack (static_cast<uint16_t> (size));
338 }
339 else
340 {
341 append (0xdd);
342 pack (size);
343 }
344 return 0;
345 }
346
352 virtual int startObject (uint32_t size = 0) override
353 {
354 if (size < 16)
355 {
356 append (static_cast<char> (0x80 | size));
357 }
358 else if (size < 65536)
359 {
360 append (0xde);
361 pack (static_cast<uint16_t> (size));
362 }
363 else
364 {
365 append (0xdf);
366 pack (size);
367 }
368 return 0;
369 }
370
376 virtual int setKey (const Value& key) override
377 {
378 if (JOIN_UNLIKELY (key.isArray () || key.isObject ()))
379 {
381 return -1;
382 }
383 return setValue (key);
384 }
385
386 protected:
391 template <typename Type>
392 void pack (Type value)
393 {
394 append (reinterpret_cast<const char*> (&swap (value)), sizeof (value));
395 }
396 };
397
402 {
403 public:
409 : StreamReader (root)
410 {
411 }
412
417 PackReader (const PackReader& other) = delete;
418
424 PackReader& operator= (const PackReader& other) = delete;
425
430 PackReader (PackReader&& other) = delete;
431
437 PackReader& operator= (PackReader&& other) = delete;
438
442 virtual ~PackReader () = default;
443
450 int deserialize (const char* document, size_t length) override
451 {
452 StringView in (document, length);
453 return read (in);
454 }
455
462 int deserialize (const char* first, const char* last) override
463 {
464 StringView in (first, last);
465 return read (in);
466 }
467
473 int deserialize (const std::string& document) override
474 {
475 StringView in (document.c_str (), document.size ());
476 return read (in);
477 }
478
484 int deserialize (std::stringstream& document) override
485 {
486 StringStreamView in (document);
487 return read (in);
488 }
489
495 int deserialize (std::istringstream& document) override
496 {
497 StringStreamView in (document);
498 return read (in);
499 }
500
506 int deserialize (std::fstream& document) override
507 {
508 FileStreamView in (document);
509 return read (in);
510 }
511
517 int deserialize (std::ifstream& document) override
518 {
519 FileStreamView in (document);
520 return read (in);
521 }
522
528 int deserialize (std::iostream& document) override
529 {
530 StreamView in (document);
531 return read (in);
532 }
533
539 int deserialize (std::istream& document) override
540 {
541 StreamView in (document);
542 return read (in);
543 }
544
545 protected:
551 template <typename ViewType>
552 int read (ViewType& document)
553 {
554 if (JOIN_LIKELY (readValue (document) == 0))
555 {
556 if (JOIN_LIKELY (document.peek () == std::char_traits<char>::eof ()))
557 {
558 return 0;
559 }
560
562 }
563
564 return -1;
565 }
566
572 template <typename ViewType>
573 int readValue (ViewType& document)
574 {
575 uint8_t head = static_cast<uint8_t> (document.peek ());
576
577 try
578 {
579 if (isArray (head))
580 {
581 return readArray (document);
582 }
583 else if (isObject (head))
584 {
585 return readObject (document);
586 }
587 else if (isNull (head))
588 {
589 return readNull (document);
590 }
591 else if (isFalse (head))
592 {
593 return readFalse (document);
594 }
595 else if (isTrue (head))
596 {
597 return readTrue (document);
598 }
599 else if (isString (head))
600 {
601 return readString (document);
602 }
603 else if (isBin (head))
604 {
605 return readBin (document);
606 }
607 else if (isNumber (head))
608 {
609 return readNumber (document);
610 }
611 else
612 {
614 return -1;
615 }
616 }
617 catch (...)
618 {
620 return -1;
621 }
622 }
623
630 template <typename ViewType>
631 int readNull (ViewType& document, bool isKey = false)
632 {
633 document.get ();
634 return (isKey) ? setKey (Value (in_place_index_t<Value::Null>{}, nullptr)) : setNull ();
635 }
636
643 template <typename ViewType>
644 int readFalse (ViewType& document, bool isKey = false)
645 {
646 document.get ();
647 return (isKey) ? setKey (Value (in_place_index_t<Value::Boolean>{}, false)) : setBool (false);
648 }
649
656 template <typename ViewType>
657 int readTrue (ViewType& document, bool isKey = false)
658 {
659 document.get ();
660 return (isKey) ? setKey (Value (in_place_index_t<Value::Boolean>{}, true)) : setBool (true);
661 }
662
668 template <typename ViewType>
669 int readArray (ViewType& document)
670 {
671 uint32_t len = 0;
672
673 if (document.getIf (0xdd))
674 {
675 len = unpack<uint32_t> (document);
676 }
677 else if (document.getIf (0xdc))
678 {
679 len = unpack<uint16_t> (document);
680 }
681 else
682 {
683 len = unpack<uint8_t> (document) & ~0x90;
684 }
685
686 if (JOIN_UNLIKELY (startArray (len) == -1))
687 {
688 return -1;
689 }
690
691 while (len)
692 {
693 if (JOIN_UNLIKELY (readValue (document) == -1))
694 {
695 return -1;
696 }
697
698 --len;
699 }
700
701 return stopArray ();
702 }
703
709 template <typename ViewType>
710 int readObject (ViewType& document)
711 {
712 uint32_t len = 0;
713
714 if (document.getIf (0xdf))
715 {
716 len = unpack<uint32_t> (document);
717 }
718 else if (document.getIf (0xde))
719 {
720 len = unpack<uint16_t> (document);
721 }
722 else
723 {
724 len = unpack<uint8_t> (document) & ~0x80;
725 }
726
727 if (JOIN_UNLIKELY (startObject (len) == -1))
728 {
729 return -1;
730 }
731
732 while (len)
733 {
734 if (JOIN_UNLIKELY (readKey (document) == -1))
735 {
736 return -1;
737 }
738
739 if (JOIN_UNLIKELY (readValue (document) == -1))
740 {
741 return -1;
742 }
743
744 --len;
745 }
746
747 return stopObject ();
748 }
749
755 template <typename ViewType>
756 int readKey (ViewType& document)
757 {
758 uint8_t head = static_cast<uint8_t> (document.peek ());
759
760 try
761 {
762 if (isNull (head))
763 {
764 return readNull (document, true);
765 }
766 else if (isFalse (head))
767 {
768 return readFalse (document, true);
769 }
770 else if (isTrue (head))
771 {
772 return readTrue (document, true);
773 }
774 else if (isString (head))
775 {
776 return readString (document, true);
777 }
778 else if (isNumber (head))
779 {
780 return readNumber (document, true);
781 }
782 else
783 {
785 return -1;
786 }
787 }
788 catch (...)
789 {
791 return -1;
792 }
793 }
794
801 template <typename ViewType>
802 int readString (ViewType& document, bool isKey = false)
803 {
804 uint32_t len = 0;
805
806 if (document.getIf (0xdb))
807 {
808 len = unpack<uint32_t> (document);
809 }
810 else if (document.getIf (0xda))
811 {
812 len = unpack<uint16_t> (document);
813 }
814 else if (document.getIf (0xd9))
815 {
816 len = unpack<uint8_t> (document);
817 }
818 else
819 {
820 len = unpack<uint8_t> (document) & ~0xa0;
821 }
822
823 std::string output;
824 output.resize (len);
825
826 if (JOIN_UNLIKELY (document.read (&output[0], len) != len))
827 {
829 return -1;
830 }
831
832 return isKey ? setKey (Value (in_place_index_t<Value::String>{}, output)) : setString (output);
833 }
834
840 template <typename ViewType>
841 int readBin (ViewType& document)
842 {
843 uint32_t len = 0;
844
845 if (document.getIf (0xc6))
846 {
847 len = unpack<uint32_t> (document);
848 }
849 else if (document.getIf (0xc5))
850 {
851 len = unpack<uint16_t> (document);
852 }
853 else if (document.getIf (0xc4))
854 {
855 len = unpack<uint8_t> (document);
856 }
857
858 std::string output;
859 output.resize (len);
860
861 if (JOIN_UNLIKELY (document.read (&output[0], len) != len))
862 {
864 return -1;
865 }
866
867 return setString (output);
868 }
869
876 template <typename ViewType>
877 int readNumber (ViewType& document, bool isKey = false)
878 {
879 uint8_t head = document.get ();
880
881 if (head <= 0x7f)
882 {
883 auto number = uint32_t (head);
884 return isKey ? setKey (Value (in_place_index_t<Value::Unsigned>{}, number)) : setUint (number);
885 }
886 else if (head >= 0xe0)
887 {
888 auto number = int32_t (static_cast<int8_t> (head));
889 return isKey ? setKey (Value (in_place_index_t<Value::Integer>{}, number)) : setInt (number);
890 }
891 else if (head == 0xd3)
892 {
893 auto number = unpack<int64_t> (document);
894 return isKey ? setKey (Value (in_place_index_t<Value::Integer64>{}, number)) : setInt64 (number);
895 }
896 else if (head == 0xcf)
897 {
898 auto number = unpack<uint64_t> (document);
899 return isKey ? setKey (Value (in_place_index_t<Value::Unsigned64>{}, number)) : setUint64 (number);
900 }
901 else if (head == 0xcb)
902 {
903 auto number = unpack<double> (document);
904 return isKey ? setKey (Value (in_place_index_t<Value::Real>{}, number)) : setDouble (number);
905 }
906 else if (head == 0xd2)
907 {
908 auto number = unpack<int32_t> (document);
909 return isKey ? setKey (Value (in_place_index_t<Value::Integer>{}, number)) : setInt (number);
910 }
911 else if (head == 0xce)
912 {
913 auto number = unpack<uint32_t> (document);
914 return isKey ? setKey (Value (in_place_index_t<Value::Unsigned>{}, number)) : setUint (number);
915 }
916 else if (head == 0xca)
917 {
918 auto number = double (unpack<float> (document));
919 return isKey ? setKey (Value (in_place_index_t<Value::Real>{}, number)) : setDouble (number);
920 }
921 else if (head == 0xd1)
922 {
923 auto number = int32_t (unpack<int16_t> (document));
924 return isKey ? setKey (Value (in_place_index_t<Value::Integer>{}, number)) : setInt (number);
925 }
926 else if (head == 0xcd)
927 {
928 auto number = uint32_t (unpack<uint16_t> (document));
929 return isKey ? setKey (Value (in_place_index_t<Value::Unsigned>{}, number)) : setUint (number);
930 }
931 else if (head == 0xd0)
932 {
933 auto number = int32_t (unpack<int8_t> (document));
934 return isKey ? setKey (Value (in_place_index_t<Value::Integer>{}, number)) : setInt (number);
935 }
936 else if (head == 0xcc)
937 {
938 auto number = uint32_t (unpack<uint8_t> (document));
939 return isKey ? setKey (Value (in_place_index_t<Value::Unsigned>{}, number)) : setUint (number);
940 }
941 else
942 {
944 return -1;
945 }
946 }
947
953 template <typename Type, typename ViewType>
954 std::enable_if_t<std::is_arithmetic<Type>::value, Type> static unpack (ViewType& document)
955 {
956 Type value;
957 if (JOIN_UNLIKELY (document.read (reinterpret_cast<char*> (&value), sizeof (value)) != sizeof (value)))
958 {
959 throw std::range_error ("not enough data to unpack");
960 }
961 return swap (value);
962 }
963
969 constexpr bool isNull (uint8_t c)
970 {
971 return (c == 0xc0);
972 }
973
979 constexpr bool isFalse (uint8_t c)
980 {
981 return (c == 0xc2);
982 }
983
989 constexpr bool isTrue (uint8_t c)
990 {
991 return (c == 0xc3);
992 }
993
999 constexpr bool isInt (uint8_t c)
1000 {
1001 return ((c <= 0x7f) || (c >= 0xe0)) || (c == 0xd0) || (c == 0xd1) || (c == 0xd2);
1002 }
1003
1009 constexpr bool isUint (uint8_t c)
1010 {
1011 return (c == 0xcc) || (c == 0xcd) || (c == 0xce);
1012 }
1013
1019 constexpr bool isInt64 (uint8_t c)
1020 {
1021 return (c == 0xd3);
1022 }
1023
1029 constexpr bool isUint64 (uint8_t c)
1030 {
1031 return (c == 0xcf);
1032 }
1033
1039 constexpr bool isReal (uint8_t c)
1040 {
1041 return (c == 0xca) || (c == 0xcb);
1042 }
1043
1049 constexpr bool isNumber (uint8_t c)
1050 {
1051 return isInt (c) || isUint (c) || isInt64 (c) || isUint64 (c) || isReal (c);
1052 }
1053
1059 constexpr bool isString (uint8_t c)
1060 {
1061 return ((c >= 0xa0) && (c <= 0xbf)) || (c == 0xd9) || (c == 0xda) || (c == 0xdb);
1062 }
1063
1069 constexpr bool isBin (uint8_t c)
1070 {
1071 return (c == 0xc4) || (c == 0xc5) || (c == 0xc6);
1072 }
1073
1079 constexpr bool isArray (uint8_t c)
1080 {
1081 return ((c >= 0x90) && (c <= 0x9f)) || (c == 0xdc) || (c == 0xdd);
1082 }
1083
1089 constexpr bool isObject (uint8_t c)
1090 {
1091 return ((c >= 0x80) && (c <= 0x8f)) || (c == 0xde) || (c == 0xdf);
1092 }
1093 };
1094}
1095
1096#endif
basic stream view.
Definition view.hpp:373
message pack reader class.
Definition pack.hpp:402
constexpr bool isString(uint8_t c)
check if string.
Definition pack.hpp:1059
int readFalse(ViewType &document, bool isKey=false)
parse a false value.
Definition pack.hpp:644
int deserialize(std::ifstream &document) override
deserialize a document.
Definition pack.hpp:517
int readValue(ViewType &document)
parse value.
Definition pack.hpp:573
PackReader & operator=(const PackReader &other)=delete
copy assignment.
constexpr bool isInt64(uint8_t c)
check if 64 bits integer.
Definition pack.hpp:1019
int deserialize(const char *document, size_t length) override
deserialize a document.
Definition pack.hpp:450
constexpr bool isInt(uint8_t c)
check if 32 bits integer.
Definition pack.hpp:999
constexpr bool isNull(uint8_t c)
check if null.
Definition pack.hpp:969
PackReader(const PackReader &other)=delete
copy constructor.
int readKey(ViewType &document)
parse a key of any type.
Definition pack.hpp:756
int deserialize(std::fstream &document) override
deserialize a document.
Definition pack.hpp:506
constexpr bool isTrue(uint8_t c)
check if true.
Definition pack.hpp:989
int read(ViewType &document)
parse a document.
Definition pack.hpp:552
int deserialize(const char *first, const char *last) override
deserialize a document.
Definition pack.hpp:462
int deserialize(std::iostream &document) override
deserialize a document.
Definition pack.hpp:528
int deserialize(std::stringstream &document) override
deserialize a document.
Definition pack.hpp:484
constexpr bool isObject(uint8_t c)
check if object.
Definition pack.hpp:1089
int readArray(ViewType &document)
parse an array value.
Definition pack.hpp:669
virtual ~PackReader()=default
destroy instance.
constexpr bool isUint(uint8_t c)
check if unsigned 32 bits integer.
Definition pack.hpp:1009
int readTrue(ViewType &document, bool isKey=false)
parse a true value.
Definition pack.hpp:657
constexpr bool isUint64(uint8_t c)
check if unsigned 64 bits integer.
Definition pack.hpp:1029
constexpr bool isFalse(uint8_t c)
check if false.
Definition pack.hpp:979
int readNumber(ViewType &document, bool isKey=false)
parse a number value.
Definition pack.hpp:877
constexpr bool isReal(uint8_t c)
check if real.
Definition pack.hpp:1039
int deserialize(std::istringstream &document) override
deserialize a document.
Definition pack.hpp:495
PackReader(PackReader &&other)=delete
move constructor.
static std::enable_if_t< std::is_arithmetic< Type >::value, Type > unpack(ViewType &document)
unpack value from stream.
Definition pack.hpp:954
int readObject(ViewType &document)
parse an object value.
Definition pack.hpp:710
int readNull(ViewType &document, bool isKey=false)
parse a null value.
Definition pack.hpp:631
int deserialize(const std::string &document) override
deserialize a document.
Definition pack.hpp:473
constexpr bool isNumber(uint8_t c)
check if number.
Definition pack.hpp:1049
constexpr bool isBin(uint8_t c)
check if binary data.
Definition pack.hpp:1069
int readString(ViewType &document, bool isKey=false)
parse a string value.
Definition pack.hpp:802
int deserialize(std::istream &document) override
deserialize a document.
Definition pack.hpp:539
constexpr bool isArray(uint8_t c)
check if array.
Definition pack.hpp:1079
PackReader(Value &root)
default constructor.
Definition pack.hpp:408
int readBin(ViewType &document)
parse binary data.
Definition pack.hpp:841
message pack writer class.
Definition pack.hpp:41
virtual int setNull() override
set null value.
Definition pack.hpp:87
PackWriter(std::ostream &document)
create instance.
Definition pack.hpp:47
virtual int setDouble(double value) override
set real value.
Definition pack.hpp:277
virtual int setString(const std::string &value) override
set string value.
Definition pack.hpp:298
virtual int setInt64(int64_t value) override
set 64 bits integer value.
Definition pack.hpp:189
virtual int setUint(uint32_t value) override
set unsigned integer value.
Definition pack.hpp:160
virtual int setBool(bool value) override
set boolean value.
Definition pack.hpp:98
virtual int setUint64(uint64_t value) override
set unsigned 64 bits integer value.
Definition pack.hpp:243
virtual ~PackWriter()=default
destroy instance.
virtual int startArray(uint32_t size=0) override
start array.
Definition pack.hpp:328
virtual int setKey(const Value &key) override
set key.
Definition pack.hpp:376
void pack(Type value)
pack value into stream.
Definition pack.hpp:392
PackWriter & operator=(const PackWriter &other)=delete
copy assignment.
virtual int setInt(int32_t value) override
set integer value.
Definition pack.hpp:116
virtual int startObject(uint32_t size=0) override
start object.
Definition pack.hpp:352
PackWriter(PackWriter &&other)=delete
move constructor.
PackWriter(const PackWriter &other)=delete
copy constructor.
stream deserializer abstract class.
Definition sax.hpp:462
virtual int stopObject() override
stop object.
Definition sax.hpp:753
virtual int startArray(uint32_t size=0) override
start array.
Definition sax.hpp:655
virtual int setInt64(int64_t value) override
set 64 bits integer value.
Definition sax.hpp:615
virtual int setUint(uint32_t value) override
set unsigned integer value.
Definition sax.hpp:605
virtual int setNull() override
set null value.
Definition sax.hpp:575
virtual int setUint64(uint64_t value) override
set unsigned 64 bits integer value.
Definition sax.hpp:625
virtual int setKey(const Value &key) override
set key.
Definition sax.hpp:743
virtual int setInt(int32_t value) override
set integer value.
Definition sax.hpp:595
virtual int startObject(uint32_t size=0) override
start object.
Definition sax.hpp:706
virtual int setBool(bool value) override
set boolean value.
Definition sax.hpp:585
virtual int stopArray() override
stop array.
Definition sax.hpp:691
virtual int setDouble(double value) override
set real value.
Definition sax.hpp:635
virtual int setString(const std::string &value) override
set string value.
Definition sax.hpp:645
stream serializer abstract class.
Definition sax.hpp:244
int setValue(const Value &value)
set value.
Definition sax.hpp:301
void append(char data) noexcept
append character to output stream in batch.
Definition sax.hpp:392
string view.
Definition view.hpp:83
value class.
Definition value.hpp:64
const std::string key(65, 'a')
key.
Definition acceptor.hpp:32
Type & swap(Type &val)
swaps byte orders.
Definition utils.hpp:184
std::error_code make_error_code(join::Errc code) noexcept
Create an std::error_code object.
Definition error.cpp:150
thread_local std::error_code lastError
last error.
Definition error.cpp:32
disambiguation tag to indicate that the contained object should be constructed in-place.
Definition traits.hpp:57
#define JOIN_LIKELY(x)
Definition utils.hpp:46
#define JOIN_UNLIKELY(x)
Definition utils.hpp:47