// get size of array or object template unsigned int jansson::_ValueBase<_Base>::size() const { if (is_object()) return json_object_size(_Base::as_json()); else return json_array_size(_Base::as_json()); } // get value at array index (const version) template const jansson::Value jansson::_ValueBase<_Base>::at(unsigned int index) const { return jansson::Value(json_array_get(_Base::as_json(), index)); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](signed int index) const { return at(index); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](unsigned int index) const { return at(index); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](signed short index) const { return at(index); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](unsigned short index) const { return at(index); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](signed long index) const { return at(index); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](unsigned long index) const { return at(index); } // get value at array index (non-const version) template jansson::_ValueBase jansson::_ValueBase<_Base>::at(unsigned int index) { return _ArrayProxy(_Base::as_json(), index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](signed int index) { return at(index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](unsigned int index) { return at(index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](signed short index) { return at(index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](unsigned short index) { return at(index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](signed long index) { return at(index); } template jansson::_ValueBase jansson::_ValueBase<_Base>::operator[](unsigned long index) { return at(index); } // get object property template const jansson::Value jansson::_ValueBase<_Base>::get(const char* key) const { return jansson::Value(json_object_get(_Base::as_json(), key)); } template const jansson::Value jansson::_ValueBase<_Base>::get(const std::string& key) const { return get(key.c_str()); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](const char* key) const { return get(key); } template const jansson::Value jansson::_ValueBase<_Base>::operator[](const std::string& key) const { return get(key.c_str()); } // clear all array/object values template void jansson::_ValueBase<_Base>::clear() { if (is_object()) json_object_clear(_Base::as_json()); else json_array_clear(_Base::as_json()); } // get value cast to specified type template const char* jansson::_ValueBase<_Base>::as_cstring() const { return json_string_value(_Base::as_json()); } template std::string jansson::_ValueBase<_Base>::as_string() const { const char* tmp = as_cstring(); return tmp == 0 ? "" : tmp; } template int jansson::_ValueBase<_Base>::as_integer() const { return json_integer_value(_Base::as_json()); } template double jansson::_ValueBase<_Base>::as_real() const { return json_real_value(_Base::as_json()); } template double jansson::_ValueBase<_Base>::as_number() const { return json_number_value(_Base::as_json()); } template bool jansson::_ValueBase<_Base>::as_boolean() const { return is_true(); } // set an object property (converts value to object is not one already) template _Base& jansson::_ValueBase<_Base>::set_key(const char* key, const jansson::Value& value) { json_object_set(_Base::as_json(), key, value._Base::as_json()); return *this; } template _Base& jansson::_ValueBase<_Base>::set_key(const std::string& key, const jansson::Value& value) { return set_key(key.c_str(), value); } // set an array index (converts value to object is not one already) template _Base& jansson::_ValueBase<_Base>::set_at(unsigned int index, const jansson::Value& value) { if (index == size()) json_array_append(_Base::as_json(), value._Base::as_json()); else json_array_set(_Base::as_json(), index, value._Base::as_json()); return *this; } // delete an object key template _Base& jansson::_ValueBase<_Base>::del_key(const char* key) { json_object_del(_Base::as_json(), key); return *this; } template _Base& jansson::_ValueBase<_Base>::del_key(const std::string& key) { return del_key(key.c_str()); } // delete an item from an array by index template _Base& jansson::_ValueBase<_Base>::del_at(unsigned int index) { json_array_remove(_Base::as_json(), index); return *this; } // insert an item into an array at a given index template _Base& jansson::_ValueBase<_Base>::insert_at(unsigned int index, const jansson::Value& value) { json_array_insert(_Base::as_json(), index, value._Base::as_json()); return *this; } // assign value to proxied array element jansson::_ArrayProxy& jansson::_ArrayProxy::operator=(const Value& value) { json_array_set(_array, _index, value.as_json()); return *this; }