Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions json5_parser/json5_parser.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#ifndef JSON_SPIRIT
#define JSON_SPIRIT
// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt
// json spirit version 4.08
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include "json5_parser_value.h"
#include "json5_parser_reader.h"
#include "json5_parser_writer.h"
#include "json5_parser_utils.h"
#endif
#ifndef JSON_SPIRIT
#define JSON_SPIRIT

// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.08

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include "json5_parser_reader.h"
#include "json5_parser_utils.h"
#include "json5_parser_value.h"
#include "json5_parser_writer.h"

#endif
96 changes: 42 additions & 54 deletions json5_parser/json5_parser_error_position.h
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
#ifndef JSON_SPIRIT_ERROR_POSITION
#define JSON_SPIRIT_ERROR_POSITION

// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.08

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif

#include <string>

namespace json5_parser
{
// 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
#ifndef JSON_SPIRIT_ERROR_POSITION
#define JSON_SPIRIT_ERROR_POSITION

// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.08

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include <string>

namespace json5_parser {
// 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_);
}
} // namespace json5_parser

#endif
258 changes: 121 additions & 137 deletions json5_parser/json5_parser_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,137 +1,121 @@
// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.08

#include "json5_parser_reader.h"
#include "json5_parser_reader_template.h"

using namespace json5_parser;

#ifdef JSON_SPIRIT_VALUE_ENABLED
bool json5_parser::read( const std::string& s, Value& value )
{
return read_string( s, value );
}

void json5_parser::read_or_throw( const std::string& s, Value& value )
{
read_string_or_throw( s, value );
}

bool json5_parser::read( std::istream& is, Value& value )
{
return read_stream( is, value );
}

void json5_parser::read_or_throw( std::istream& is, Value& value )
{
read_stream_or_throw( is, value );
}

bool json5_parser::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
{
return read_range( begin, end, value );
}

void json5_parser::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 json5_parser::read( const std::wstring& s, wValue& value )
{
return read_string( s, value );
}

void json5_parser::read_or_throw( const std::wstring& s, wValue& value )
{
read_string_or_throw( s, value );
}

bool json5_parser::read( std::wistream& is, wValue& value )
{
return read_stream( is, value );
}

void json5_parser::read_or_throw( std::wistream& is, wValue& value )
{
read_stream_or_throw( is, value );
}

bool json5_parser::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
{
return read_range( begin, end, value );
}

void json5_parser::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 json5_parser::read( const std::string& s, mValue& value )
{
return read_string( s, value );
}

void json5_parser::read_or_throw( const std::string& s, mValue& value )
{
read_string_or_throw( s, value );
}

bool json5_parser::read( std::istream& is, mValue& value )
{
return read_stream( is, value );
}

void json5_parser::read_or_throw( std::istream& is, mValue& value )
{
read_stream_or_throw( is, value );
}

bool json5_parser::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
{
return read_range( begin, end, value );
}

void json5_parser::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 json5_parser::read( const std::wstring& s, wmValue& value )
{
return read_string( s, value );
}

void json5_parser::read_or_throw( const std::wstring& s, wmValue& value )
{
read_string_or_throw( s, value );
}

bool json5_parser::read( std::wistream& is, wmValue& value )
{
return read_stream( is, value );
}

void json5_parser::read_or_throw( std::wistream& is, wmValue& value )
{
read_stream_or_throw( is, value );
}

bool json5_parser::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
{
return read_range( begin, end, value );
}

void json5_parser::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
{
begin = read_range_or_throw( begin, end, value );
}
#endif
// Copyright John W. Wilkinson 2007 - 2014
// Distributed under the MIT License, see accompanying file LICENSE.txt

// json spirit version 4.08

#include "json5_parser_reader.h"
#include "json5_parser_reader_template.h"

using namespace json5_parser;

#ifdef JSON_SPIRIT_VALUE_ENABLED
bool json5_parser::read(const std::string& s, Value& value) {
return read_string(s, value);
}

void json5_parser::read_or_throw(const std::string& s, Value& value) {
read_string_or_throw(s, value);
}

bool json5_parser::read(std::istream& is, Value& value) {
return read_stream(is, value);
}

void json5_parser::read_or_throw(std::istream& is, Value& value) {
read_stream_or_throw(is, value);
}

bool json5_parser::read(std::string::const_iterator& begin,
std::string::const_iterator end, Value& value) {
return read_range(begin, end, value);
}

void json5_parser::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 json5_parser::read(const std::wstring& s, wValue& value) {
return read_string(s, value);
}

void json5_parser::read_or_throw(const std::wstring& s, wValue& value) {
read_string_or_throw(s, value);
}

bool json5_parser::read(std::wistream& is, wValue& value) {
return read_stream(is, value);
}

void json5_parser::read_or_throw(std::wistream& is, wValue& value) {
read_stream_or_throw(is, value);
}

bool json5_parser::read(std::wstring::const_iterator& begin,
std::wstring::const_iterator end, wValue& value) {
return read_range(begin, end, value);
}

void json5_parser::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 json5_parser::read(const std::string& s, mValue& value) {
return read_string(s, value);
}

void json5_parser::read_or_throw(const std::string& s, mValue& value) {
read_string_or_throw(s, value);
}

bool json5_parser::read(std::istream& is, mValue& value) {
return read_stream(is, value);
}

void json5_parser::read_or_throw(std::istream& is, mValue& value) {
read_stream_or_throw(is, value);
}

bool json5_parser::read(std::string::const_iterator& begin,
std::string::const_iterator end, mValue& value) {
return read_range(begin, end, value);
}

void json5_parser::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 json5_parser::read(const std::wstring& s, wmValue& value) {
return read_string(s, value);
}

void json5_parser::read_or_throw(const std::wstring& s, wmValue& value) {
read_string_or_throw(s, value);
}

bool json5_parser::read(std::wistream& is, wmValue& value) {
return read_stream(is, value);
}

void json5_parser::read_or_throw(std::wistream& is, wmValue& value) {
read_stream_or_throw(is, value);
}

bool json5_parser::read(std::wstring::const_iterator& begin,
std::wstring::const_iterator end, wmValue& value) {
return read_range(begin, end, value);
}

void json5_parser::read_or_throw(std::wstring::const_iterator& begin,
std::wstring::const_iterator end, wmValue& value) {
begin = read_range_or_throw(begin, end, value);
}
#endif
Loading