json_spirit_error_position.h 1.5 KB

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