rename ArrayProxy to ElementProxy and ObjectProxy to PropertyProxy
This commit is contained in:
parent
49a64a6edf
commit
2dc2b6bab7
40
janssonxx.h
40
janssonxx.h
@ -23,8 +23,8 @@ namespace jansson {
|
|||||||
class Value;
|
class Value;
|
||||||
|
|
||||||
namespace _private {
|
namespace _private {
|
||||||
class ArrayProxy;
|
class ElementProxy;
|
||||||
class ObjectProxy;
|
class PropertyProxy;
|
||||||
|
|
||||||
// base class for JSON value interface
|
// base class for JSON value interface
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
@ -69,14 +69,14 @@ namespace jansson {
|
|||||||
inline const Value operator[](unsigned long index) const;
|
inline const Value operator[](unsigned long index) const;
|
||||||
|
|
||||||
// get value at array index (non-const version)
|
// get value at array index (non-const version)
|
||||||
inline ValueBase<ArrayProxy> at(unsigned int index);
|
inline ValueBase<ElementProxy> at(unsigned int index);
|
||||||
|
|
||||||
inline ValueBase<ArrayProxy> operator[](signed int index);
|
inline ValueBase<ElementProxy> operator[](signed int index);
|
||||||
inline ValueBase<ArrayProxy> operator[](unsigned int index);
|
inline ValueBase<ElementProxy> operator[](unsigned int index);
|
||||||
inline ValueBase<ArrayProxy> operator[](signed short index);
|
inline ValueBase<ElementProxy> operator[](signed short index);
|
||||||
inline ValueBase<ArrayProxy> operator[](unsigned short index);
|
inline ValueBase<ElementProxy> operator[](unsigned short index);
|
||||||
inline ValueBase<ArrayProxy> operator[](signed long index);
|
inline ValueBase<ElementProxy> operator[](signed long index);
|
||||||
inline ValueBase<ArrayProxy> operator[](unsigned long index);
|
inline ValueBase<ElementProxy> operator[](unsigned long index);
|
||||||
|
|
||||||
// get object property (const version)
|
// get object property (const version)
|
||||||
inline const Value get(const char* key) const;
|
inline const Value get(const char* key) const;
|
||||||
@ -86,11 +86,11 @@ namespace jansson {
|
|||||||
inline const Value operator[](const std::string& key) const;
|
inline const Value operator[](const std::string& key) const;
|
||||||
|
|
||||||
// get object property (non-const version)
|
// get object property (non-const version)
|
||||||
inline ValueBase<ObjectProxy> get(const char* key);
|
inline ValueBase<PropertyProxy> get(const char* key);
|
||||||
|
|
||||||
inline ValueBase<ObjectProxy> get(const std::string& key);
|
inline ValueBase<PropertyProxy> get(const std::string& key);
|
||||||
inline ValueBase<ObjectProxy> operator[](const char* key);
|
inline ValueBase<PropertyProxy> operator[](const char* key);
|
||||||
inline ValueBase<ObjectProxy> operator[](const std::string& key);
|
inline ValueBase<PropertyProxy> operator[](const std::string& key);
|
||||||
|
|
||||||
// clear all array/object values
|
// clear all array/object values
|
||||||
inline void clear();
|
inline void clear();
|
||||||
@ -164,13 +164,13 @@ namespace jansson {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// proxies an array element
|
// proxies an array element
|
||||||
class ArrayProxy {
|
class ElementProxy {
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
ArrayProxy(json_t* array, unsigned int index) : _array(array), _index(index) {}
|
ElementProxy(json_t* array, unsigned int index) : _array(array), _index(index) {}
|
||||||
|
|
||||||
// assign to the proxied element
|
// assign to the proxied element
|
||||||
inline ArrayProxy& operator=(const Value& value);
|
inline ElementProxy& operator=(const Value& value);
|
||||||
|
|
||||||
// get the proxied element
|
// get the proxied element
|
||||||
json_t* as_json() const { return json_array_get(_array, _index); }
|
json_t* as_json() const { return json_array_get(_array, _index); }
|
||||||
@ -184,13 +184,13 @@ namespace jansson {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// proxies an object property
|
// proxies an object property
|
||||||
class ObjectProxy {
|
class PropertyProxy {
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
ObjectProxy(json_t* array, const char* key) : _object(array), _key(key) {}
|
PropertyProxy(json_t* array, const char* key) : _object(array), _key(key) {}
|
||||||
|
|
||||||
// assign to the proxied element
|
// assign to the proxied element
|
||||||
inline ObjectProxy& operator=(const Value& value);
|
inline PropertyProxy& operator=(const Value& value);
|
||||||
|
|
||||||
// get the proxied element
|
// get the proxied element
|
||||||
json_t* as_json() const { return json_object_get(_object, _key); }
|
json_t* as_json() const { return json_object_get(_object, _key); }
|
||||||
@ -275,7 +275,7 @@ namespace jansson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// construct a new iterator for a given object
|
// construct a new iterator for a given object
|
||||||
Iterator(const _private::ValueBase<_private::ObjectProxy>& value) : _object(value.as_json()), _iter(0) {
|
Iterator(const _private::ValueBase<_private::PropertyProxy>& value) : _object(value.as_json()), _iter(0) {
|
||||||
_iter = json_object_iter(_object.as_json());
|
_iter = json_object_iter(_object.as_json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,22 +28,22 @@ const jansson::Value jansson::_private::ValueBase<_Base>::operator[](unsigned lo
|
|||||||
|
|
||||||
// get value at array index (non-const version)
|
// get value at array index (non-const version)
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::at(unsigned int index) {
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::at(unsigned int index) {
|
||||||
return ArrayProxy(_Base::as_json(), index);
|
return ElementProxy(_Base::as_json(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](signed int index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](signed int index) { return at(index); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned int index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned int index) { return at(index); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](signed short index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](signed short index) { return at(index); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned short index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned short index) { return at(index); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](signed long index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](signed long index) { return at(index); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ArrayProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned long index) { return at(index); }
|
jansson::_private::ValueBase<jansson::_private::ElementProxy> jansson::_private::ValueBase<_Base>::operator[](unsigned long index) { return at(index); }
|
||||||
|
|
||||||
// get object property (const version)
|
// get object property (const version)
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
@ -60,16 +60,16 @@ const jansson::Value jansson::_private::ValueBase<_Base>::operator[](const std::
|
|||||||
|
|
||||||
// get object property (non-const version)
|
// get object property (non-const version)
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ObjectProxy> jansson::_private::ValueBase<_Base>::get(const char* key) {
|
jansson::_private::ValueBase<jansson::_private::PropertyProxy> jansson::_private::ValueBase<_Base>::get(const char* key) {
|
||||||
return ObjectProxy(_Base::as_json(), key);
|
return PropertyProxy(_Base::as_json(), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ObjectProxy> jansson::_private::ValueBase<_Base>::get(const std::string& key) { return get(key.c_str()); }
|
jansson::_private::ValueBase<jansson::_private::PropertyProxy> jansson::_private::ValueBase<_Base>::get(const std::string& key) { return get(key.c_str()); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ObjectProxy> jansson::_private::ValueBase<_Base>::operator[](const char* key) { return get(key); }
|
jansson::_private::ValueBase<jansson::_private::PropertyProxy> jansson::_private::ValueBase<_Base>::operator[](const char* key) { return get(key); }
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
jansson::_private::ValueBase<jansson::_private::ObjectProxy> jansson::_private::ValueBase<_Base>::operator[](const std::string& key) { return get(key.c_str()); }
|
jansson::_private::ValueBase<jansson::_private::PropertyProxy> jansson::_private::ValueBase<_Base>::operator[](const std::string& key) { return get(key.c_str()); }
|
||||||
|
|
||||||
// clear all array/object values
|
// clear all array/object values
|
||||||
template <typename _Base>
|
template <typename _Base>
|
||||||
@ -146,13 +146,13 @@ template <typename _Base>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assign value to proxied array element
|
// assign value to proxied array element
|
||||||
jansson::_private::ArrayProxy& jansson::_private::ArrayProxy::operator=(const Value& value) {
|
jansson::_private::ElementProxy& jansson::_private::ElementProxy::operator=(const Value& value) {
|
||||||
json_array_set(_array, _index, value.as_json());
|
json_array_set(_array, _index, value.as_json());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign value to proxied object property
|
// assign value to proxied object property
|
||||||
jansson::_private::ObjectProxy& jansson::_private::ObjectProxy::operator=(const Value& value) {
|
jansson::_private::PropertyProxy& jansson::_private::PropertyProxy::operator=(const Value& value) {
|
||||||
json_object_set(_object, _key, value.as_json());
|
json_object_set(_object, _key, value.as_json());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user