Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/format/free_funcs.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // ---------------------------------------------------------------------------- | |
2 // free_funcs.hpp : implementation of the free functions of boost::format | |
3 // ---------------------------------------------------------------------------- | |
4 | |
5 // Copyright Samuel Krempp 2003. Use, modification, and distribution are | |
6 // subject to the Boost Software License, Version 1.0. (See accompanying | |
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
8 | |
9 // See http://www.boost.org/libs/format for library home page | |
10 | |
11 // ---------------------------------------------------------------------------- | |
12 | |
13 #ifndef BOOST_FORMAT_FUNCS_HPP | |
14 #define BOOST_FORMAT_FUNCS_HPP | |
15 | |
16 #include <boost/format/format_class.hpp> | |
17 #include <boost/throw_exception.hpp> | |
18 | |
19 namespace boost { | |
20 | |
21 template<class Ch, class Tr, class Alloc> inline | |
22 std::basic_string<Ch, Tr, Alloc> str(const basic_format<Ch, Tr, Alloc>& f) { | |
23 // adds up all pieces of strings and converted items, and return the formatted string | |
24 return f.str(); | |
25 } | |
26 namespace io { | |
27 using ::boost::str; // keep compatibility with when it was defined in this N.S. | |
28 } // - namespace io | |
29 | |
30 #ifndef BOOST_NO_TEMPLATE_STD_STREAM | |
31 template<class Ch, class Tr, class Alloc> | |
32 std::basic_ostream<Ch, Tr> & | |
33 operator<<( std::basic_ostream<Ch, Tr> & os, | |
34 const basic_format<Ch, Tr, Alloc>& f) | |
35 #else | |
36 template<class Ch, class Tr, class Alloc> | |
37 std::ostream & | |
38 operator<<( std::ostream & os, | |
39 const basic_format<Ch, Tr, Alloc>& f) | |
40 #endif | |
41 // effect: "return os << str(f);" but we can do it faster | |
42 { | |
43 typedef boost::basic_format<Ch, Tr, Alloc> format_t; | |
44 if(f.items_.size()==0) | |
45 os << f.prefix_; | |
46 else { | |
47 if(f.cur_arg_ < f.num_args_) | |
48 if( f.exceptions() & io::too_few_args_bit ) | |
49 // not enough variables supplied | |
50 boost::throw_exception(io::too_few_args(f.cur_arg_, f.num_args_)); | |
51 if(f.style_ & format_t::special_needs) | |
52 os << f.str(); | |
53 else { | |
54 // else we dont have to count chars output, so we dump directly to os : | |
55 os << f.prefix_; | |
56 for(unsigned long i=0; i<f.items_.size(); ++i) { | |
57 const typename format_t::format_item_t& item = f.items_[i]; | |
58 os << item.res_; | |
59 os << item.appendix_; | |
60 } | |
61 } | |
62 } | |
63 f.dumped_=true; | |
64 return os; | |
65 } | |
66 | |
67 } // namespace boost | |
68 | |
69 | |
70 #endif // BOOST_FORMAT_FUNCS_HPP |