Alexander Afanasyev | 01106cd | 2013-02-27 01:01:22 -0800 | [diff] [blame] | 1 | #ifndef JSON_SPIRIT_ERROR_POSITION
|
| 2 | #define JSON_SPIRIT_ERROR_POSITION
|
| 3 |
|
| 4 | // Copyright John W. Wilkinson 2007 - 2011
|
| 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt
|
| 6 |
|
| 7 | // json spirit version 4.05
|
| 8 |
|
| 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
| 10 | # pragma once
|
| 11 | #endif
|
| 12 |
|
| 13 | #include <string>
|
| 14 |
|
| 15 | namespace json_spirit
|
| 16 | {
|
| 17 | // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error.
|
| 18 | // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read"
|
| 19 | // functions that return a bool.
|
| 20 | //
|
| 21 | struct Error_position
|
| 22 | {
|
| 23 | Error_position();
|
| 24 | Error_position( unsigned int line, unsigned int column, const std::string& reason );
|
| 25 | bool operator==( const Error_position& lhs ) const;
|
| 26 | unsigned int line_;
|
| 27 | unsigned int column_;
|
| 28 | std::string reason_;
|
| 29 | };
|
| 30 |
|
| 31 | inline Error_position::Error_position()
|
| 32 | : line_( 0 )
|
| 33 | , column_( 0 )
|
| 34 | {
|
| 35 | }
|
| 36 |
|
| 37 | inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason )
|
| 38 | : line_( line )
|
| 39 | , column_( column )
|
| 40 | , reason_( reason )
|
| 41 | {
|
| 42 | }
|
| 43 |
|
| 44 | inline bool Error_position::operator==( const Error_position& lhs ) const
|
| 45 | {
|
| 46 | if( this == &lhs ) return true;
|
| 47 |
|
| 48 | return ( reason_ == lhs.reason_ ) &&
|
| 49 | ( line_ == lhs.line_ ) &&
|
| 50 | ( column_ == lhs.column_ );
|
| 51 | }
|
| 52 | }
|
| 53 |
|
| 54 | #endif
|