Sha256: fc18a3b0b9f9a21a691703fce0acd878c15b0b910f3065eb7c0d44c8ce0f3cde
Contents?: true
Size: 1.26 KB
Versions: 24
Compression:
Stored size: 1.26 KB
Contents
// Copyright (c) 2019-2020 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_BINARY_HPP #define TAO_JSON_EVENTS_INVALID_STRING_TO_BINARY_HPP #include <utility> #include <vector> #include "../binary_view.hpp" #include "../utf8.hpp" namespace tao::json::events { template< typename Consumer > struct invalid_string_to_binary : 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 { const std::byte* data = reinterpret_cast< const std::byte* >( v.data() ); Consumer::binary( std::vector< std::byte >( data, data + v.size() ) ); } } void string( const std::string_view v ) { if( internal::validate_utf8_nothrow( v ) ) { Consumer::string( v ); } else { Consumer::binary( tao::binary_view( reinterpret_cast< const std::byte* >( v.data() ), v.size() ) ); } } }; } // namespace tao::json::events #endif
Version data entries
24 entries across 24 versions & 1 rubygems