Sha256: 9e1c0730c627836d6a33830af3f56488b855201464391484bd2b58669f49c2fb
Contents?: true
Size: 1.45 KB
Versions: 48
Compression:
Stored size: 1.45 KB
Contents
#ifndef TAO_JSON_CONTRIB_POINTER_TRAITS_HPP #define TAO_JSON_CONTRIB_POINTER_TRAITS_HPP #include "../pointer.hpp" #include "../traits.hpp" namespace tao::json { struct token_traits { template< template< typename... > class Traits > static void assign( basic_value< Traits >& v, const token& t ) { if( t.has_index() ) { v = t.index(); } else { v = t.key(); } } template< template< typename... > class Traits, typename Consumer > static void produce( Consumer& c, const token& t ) { if( t.has_index() ) { json::events::produce< Traits >( c, t.index() ); } else { json::events::produce< Traits >( c, t.key() ); } } }; struct pointer_traits { template< template< typename... > class Traits > static void assign( basic_value< Traits >& v, const pointer& p ) { v.prepare_array().reserve( p.size() ); for( const auto& i : p ) { v.emplace_back( i ); } } template< template< typename... > class Traits, typename Consumer > static void produce( Consumer& c, const pointer& p ) { c.begin_array( p.size() ); for( const auto& i : p ) { json::events::produce< Traits >( c, i ); c.element(); } c.end_array( p.size() ); } }; } // namespace tao::json #endif
Version data entries
48 entries across 48 versions & 1 rubygems