Sha256: 0c9874e21dfc43c1cb65a1139adc3b432f7bcfa6c3221bf470edbcb2eeea519b

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

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

#ifndef TAO_JSON_INTERNAL_FORMAT_HPP
#define TAO_JSON_INTERNAL_FORMAT_HPP

#include <ostream>
#include <sstream>
#include <string>
#include <typeinfo>
#include <utility>

#include "escape.hpp"

#include "../forward.hpp"
#include "../message_extension.hpp"
#include "../type.hpp"

namespace tao::json::internal
{
   inline void to_stream( std::ostream& os, const bool v )
   {
      os << ( v ? "true" : "false" );
   }

   inline void to_stream( std::ostream& os, const type t )
   {
      os << to_string( t );
   }

   template< typename T >
   void to_stream( std::ostream& os, const T& t )
   {
      os << t;
   }

   template< std::size_t N >
   void to_stream( std::ostream& os, const char ( &t )[ N ] )
   {
      os.write( t, N - 1 );
   }

   template< typename... Ts >
   void format_to( std::ostream& oss, const Ts&... ts )
   {
      ( internal::to_stream( oss, ts ), ... );
   }

   template< typename... Ts >
   [[nodiscard]] std::string format( const Ts&... ts )
   {
      std::ostringstream oss;
      format_to( oss, ts... );
      return std::move( oss ).str();
   }

}  // namespace tao::json::internal

#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/internal/format.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp
couchbase-3.3.0 ext/couchbase/third_party/json/include/tao/json/internal/format.hpp