Sha256: 77bc292b2a373369d4096441ea0ccc30a4e0335428478589b0cb422abd51294c

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

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

#ifndef TAO_JSON_EVENTS_INVALID_STRING_TO_EXCEPTION_HPP
#define TAO_JSON_EVENTS_INVALID_STRING_TO_EXCEPTION_HPP

#include <stdexcept>
#include <utility>

#include "../internal/hexdump.hpp"
#include "../utf8.hpp"

namespace tao::json::events
{
   template< typename Consumer >
   struct invalid_string_to_exception
      : Consumer
   {
      using Consumer::Consumer;

      void string( const char* v )
      {
         string( std::string_view( v ) );
      }

      void string( std::string&& v )
      {
         if( internal::validate_utf8_nothrow( v ) ) {
            Consumer::string( std::move( v ) );
         }
         else {
            throw std::runtime_error( "invalid UTF8 string: $" + internal::hexdump( v ) );
         }
      }

      void string( const std::string_view v )
      {
         if( internal::validate_utf8_nothrow( v ) ) {
            Consumer::string( v );
         }
         else {
            throw std::runtime_error( "invalid UTF8 string: $" + internal::hexdump( v ) );
         }
      }
   };

}  // namespace tao::json::events

#endif

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
couchbase-3.4.5 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp
couchbase-3.3.0 ext/couchbase/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp