the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 171 lines 5.2 kB view raw
1// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2// (C) Copyright 2003-2007 Jonathan Turkanis 3// Distributed under the Boost Software License, Version 1.0. (See accompanying 4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 6// See http://www.boost.org/libs/iostreams for documentation. 7 8#ifndef BOOST_IOSTREAMS_WRITE_HPP_INCLUDED 9#define BOOST_IOSTREAMS_WRITE_HPP_INCLUDED 10 11#if defined(_MSC_VER) && (_MSC_VER >= 1020) 12# pragma once 13#endif 14 15#include <boost/config.hpp> // DEDUCED_TYPENAME, MSVC. 16#include <boost/detail/workaround.hpp> 17#include <boost/iostreams/categories.hpp> 18#include <boost/iostreams/detail/char_traits.hpp> 19#include <boost/iostreams/detail/dispatch.hpp> 20#include <boost/iostreams/detail/ios.hpp> // streamsize. 21#include <boost/iostreams/detail/streambuf.hpp> 22#include <boost/iostreams/detail/wrap_unwrap.hpp> 23#include <boost/iostreams/operations_fwd.hpp> 24#include <boost/iostreams/traits.hpp> 25#include <boost/mpl/if.hpp> 26 27// Must come last. 28#include <boost/iostreams/detail/config/disable_warnings.hpp> 29 30#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-----------------------------------// 31# include <boost/iostreams/detail/vc6/write.hpp> 32#else // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //--------------------------// 33 34namespace boost { namespace iostreams { 35 36namespace detail { 37 38template<typename T> 39struct write_device_impl; 40 41template<typename T> 42struct write_filter_impl; 43 44} // End namespace detail. 45 46template<typename T> 47bool put(T& t, typename char_type_of<T>::type c) 48{ return detail::write_device_impl<T>::put(detail::unwrap(t), c); } 49 50template<typename T> 51inline std::streamsize write 52 (T& t, const typename char_type_of<T>::type* s, std::streamsize n) 53{ return detail::write_device_impl<T>::write(detail::unwrap(t), s, n); } 54 55template<typename T, typename Sink> 56inline std::streamsize 57write( T& t, Sink& snk, const typename char_type_of<T>::type* s, 58 std::streamsize n ) 59{ return detail::write_filter_impl<T>::write(detail::unwrap(t), snk, s, n); } 60 61namespace detail { 62 63//------------------Definition of write_device_impl---------------------------// 64 65template<typename T> 66struct write_device_impl 67 : mpl::if_< 68 is_custom<T>, 69 operations<T>, 70 write_device_impl< 71 BOOST_DEDUCED_TYPENAME 72 dispatch< 73 T, ostream_tag, streambuf_tag, output 74 >::type 75 > 76 >::type 77 { }; 78 79template<> 80struct write_device_impl<ostream_tag> { 81 template<typename T> 82 static bool put(T& t, typename char_type_of<T>::type c) 83 { 84 typedef typename char_type_of<T>::type char_type; 85 typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) traits_type; 86 return !traits_type::eq_int_type( t.rdbuf()->sputc(c), 87 traits_type::eof() ); 88 } 89 90 template<typename T> 91 static std::streamsize write 92 (T& t, const typename char_type_of<T>::type* s, std::streamsize n) 93 { return t.rdbuf()->sputn(s, n); } 94}; 95 96template<> 97struct write_device_impl<streambuf_tag> { 98 template<typename T> 99 static bool put(T& t, typename char_type_of<T>::type c) 100 { 101 typedef typename char_type_of<T>::type char_type; 102 typedef BOOST_IOSTREAMS_CHAR_TRAITS(char_type) traits_type; 103 return !traits_type::eq_int_type(t.sputc(c), traits_type::eof()); 104 } 105 106 template<typename T> 107 static std::streamsize write 108 (T& t, const typename char_type_of<T>::type* s, std::streamsize n) 109 { return t.sputn(s, n); } 110}; 111 112template<> 113struct write_device_impl<output> { 114 template<typename T> 115 static bool put(T& t, typename char_type_of<T>::type c) 116 { return t.write(&c, 1) == 1; } 117 118 template<typename T> 119 static std::streamsize 120 write(T& t, const typename char_type_of<T>::type* s, std::streamsize n) 121 { return t.write(s, n); } 122}; 123 124//------------------Definition of write_filter_impl---------------------------// 125 126template<typename T> 127struct write_filter_impl 128 : mpl::if_< 129 is_custom<T>, 130 operations<T>, 131 write_filter_impl< 132 BOOST_DEDUCED_TYPENAME 133 dispatch< 134 T, multichar_tag, any_tag 135 >::type 136 > 137 >::type 138 { }; 139 140template<> 141struct write_filter_impl<multichar_tag> { 142 template<typename T, typename Sink> 143 static std::streamsize 144 write( T& t, Sink& snk, const typename char_type_of<T>::type* s, 145 std::streamsize n ) 146 { return t.write(snk, s, n); } 147}; 148 149template<> 150struct write_filter_impl<any_tag> { 151 template<typename T, typename Sink> 152 static std::streamsize 153 write( T& t, Sink& snk, const typename char_type_of<T>::type* s, 154 std::streamsize n ) 155 { 156 for (std::streamsize off = 0; off < n; ++off) 157 if (!t.put(snk, s[off])) 158 return off; 159 return n; 160 } 161}; 162 163} // End namespace detail. 164 165} } // End namespaces iostreams, boost. 166 167#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-------------------------// 168 169#include <boost/iostreams/detail/config/enable_warnings.hpp> 170 171#endif // #ifndef BOOST_IOSTREAMS_WRITE_HPP_INCLUDED