Sha256: 183f5de60cf7bd4da4800fe56383dc279ce7fba1d477faf73fa60e5caef6691e

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

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

#ifndef TAO_JSON_SRC_TEST_JSON_UNHEX_HPP
#define TAO_JSON_SRC_TEST_JSON_UNHEX_HPP

#include <cassert>
#include <string>

namespace tao::json
{
   [[nodiscard]] inline char test_unhex( const char c )
   {
      if( ( '0' <= c ) && ( c <= '9' ) ) {
         return static_cast< char >( c - '0' );
      }
      if( ( 'a' <= c ) && ( c <= 'f' ) ) {
         return static_cast< char >( c - 'a' + 10 );
      }
      if( ( 'A' <= c ) && ( c <= 'F' ) ) {
         return static_cast< char >( c - 'A' + 10 );
      }
      // LCOV_EXCL_START
      assert( false );
      return 0;
      // LCOV_EXCL_STOP
   }

   [[nodiscard]] inline std::string test_unhex( const std::string& data )
   {
      assert( !( data.size() & 1 ) );
      std::string result;
      result.reserve( data.size() / 2 );
      for( std::string::size_type i = 0; i < data.size(); i += 2 ) {
         result += static_cast< char >( ( test_unhex( data[ i ] ) << 4 ) + test_unhex( data[ i + 1 ] ) );
      }
      return result;
   }

}  // namespace tao::json

#endif

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.4 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.3 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.2 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/json/src/test/json/test_unhex.hpp
couchbase-3.0.0.alpha.1 ext/third_party/json/src/test/json/test_unhex.hpp