projects
/
jansson.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
C++: Optimize PropertyProxy
[jansson.git]
/
src
/
jansson.hpp
diff --git
a/src/jansson.hpp
b/src/jansson.hpp
index
f435493
..
efb4b52
100644
(file)
--- a/
src/jansson.hpp
+++ b/
src/jansson.hpp
@@
-127,10
+127,11
@@
namespace json {
inline _Base& insert_at(unsigned int index, const Value& value);
// write the value to a file
inline _Base& insert_at(unsigned int index, const Value& value);
// write the value to a file
- inline int save_file(const char* path, int flags = 0) const;
+ inline int dump_file(const char* path, int flags = 0) const;
+ inline int dump_file(const std::string& path, int flags = 0) const;
// write the value to a string (caller must deallocate with free()!)
// write the value to a string (caller must deallocate with free()!)
- inline char*
save_string
(int flags = 0) const;
+ inline char*
dumps
(int flags = 0) const;
};
// represents any JSON value, private base
};
// represents any JSON value, private base
@@
-165,8
+166,9
@@
namespace json {
// proxies an array element
class ElementProxy {
public:
// proxies an array element
class ElementProxy {
public:
- // constructor
- ElementProxy(json_t* array, unsigned int index) : _array(array), _index(index) {}
+ ElementProxy(json_t* array, unsigned int index);
+ ElementProxy(const ElementProxy& other);
+ ~ElementProxy();
// assign to the proxied element
inline ElementProxy& operator=(const Value& value);
// assign to the proxied element
inline ElementProxy& operator=(const Value& value);
@@
-185,8
+187,9
@@
namespace json {
// proxies an object property
class PropertyProxy {
public:
// proxies an object property
class PropertyProxy {
public:
- // constructor
- PropertyProxy(json_t* array, const char* key) : _object(array), _key(key) {}
+ PropertyProxy(json_t* object, const char *key);
+ PropertyProxy(const PropertyProxy& other);
+ ~PropertyProxy();
// assign to the proxied element
inline PropertyProxy& operator=(const Value& value);
// assign to the proxied element
inline PropertyProxy& operator=(const Value& value);
@@
-198,8
+201,11
@@
namespace json {
// array object we wrap
json_t* _object;
// array object we wrap
json_t* _object;
+ // iterator pointing to property
+ void* _iter;
+
// key of property
// key of property
- c
onst c
har* _key;
+ char* _key;
};
} // namespace json::detail
};
} // namespace json::detail
@@
-289,9
+295,11
@@
namespace json {
// load a file as a JSON value
inline Value load_file(const char* path, json_error_t* error = 0);
// load a file as a JSON value
inline Value load_file(const char* path, json_error_t* error = 0);
+ inline Value load_file(const std::string& path, json_error_t* error = 0);
// load a string as a JSON value
// load a string as a JSON value
- inline Value load_string(const char* string, json_error_t* error = 0);
+ inline Value loads(const char* string, json_error_t* error = 0);
+ inline Value loads(const std::string& string, json_error_t* error = 0);
} // namespace json
} // namespace json