NEC mBaaS Embedded SDK  6.2.0
 全て クラス ネームスペース ファイル 関数 変数 列挙型 列挙型の値
nb_result.h
説明を見る。
1 /*
2  * COPYRIGHT (C) 2017 NEC CORPORATION
3  *
4  * ALL RIGHTS RESERVED BY NEC CORPORATION, THIS PROGRAM
5  * MUST BE USED SOLELY FOR THE PURPOSE FOR WHICH IT WAS
6  * FURNISHED BY NEC CORPORATION, NO PART OF THIS PROGRAM
7  * MAY BE REPRODUCED OR DISCLOSED TO OTHERS, IN ANY FORM
8  * WITHOUT THE PRIOR WRITTEN PERMISSION OF NEC CORPORATION.
9  *
10  * NEC CONFIDENTIAL AND PROPRIETARY
11  */
12 
13 #ifndef NECBAAS_NBRESULT_H
14 #define NECBAAS_NBRESULT_H
15 
16 #include <string>
17 #include "necbaas/nb_rest_error.h"
18 #include "necbaas/nb_result_code.h"
19 
20 namespace necbaas {
21 
31 template <typename T>
32 class NbResult {
33  public:
37  NbResult() {};
38 
43  explicit NbResult(NbResultCode result_code) : result_code_(result_code) {};
44 
48  ~NbResult() {};
49 
56  bool IsSuccess() const {
57  return (result_code_ == NbResultCode::NB_OK);
58  };
59 
66  bool IsRestError() const {
67  return (result_code_ == NbResultCode::NB_ERROR_RESPONSE);
68  };
69 
76  bool IsFatalError() const {
77  return (!IsSuccess() && !IsRestError());
78  };
79 
85  return result_code_;
86  };
87 
94  void SetResultCode(NbResultCode result_code) {
95  result_code_ = result_code;
96  };
97 
102  const T &GetSuccessData() const {
103  return success_data_;
104  };
105 
112  void SetSuccessData(const T &success_data) {
113  success_data_ = success_data;
114  };
115 
120  const NbRestError &GetRestError() const {
121  return rest_error_;
122  };
123 
130  void SetRestError(const NbRestError &rest_error) {
131  rest_error_ = rest_error;
132  };
133 
134  private:
135  NbResultCode result_code_{NbResultCode::NB_FATAL};
136  T success_data_;
137  NbRestError rest_error_;
138 };
139 } // namespace necbaas
140 #endif // NECBAAS_NBRESULT_H
RESTエラー構造体.
Definition: nb_rest_error.h:26
const NbRestError & GetRestError() const
RESTエラーデータ取得.
Definition: nb_result.h:120
bool IsRestError() const
RESTエラー判定.
Definition: nb_result.h:66
~NbResult()
デストラクタ.
Definition: nb_result.h:48
void SetSuccessData(const T &success_data)
[内部処理用]
Definition: nb_result.h:112
const T & GetSuccessData() const
処理成功データ取得.
Definition: nb_result.h:102
NbResultCode GetResultCode() const
処理結果コード取得.
Definition: nb_result.h:84
bool IsFatalError() const
処理結果エラー判定.
Definition: nb_result.h:76
void SetResultCode(NbResultCode result_code)
[内部処理用]
Definition: nb_result.h:94
REST API処理結果クラス.
Definition: nb_result.h:32
bool IsSuccess() const
処理結果成功判定.
Definition: nb_result.h:56
NbResult()
コンストラクタ.
Definition: nb_result.h:37
NbResultCode
処理結果コード.
Definition: nb_result_code.h:21
NbResult(NbResultCode result_code)
コンストラクタ.
Definition: nb_result.h:43
void SetRestError(const NbRestError &rest_error)
[内部処理用]
Definition: nb_result.h:130