Sha256: 79c06680f6e8f9ecb7ebe32ec0c88818d0bfaed7c67306d5ebdca99d79ae3c73

Contents?: true

Size: 1.84 KB

Versions: 34

Compression:

Stored size: 1.84 KB

Contents

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

#ifndef TAO_JSON_PRODUCE_HPP
#define TAO_JSON_PRODUCE_HPP

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

#include "forward.hpp"

#include "events/produce.hpp"
#include "events/to_pretty_stream.hpp"
#include "events/to_stream.hpp"
#include "events/to_string.hpp"
#include "events/to_value.hpp"

namespace tao::json::produce
{
   template< template< typename... > class Traits = traits, typename T >
   [[nodiscard]] basic_value< Traits > to_value( T&& t )
   {
      events::to_basic_value< Traits > consumer;
      events::produce< Traits >( consumer, std::forward< T >( t ) );
      return std::move( consumer.value );
   }

   template< template< typename... > class Traits = traits, typename T >
   void to_stream( std::ostream& os, const T& t )
   {
      events::to_stream consumer( os );
      events::produce< Traits >( consumer, t );
   }

   template< template< typename... > class Traits = traits, typename T >
   void to_stream( std::ostream& os, const T& t, const std::size_t indent )
   {
      events::to_pretty_stream consumer( os, indent );
      events::produce< Traits >( consumer, t );
   }

   template< template< typename... > class Traits = traits, typename T, typename S >
   void to_stream( std::ostream& os, const T& t, const std::size_t indent, S&& eol )
   {
      events::to_pretty_stream consumer( os, indent, std::forward< S >( eol ) );
      events::produce< Traits >( consumer, t );
   }

   template< template< typename... > class Traits = traits, typename... Ts >
   [[nodiscard]] std::string to_string( Ts&&... ts )
   {
      std::ostringstream oss;
      to_stream< Traits >( oss, std::forward< Ts >( ts )... );
      return oss.str();
   }

}  // namespace tao::json::produce

#endif

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
couchbase-3.2.0-universal-darwin-20 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.2.0 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.1.1 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.1.1-universal-darwin-20 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.1.0 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.3 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.3-universal-darwin-20 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.2 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.1-universal-darwin-19 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.1 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0-universal-darwin-19 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.beta.1 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.5 ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/json/include/tao/json/produce.hpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/json/include/tao/json/produce.hpp