-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is lightweight and relies on boost spirit, which we already use, so there are no new dependencies. There were some other libraries that also looked good, but they weren't already packages for existing Debian distros like squeeze or even wheezy. Signed-off-by: Sage Weil <[email protected]>
- Loading branch information
Showing
16 changed files
with
2,288 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,35 @@ License: | |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Files: src/json_spirit | ||
Copyright: | ||
Copyright John W. Wilkinson 2007 - 2011 | ||
License: | ||
The MIT License | ||
|
||
Copyright (c) 2007 - 2010 John W. Wilkinson | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
Packaging: | ||
Copyright (C) 2004-2009 by Sage Weil <[email protected]> | ||
Copyright (C) 2010 Canonical, Ltd. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef JSON_SPIRIT | ||
#define JSON_SPIRIT | ||
|
||
// Copyright John W. Wilkinson 2007 - 2011 | ||
// Distributed under the MIT License, see accompanying file LICENSE.txt | ||
|
||
// json spirit version 4.05 | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER >= 1020) | ||
# pragma once | ||
#endif | ||
|
||
#include "json_spirit_value.h" | ||
#include "json_spirit_reader.h" | ||
#include "json_spirit_writer.h" | ||
#include "json_spirit_utils.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#ifndef JSON_SPIRIT_ERROR_POSITION | ||
#define JSON_SPIRIT_ERROR_POSITION | ||
|
||
// Copyright John W. Wilkinson 2007 - 2011 | ||
// Distributed under the MIT License, see accompanying file LICENSE.txt | ||
|
||
// json spirit version 4.05 | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER >= 1020) | ||
# pragma once | ||
#endif | ||
|
||
#include <string> | ||
|
||
namespace json_spirit | ||
{ | ||
// An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. | ||
// Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" | ||
// functions that return a bool. | ||
// | ||
struct Error_position | ||
{ | ||
Error_position(); | ||
Error_position( unsigned int line, unsigned int column, const std::string& reason ); | ||
bool operator==( const Error_position& lhs ) const; | ||
unsigned int line_; | ||
unsigned int column_; | ||
std::string reason_; | ||
}; | ||
|
||
inline Error_position::Error_position() | ||
: line_( 0 ) | ||
, column_( 0 ) | ||
{ | ||
} | ||
|
||
inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) | ||
: line_( line ) | ||
, column_( column ) | ||
, reason_( reason ) | ||
{ | ||
} | ||
|
||
inline bool Error_position::operator==( const Error_position& lhs ) const | ||
{ | ||
if( this == &lhs ) return true; | ||
|
||
return ( reason_ == lhs.reason_ ) && | ||
( line_ == lhs.line_ ) && | ||
( column_ == lhs.column_ ); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright John W. Wilkinson 2007 - 2011 | ||
// Distributed under the MIT License, see accompanying file LICENSE.txt | ||
|
||
// json spirit version 4.05 | ||
|
||
#include "json_spirit_reader.h" | ||
#include "json_spirit_reader_template.h" | ||
|
||
using namespace json_spirit; | ||
|
||
#ifdef JSON_SPIRIT_VALUE_ENABLED | ||
bool json_spirit::read( const std::string& s, Value& value ) | ||
{ | ||
return read_string( s, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( const std::string& s, Value& value ) | ||
{ | ||
read_string_or_throw( s, value ); | ||
} | ||
|
||
bool json_spirit::read( std::istream& is, Value& value ) | ||
{ | ||
return read_stream( is, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::istream& is, Value& value ) | ||
{ | ||
read_stream_or_throw( is, value ); | ||
} | ||
|
||
bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) | ||
{ | ||
return read_range( begin, end, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ) | ||
{ | ||
begin = read_range_or_throw( begin, end, value ); | ||
} | ||
#endif | ||
|
||
#if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) | ||
bool json_spirit::read( const std::wstring& s, wValue& value ) | ||
{ | ||
return read_string( s, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( const std::wstring& s, wValue& value ) | ||
{ | ||
read_string_or_throw( s, value ); | ||
} | ||
|
||
bool json_spirit::read( std::wistream& is, wValue& value ) | ||
{ | ||
return read_stream( is, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::wistream& is, wValue& value ) | ||
{ | ||
read_stream_or_throw( is, value ); | ||
} | ||
|
||
bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) | ||
{ | ||
return read_range( begin, end, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ) | ||
{ | ||
begin = read_range_or_throw( begin, end, value ); | ||
} | ||
#endif | ||
|
||
#ifdef JSON_SPIRIT_MVALUE_ENABLED | ||
bool json_spirit::read( const std::string& s, mValue& value ) | ||
{ | ||
return read_string( s, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( const std::string& s, mValue& value ) | ||
{ | ||
read_string_or_throw( s, value ); | ||
} | ||
|
||
bool json_spirit::read( std::istream& is, mValue& value ) | ||
{ | ||
return read_stream( is, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::istream& is, mValue& value ) | ||
{ | ||
read_stream_or_throw( is, value ); | ||
} | ||
|
||
bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) | ||
{ | ||
return read_range( begin, end, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ) | ||
{ | ||
begin = read_range_or_throw( begin, end, value ); | ||
} | ||
#endif | ||
|
||
#if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) | ||
bool json_spirit::read( const std::wstring& s, wmValue& value ) | ||
{ | ||
return read_string( s, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( const std::wstring& s, wmValue& value ) | ||
{ | ||
read_string_or_throw( s, value ); | ||
} | ||
|
||
bool json_spirit::read( std::wistream& is, wmValue& value ) | ||
{ | ||
return read_stream( is, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::wistream& is, wmValue& value ) | ||
{ | ||
read_stream_or_throw( is, value ); | ||
} | ||
|
||
bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) | ||
{ | ||
return read_range( begin, end, value ); | ||
} | ||
|
||
void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ) | ||
{ | ||
begin = read_range_or_throw( begin, end, value ); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef JSON_SPIRIT_READER | ||
#define JSON_SPIRIT_READER | ||
|
||
// Copyright John W. Wilkinson 2007 - 2011 | ||
// Distributed under the MIT License, see accompanying file LICENSE.txt | ||
|
||
// json spirit version 4.05 | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER >= 1020) | ||
# pragma once | ||
#endif | ||
|
||
#include "json_spirit_value.h" | ||
#include "json_spirit_error_position.h" | ||
#include <iostream> | ||
|
||
namespace json_spirit | ||
{ | ||
// functions to reads a JSON values | ||
|
||
#ifdef JSON_SPIRIT_VALUE_ENABLED | ||
bool read( const std::string& s, Value& value ); | ||
bool read( std::istream& is, Value& value ); | ||
bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); | ||
|
||
void read_or_throw( const std::string& s, Value& value ); | ||
void read_or_throw( std::istream& is, Value& value ); | ||
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value ); | ||
#endif | ||
|
||
#if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) | ||
bool read( const std::wstring& s, wValue& value ); | ||
bool read( std::wistream& is, wValue& value ); | ||
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); | ||
|
||
void read_or_throw( const std::wstring& s, wValue& value ); | ||
void read_or_throw( std::wistream& is, wValue& value ); | ||
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value ); | ||
#endif | ||
|
||
#ifdef JSON_SPIRIT_MVALUE_ENABLED | ||
bool read( const std::string& s, mValue& value ); | ||
bool read( std::istream& is, mValue& value ); | ||
bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); | ||
|
||
void read_or_throw( const std::string& s, mValue& value ); | ||
void read_or_throw( std::istream& is, mValue& value ); | ||
void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value ); | ||
#endif | ||
|
||
#if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) | ||
bool read( const std::wstring& s, wmValue& value ); | ||
bool read( std::wistream& is, wmValue& value ); | ||
bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); | ||
|
||
void read_or_throw( const std::wstring& s, wmValue& value ); | ||
void read_or_throw( std::wistream& is, wmValue& value ); | ||
void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value ); | ||
#endif | ||
} | ||
|
||
#endif |
Oops, something went wrong.