Sha256: acbc67cf79ccc8a1459ed961882b07ba03f2fa944ead1ba076840725610d8fcd

Contents?: true

Size: 1.71 KB

Versions: 24

Compression:

Stored size: 1.71 KB

Contents

// Copyright (c) 2014-2020 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef TAO_JSON_PEGTL_PARSE_ERROR_HPP
#define TAO_JSON_PEGTL_PARSE_ERROR_HPP

#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>

#include "config.hpp"
#include "position.hpp"

namespace TAO_JSON_PEGTL_NAMESPACE
{
   struct parse_error
      : std::runtime_error
   {
      template< typename Msg >
      parse_error( Msg&& msg, std::vector< position > in_positions )
         : std::runtime_error( std::forward< Msg >( msg ) ),
           positions( std::move( in_positions ) )
      {
      }

      template< typename Msg >
      parse_error( Msg&& msg, const position& pos )
         : std::runtime_error( std::forward< Msg >( msg ) ),
           positions( 1, pos )
      {
      }

      template< typename Msg >
      parse_error( Msg&& msg, position&& pos )
         : std::runtime_error( std::forward< Msg >( msg ) )
      {
         positions.emplace_back( std::move( pos ) );
      }

      template< typename Msg, typename Input >
      parse_error( Msg&& msg, const Input& in )
         : parse_error( std::forward< Msg >( msg ), in.position() )
      {
      }

      std::vector< position > positions;
   };

   inline std::ostream& operator<<( std::ostream& o, const parse_error& e )
   {
      for( auto it = e.positions.rbegin(); it != e.positions.rend(); ++it ) {
         o << *it << ": ";
      }
      return o << e.what();
   }

   [[nodiscard]] inline std::string to_string( const parse_error& e )
   {
      std::ostringstream o;
      o << e;
      return o.str();
   }

}  // namespace TAO_JSON_PEGTL_NAMESPACE

#endif

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
couchbase-3.0.0-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.beta.1 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.5 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.4 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.3 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp
couchbase-3.0.0.alpha.2 ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp