// Copyright (c) 2010 Sean Middleditch <sean@middleditch.us>
+// Copyright (c) 2010 Petri Lehtinen <petri@digip.org>
//
// Jansson is free software; you can redistribute it and/or modify
// it under the terms of the MIT license. See LICENSE for details.
-#if !defined(JANSSON_HPP)
-#define JANSSON_HPP 1
+#ifndef JANSSON_HPP
+#define JANSSON_HPP
#include <string>
#include <ostream>
#include <istream>
#include <sstream>
+
+// Included so that standard functions don't end up in namespace json
+#include <cstdio>
+
+// For free()
#include <cstdlib>
namespace json {
class Value;
// implementation details; do not use directly
- namespace _private {
+ namespace detail {
class ElementProxy;
class PropertyProxy;
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;
// 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
const char* _key;
};
- } // namespace json::_private
+ } // namespace json::detail
// represents any JSON value
- class Value : public _private::ValueBase<_private::Basic> {
+ class Value : public detail::ValueBase<detail::Basic> {
public:
// construct Value from input
explicit inline Value(const char* value);
explicit inline Value(double value);
// empty constructor
- Value() : _private::ValueBase<_private::Basic>() {}
+ Value() : detail::ValueBase<detail::Basic>() {}
// copy constructor for base
- Value(const _private::Basic& value) : _private::ValueBase<_private::Basic>(value) {}
+ Value(const detail::Basic& value) : detail::ValueBase<detail::Basic>(value) {}
// copy constructor for base
- Value(const _private::ValueBase<_private::Basic>& value) : _private::ValueBase<_private::Basic>(value) {}
+ Value(const detail::ValueBase<detail::Basic>& value) : detail::ValueBase<detail::Basic>(value) {}
// copy constructor
- Value(const Value& value) : _private::ValueBase<_private::Basic>(value) {}
+ Value(const Value& value) : detail::ValueBase<detail::Basic>(value) {}
// create reference to value
- explicit Value(json_t* json) : _private::ValueBase<_private::Basic>(json) {}
+ explicit Value(json_t* json) : detail::ValueBase<detail::Basic>(json) {}
};
// iterators over a JSON object
inline Iterator(const Value& value);
// construct a new iterator for a given object
- inline Iterator(const _private::ValueBase<_private::PropertyProxy>& value);
+ inline Iterator(const detail::ValueBase<detail::PropertyProxy>& value);
// increment iterator
inline void next();
inline Value load_file(const char* path, json_error_t* error = 0);
// 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);
} // namespace json
inline std::istream& operator>>(std::istream& is, json::Value& value);
// include implementation code
-#define IN_JANSSON_HPP 1
-#include "jansson-impl.hpp"
+#define IN_JANSSON_HPP
+#include "jansson.ipp"
#undef IN_JANSSON_HPP
#endif // defined(JANSSON_HPP)