13 #pragma managed( push, off ) 45 : m_pcJsonRoot( pcJson )
46 , m_pcJsonCurrent( m_pcJsonRoot )
65 if (
nullptr == pcJson ) {
70 else if ( pcJson != pcJson->GetJsonRoot() ) {
96 if (
nullptr == pcJson ) {
168 int nPoint = rcStream.GetStreamPoint();
196 rcStream.SetStreamPoint( nPoint );
218 else if ( !rcStreamOut.OutputNewLine() ) {
279 if (
nullptr == pcJson ) {
356 if ( !
CreateJsonPath( pszPath, pcJson ) || (
nullptr == pcJson ) ) {
395 if (
nullptr == pcJson ) {
402 CJson* pcParent =
nullptr;
403 for ( ;
nullptr != pcJson; pcJson = pcParent ) {
406 if (
nullptr != pcParent ) {
411 if (
nullptr == pcJsonString ) {
417 wchar_t const* pszString = *pcJsonString;
418 if (
nullptr == pszString ) {
424 size_t len = ::wcslen( pszString );
425 if ( ( 0 == len ) || (
nullptr != ::wcschr( pszString, L
' ' ) ) ) {
427 if ( !rcPath.Insert( 0,
CString().Format( L
"\"%s\"", pszString ) ) ) {
433 else if ( !rcPath.Insert( 0, pszString ) ) {
439 rcPath.Insert( 0, L
'/' );
445 if (
nullptr == pcJsonArray ) {
451 int nCount = pcJsonArray->
GetCount();
453 for ( ;; ++nIndex ) {
455 if ( nCount <= nIndex ) {
461 else if ( pcJson == ( *pcJsonArray )[ nIndex ] ) {
473 else if ( !rcPath.Insert( 0,
CString().Format( L
"[%d]", nIndex ) ) ) {
481 if ( pcJson->IsJsonObject() ) {
483 if ( !rcPath.Insert( 0, L
'/' ) ) {
492 if (
nullptr == pcParent ) {
495 if ( 0 < rcPath.GetCount() ) {
503 rcPath.Insert( 0, L
'/' );
521 CJson* result =
nullptr;
524 if (
nullptr == pszPath ) {
529 else if (
nullptr == pcJson ) {
539 for (
int nToken = 0;
nullptr != pcJson; ) {
561 else if ( 1 == nToken ) {
563 pcJson = pcJson->GetJsonRoot();
578 pcJson = pcJson->GetJsonParent();
584 if (
nullptr == pcJsonPair ) {
587 if (
nullptr == pcJsonObject ) {
594 if (
nullptr == pcJsonPair ) {
607 if (
nullptr == pcJsonArray ) {
613 int nIndex =
static_cast< int >( ::wcstol( cToken,
nullptr, 10 ) );
636 if (
nullptr == pcJson ) {
642 if ( pcJson->IsJsonToken() ) {
645 if (
nullptr == pcJsonToken ) {
651 wchar_t const* pszString = *pcJsonToken;
652 if (
nullptr == pszString ) {
658 if ( bQuotes && pcJson->IsJsonString() ) {
660 if ( !rcValue.Push(
CString().Format( L
"\"%s\"", pszString ) ) ) {
666 else if ( !rcValue.Push( pszString ) ) {
672 else if ( pcJson->IsJsonContainer() ) {
675 if (
nullptr == pcJsonContainer ) {
680 else if ( 0 == pcJsonContainer->
GetCount() ) {
682 if ( pcJson->IsJsonObject() ) {
684 if ( !rcValue.Push( L
"{}" ) ) {
689 else if ( pcJson->IsJsonArray() ) {
691 if ( !rcValue.Push( L
"[]" ) ) {
702 else if ( pcJson->IsJsonObject() ) {
704 if ( !rcValue.Push( L
"{...}" ) ) {
709 else if ( pcJson->IsJsonArray() ) {
711 if ( !rcValue.Push( L
"[...]" ) ) {
722 else if ( pcJson->IsJsonPair() ) {
729 else if ( !rcValue.Push( L
": " ) ) {
734 else if ( !
GetJsonSetValue( rcValue, pcJson->GetJsonValue(), false ) ) {
747 wchar_t const* pszString = L
"";
748 switch ( pcJson->GetJsonClass() ) {
758 rcValue += pszString;
784 CJson* pcParent =
nullptr;
785 if (
nullptr != rpcJson ) {
791 CJson* pcParentFirst = pcParent;
794 CJson* pcJsonNew =
nullptr;
795 if (
nullptr == pcParent ) {
798 if (
nullptr == pcJsonNew ) {
801 if (
nullptr == pcJsonNew ) {
811 if (
nullptr == pcJsonNew ) {
820 if (
nullptr == pcJsonNew ) {
829 if (
nullptr == pcJsonNew ) {
842 if (
nullptr == pcParent ) {
850 if (
nullptr == pcJsonContainer ) {
856 int nIndex = pcJsonContainer->
Find( rpcJson );
864 if (
nullptr != pcJsonElement ) {
866 delete pcJsonElement;
889 if (
nullptr == pcJsonPair ) {
930 if (
nullptr == rpcJson ) {
937 if (
nullptr != pcParent ) {
942 if (
nullptr == pcJsonContainer ) {
948 int nIndex = pcJsonContainer->
Find( rpcJson );
954 else if ( !pcJsonContainer->
Remove( nIndex ) ) {
963 int nCount = pcJsonContainer->
GetCount();
970 if ( nCount <= nIndex ) {
972 nIndex = ( nCount - 1 );
976 rpcJson = ( *pcJsonContainer )[ nIndex ];
1015 bool result =
false;
1018 if (
nullptr == pszPath ) {
1038 CJson* pcParent =
nullptr;
1039 if (
nullptr != rpcJson ) {
1058 else if ( 1 == nToken ) {
1060 if (
nullptr != rpcJson ) {
1062 rpcJson = rpcJson->GetJsonRoot();
1078 if (
nullptr == pcParent ) {
1086 if (
nullptr != pcParentParent ) {
1088 pcParent = pcParentParent;
1100 if (
nullptr == rpcJson ) {
1103 if (
nullptr == pcJsonObject ) {
1109 else if ( rpcJson->IsJsonObject() ) {
1112 if (
nullptr == pcJsonObject ) {
1118 else if (
nullptr == pcParent ) {
1121 if (
nullptr == pcJsonObject ) {
1126 else if ( rpcJson->IsJsonPair() ) {
1129 if (
nullptr == pcJsonPair ) {
1134 else if ( !pcJsonObject->
Push( pcJsonPair ) ) {
1147 if (
nullptr == pcJsonObject ) {
1156 if (
nullptr == pcParentArray ) {
1162 int nIndex = pcParentArray->
Find( rpcJson );
1170 if (
nullptr == pcJsonObject ) {
1176 delete ( *pcParentArray )[ nIndex ];
1179 ( *pcParentArray )[ nIndex ] = pcJsonObject;
1185 if (
nullptr == pcParentPair ) {
1192 if (
nullptr == pcJsonObject ) {
1207 if (
nullptr == pcJsonPair ) {
1209 pcJsonPair =
new CJsonPair( pcJsonObject, cToken );
1210 if (
nullptr == pcJsonPair ) {
1215 else if ( !pcJsonObject->
Push( pcJsonPair ) ) {
1228 if (
nullptr == rpcJson ) {
1231 if (
nullptr == pcJsonArray ) {
1237 else if ( rpcJson->IsJsonArray() ) {
1240 if (
nullptr == pcJsonArray ) {
1246 else if (
nullptr == pcParent ) {
1248 if ( rpcJson->IsJsonArray() ) {
1251 if (
nullptr == pcJsonArray ) {
1259 if (
nullptr == pcJsonArray ) {
1269 if (
nullptr == pcParentArray ) {
1275 int nIndex = pcParentArray->
Find( rpcJson );
1282 pcJsonArray =
new CJsonArray( pcParentArray );
1283 if (
nullptr == pcJsonArray ) {
1289 delete ( *pcParentArray )[ nIndex ];
1292 ( *pcParentArray )[ nIndex ] = pcJsonArray;
1298 if (
nullptr == pcParentPair ) {
1304 pcJsonArray =
new CJsonArray( pcParentPair );
1305 if (
nullptr == pcJsonArray ) {
1319 int nIndex =
static_cast< int >( ::wcstol( cToken,
nullptr, 10 ) );
1320 if ( pcJsonArray->
GetCount() <= nIndex ) {
1329 rpcJson = ( *pcJsonArray )[ nIndex ];
1354 bool result =
false;
1357 if (
nullptr == pcJson ) {
1362 else if ( pcJson->IsJsonContainer() ) {
1365 if (
nullptr == pcJsonContainer ) {
1371 int nCount = pcJsonContainer->
GetCount();
1372 if ( 0 == nCount ) {
1380 else if ( !rcPathList.Push( cPath ) ) {
1392 else if ( !rcPathList.Push(
CString().Format( L
" = %s\n", cValue.
GetBuffer() ) ) ) {
1400 for ( ; nCount > nIndex; ++nIndex ) {
1402 CJson* pcJsonElement = ( *pcJsonContainer )[ nIndex ];
1420 else if ( pcJson->IsJsonToken() ) {
1428 else if ( !rcPathList.Push( cPath ) ) {
1440 else if ( !rcPathList.Push(
CString().Format( L
" = %s\n", cValue.
GetBuffer() ) ) ) {
1446 else if ( pcJson->IsJsonPair() ) {
1475 int nPoint = rcStream.GetStreamPoint();
1479 if ( !rcStream.InputChar( ch ) ) {
1484 else if ( L
'/' == ch ) {
1486 rcString.Push( ch );
1490 else if ( L
'.' == ch ) {
1492 rcString.Push( ch );
1496 nPoint = rcStream.GetStreamPoint();
1499 if ( rcStream.InputChar( ch ) ) {
1503 rcString.Push( ch );
1508 rcStream.SetStreamPoint( nPoint );
1513 else if ( L
'[' == ch ) {
1515 rcStream.SkipSpace();
1525 rcStream.SkipSpace();
1528 if ( !rcStream.SkipChar( L
']' ) ) {
1534 rcString.Push( cJsonToken );
1538 else if ( bEqual && ( L
'=' == ch ) ) {
1540 rcStream.SkipSpace();
1543 rcString.Push( L
'=' );
1547 else if ( bEqual && ( 0 != ::iswspace( ch ) ) ) {
1549 rcStream.SkipSpace();
1552 if ( !rcStream.SkipChar( L
'=' ) ) {
1558 rcStream.SkipSpace();
1561 rcString.Push( L
'=' );
1567 if ( L
'\"' == ch ) {
1574 else if ( !rcStream.SkipChar( L
'\"' ) ) {
1581 rcStream.SetStreamPoint( nPoint );
1591 rcString.Push( cJsonToken );
1604 bool result =
false;
1607 int nLen = rcString.GetCount();
1613 else if ( L
'\"' != rcString[ 0 ] ) {
1618 else if ( L
'\"' != rcString[ nLen - 1 ] ) {
1623 else if ( rcString.Remove( ( nLen - 1 ) ) ) {
1628 else if ( rcString.Remove( 0 ) ) {
1642 #pragma managed( pop )
virtual bool OutputJson(CStreamOut &rcStreamOut) noexcept
JSONクラス出力関数
virtual bool GetCurrentSetValue(CString &rcValue, bool bClassName=false, bool bQuotes=true) noexcept
カレント設定値文字列取得関数
virtual ~CJsonDocument() noexcept
デストラクタ
virtual CJsonValue * GetJsonValue() noexcept
static bool SetJsonSetValue(wchar_t const *pszValue, CJson *&rpcJson) noexcept
JSON設定値設定関数
virtual CJsonContainer * GetJsonContainer() noexcept
virtual CJsonContainer * GetJsonContainer() noexcept override
JSONクラスインスタンス取得関数
virtual CJsonPair * GetJsonPair() noexcept override
JSONクラスインスタンス取得関数
CJsonDocument(CJson *pcJson=nullptr) noexcept
コンストラクタ
virtual CJsonObject * GetJsonObject() noexcept override
JSONクラスインスタンス取得関数
virtual CJson * GetJsonParent() noexcept
親JSONクラス取得関数
virtual bool Remove() noexcept
削除関数
virtual bool DeleteCurrentJson() noexcept
カレントJSONクラス削除関数
virtual bool GetCurrentPath(CString &rcPath) noexcept
カレントパス取得関数
virtual bool SetRootJson(CJson *pcJson) noexcept
ルートJSONクラス設定関数
virtual bool IsStreamEnd() const noexcept
ストリーム終端状態取得関数
virtual CJson * GetJsonRoot() noexcept
ルートJSONクラス取得関数
virtual bool CreatePath(wchar_t const *pszPath) noexcept
JSONパス作成関数
static bool GetJsonSetValue(CString &rcValue, CJson *pcJson, bool bClassName=false, bool bQuotes=true) noexcept
JSON設定値文字列取得関数
virtual bool SetJsonElement(int nIndex, CJson *pcJson) noexcept
JSONエレメント設定関数
static EJsonPathToken InputPathToken(CStream &rcStream, CString &rcString, bool bEqual=false) noexcept
JSONパストークン入力関数
virtual bool Push(Type const &rElement) noexcept
プッシュ関数
virtual bool ExtendJsonElementCount(int nCount) noexcept
JSONエレメント数拡張関数
virtual CJsonPair * GetJsonPair(wchar_t const *pszName) noexcept
JSONペア取得関数
virtual CJsonArray * GetJsonArray() noexcept override
JSONクラスインスタンス取得関数
virtual CJsonValue * GetJsonValue() noexcept override
static bool DeleteQuotes(CString &rcString) noexcept
JSON文字列二重引用符削除関数
virtual bool InputJsonChars(CStream &rcStream, wchar_t const *pszNgChars=nullptr) noexcept
JSON文字集合入力関数
virtual int Find(Type const &rElement) const noexcept
検索関数
virtual bool CompactDocument() noexcept
コンパクト化関数
virtual void SetJsonParent(CJson *pcParent) noexcept
親JSONクラス設定関数
static bool GetJsonPathList(CString &rcPathList, CJson *pcJson) noexcept
JSONパスリスト取得関数
static bool GetJsonPath(CString &rcPath, CJson *pcJson) noexcept
JSONパス取得関数
static CJson * FindJsonPath(wchar_t const *pszPath, CJson *pcJson) noexcept
JSONパス検索関数
virtual bool SetJsonValue(CJsonValue *pcJsonValue) noexcept
JSONバリュー設定関数
virtual CJsonString * GetJsonString() noexcept
virtual void ClearDocument() noexcept
クリア関数
virtual bool IsJsonObject() noexcept
JSONクラス種別判定関数
virtual bool CompactJson() noexcept
JSONクラスコンパクト化関数
virtual bool IsJsonPair() noexcept
virtual CJsonArray * GetJsonArray() noexcept
virtual bool OutputDocument(CStreamOut &rcStreamOut) noexcept
JSONドキュメント出力関数
virtual bool SetCurrentSetValue(wchar_t const *pszValue) noexcept
カレント設定値文字列設定関数
virtual bool IsJsonContainer() noexcept
virtual bool InputJsonInt(CStream &rcStream) noexcept
JSON整数部入力関数
static bool SetJsonSetValueByStream(CStream &rcStream, CJson *&rpcJson) noexcept
JSON設定値ストリーム設定関数
static CJsonValue * CreateInputJson(CStream &rcStream, CJson *pcParent) noexcept
JSONバリュー入力作成関数
virtual CJsonPair * GetJsonPair() noexcept
virtual bool SetCurrentPath(wchar_t const *pszPath) noexcept
カレントパス設定関数
static bool CreateJsonPath(wchar_t const *pszPath, CJson *&rpcJson) noexcept
JSONパス作成関数
EJsonPathToken
JSONパストークン種別列挙体
virtual bool InputDocument(CStream &rcStream) noexcept
JSONドキュメント入力関数
virtual bool IsJsonArray() noexcept
virtual CJsonToken * GetJsonToken() noexcept override
JSONクラスインスタンス取得関数
CJson * m_pcJsonRoot
ルートJSONクラスポインタ
CJson * m_pcJsonCurrent
カレントJSONクラスポインタ
virtual CJson * GetJsonElement(int nIndex) noexcept
JSONエレメント取得関数
virtual wchar_t const * GetBuffer() const noexcept
文字列バッファ取得関数
virtual CJsonObject * GetJsonObject() noexcept
JSONクラスインスタンス取得関数
static CJsonPair * CreateInputJson(CStream &rcStream, CJson *pcParent) noexcept
JSONペア入力作成関数
static bool DeleteJson(CJson *&rpcJson) noexcept
JSONクラス削除関数
virtual bool SetCurrentJson(CJson *pcJson) noexcept
カレントJSONクラス設定関数
virtual int GetCount() const noexcept
配列要素数取得関数