13 #ifndef NECBAAS_NBJSONARRAY_H 
   14 #define NECBAAS_NBJSONARRAY_H 
   19 #include <json/json.h> 
   21 #include "necbaas/internal/nb_logger.h" 
   50     explicit NbJsonArray(
const std::string &json_string);
 
   63     void PutAll(
const std::string &json);
 
   76         value_.resize(container.size());
 
   78         for (
auto container_value : container) {
 
   79             value_[i] = container_value;
 
   96     int GetInt(
unsigned int index, 
int default_value = 0) 
const;
 
  110     int64_t 
GetInt64(
unsigned int index, int64_t default_value = 0) 
const;
 
  122     double GetDouble(
unsigned int index, 
double default_value = 0.0) 
const;
 
  134     bool GetBoolean(
unsigned int index, 
bool default_value = 
false) 
const;
 
  146     std::string 
GetString(
unsigned int index, 
const std::string &default_value = 
"") 
const;
 
  183     template <
typename T>
 
  184     void GetAllInt(T *out_container, 
int default_value = 0)
 const {
 
  185         GetAllList(out_container, default_value, &Json::Value::isNumeric, &Json::Value::asInt);
 
  201     template <
typename T>
 
  202     void GetAllInt64(T *out_container, int64_t default_value = 0)
 const {
 
  203         GetAllList(out_container, default_value, &Json::Value::isNumeric, &Json::Value::asInt64);
 
  217     template <
typename T>
 
  218     void GetAllDouble(T *out_container, 
double default_value = 0.0)
 const {
 
  219         GetAllList(out_container, default_value, &Json::Value::isNumeric, &Json::Value::asDouble);
 
  233     template <
typename T>
 
  235         GetAllList(out_container, default_value, &Json::Value::isBool, &Json::Value::asBool);
 
  249     template <
typename T>
 
  250     void GetAllString(T *out_container, 
const std::string &default_value = 
"")
 const {
 
  251         GetAllList(out_container, default_value, &Json::Value::isString, &Json::Value::asString);
 
  291     const Json::Value &
operator[](
unsigned int index) 
const;
 
  326     bool PutNull(
unsigned int index);
 
  345     template <
typename T>
 
  347         if (value_.size() == std::numeric_limits<unsigned int>::max()) {
 
  351         value_[value_.size()] = value;
 
  417     void Remove(
unsigned int index);
 
  439     void Replace(
const Json::Value &value);
 
  461     template <
typename T, 
typename U>
 
  462     void GetAllList(T *out_container, 
const U &default_value, 
bool (Json::Value::*is_type)(
void) 
const,
 
  463                     U (Json::Value::*as_type)(
void) 
const)
 const {
 
  464         if (out_container == 
nullptr) {
 
  467         out_container->clear();
 
  468         for (
unsigned int i = 0; i < 
GetSize(); ++i) {
 
  469             if ((value_[i].*is_type)()) {
 
  471                     out_container->push_back((value_[i].*as_type)());
 
  473                 catch (
const Json::LogicError &ex) {
 
  474                     NBLOG(ERROR) << ex.what();
 
  475                     out_container->push_back(default_value);
 
  478                 out_container->push_back(default_value);
 
  484 #endif  // NECBAAS_NBJSONARRAY_H 
bool AppendJsonArray(const NbJsonArray &json_array)
配列末尾に追加(Json配列). 
int64_t GetInt64(unsigned int index, int64_t default_value=0) const 
64bit整数値取得. 
std::string ToJsonString() const 
Json文字列変換. 
unsigned int GetSize() const 
Json配列サイズ取得. 
const Json::Value & GetSubstitutableValue() const 
[内部処理用] 
NbJsonType GetType(unsigned int index) const 
Jsonタイプ取得. 
bool operator==(const NbJsonArray &other) const 
==演算子. 
std::string GetString(unsigned int index, const std::string &default_value="") const 
文字列取得. 
bool AppendJsonObject(const NbJsonObject &json_object)
配列末尾に追加(Jsonオブジェクト). 
bool Append(T value)
配列末尾に追加. 
Definition: nb_json_array.h:346
void GetAllInt(T *out_container, int default_value=0) const 
整数値リスト取得. 
Definition: nb_json_array.h:184
NbJsonArray GetJsonArray(unsigned int index) const 
Json配列取得. 
NbJsonType
Json値のタイプ. 
Definition: nb_json_type.h:21
void GetAllDouble(T *out_container, double default_value=0.0) const 
浮動小数点値リスト取得. 
Definition: nb_json_array.h:218
double GetDouble(unsigned int index, double default_value=0.0) const 
浮動小数点値取得. 
bool PutJsonObject(unsigned int index, const NbJsonObject &json_object)
Jsonオブジェクト設定. 
void PutAll(const std::string &json)
全データセット. 
void Remove(unsigned int index)
Index削除. 
void GetAllBoolean(T *out_container, bool default_value=false) const 
真偽値リスト取得. 
Definition: nb_json_array.h:234
bool GetBoolean(unsigned int index, bool default_value=false) const 
真偽値取得. 
Jsonオブジェクト. 
Definition: nb_json_object.h:34
NbJsonObject GetJsonObject(unsigned int index) const 
Jsonオブジェクト取得. 
void PutAllList(const T &container)
全データセット(リスト形式). 
Definition: nb_json_array.h:75
void GetAllString(T *out_container, const std::string &default_value="") const 
文字列リスト取得. 
Definition: nb_json_array.h:250
bool PutJsonArray(unsigned int index, const NbJsonArray &json_array)
Json配列設定. 
bool AppendNull()
配列末尾に追加(null). 
int GetInt(unsigned int index, int default_value=0) const 
整数値取得. 
bool PutNull(unsigned int index)
null設定. 
void GetAllInt64(T *out_container, int64_t default_value=0) const 
64bit整数値リスト取得. 
Definition: nb_json_array.h:202
bool IsEmpty() const 
オブジェクト空確認. 
Json::Value & operator[](unsigned int index)
Value設定用添え字演算子. 
Json配列. 
Definition: nb_json_array.h:37
void Replace(const Json::Value &value)
[内部処理用]