42#include <unordered_map>
46#include <boost/lexical_cast.hpp>
47#include <boost/functional/hash.hpp>
58 constexpr bool debug =
true;
189 inline std::string to_string(
state aState)
194 return std::string{
"Error" };
196 return std::string{
"Ignore" };
198 return std::string{
"EndOfParse" };
200 return std::string{
"Element" };
202 return std::string{
"Object" };
204 return std::string{
"Array" };
206 return std::string{
"Close" };
208 return std::string{
"Value" };
210 return std::string{
"NeedValueSeparator" };
212 return std::string{
"NeedValue" };
214 return std::string{
"NeedObjectValueSeparator" };
216 return std::string{
"NeedObjectValue" };
218 return std::string{
"Keyword" };
220 return std::string{
"Name" };
222 return std::string{
"EndName" };
224 return std::string{
"String" };
226 return std::string{
"StringEnd" };
228 return std::string{
"NumberIntNeedDigit" };
230 return std::string{
"NumberInt" };
232 return std::string{
"NumberFracNeedDigit" };
234 return std::string{
"NumberFrac" };
236 return std::string{
"NumberExpSign" };
238 return std::string{
"NumberExpIntNeedDigit" };
240 return std::string{
"NumberExpInt" };
242 return std::string{
"Escaping" };
244 return std::string{
"Escaped" };
246 return std::string{
"EscapingUnicode" };
249 return std::string{
"Comment" };
251 return std::string{
"??" };
255 template <json_syntax Syntax>
262 std::array<state, TOKEN_COUNT>
264 SXXX,
SOBJ,
SCLO,
SXXX,
SXXX,
SXXX,
SNOV,
SNAM,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SKEY,
SKEY,
SXXX,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
271 std::array<state, TOKEN_COUNT>
273 SXXX,
SOBJ,
SCLO,
SXXX,
SXXX,
SXXX,
SNOV,
SNAM,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SKEY,
SKEY,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
278 template <json_syntax Syntax>
285 std::array<state, TOKEN_COUNT>
287 SXXX,
SOBJ,
SXXX,
SARR,
SXXX,
SXXX,
SXXX,
SSTR,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SNU1,
SNU2,
SKEY,
SKEY,
SXXX,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
294 std::array<state, TOKEN_COUNT>
296 SXXX,
SOBJ,
SXXX,
SARR,
SXXX,
SXXX,
SXXX,
SSTR,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SNU1,
SNU2,
SKEY,
SKEY,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
301 template <json_syntax Syntax>
308 std::array<state, TOKEN_COUNT>
310 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNAM,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SKEY,
SKEY,
SXXX,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
317 std::array<state, TOKEN_COUNT>
319 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNAM,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SKEY,
SKEY,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
324 template <json_syntax Syntax>
331 std::array<state, TOKEN_COUNT>
333 SXXX,
SOBJ,
SCLO,
SARR,
SCLO,
SXXX,
SXXX,
SSTR,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SNU1,
SNU2,
SKEY,
SKEY,
SXXX,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SZZZ
340 std::array<state, TOKEN_COUNT>
342 SXXX,
SOBJ,
SCLO,
SARR,
SCLO,
SXXX,
SXXX,
SSTR,
SKEY,
SXXX,
SKEY,
SKEY,
SKEY,
SNU1,
SNU2,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SIGN,
SIGN,
SZZZ
347 template <json_syntax Syntax>
354 std::array<state, TOKEN_COUNT>
356 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SELE,
SELE,
SXXX,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SXXX,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SXXX,
SXXX,
SXXX,
SELE,
SELE,
SXXX
363 std::array<state, TOKEN_COUNT>
365 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SELE,
SELE,
SXXX,
SKEY,
SXXX,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SELE,
SELE,
SXXX
372 std::array<state, TOKEN_COUNT>
374 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SELE,
SKEY,
SXXX,
SKEY,
SXXX,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SKEY,
SELE,
SELE,
SXXX
379 template <json_syntax Syntax>
383 std::array<state, TOKEN_COUNT>
385 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
388 std::array<state, TOKEN_COUNT>
390 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
393 std::array<state, TOKEN_COUNT>
395 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
398 std::array<state, TOKEN_COUNT>
400 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SZZZ
403 object_state<Syntax>(),
405 std::array<state, TOKEN_COUNT>
407 SXXX,
SOBJ,
SXXX,
SARR,
SCLO,
SXXX,
SXXX,
SSTR,
SKEY,
SXXX,
SKEY,
SKEY,
SXXX,
SNU1,
SNU2,
SKEY,
SKEY,
SXXX,
SKEY,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
410 std::array<state, TOKEN_COUNT>
412 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
415 value_state<Syntax>(),
417 std::array<state, TOKEN_COUNT>
419 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SVAL,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
422 need_value_state<Syntax>(),
424 std::array<state, TOKEN_COUNT>
426 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SNOV,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
429 need_object_value_state<Syntax>(),
431 keyword_state<Syntax>(),
433 std::array<state, TOKEN_COUNT>
435 SXXX,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SENM,
SNAM,
SESC,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SNAM,
SXXX,
SXXX
438 std::array<state, TOKEN_COUNT>
440 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SELE,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SIGN,
SIGN,
SXXX
443 std::array<state, TOKEN_COUNT>
445 SXXX,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSEN,
SSTR,
SESC,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SSTR,
SXXX,
SXXX
448 std::array<state, TOKEN_COUNT>
450 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SELE,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SELE,
SELE,
SXXX
453 std::array<state, TOKEN_COUNT>
455 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU2,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
458 std::array<state, TOKEN_COUNT>
460 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SELE,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU2,
SXXX,
SXXX,
SNU3,
SNU5,
SXXX,
SXXX,
SXXX,
SELE,
SELE,
SXXX
463 std::array<state, TOKEN_COUNT>
465 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU4,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
468 std::array<state, TOKEN_COUNT>
470 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SELE,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU4,
SXXX,
SXXX,
SXXX,
SNU5,
SXXX,
SXXX,
SXXX,
SELE,
SELE,
SXXX
473 std::array<state, TOKEN_COUNT>
475 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU6,
SNU6,
SNU7,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
478 std::array<state, TOKEN_COUNT>
480 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU7,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX
483 std::array<state, TOKEN_COUNT>
485 SXXX,
SXXX,
SCLO,
SXXX,
SCLO,
SXXX,
SELE,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SNU7,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SELE,
SELE,
SXXX
488 std::array<state, TOKEN_COUNT>
490 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SESD,
SXXX,
SESD,
SEUN,
SESD,
SXXX,
SXXX,
SXXX,
SXXX,
SESD,
SXXX,
SXXX,
SXXX,
SESD,
SXXX,
SXXX,
SXXX,
SXXX
493 std::array<state, TOKEN_COUNT>
495 SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,
SXXX,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A,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
579 TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
TCHA,
583 template <
typename CharT>
584 inline token to_token(
const std::array<token, 256>& aTokenTable, CharT aCharacter)
586 auto const tableIndex = std::min<std::size_t>(
static_cast<typename std::make_unsigned<CharT>::type
>(aCharacter), 0xFFu);
587 return aTokenTable[tableIndex];
590 template <json_syntax Syntax,
typename CharT>
593 auto const token =
to_token(sTokenTable<Syntax>, aCharacter);
594 auto const stateIndex =
static_cast<std::size_t
>(aCurrentState);
595 return sStateTables<Syntax>[stateIndex][
static_cast<std::size_t
>(
token)];
598 template <json_syntax Syntax,
typename CharT>
602 return next_state<Syntax>(aCurrentState, aCurrentCharacter);
605 auto const token =
to_token(sTokenTable<Syntax>, aCurrentCharacter);
606 switch (aCurrentState)
611 return next_state<Syntax>(aPreviousState, aPreviousState, aCurrentCharacter, aNextCharacter);
615 auto const nextToken =
to_token(sTokenTable<Syntax>, aNextCharacter);
627 auto const nextToken =
to_token(sTokenTable<Syntax>, aNextCharacter);
635 auto const stateIndex =
static_cast<std::size_t
>(aCurrentState);
636 return sStateTables<Syntax>[stateIndex][
static_cast<std::size_t
>(
token)];
642 template <
typename String>
645 return std::hash<typename String::value_type>{}(aString[0]);
650 namespace json_detail
652 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
664 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
677 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
678 template <
typename IteratorTraits>
679 class basic_json_value<Syntax, Alloc, CharT, Traits, CharAlloc>::iterator_base :
public IteratorTraits
682 typedef IteratorTraits traits;
684 using typename traits::iterator_category;
685 using typename traits::value_type;
686 using typename traits::difference_type;
687 using typename traits::pointer;
688 using typename traits::reference;
693 iterator_base() : iValue{
nullptr }
696 iterator_base(
const iterator_base& aOther) : iValue{ aOther.iValue }
700 iterator_base(value_pointer aValue) : iValue{ aValue }
715 iValue = value().next_sibling();
723 bool operator==(
const iterator_base& aOther)
const
725 return iValue == aOther.iValue;
727 bool operator!=(
const iterator_base& aOther)
const
729 return iValue != aOther.iValue;
732 value_reference value()
const
738 return iValue !=
nullptr && value().has_parent();
740 value_pointer
parent()
const
747 value_pointer iValue;
750 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
751 class basic_json_value<Syntax, Alloc, CharT, Traits, CharAlloc>::
iterator : iterator_base<typename json_detail::iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>>
753 typedef iterator_base<typename json_detail::iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>> base_type;
756 using typename base_type::iterator_category;
757 using typename base_type::value_type;
758 using typename base_type::difference_type;
759 using typename base_type::pointer;
760 using typename base_type::reference;
762 using typename base_type::value_pointer;
771 iterator(value_pointer aValue) : base_type{ aValue }
775 using base_type::operator*;
776 using base_type::operator->;
780 base_type::operator++();
785 auto previous = *
this;
786 base_type::operator++();
791 base_type::operator--();
796 auto previous = *
this;
797 base_type::operator--();
803 return base_type::operator==(aRhs);
807 return base_type::operator!=(aRhs);
810 using base_type::value;
813 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
814 class basic_json_value<Syntax, Alloc, CharT, Traits, CharAlloc>::
const_iterator : iterator_base<typename json_detail::const_iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>>
816 typedef iterator_base<typename json_detail::const_iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>> base_type;
819 using typename base_type::iterator_category;
820 using typename base_type::value_type;
821 using typename base_type::difference_type;
822 using typename base_type::pointer;
823 using typename base_type::reference;
825 using typename base_type::value_pointer;
841 using base_type::operator*;
842 using base_type::operator->;
846 base_type::operator++();
851 auto previous = *
this;
852 base_type::operator++();
857 base_type::operator--();
862 auto previous = *
this;
863 base_type::operator--();
869 return base_type::operator==(aRhs);
873 return base_type::operator!=(aRhs);
876 using base_type::value;
879 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
880 template <
typename IteratorTraits>
881 class basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::iterator_base :
public IteratorTraits
884 typedef IteratorTraits traits;
886 using typename traits::iterator_category;
887 using typename traits::value_type;
888 using typename traits::difference_type;
889 using typename traits::pointer;
890 using typename traits::reference;
895 iterator_base() : iValue{ nullptr }
898 iterator_base(
const iterator_base& aOther) : iValue{ aOther.iValue }
902 iterator_base(value_pointer aValue) : iValue{ aValue }
917 if (value().has_children())
918 iValue = value().first_child();
919 else if (!value().is_last_sibling())
920 iValue = value().next_sibling();
922 iValue = value().next_parent_sibling();
930 bool operator==(
const iterator_base& aOther)
const
932 return iValue == aOther.iValue;
934 bool operator!=(
const iterator_base& aOther)
const
936 return iValue != aOther.iValue;
939 value_reference value()
const
943 bool has_parent()
const
945 return iValue !=
nullptr && value().has_parent();
947 value_pointer parent()
const
950 return &value().parent();
954 value_pointer iValue;
957 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
958 class basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::
iterator :
public iterator_base<typename json_detail::iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>>
960 typedef iterator_base<typename json_detail::iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>> base_type;
961 friend class basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>;
963 using typename base_type::iterator_category;
964 using typename base_type::value_type;
965 using typename base_type::difference_type;
966 using typename base_type::pointer;
967 using typename base_type::reference;
969 using typename base_type::value_pointer;
978 iterator(value_pointer aValue) : base_type{ aValue }
982 using base_type::operator*;
983 using base_type::operator->;
987 base_type::operator++();
992 auto previous = *
this;
993 base_type::operator++();
998 base_type::operator--();
1003 auto previous = *
this;
1004 base_type::operator--();
1010 return base_type::operator==(aRhs);
1014 return base_type::operator!=(aRhs);
1017 using base_type::value;
1020 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1021 class basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::
const_iterator :
public iterator_base<typename json_detail::const_iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>>
1023 typedef iterator_base<typename json_detail::const_iterator_traits<Syntax, Alloc, CharT, Traits, CharAlloc>> base_type;
1024 friend class basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>;
1026 using typename base_type::iterator_category;
1027 using typename base_type::value_type;
1028 using typename base_type::difference_type;
1029 using typename base_type::pointer;
1030 using typename base_type::reference;
1032 using typename base_type::value_pointer;
1048 using base_type::operator*;
1049 using base_type::operator->;
1053 base_type::operator++();
1058 auto previous = *
this;
1059 base_type::operator++();
1064 base_type::operator--();
1069 auto previous = *
this;
1070 base_type::operator--();
1076 return base_type::operator==(aRhs);
1080 return base_type::operator!=(aRhs);
1083 using base_type::value;
1086 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1091 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1094 if (!
read(aPath, aValidateUtf))
1098 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1099 template <
typename Elem,
typename ElemTraits>
1102 if (!
read(aInput, aValidateUtf))
1106 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1109 iCursor =
decltype(iCursor){};
1111 iUtf16HighSurrogate = std::nullopt;
1114 template <json_syntax Syntax>
1125 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1128 std::ifstream input{ aPath, std::ios::binary };
1131 iErrorText =
"failed to open " + std::string{ document_type<Syntax>() } +
" file '" + aPath +
"'";
1134 bool ok = do_read(input, aValidateUtf);
1138 iErrorText =
"failed to parse " + std::string{ document_type<Syntax>() } +
" file '" + aPath +
"', " + iErrorText;
1142 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1143 template <
typename Elem,
typename ElemTraits>
1148 iErrorText =
"failed to read " + std::string{ document_type<Syntax>() } +
" text";
1151 bool ok = do_read(aInput, aValidateUtf);
1155 iErrorText =
"failed to parse " + std::string{ document_type<Syntax>() } +
" text, " + iErrorText;
1159 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1160 template <
typename Elem,
typename ElemTraits>
1167 iErrorText =
"input stream bad";
1171 typedef typename std::basic_istream<CharT, Traits>::pos_type pos_type;
1173 aInput.seekg(0, std::ios::end);
1176 count = aInput.tellg();
1177 if (count ==
static_cast<pos_type
>(-1))
1179 aInput.seekg(0, std::ios::beg);
1184 if (count !=
typename std::basic_istream<CharT>::pos_type(0))
1188 aInput.read(&document()[0], count);
1194 while (aInput.read(buffer,
sizeof(buffer)))
1200 if (document().empty())
1202 iErrorText =
"empty document";
1207 document().push_back(character_type{
'\n' });
1208 document().push_back(character_type{
'\0' });
1212 iErrorText =
"invalid utf-8";
1219 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1220 inline bool basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::do_parse()
1227 element currentElement = {};
1232 auto nextInputCh = &*document().begin();
1233 auto nextOutputCh = nextInputCh;
1235 auto increment_cursor = [&nextInputCh,
this]()
1237 if (*nextInputCh++ !=
'\n')
1251 if (*nextInputCh !=
'\n')
1252 std::cout << *nextInputCh;
1258 if constexpr (!usePreviousState)
1259 nextState = json_detail::next_state<syntax>(currentState, *nextInputCh);
1262 bool skippingComment =
false;
1263 auto tempState = currentState;
1265 nextState = json_detail::next_state<syntax>(tempState, previousState, *nextInputCh, nextInputCh != &iDocumentText.back() ? *(nextInputCh + 1) :
'\0');
1267 if (skippingComment)
1269 if (tempState != nextState && currentElement.start !=
nullptr && nextOutputCh == currentElement.start)
1271 tempState = nextState;
1276 }
while (skippingComment);
1282 switch (currentState)
1287 switch (
to_token(json_detail::sTokenTable<json_syntax::Functional>, *nextInputCh))
1294 currentElement.type = element::Keyword;
1295 nextOutputCh = nextInputCh;
1311 create_parse_error();
1314 if (nextInputCh != &iDocumentText.back())
1316 create_parse_error();
1321 if (currentState == nextState)
1323 switch (currentState)
1328 if (currentElement.start != nextOutputCh)
1329 *nextOutputCh++ = *nextInputCh;
1341 std::cout <<
"(" <<
to_string(currentState) <<
" -> " <<
to_string(nextState) <<
")";
1346 switch (currentElement.type)
1348 case element::Unknown:
1350 case element::String:
1352 json_string newString{ currentElement.start, currentElement.start == nextOutputCh ? nextInputCh - 1 : nextOutputCh };
1353 buy_value(currentElement, newString);
1357 if (context() ==
json_type::Object && std::holds_alternative<std::monostate>(currentElement.name))
1359 json_string newString{ currentElement.start, currentElement.start == nextOutputCh ? nextInputCh - 1 : nextOutputCh };
1360 currentElement.name = newString;
1363 case element::Number:
1365 json_string newNumber{ currentElement.start, currentElement.start == nextOutputCh ? nextInputCh : nextOutputCh };
1368 std::visit([
this, ¤tElement](
auto&& arg)
1370 buy_value(currentElement, std::forward<
decltype(arg)>(arg));
1377 case element::Keyword:
1379 static const std::unordered_map<std::string_view, json_detail::keyword, json_detail::hash_first_character> sJsonKeywords =
1385 auto keywordText =
json_string{ currentElement.start, currentElement.start == nextOutputCh ? nextInputCh : nextOutputCh };
1386 auto keyword = sJsonKeywords.find(keywordText);
1387 if (keyword != sJsonKeywords.end())
1389 if (context() ==
json_type::Object && std::holds_alternative<std::monostate>(currentElement.name))
1391 create_parse_error(
"bad object field name");
1397 buy_value(currentElement,
json_bool{
true });
1400 buy_value(currentElement,
json_bool{
false });
1411 create_parse_error(
"keywords unavailable");
1414 if (context() ==
json_type::Object && std::holds_alternative<std::monostate>(currentElement.name))
1417 currentElement.type = element::Name;
1420 buy_value(currentElement,
json_keyword{ keywordText });
1428 iCompositeValueStack.pop_back();
1434 if (std::holds_alternative<std::monostate>(currentElement.name))
1438 else if (*nextInputCh ==
',')
1448 if (std::holds_alternative<std::monostate>(currentElement.name))
1457 if (*nextInputCh ==
',')
1470 currentElement.type = element::Unknown;
1471 currentElement.start =
nullptr;
1474 currentElement.type = element::String;
1475 currentElement.start = (nextOutputCh = nextInputCh + 1);
1478 currentElement.type = element::Name;
1479 currentElement.start = (nextOutputCh = nextInputCh + 1);
1482 if (std::holds_alternative<std::monostate>(currentElement.name))
1486 currentElement.start,
1487 currentElement.start == nextOutputCh ? nextInputCh : nextOutputCh
1489 currentElement.name = newName;
1493 currentElement.type = element::Number;
1494 currentElement.start = nextInputCh;
1497 if (currentElement.type != element::Number)
1499 currentElement.type = element::Number;
1500 currentElement.start = nextInputCh;
1506 iCompositeValueStack.
push_back(newArray);
1513 iCompositeValueStack.
push_back(newObject);
1517 currentElement.type = element::Keyword;
1518 currentElement.start = (nextOutputCh = nextInputCh);
1524 if (*nextInputCh != *(currentElement.start - 1))
1529 if (nextOutputCh == currentElement.start)
1533 switch (*(nextInputCh))
1536 (*nextOutputCh++) =
'\"';
1539 (*nextOutputCh++) =
'\\';
1542 (*nextOutputCh++) =
'/';
1545 (*nextOutputCh++) =
'\b';
1548 (*nextOutputCh++) =
'\f';
1551 (*nextOutputCh++) =
'\n';
1554 (*nextOutputCh++) =
'\r';
1557 (*nextOutputCh++) =
'\t';
1567 if (currentElement.auxType != element::EscapedUnicode)
1569 currentElement.auxType = element::EscapedUnicode;
1570 currentElement.auxStart = nextInputCh;
1572 if (nextInputCh + 1 - currentElement.auxStart == 4)
1574 string_type s{ currentElement.auxStart, nextInputCh + 1 };
1575 char16_t u16ch =
static_cast<char16_t>(std::stoul(s,
nullptr, 16));
1578 iUtf16HighSurrogate = u16ch;
1579 currentElement.auxType = element::Unknown;
1580 currentElement.type = element::String;
1590 char16_t surrogatePair[] = { *iUtf16HighSurrogate, u16ch };
1591 auto utf8 =
utf16_to_utf8(std::u16string(&surrogatePair[0], 2));
1592 nextOutputCh = std::copy(utf8.begin(), utf8.end(), nextOutputCh);
1597 (*nextOutputCh++) =
static_cast<character_type
>(*iUtf16HighSurrogate);
1598 (*nextOutputCh++) =
static_cast<character_type
>(u16ch);
1603 char16_t surrogatePair[] = { *iUtf16HighSurrogate, u16ch };
1610 iUtf16HighSurrogate = std::nullopt;
1619 nextOutputCh = std::copy(utf8.begin(), utf8.end(), nextOutputCh);
1624 *(nextOutputCh++) =
static_cast<character_type
>(u16ch);
1628 *(nextOutputCh++) =
static_cast<character_type
>(u16ch);
1634 currentElement.auxType = element::Unknown;
1646 if (currentState != nextState)
1649 std::cout <<
"(" <<
to_string(nextState) <<
")";
1650 currentState = nextState;
1653 catch (std::exception& e)
1655 create_parse_error(e.what());
1664 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1667 std::ofstream output{ aPath, std::ofstream::out | std::ofstream::trunc };
1668 return write(output, aIndent);
1671 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1672 template <
typename Elem,
typename ElemTraits>
1675 static const string_type trueString =
"true";
1676 static const string_type falseString =
"false";
1677 static const string_type nullString =
"null";
1680 auto indent = [&aOutput, &aIndent, &level]()
1682 for (int32_t l = 0; l < level; ++l)
1685 for (
auto i = cbegin(); i != end; ++i)
1687 auto const& v = **i;
1689 if (i.value().has_name())
1691 if (!i.value().name_is_keyword())
1692 aOutput <<
'\"' << i.value().name() <<
"\": ";
1694 aOutput << i.value().name() <<
": ";
1696 switch (i.value().type())
1700 if (i.value().is_populated_composite())
1703 aOutput << std::endl;
1710 if (i.value().is_populated_composite())
1713 aOutput << std::endl;
1719 aOutput << std::get<json_double>(v);
1722 aOutput << std::get<json_int64>(v);
1725 aOutput << std::get<json_uint64>(v);
1728 aOutput << std::get<json_int>(v);
1731 aOutput << std::get<json_uint>(v);
1735 for (
auto const& ch : std::get<json_string>(v))
1760 if (
static_cast<uint32_t
>(ch) >= 32u)
1763 aOutput <<
"\\u" << std::hex << std::setw(4) << std::setfill(
'0') << (int)ch;
1768 aOutput << (std::get<json_bool>(v) ? trueString : falseString);
1771 aOutput << nullString;
1774 aOutput << std::get<json_keyword>(v).text;
1780 if (!i.value().is_composite() || i.value().is_empty_composite())
1782 auto next = &i.value();
1783 bool needNewline =
false;
1784 while (next->is_last_sibling() && next->has_parent())
1787 auto nextParent = &next->parent();
1790 aOutput << std::endl;
1797 aOutput << std::endl;
1802 if (!nextParent->is_last_sibling())
1809 if (needNewline && level > 0)
1810 aOutput << std::endl;
1812 if (!i.value().is_last_sibling() && (!i.value().is_composite() || i.value().is_empty_composite()))
1813 aOutput <<
',' << std::endl;
1818 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1824 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1827 return iDocumentText;
1830 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1836 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1839 return iRoot != std::nullopt;
1842 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1845 if (iRoot == std::nullopt)
1850 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1856 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1862 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1865 auto bitStart = aPath.
begin();
1866 auto bitEnd = std::find(bitStart, aPath.
end(),
'.');
1868 if (bitEnd == bitStart)
1872 auto existing = std::find_if(node->
begin(), node->
end(), [&](
auto&& child) { return child.name() == std::string_view{ &*bitStart, static_cast<std::string_view::size_type>(std::distance(bitStart, bitEnd)) }; });
1873 if (existing == node->
end())
1876 bitStart = (bitEnd != aPath.
end() ?
std::next(bitEnd) : bitEnd);
1877 bitEnd = std::find(bitStart, aPath.
end(),
'.');
1878 }
while (bitStart != aPath.end());
1882 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1888 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1889 template <
typename Visitor>
1893 root().
visit(std::forward<Visitor>(aVisitor));
1896 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1897 template <
typename Visitor>
1901 root().
visit(std::forward<Visitor>(aVisitor));
1904 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1910 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1916 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1919 if (iRoot != std::nullopt)
1924 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1930 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1933 if (iRoot != std::nullopt)
1938 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1944 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1948 if (!aExtraInfo.empty())
1954 text +=
"line " + boost::lexical_cast<string_type>(aDocumentSourceLocation.
line) +
", col " + boost::lexical_cast<string_type>(aDocumentSourceLocation.
column);
1958 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1964 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1967 return to_error_text(iCursor, aExtraInfo);
1970 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1971 inline typename basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::json_string& basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::document()
1973 return iDocumentText;
1976 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1977 inline json_type basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::context()
const
1979 if (!iCompositeValueStack.empty())
1980 return iCompositeValueStack.back()->type();
1981 return json_type::Unknown;
1984 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
1985 template <
typename T>
1986 inline typename basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::json_value* basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::buy_value(element& aCurrentElement, T&& aValue)
1990 case json_type::Array:
1992 auto newObject = iCompositeValueStack.back()->buy_child(std::forward<T>(aValue));
1993 newObject->set_document_source_location(iCursor);
1994 if constexpr(std::is_same_v<typename std::remove_cv<typename std::remove_reference<T>::type>::type,
json_array>)
1995 newObject->template as<json_array>().set_contents(*newObject);
1996 else if constexpr(std::is_same_v<typename std::remove_cv<typename std::remove_reference<T>::type>::type,
json_object>)
1997 newObject->template as<json_object>().set_contents(*newObject);
2000 case json_type::Object:
2002 auto newObject = iCompositeValueStack.back()->buy_child(std::forward<T>(aValue));
2003 newObject->set_document_source_location(iCursor);
2004 if constexpr(std::is_same_v<typename std::remove_cv<typename std::remove_reference<T>::type>::type,
json_array>)
2005 newObject->template as<json_array>().set_contents(*newObject);
2006 else if constexpr(std::is_same_v<typename std::remove_cv<typename std::remove_reference<T>::type>::type,
json_object>)
2007 newObject->template as<json_object>().set_contents(*newObject);
2008 if (std::holds_alternative<json_string>(aCurrentElement.name))
2009 newObject->set_name(std::get<json_string>(aCurrentElement.name));
2011 newObject->set_name(std::get<json_keyword>(aCurrentElement.name));
2012 aCurrentElement.name = std::monostate{};
2016 root() = std::forward<T>(aValue);
2017 root().set_document_source_location(iCursor);
2022 template <json_syntax Syntax,
typename Alloc,
typename CharT,
typename Traits,
typename CharAlloc>
2023 inline void basic_json<Syntax, Alloc, CharT, Traits, CharAlloc>::create_parse_error(
const string_type& aExtraInfo)
const
2025 iErrorText = to_error_text(aExtraInfo);
bool operator!=(const const_iterator &aRhs) const
const_iterator operator++(int)
const_iterator operator--(int)
const_iterator & operator++()
bool operator==(const const_iterator &aRhs) const
const_iterator & operator--()
const_iterator(const iterator &aOther)
const_iterator(const const_iterator &aOther)
bool operator!=(const iterator &aRhs) const
bool operator==(const iterator &aRhs) const
iterator(const iterator &aOther)
const_iterator operator++(int)
const_iterator(const iterator &aOther)
const_iterator operator--(int)
const_iterator & operator--()
const_iterator & operator++()
bool operator!=(const const_iterator &aRhs) const
bool operator==(const const_iterator &aRhs) const
const_iterator(const const_iterator &aOther)
iterator(const iterator &aOther)
bool operator!=(const iterator &aRhs) const
bool operator==(const iterator &aRhs) const
const_reference parent() const
const_iterator begin() const
const_iterator end() const
void push_back(T &&aValue)
const json_document_source_location & document_source_location() const
const value_type & operator*() const
bool write(const std::string &aPath, const string_type &aIndent=string_type(2, character_type{' '}))
void visit(Visitor &&aVisitor) const
json_encoding encoding() const
const json_string & document() const
bool read(const std::string &aPath, bool aValidateUtf=false)
const json_value & root() const
const json_value & croot() const
const json_value & at(const json_string &aPath) const
const string_type & error_text() const
string_type::size_type size_type
string_type to_std_string() const
bool operator!=(color_or_gradient const &lhs, color const &rhs) noexcept
std::string to_string(note const &aNote)
bool operator==(const basic_rect< CoordinateType, CoordinateSystem > &left, const basic_rect< CoordinateType, CoordinateSystem > &right)
constexpr std::size_t STATE_COUNT
constexpr std::array< state, TOKEN_COUNT > need_value_state()
constexpr std::array< std::array< state, TOKEN_COUNT >, STATE_COUNT > sStateTables
constexpr std::array< state, TOKEN_COUNT > value_state()
@ NeedObjectValueSeparator
constexpr std::size_t TOKEN_COUNT
state next_state(state aCurrentState, CharT aCharacter)
constexpr std::array< state, TOKEN_COUNT > keyword_state()
constexpr std::array< state, TOKEN_COUNT > object_state()
constexpr std::array< state, TOKEN_COUNT > need_object_value_state()
token to_token(const std::array< token, 256 > &aTokenTable, CharT aCharacter)
constexpr std::array< token, 256 > sTokenTable
basic_vector< T, D, Type > operator*(const basic_vector< T, D, Type > &left, const T &right)
bool is_low_surrogate(unicode_char_t aCharacter)
bool is_high_surrogate(unicode_char_t aCharacter)
json::json_array json_array
bool check_utf8(const std::basic_string_view< CharT, Traits > &aString)
constexpr const char * document_type()
json::json_string json_string
number_t string_to_number(const std::basic_string_view< CharT, Traits > &aStringView)
json::json_bool json_bool
std::string utf16_to_utf8(const std::u16string &aString, CharacterMapUpdater aCharacterMapUpdater)
json::json_null json_null
json::json_object json_object
std::u32string utf8_to_utf32(std::string_view const &aStringView, Callback aCallback, bool aCodePageFallback=false)
to_const_reference_t< T > to_const(T &&object)
json::json_value json_value
json::json_keyword json_keyword
double string_to_double(const std::basic_string_view< CharT, Traits > &aStringView)
it_type next(it_type it, const typename iterator_traits< it_type >::difference_type distance=1)
constexpr decltype(auto) visit(Visitor &&vis, neolib::variant< Types... > &&var)
std::ptrdiff_t difference_type
const value_type * pointer
std::bidirectional_iterator_tag iterator_category
neolib::basic_json< Syntax, Alloc, CharT, Traits, CharAlloc > document_type
const value_type & reference
neolib::basic_json_value< Syntax, Alloc, CharT, Traits, CharAlloc > value_type
std::size_t operator()(const String &aString) const noexcept
neolib::basic_json< Syntax, Alloc, CharT, Traits, CharAlloc > document_type
std::bidirectional_iterator_tag iterator_category
std::ptrdiff_t difference_type
neolib::basic_json_value< Syntax, Alloc, CharT, Traits, CharAlloc > value_type