Solution46
CJsonFixed.cpp
[詳解]
1 //=============================================================================
2 /// @file
3 /// JSON固定値クラス実装ファイル
4 ///
5 /// JSON固定値クラス実装ファイルです。
6 ///
7 /// $Id: CJsonFixed.cpp 245 2019-03-20 15:03:41Z admin $
8 /// $Date: 2019-03-21 00:03:41 +0900 (2019/03/21 (木)) $
9 /// $Author: admin $
10 ///
11 /// @attention なし
12 
13 #pragma managed( push, off )
14 
15 //=============================================================================
16 // インクルードファイル
17 #include <CJsonFixed.h>
18 
19 //=============================================================================
20 // JSONライブラリ名前空間
21 namespace LibJson {
22  //=========================================================================
23  // JSON固定値クラス
24  //=========================================================================
25  // 構築子と解体子
26  //-------------------------------------------------------------------------
27  // コンストラクタ
28  CJsonFixed::CJsonFixed( CJson* pcParent, wchar_t const* pszString ) noexcept
29  // 基底クラスコンストラクタ
30  : CJsonToken( pcParent, pszString )
31  {}
32 
33  //=========================================================================
34  // 公開関数
35  //-------------------------------------------------------------------------
36  // JSONクラス入力関数
37  bool CJsonFixed::InputJson( CStream& rcStream ) noexcept {
38  // 処理ブロック
39  bool result = false;
40  do {
41  // クリアする
42  ClearJson();
43 
44  // ストリームポインタをプッシュする
45  if ( !PushStreamPoints( rcStream ) ) {
46  // 失敗!
47  break;
48  }
49  // 処理ブロック
50  else do {
51  // 空白をスキップする
52  rcStream.SkipSpace();
53 
54  // JSON固定文字列を入力する
55  if ( !InputJsonFixedString( rcStream, L"true" ) ) {
56  // JSON固定文字列を入力する
57  if ( !InputJsonFixedString( rcStream, L"false" ) ) {
58  // JSON固定文字列を入力する
59  if ( !InputJsonFixedString( rcStream, L"null" ) ) {
60  // 失敗!
61  break;
62  }
63  }
64  }
65 
66  // コンパクト化する
67  if ( !CString::CompactBuffer() ) {
68  // 失敗!
69  break;
70  }
71 
72  // 成功!
73  result = true;
74  } while ( false );
75 
76  // ストリームポインタをポップする
77  PopStreamPoints( rcStream, !result );
78  } while ( false );
79 
80  // 実行結果を返す
81  return result;
82  }
83 
84  //=========================================================================
85  // 静的公開関数
86  //-------------------------------------------------------------------------
87  // JSON固定値入力作成関数
88  CJsonFixed* CJsonFixed::CreateInputJson( CStream& rcStream, CJson* pcParent ) noexcept {
89  // 処理ブロック
90  CJsonFixed* result = nullptr;
91  do {
92  // JSON固定値を作成する
93  CJsonFixed* pcJsonFixed = new CJsonFixed( pcParent );
94  if ( nullptr == pcJsonFixed ) {
95  // 失敗!
96  break;
97  }
98  // JSON固定値を入力する
99  else if ( !pcJsonFixed->InputJson( rcStream ) ) {
100  // JSON固定値を削除する
101  delete pcJsonFixed;
102 
103  // 失敗!
104  break;
105  }
106 
107  // 成功!
108  result = pcJsonFixed;
109  } while ( false );
110 
111  // 実行結果を返す
112  return result;
113  }
114 }
115 
116 #pragma managed( pop )
JSONライブラリ名前空間
Definition: CJson.h:24
static CJsonFixed * CreateInputJson(CStream &rcStream, CJson *pcParent) noexcept
JSON固定値入力作成関数
Definition: CJsonFixed.cpp:88
ストリームクラス
Definition: CStream.h:31
JSONクラス
Definition: CJson.h:44
CJsonFixed(CJson *pcParent, wchar_t const *pszString=nullptr) noexcept
コンストラクタ
Definition: CJsonFixed.cpp:28
JSONトークンクラス
Definition: CJsonToken.h:32
virtual bool CompactBuffer() noexcept
バッファサイズコンパクト化関数
Definition: CString.cpp:348
JSON固定値クラス
Definition: CJsonFixed.h:30
JSON固定値クラスヘッダファイル
virtual bool InputJson(CStream &rcStream) noexcept override
JSONクラス入力関数
Definition: CJsonFixed.cpp:37