* Removed references to char_traits so that boost/format also works on

GCC 2.95.
This commit is contained in:
Eelco Dolstra 2003-09-11 10:23:55 +00:00
parent d930a9bc5a
commit 1c7d6bf5fc
15 changed files with 222 additions and 239 deletions

View file

@ -1,3 +1,3 @@
SUBDIRS = externals src scripts corepkgs doc SUBDIRS = externals boost src scripts corepkgs doc
EXTRA_DIST = boost/*.hpp boost/format/*.hpp substitute.mk EXTRA_DIST = substitute.mk

1
boost/Makefile.am Normal file
View file

@ -0,0 +1 @@
SUBDIRS = format

View file

@ -25,6 +25,9 @@
#include <cassert> #include <cassert>
#include <locale> #include <locale>
//#define BOOST_NO_STD_LOCALE
//#define BOOST_NO_LOCALE_ISIDIGIT
//#include <cctype>
#include <boost/format/macros_default.hpp> #include <boost/format/macros_default.hpp>
@ -54,15 +57,15 @@ namespace boost
#include <boost/format/exceptions.hpp> #include <boost/format/exceptions.hpp>
// **** Implementation ------------------------------------------- // **** Implementation -------------------------------------------
#include <boost/format/format_implementation.hpp> // member functions //#include <boost/format/format_implementation.hpp> // member functions
#include <boost/format/group.hpp> // class for grouping arguments #include <boost/format/group.hpp> // class for grouping arguments
#include <boost/format/feed_args.hpp> // argument-feeding functions #include <boost/format/feed_args.hpp> // argument-feeding functions
#include <boost/format/parsing.hpp> // format-string parsing (member-)functions //#include <boost/format/parsing.hpp> // format-string parsing (member-)functions
// **** Implementation of the free functions ---------------------- // **** Implementation of the free functions ----------------------
#include <boost/format/free_funcs.hpp> //#include <boost/format/free_funcs.hpp>
#endif // BOOST_FORMAT_HPP #endif // BOOST_FORMAT_HPP

3
boost/format/Makefile.am Normal file
View file

@ -0,0 +1,3 @@
noinst_LIBRARIES = libformat.a
libformat_a_SOURCES = format_implementation.cc free_funcs.cc parsing.cc

View file

@ -31,17 +31,16 @@ namespace io {
namespace detail { namespace detail {
namespace { namespace {
template<class Tr, class Ch> inline inline
void empty_buf(BOOST_IO_STD basic_ostringstream<Ch,Tr> & os) { void empty_buf(BOOST_IO_STD ostringstream & os) {
static const std::basic_string<Ch, Tr> emptyStr; static const std::string emptyStr;
os.str(emptyStr); os.str(emptyStr);
} }
template<class Ch, class Tr> void do_pad( std::string & s,
void do_pad( std::basic_string<Ch,Tr> & s,
std::streamsize w, std::streamsize w,
const Ch c, const char c,
std::ios_base::fmtflags f, std::ios::fmtflags f,
bool center) bool center)
// applies centered / left / right padding to the string s. // applies centered / left / right padding to the string s.
// Effects : string s is padded. // Effects : string s is padded.
@ -59,7 +58,7 @@ namespace {
} }
else else
{ {
if(f & std::ios_base::left) { if(f & std::ios::left) {
s.append(n, c); s.append(n, c);
} }
else { else {
@ -69,32 +68,32 @@ namespace {
} // -do_pad(..) } // -do_pad(..)
template< class Ch, class Tr, class T> inline template<class T> inline
void put_head(BOOST_IO_STD basic_ostream<Ch, Tr>& , const T& ) { void put_head(BOOST_IO_STD ostream& , const T& ) {
} }
template< class Ch, class Tr, class T> inline template<class T> inline
void put_head( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const group1<T>& x ) { void put_head( BOOST_IO_STD ostream& os, const group1<T>& x ) {
os << group_head(x.a1_); // send the first N-1 items, not the last os << group_head(x.a1_); // send the first N-1 items, not the last
} }
template< class Ch, class Tr, class T> inline template<class T> inline
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const T& x ) { void put_last( BOOST_IO_STD ostream& os, const T& x ) {
os << x ; os << x ;
} }
template< class Ch, class Tr, class T> inline template<class T> inline
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const group1<T>& x ) { void put_last( BOOST_IO_STD ostream& os, const group1<T>& x ) {
os << group_last(x.a1_); // this selects the last element os << group_last(x.a1_); // this selects the last element
} }
#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
template< class Ch, class Tr, class T> inline template<class T> inline
void put_head( BOOST_IO_STD basic_ostream<Ch, Tr>& , T& ) { void put_head( BOOST_IO_STD ostream& , T& ) {
} }
template< class Ch, class Tr, class T> inline template<class T> inline
void put_last( BOOST_IO_STD basic_ostream<Ch, Tr>& os, T& x ) { void put_last( BOOST_IO_STD ostream& os, T& x ) {
os << x ; os << x ;
} }
#endif #endif
@ -102,19 +101,19 @@ namespace {
template< class Ch, class Tr, class T> template<class T>
void put( T x, void put( T x,
const format_item<Ch, Tr>& specs, const format_item& specs,
std::basic_string<Ch, Tr> & res, std::string & res,
BOOST_IO_STD basic_ostringstream<Ch, Tr>& oss_ ) BOOST_IO_STD ostringstream& oss_ )
{ {
// does the actual conversion of x, with given params, into a string // does the actual conversion of x, with given params, into a string
// using the *supplied* strinstream. (the stream state is important) // using the *supplied* strinstream. (the stream state is important)
typedef std::basic_string<Ch, Tr> string_t; typedef std::string string_t;
typedef format_item<Ch, Tr> format_item_t; typedef format_item format_item_t;
stream_format_state<Ch, Tr> prev_state(oss_); stream_format_state prev_state(oss_);
specs.state_.apply_on(oss_); specs.state_.apply_on(oss_);
@ -124,8 +123,8 @@ void put( T x,
empty_buf( oss_); empty_buf( oss_);
const std::streamsize w=oss_.width(); const std::streamsize w=oss_.width();
const std::ios_base::fmtflags fl=oss_.flags(); const std::ios::fmtflags fl=oss_.flags();
const bool internal = (fl & std::ios_base::internal) != 0; const bool internal = (fl & std::ios::internal) != 0;
const bool two_stepped_padding = internal const bool two_stepped_padding = internal
&& ! ( specs.pad_scheme_ & format_item_t::spacepad ) && ! ( specs.pad_scheme_ & format_item_t::spacepad )
&& specs.truncate_ < 0 ; && specs.truncate_ < 0 ;
@ -203,8 +202,8 @@ void put( T x,
template< class Ch, class Tr, class T> template<class T>
void distribute(basic_format<Ch,Tr>& self, T x) void distribute(basic_format& self, T x)
// call put(x, ..) on every occurence of the current argument : // call put(x, ..) on every occurence of the current argument :
{ {
if(self.cur_arg_ >= self.num_args_) if(self.cur_arg_ >= self.num_args_)
@ -217,16 +216,16 @@ void distribute(basic_format<Ch,Tr>& self, T x)
{ {
if(self.items_[i].argN_ == self.cur_arg_) if(self.items_[i].argN_ == self.cur_arg_)
{ {
put<Ch, Tr, T> (x, self.items_[i], self.items_[i].res_, self.oss_ ); put<T> (x, self.items_[i], self.items_[i].res_, self.oss_ );
} }
} }
} }
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& feed(basic_format<Ch,Tr>& self, T x) basic_format& feed(basic_format& self, T x)
{ {
if(self.dumped_) self.clear(); if(self.dumped_) self.clear();
distribute<Ch, Tr, T> (self, x); distribute<T> (self, x);
++self.cur_arg_; ++self.cur_arg_;
if(self.bound_.size() != 0) if(self.bound_.size() != 0)
{ {

View file

@ -30,26 +30,21 @@
namespace boost { namespace boost {
template<class Ch, class Tr>
class basic_format class basic_format
{ {
public: public:
typedef Ch CharT; // those 2 are necessary for borland compatibilty, typedef std::string string_t;
typedef Tr Traits; // in the body of the operator% template. typedef BOOST_IO_STD ostringstream internal_stream_t;
typedef std::basic_string<Ch, Tr> string_t;
typedef BOOST_IO_STD basic_ostringstream<Ch, Tr> internal_stream_t;
private: private:
typedef BOOST_IO_STD basic_ostream<Ch, Tr> stream_t; typedef BOOST_IO_STD ostream stream_t;
typedef io::detail::stream_format_state<Ch, Tr> stream_format_state; typedef io::detail::stream_format_state stream_format_state;
typedef io::detail::format_item<Ch, Tr> format_item_t; typedef io::detail::format_item format_item_t;
public: public:
basic_format(const Ch* str); basic_format(const char* str);
basic_format(const string_t& s); basic_format(const string_t& s);
#ifndef BOOST_NO_STD_LOCALE #ifndef BOOST_NO_STD_LOCALE
basic_format(const Ch* str, const std::locale & loc); basic_format(const char* str, const std::locale & loc);
basic_format(const string_t& s, const std::locale & loc); basic_format(const string_t& s, const std::locale & loc);
#endif // no locale #endif // no locale
basic_format(const basic_format& x); basic_format(const basic_format& x);
@ -60,13 +55,13 @@ public:
// pass arguments through those operators : // pass arguments through those operators :
template<class T> basic_format& operator%(const T& x) template<class T> basic_format& operator%(const T& x)
{ {
return io::detail::feed<CharT, Traits, const T&>(*this,x); return io::detail::feed<const T&>(*this,x);
} }
#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
template<class T> basic_format& operator%(T& x) template<class T> basic_format& operator%(T& x)
{ {
return io::detail::feed<CharT, Traits, T&>(*this,x); return io::detail::feed<T&>(*this,x);
} }
#endif #endif
@ -93,21 +88,21 @@ public:
// final output // final output
string_t str() const; string_t str() const;
friend BOOST_IO_STD basic_ostream<Ch, Tr>& friend BOOST_IO_STD ostream&
operator<< <Ch, Tr> ( BOOST_IO_STD basic_ostream<Ch, Tr>& , const basic_format& ); operator<< ( BOOST_IO_STD ostream& , const basic_format& );
template<class Ch2, class Tr2, class T> friend basic_format<Ch2, Tr2>& template<class T> friend basic_format&
io::detail::feed(basic_format<Ch2,Tr2>&, T); io::detail::feed(basic_format&, T);
template<class Ch2, class Tr2, class T> friend template<class T> friend
void io::detail::distribute(basic_format<Ch2,Tr2>&, T); void io::detail::distribute(basic_format&, T);
template<class Ch2, class Tr2, class T> friend template<class T> friend
basic_format<Ch2, Tr2>& io::detail::modify_item_body(basic_format<Ch2, Tr2>&, int, const T&); basic_format& io::detail::modify_item_body(basic_format&, int, const T&);
template<class Ch2, class Tr2, class T> friend template<class T> friend
basic_format<Ch2, Tr2>& io::detail::bind_arg_body(basic_format<Ch2, Tr2>&, int, const T&); basic_format& io::detail::bind_arg_body(basic_format&, int, const T&);
// make the members private only if the friend templates are supported // make the members private only if the friend templates are supported
private: private:

View file

@ -24,13 +24,9 @@
namespace boost { namespace boost {
template<class charT, class Traits = BOOST_IO_STD char_traits<charT> > class basic_format; class basic_format;
typedef basic_format<char > format; typedef basic_format format;
#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF)
typedef basic_format<wchar_t > wformat;
#endif
namespace io { namespace io {
enum format_error_bits { bad_format_string_bit = 1, enum format_error_bits { bad_format_string_bit = 1,
@ -39,15 +35,13 @@ enum format_error_bits { bad_format_string_bit = 1,
all_error_bits = 255, no_error_bits=0 }; all_error_bits = 255, no_error_bits=0 };
// Convertion: format to string // Convertion: format to string
template<class Ch, class Tr> std::string str(const basic_format& ) ;
std::basic_string<Ch, Tr> str(const basic_format<Ch, Tr>& ) ;
} // namespace io } // namespace io
template< class Ch, class Tr> BOOST_IO_STD ostream&
BOOST_IO_STD basic_ostream<Ch, Tr>& operator<<( BOOST_IO_STD ostream&, const basic_format&);
operator<<( BOOST_IO_STD basic_ostream<Ch, Tr>&, const basic_format<Ch, Tr>&);
} // namespace boost } // namespace boost

View file

@ -22,13 +22,12 @@
//#include <boost/throw_exception.hpp> //#include <boost/throw_exception.hpp>
//#include <boost/assert.hpp> //#include <boost/assert.hpp>
#include <boost/format/format_class.hpp> #include <boost/format.hpp>
namespace boost { namespace boost {
// -------- format:: ------------------------------------------- // -------- format:: -------------------------------------------
template< class Ch, class Tr> basic_format::basic_format(const char* str)
basic_format<Ch, Tr> ::basic_format(const Ch* str)
: style_(0), cur_arg_(0), num_args_(0), dumped_(false), : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
items_(), oss_(), exceptions_(io::all_error_bits) items_(), oss_(), exceptions_(io::all_error_bits)
{ {
@ -39,8 +38,7 @@ basic_format<Ch, Tr> ::basic_format(const Ch* str)
} }
#ifndef BOOST_NO_STD_LOCALE #ifndef BOOST_NO_STD_LOCALE
template< class Ch, class Tr> basic_format::basic_format(const char* str, const std::locale & loc)
basic_format<Ch, Tr> ::basic_format(const Ch* str, const std::locale & loc)
: style_(0), cur_arg_(0), num_args_(0), dumped_(false), : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
items_(), oss_(), exceptions_(io::all_error_bits) items_(), oss_(), exceptions_(io::all_error_bits)
{ {
@ -51,8 +49,7 @@ basic_format<Ch, Tr> ::basic_format(const Ch* str, const std::locale & loc)
parse( str ); parse( str );
} }
template< class Ch, class Tr> basic_format::basic_format(const string_t& s, const std::locale & loc)
basic_format<Ch, Tr> ::basic_format(const string_t& s, const std::locale & loc)
: style_(0), cur_arg_(0), num_args_(0), dumped_(false), : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
items_(), oss_(), exceptions_(io::all_error_bits) items_(), oss_(), exceptions_(io::all_error_bits)
{ {
@ -62,8 +59,7 @@ basic_format<Ch, Tr> ::basic_format(const string_t& s, const std::locale & loc)
} }
#endif //BOOST_NO_STD_LOCALE #endif //BOOST_NO_STD_LOCALE
template< class Ch, class Tr> basic_format::basic_format(const string_t& s)
basic_format<Ch, Tr> ::basic_format(const string_t& s)
: style_(0), cur_arg_(0), num_args_(0), dumped_(false), : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
items_(), oss_(), exceptions_(io::all_error_bits) items_(), oss_(), exceptions_(io::all_error_bits)
{ {
@ -71,8 +67,7 @@ basic_format<Ch, Tr> ::basic_format(const string_t& s)
parse(s); parse(s);
} }
template< class Ch, class Tr> basic_format:: basic_format(const basic_format& x)
basic_format<Ch, Tr> :: basic_format(const basic_format& x)
: style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false), : style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false),
items_(x.items_), prefix_(x.prefix_), bound_(x.bound_), items_(x.items_), prefix_(x.prefix_), bound_(x.bound_),
oss_(), // <- we obviously can't copy x.oss_ oss_(), // <- we obviously can't copy x.oss_
@ -81,8 +76,7 @@ basic_format<Ch, Tr> :: basic_format(const basic_format& x)
state0_.apply_on(oss_); state0_.apply_on(oss_);
} }
template< class Ch, class Tr> basic_format& basic_format::operator= (const basic_format& x)
basic_format<Ch, Tr>& basic_format<Ch, Tr> ::operator= (const basic_format& x)
{ {
if(this == &x) if(this == &x)
return *this; return *this;
@ -102,14 +96,12 @@ basic_format<Ch, Tr>& basic_format<Ch, Tr> ::operator= (const basic_format& x)
} }
template< class Ch, class Tr> unsigned char basic_format::exceptions() const
unsigned char basic_format<Ch,Tr> ::exceptions() const
{ {
return exceptions_; return exceptions_;
} }
template< class Ch, class Tr> unsigned char basic_format::exceptions(unsigned char newexcept)
unsigned char basic_format<Ch,Tr> ::exceptions(unsigned char newexcept)
{ {
unsigned char swp = exceptions_; unsigned char swp = exceptions_;
exceptions_ = newexcept; exceptions_ = newexcept;
@ -117,8 +109,7 @@ unsigned char basic_format<Ch,Tr> ::exceptions(unsigned char newexcept)
} }
template< class Ch, class Tr> basic_format& basic_format ::clear()
basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear()
// empty the string buffers (except bound arguments, see clear_binds() ) // empty the string buffers (except bound arguments, see clear_binds() )
// and make the format object ready for formatting a new set of arguments // and make the format object ready for formatting a new set of arguments
{ {
@ -138,8 +129,7 @@ basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear()
return *this; return *this;
} }
template< class Ch, class Tr> basic_format& basic_format ::clear_binds()
basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear_binds()
// cancel all bindings, and clear() // cancel all bindings, and clear()
{ {
bound_.resize(0); bound_.resize(0);
@ -147,8 +137,7 @@ basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear_binds()
return *this; return *this;
} }
template< class Ch, class Tr> basic_format& basic_format::clear_bind(int argN)
basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear_bind(int argN)
// cancel the binding of ONE argument, and clear() // cancel the binding of ONE argument, and clear()
{ {
if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] )
@ -164,8 +153,7 @@ basic_format<Ch,Tr>& basic_format<Ch,Tr> ::clear_bind(int argN)
template< class Ch, class Tr> std::string basic_format::str() const
std::basic_string<Ch,Tr> basic_format<Ch,Tr> ::str() const
{ {
dumped_=true; dumped_=true;
if(items_.size()==0) if(items_.size()==0)
@ -201,8 +189,8 @@ std::basic_string<Ch,Tr> basic_format<Ch,Tr> ::str() const
namespace io { namespace io {
namespace detail { namespace detail {
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& bind_arg_body( basic_format<Ch, Tr>& self, basic_format& bind_arg_body( basic_format& self,
int argN, int argN,
const T& val) const T& val)
// bind one argument to a fixed value // bind one argument to a fixed value
@ -239,8 +227,8 @@ basic_format<Ch, Tr>& bind_arg_body( basic_format<Ch, Tr>& self,
return self; return self;
} }
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& modify_item_body( basic_format<Ch, Tr>& self, basic_format& modify_item_body( basic_format& self,
int itemN, int itemN,
const T& manipulator) const T& manipulator)
// applies a manipulator to the format_item describing a given directive. // applies a manipulator to the format_item describing a given directive.

View file

@ -19,27 +19,26 @@
#ifndef BOOST_FORMAT_FUNCS_HPP #ifndef BOOST_FORMAT_FUNCS_HPP
#define BOOST_FORMAT_FUNCS_HPP #define BOOST_FORMAT_FUNCS_HPP
#include "boost/format/format_class.hpp" #include "boost/format.hpp"
//#include "boost/throw_exception.hpp" //#include "boost/throw_exception.hpp"
namespace boost { namespace boost {
namespace io { namespace io {
template<class Ch, class Tr> inline inline
std::basic_string<Ch, Tr> str(const basic_format<Ch, Tr>& f) std::string str(const basic_format& f)
// adds up all pieces of strings and converted items, and return the formatted string // adds up all pieces of strings and converted items, and return the formatted string
{ {
return f.str(); return f.str();
} }
} // - namespace io } // - namespace io
template< class Ch, class Tr> BOOST_IO_STD ostream&
BOOST_IO_STD basic_ostream<Ch, Tr>& operator<<( BOOST_IO_STD ostream& os,
operator<<( BOOST_IO_STD basic_ostream<Ch, Tr>& os, const boost::basic_format& f)
const boost::basic_format<Ch, Tr>& f)
// effect: "return os << str(f);" but we can try to do it faster // effect: "return os << str(f);" but we can try to do it faster
{ {
typedef boost::basic_format<Ch, Tr> format_t; typedef boost::basic_format format_t;
if(f.items_.size()==0) if(f.items_.size()==0)
os << f.prefix_; os << f.prefix_;
else { else {
@ -53,7 +52,7 @@ operator<<( BOOST_IO_STD basic_ostream<Ch, Tr>& os,
os << f.prefix_; os << f.prefix_;
for(unsigned long i=0; i<f.items_.size(); ++i) for(unsigned long i=0; i<f.items_.size(); ++i)
{ {
const typename format_t::format_item_t& item = f.items_[i]; const format_t::format_item_t& item = f.items_[i];
os << item.res_; os << item.res_;
os << item.appendix_; os << item.appendix_;

View file

@ -45,8 +45,8 @@ struct group0
template <class Ch, class Tr> template <class Ch, class Tr>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << ( BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << ( BOOST_IO_STD ostream& os,
const group0& ) const group0& )
{ {
return os; return os;
@ -63,8 +63,8 @@ struct group1
template <class Ch, class Tr, class T1> template <class Ch, class Tr, class T1>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group1<T1>& x) const group1<T1>& x)
{ {
os << x.a1_; os << x.a1_;
@ -86,8 +86,8 @@ struct group2
template <class Ch, class Tr, class T1,class T2> template <class Ch, class Tr, class T1,class T2>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group2<T1,T2>& x) const group2<T1,T2>& x)
{ {
os << x.a1_<< x.a2_; os << x.a1_<< x.a2_;
@ -107,8 +107,8 @@ struct group3
template <class Ch, class Tr, class T1,class T2,class T3> template <class Ch, class Tr, class T1,class T2,class T3>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group3<T1,T2,T3>& x) const group3<T1,T2,T3>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_; os << x.a1_<< x.a2_<< x.a3_;
@ -129,8 +129,8 @@ struct group4
template <class Ch, class Tr, class T1,class T2,class T3,class T4> template <class Ch, class Tr, class T1,class T2,class T3,class T4>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group4<T1,T2,T3,T4>& x) const group4<T1,T2,T3,T4>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_;
@ -152,8 +152,8 @@ struct group5
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group5<T1,T2,T3,T4,T5>& x) const group5<T1,T2,T3,T4,T5>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_;
@ -176,8 +176,8 @@ struct group6
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group6<T1,T2,T3,T4,T5,T6>& x) const group6<T1,T2,T3,T4,T5,T6>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_;
@ -201,8 +201,8 @@ struct group7
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group7<T1,T2,T3,T4,T5,T6,T7>& x) const group7<T1,T2,T3,T4,T5,T6,T7>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_;
@ -227,8 +227,8 @@ struct group8
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group8<T1,T2,T3,T4,T5,T6,T7,T8>& x) const group8<T1,T2,T3,T4,T5,T6,T7,T8>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_;
@ -254,8 +254,8 @@ struct group9
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group9<T1,T2,T3,T4,T5,T6,T7,T8,T9>& x) const group9<T1,T2,T3,T4,T5,T6,T7,T8,T9>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_;
@ -282,8 +282,8 @@ struct group10
template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10>
inline inline
BOOST_IO_STD basic_ostream<Ch, Tr>& BOOST_IO_STD ostream&
operator << (BOOST_IO_STD basic_ostream<Ch, Tr>& os, operator << (BOOST_IO_STD ostream& os,
const group10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>& x) const group10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>& x)
{ {
os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_<< x.a10_; os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_<< x.a10_;

View file

@ -33,22 +33,21 @@ namespace detail {
// -------------- // --------------
// set of params that define the format state of a stream // set of params that define the format state of a stream
template<class Ch, class Tr>
struct stream_format_state struct stream_format_state
{ {
typedef BOOST_IO_STD basic_ios<Ch, Tr> basic_ios; typedef std::ios basic_ios;
std::streamsize width_; std::streamsize width_;
std::streamsize precision_; std::streamsize precision_;
Ch fill_; char fill_;
std::ios_base::fmtflags flags_; std::ios::fmtflags flags_;
stream_format_state() : width_(-1), precision_(-1), fill_(0), flags_(std::ios_base::dec) {} stream_format_state() : width_(-1), precision_(-1), fill_(0), flags_(std::ios::dec) {}
stream_format_state(basic_ios& os) {set_by_stream(os); } stream_format_state(basic_ios& os) {set_by_stream(os); }
void apply_on(basic_ios & os) const; //- applies format_state to the stream void apply_on(basic_ios & os) const; //- applies format_state to the stream
template<class T> void apply_manip(T manipulator) //- modifies state by applying manipulator. template<class T> void apply_manip(T manipulator) //- modifies state by applying manipulator.
{ apply_manip_body<Ch, Tr, T>( *this, manipulator) ; } { apply_manip_body<T>( *this, manipulator) ; }
void reset(); //- sets to default state. void reset(); //- sets to default state.
void set_by_stream(const basic_ios& os); //- sets to os's state. void set_by_stream(const basic_ios& os); //- sets to os's state.
}; };
@ -58,7 +57,6 @@ struct stream_format_state
// -------------- // --------------
// format_item : stores all parameters that can be defined by directives in the format-string // format_item : stores all parameters that can be defined by directives in the format-string
template<class Ch, class Tr>
struct format_item struct format_item
{ {
enum pad_values { zeropad = 1, spacepad =2, centered=4, tabulation = 8 }; enum pad_values { zeropad = 1, spacepad =2, centered=4, tabulation = 8 };
@ -67,10 +65,10 @@ struct format_item
argN_tabulation = -2, // tabulation directive. (no argument read) argN_tabulation = -2, // tabulation directive. (no argument read)
argN_ignored = -3 // ignored directive. (no argument read) argN_ignored = -3 // ignored directive. (no argument read)
}; };
typedef BOOST_IO_STD basic_ios<Ch, Tr> basic_ios; typedef BOOST_IO_STD ios basic_ios;
typedef detail::stream_format_state<Ch, Tr> stream_format_state; typedef detail::stream_format_state stream_format_state;
typedef std::basic_string<Ch, Tr> string_t; typedef std::string string_t;
typedef BOOST_IO_STD basic_ostringstream<Ch, Tr> internal_stream_t; typedef BOOST_IO_STD ostringstream internal_stream_t;
int argN_; //- argument number (starts at 0, eg : %1 => argN=0) int argN_; //- argument number (starts at 0, eg : %1 => argN=0)
@ -98,8 +96,8 @@ struct format_item
// ----------------------------------------------------------- // -----------------------------------------------------------
// --- stream_format_state:: ------------------------------------------- // --- stream_format_state:: -------------------------------------------
template<class Ch, class Tr> inline inline
void stream_format_state<Ch,Tr> ::apply_on(basic_ios & os) const void stream_format_state::apply_on(basic_ios & os) const
// set the state of this stream according to our params // set the state of this stream according to our params
{ {
if(width_ != -1) if(width_ != -1)
@ -111,8 +109,8 @@ void stream_format_state<Ch,Tr> ::apply_on(basic_ios & os) const
os.flags(flags_); os.flags(flags_);
} }
template<class Ch, class Tr> inline inline
void stream_format_state<Ch,Tr> ::set_by_stream(const basic_ios& os) void stream_format_state::set_by_stream(const basic_ios& os)
// set our params according to the state of this stream // set our params according to the state of this stream
{ {
flags_ = os.flags(); flags_ = os.flags();
@ -121,42 +119,42 @@ void stream_format_state<Ch,Tr> ::set_by_stream(const basic_ios& os)
fill_ = os.fill(); fill_ = os.fill();
} }
template<class Ch, class Tr, class T> inline template<class T> inline
void apply_manip_body( stream_format_state<Ch, Tr>& self, void apply_manip_body( stream_format_state& self,
T manipulator) T manipulator)
// modify our params according to the manipulator // modify our params according to the manipulator
{ {
BOOST_IO_STD basic_stringstream<Ch, Tr> ss; BOOST_IO_STD stringstream ss;
self.apply_on( ss ); self.apply_on( ss );
ss << manipulator; ss << manipulator;
self.set_by_stream( ss ); self.set_by_stream( ss );
} }
template<class Ch, class Tr> inline inline
void stream_format_state<Ch,Tr> ::reset() void stream_format_state::reset()
// set our params to standard's default state // set our params to standard's default state
{ {
width_=-1; precision_=-1; fill_=0; width_=-1; precision_=-1; fill_=0;
flags_ = std::ios_base::dec; flags_ = std::ios::dec;
} }
// --- format_items:: ------------------------------------------- // --- format_items:: -------------------------------------------
template<class Ch, class Tr> inline inline
void format_item<Ch, Tr> ::compute_states() void format_item::compute_states()
// reflect pad_scheme_ on state_ and ref_state_ // reflect pad_scheme_ on state_ and ref_state_
// because some pad_schemes has complex consequences on several state params. // because some pad_schemes has complex consequences on several state params.
{ {
if(pad_scheme_ & zeropad) if(pad_scheme_ & zeropad)
{ {
if(ref_state_.flags_ & std::ios_base::left) if(ref_state_.flags_ & std::ios::left)
{ {
pad_scheme_ = pad_scheme_ & (~zeropad); // ignore zeropad in left alignment pad_scheme_ = pad_scheme_ & (~zeropad); // ignore zeropad in left alignment
} }
else else
{ {
ref_state_.fill_='0'; ref_state_.fill_='0';
ref_state_.flags_ |= std::ios_base::internal; ref_state_.flags_ |= std::ios::internal;
} }
} }
state_ = ref_state_; state_ = ref_state_;

View file

@ -26,8 +26,8 @@ namespace boost {
namespace io { namespace io {
namespace detail { namespace detail {
template<class Ch, class Tr> struct stream_format_state; struct stream_format_state;
template<class Ch, class Tr> struct format_item; struct format_item;
} }
@ -37,24 +37,24 @@ namespace detail {
// but MSVC have problems with template member functions : // but MSVC have problems with template member functions :
// defined in format_implementation.hpp : // defined in format_implementation.hpp :
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& modify_item_body( basic_format<Ch, Tr>& self, basic_format& modify_item_body( basic_format& self,
int itemN, const T& manipulator); int itemN, const T& manipulator);
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& bind_arg_body( basic_format<Ch, Tr>& self, basic_format& bind_arg_body( basic_format& self,
int argN, const T& val); int argN, const T& val);
template<class Ch, class Tr, class T> template<class T>
void apply_manip_body( stream_format_state<Ch, Tr>& self, void apply_manip_body( stream_format_state& self,
T manipulator); T manipulator);
// argument feeding (defined in feed_args.hpp ) : // argument feeding (defined in feed_args.hpp ) :
template<class Ch, class Tr, class T> template<class T>
void distribute(basic_format<Ch,Tr>& self, T x); void distribute(basic_format& self, T x);
template<class Ch, class Tr, class T> template<class T>
basic_format<Ch, Tr>& feed(basic_format<Ch,Tr>& self, T x); basic_format& feed(basic_format& self, T x);
} // namespace detail } // namespace detail

View file

@ -22,7 +22,7 @@
#define BOOST_FORMAT_PARSING_HPP #define BOOST_FORMAT_PARSING_HPP
#include <boost/format/format_class.hpp> #include <boost/format.hpp>
//#include <boost/throw_exception.hpp> //#include <boost/throw_exception.hpp>
//#include <boost/assert.hpp> //#include <boost/assert.hpp>
@ -31,8 +31,8 @@ namespace boost {
namespace io { namespace io {
namespace detail { namespace detail {
template<class Ch, class Stream> inline template<class Stream> inline
bool wrap_isdigit(Ch c, Stream &os) bool wrap_isdigit(char c, Stream &os)
{ {
#ifndef BOOST_NO_LOCALE_ISIDIGIT #ifndef BOOST_NO_LOCALE_ISIDIGIT
return std::isdigit(c, os.rdbuf()->getloc() ); return std::isdigit(c, os.rdbuf()->getloc() );
@ -42,10 +42,10 @@ namespace detail {
#endif #endif
} //end- wrap_isdigit(..) } //end- wrap_isdigit(..)
template<class Res, class Ch, class Tr> inline template<class Res> inline
Res str2int(const std::basic_string<Ch, Tr>& s, Res str2int(const std::string& s,
typename std::basic_string<Ch, Tr>::size_type start, std::string::size_type start,
BOOST_IO_STD basic_ios<Ch,Tr> &os, BOOST_IO_STD ios &os,
const Res = Res(0) ) const Res = Res(0) )
// Input : char string, with starting index // Input : char string, with starting index
// a basic_ios& merely to call its widen/narrow member function in the desired locale. // a basic_ios& merely to call its widen/narrow member function in the desired locale.
@ -54,7 +54,7 @@ namespace detail {
{ {
Res n = 0; Res n = 0;
while(start<s.size() && wrap_isdigit(s[start], os) ) { while(start<s.size() && wrap_isdigit(s[start], os) ) {
char cur_ch = os.narrow( s[start], 0); char cur_ch = s[start];
BOOST_ASSERT(cur_ch != 0 ); // since we called isdigit, this should not happen. BOOST_ASSERT(cur_ch != 0 ); // since we called isdigit, this should not happen.
n *= 10; n *= 10;
n += cur_ch - '0'; // 22.2.1.1.2 of the C++ standard n += cur_ch - '0'; // 22.2.1.1.2 of the C++ standard
@ -63,10 +63,9 @@ namespace detail {
return n; return n;
} }
template<class Ch, class Tr> void skip_asterisk(const std::string & buf,
void skip_asterisk(const std::basic_string<Ch,Tr> & buf, std::string::size_type * pos_p,
typename std::basic_string<Ch,Tr>::size_type * pos_p, BOOST_IO_STD ios &os)
BOOST_IO_STD basic_ios<Ch, Tr> &os)
// skip printf's "asterisk-fields" directives in the format-string buf // skip printf's "asterisk-fields" directives in the format-string buf
// Input : char string, with starting index *pos_p // Input : char string, with starting index *pos_p
// a basic_ios& merely to call its widen/narrow member function in the desired locale. // a basic_ios& merely to call its widen/narrow member function in the desired locale.
@ -76,10 +75,10 @@ namespace detail {
using namespace std; using namespace std;
BOOST_ASSERT( pos_p != 0); BOOST_ASSERT( pos_p != 0);
if(*pos_p >= buf.size() ) return; if(*pos_p >= buf.size() ) return;
if(buf[ *pos_p]==os.widen('*')) { if(buf[ *pos_p]=='*') {
++ (*pos_p); ++ (*pos_p);
while (*pos_p < buf.size() && wrap_isdigit(buf[*pos_p],os)) ++(*pos_p); while (*pos_p < buf.size() && wrap_isdigit(buf[*pos_p],os)) ++(*pos_p);
if(buf[*pos_p]==os.widen('$')) ++(*pos_p); if(buf[*pos_p]=='$') ++(*pos_p);
} }
} }
@ -95,11 +94,10 @@ namespace detail {
template<class Ch, class Tr> bool parse_printf_directive(const std::string & buf,
bool parse_printf_directive(const std::basic_string<Ch, Tr> & buf, std::string::size_type * pos_p,
typename std::basic_string<Ch, Tr>::size_type * pos_p, detail::format_item * fpar,
detail::format_item<Ch, Tr> * fpar, BOOST_IO_STD ios &os,
BOOST_IO_STD basic_ios<Ch,Tr> &os,
unsigned char exceptions) unsigned char exceptions)
// Input : a 'printf-directive' in the format-string, starting at buf[ *pos_p ] // Input : a 'printf-directive' in the format-string, starting at buf[ *pos_p ]
// a basic_ios& merely to call its widen/narrow member function in the desired locale. // a basic_ios& merely to call its widen/narrow member function in the desired locale.
@ -109,14 +107,14 @@ namespace detail {
// Effects : - *pos_p is incremented so that buf[*pos_p] is the first char after the directive // Effects : - *pos_p is incremented so that buf[*pos_p] is the first char after the directive
// - *fpar is set with the parameters read in the directive // - *fpar is set with the parameters read in the directive
{ {
typedef format_item<Ch, Tr> format_item_t; typedef format_item format_item_t;
BOOST_ASSERT( pos_p != 0); BOOST_ASSERT( pos_p != 0);
typename std::basic_string<Ch, Tr>::size_type &i1 = *pos_p, std::string::size_type &i1 = *pos_p,
i0; i0;
fpar->argN_ = format_item_t::argN_no_posit; // if no positional-directive fpar->argN_ = format_item_t::argN_no_posit; // if no positional-directive
bool in_brackets=false; bool in_brackets=false;
if(buf[i1]==os.widen('|')) if(buf[i1]=='|')
{ {
in_brackets=true; in_brackets=true;
if( ++i1 >= buf.size() ) { if( ++i1 >= buf.size() ) {
@ -126,7 +124,7 @@ namespace detail {
} }
// the flag '0' would be picked as a digit for argument order, but here it's a flag : // the flag '0' would be picked as a digit for argument order, but here it's a flag :
if(buf[i1]==os.widen('0')) if(buf[i1]=='0')
goto parse_flags; goto parse_flags;
// handle argument order (%2$d) or possibly width specification: %2d // handle argument order (%2$d) or possibly width specification: %2d
@ -142,7 +140,7 @@ namespace detail {
int n=str2int(buf,i0, os, int(0) ); int n=str2int(buf,i0, os, int(0) );
// %N% case : this is already the end of the directive // %N% case : this is already the end of the directive
if( buf[i1] == os.widen('%') ) if( buf[i1] == '%' )
{ {
fpar->argN_ = n-1; fpar->argN_ = n-1;
++i1; ++i1;
@ -152,7 +150,7 @@ namespace detail {
else return true; else return true;
} }
if ( buf[i1]==os.widen('$') ) if ( buf[i1]=='$' )
{ {
fpar->argN_ = n-1; fpar->argN_ = n-1;
++i1; ++i1;
@ -171,14 +169,14 @@ namespace detail {
while ( i1 <buf.size()) // as long as char is one of + - = # 0 l h or ' ' while ( i1 <buf.size()) // as long as char is one of + - = # 0 l h or ' '
{ {
// misc switches // misc switches
switch (os.narrow(buf[i1], 0)) switch (buf[i1])
{ {
case '\'' : break; // no effect yet. (painful to implement) case '\'' : break; // no effect yet. (painful to implement)
case 'l': case 'l':
case 'h': // short/long modifier : for printf-comaptibility (no action needed) case 'h': // short/long modifier : for printf-comaptibility (no action needed)
break; break;
case '-': case '-':
fpar->ref_state_.flags_ |= std::ios_base::left; fpar->ref_state_.flags_ |= std::ios::left;
break; break;
case '=': case '=':
fpar->pad_scheme_ |= format_item_t::centered; fpar->pad_scheme_ |= format_item_t::centered;
@ -187,7 +185,7 @@ namespace detail {
fpar->pad_scheme_ |= format_item_t::spacepad; fpar->pad_scheme_ |= format_item_t::spacepad;
break; break;
case '+': case '+':
fpar->ref_state_.flags_ |= std::ios_base::showpos; fpar->ref_state_.flags_ |= std::ios::showpos;
break; break;
case '0': case '0':
fpar->pad_scheme_ |= format_item_t::zeropad; fpar->pad_scheme_ |= format_item_t::zeropad;
@ -195,7 +193,7 @@ namespace detail {
// so just add 'zeropad' flag for now, it will be processed later. // so just add 'zeropad' flag for now, it will be processed later.
break; break;
case '#': case '#':
fpar->ref_state_.flags_ |= std::ios_base::showpoint | std::ios_base::showbase; fpar->ref_state_.flags_ |= std::ios::showpoint | std::ios::showbase;
break; break;
default: default:
goto parse_width; goto parse_width;
@ -223,7 +221,7 @@ namespace detail {
return true; return true;
} }
// handle precision spec // handle precision spec
if (buf[i1]==os.widen('.')) if (buf[i1]=='.')
{ {
++i1; ++i1;
skip_asterisk(buf, &i1, os); skip_asterisk(buf, &i1, os);
@ -239,51 +237,51 @@ namespace detail {
// handle formatting-type flags : // handle formatting-type flags :
while( i1<buf.size() && while( i1<buf.size() &&
( buf[i1]==os.widen('l') || buf[i1]==os.widen('L') || buf[i1]==os.widen('h')) ) ( buf[i1]=='l' || buf[i1]=='L' || buf[i1]=='h') )
++i1; ++i1;
if( i1>=buf.size()) { if( i1>=buf.size()) {
maybe_throw_exception(exceptions); maybe_throw_exception(exceptions);
return true; return true;
} }
if( in_brackets && buf[i1]==os.widen('|') ) if( in_brackets && buf[i1]=='|' )
{ {
++i1; ++i1;
return true; return true;
} }
switch (os.narrow(buf[i1], 0) ) switch (buf[i1])
{ {
case 'X': case 'X':
fpar->ref_state_.flags_ |= std::ios_base::uppercase; fpar->ref_state_.flags_ |= std::ios::uppercase;
case 'p': // pointer => set hex. case 'p': // pointer => set hex.
case 'x': case 'x':
fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ &= ~std::ios::basefield;
fpar->ref_state_.flags_ |= std::ios_base::hex; fpar->ref_state_.flags_ |= std::ios::hex;
break; break;
case 'o': case 'o':
fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ &= ~std::ios::basefield;
fpar->ref_state_.flags_ |= std::ios_base::oct; fpar->ref_state_.flags_ |= std::ios::oct;
break; break;
case 'E': case 'E':
fpar->ref_state_.flags_ |= std::ios_base::uppercase; fpar->ref_state_.flags_ |= std::ios::uppercase;
case 'e': case 'e':
fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; fpar->ref_state_.flags_ &= ~std::ios::floatfield;
fpar->ref_state_.flags_ |= std::ios_base::scientific; fpar->ref_state_.flags_ |= std::ios::scientific;
fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ &= ~std::ios::basefield;
fpar->ref_state_.flags_ |= std::ios_base::dec; fpar->ref_state_.flags_ |= std::ios::dec;
break; break;
case 'f': case 'f':
fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; fpar->ref_state_.flags_ &= ~std::ios::floatfield;
fpar->ref_state_.flags_ |= std::ios_base::fixed; fpar->ref_state_.flags_ |= std::ios::fixed;
case 'u': case 'u':
case 'd': case 'd':
case 'i': case 'i':
fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ &= ~std::ios::basefield;
fpar->ref_state_.flags_ |= std::ios_base::dec; fpar->ref_state_.flags_ |= std::ios::dec;
break; break;
case 'T': case 'T':
@ -296,20 +294,20 @@ namespace detail {
fpar->argN_ = format_item_t::argN_tabulation; fpar->argN_ = format_item_t::argN_tabulation;
break; break;
case 't': case 't':
fpar->ref_state_.fill_ = os.widen(' '); fpar->ref_state_.fill_ = ' ';
fpar->pad_scheme_ |= format_item_t::tabulation; fpar->pad_scheme_ |= format_item_t::tabulation;
fpar->argN_ = format_item_t::argN_tabulation; fpar->argN_ = format_item_t::argN_tabulation;
break; break;
case 'G': case 'G':
fpar->ref_state_.flags_ |= std::ios_base::uppercase; fpar->ref_state_.flags_ |= std::ios::uppercase;
break; break;
case 'g': // 'g' conversion is default for floats. case 'g': // 'g' conversion is default for floats.
fpar->ref_state_.flags_ &= ~std::ios_base::basefield; fpar->ref_state_.flags_ &= ~std::ios::basefield;
fpar->ref_state_.flags_ |= std::ios_base::dec; fpar->ref_state_.flags_ |= std::ios::dec;
// CLEAR all floatield flags, so stream will CHOOSE // CLEAR all floatield flags, so stream will CHOOSE
fpar->ref_state_.flags_ &= ~std::ios_base::floatfield; fpar->ref_state_.flags_ &= ~std::ios::floatfield;
break; break;
case 'C': case 'C':
@ -331,7 +329,7 @@ namespace detail {
if( in_brackets ) if( in_brackets )
{ {
if( i1<buf.size() && buf[i1]==os.widen('|') ) if( i1<buf.size() && buf[i1]=='|' )
{ {
++i1; ++i1;
return true; return true;
@ -348,15 +346,14 @@ namespace detail {
// ----------------------------------------------- // -----------------------------------------------
// format :: parse(..) // format :: parse(..)
template<class Ch, class Traits> void basic_format::parse(const string_t & buf)
void basic_format<Ch, Traits> ::parse(const string_t & buf)
// parse the format-string // parse the format-string
{ {
using namespace std; using namespace std;
const Ch arg_mark = oss_.widen('%'); const char arg_mark = '%';
bool ordered_args=true; bool ordered_args=true;
int max_argN=-1; int max_argN=-1;
typename string_t::size_type i1=0; string_t::size_type i1=0;
int num_items=0; int num_items=0;
// A: find upper_bound on num_items and allocates arrays // A: find upper_bound on num_items and allocates arrays
@ -382,7 +379,7 @@ void basic_format<Ch, Traits> ::parse(const string_t & buf)
// B: Now the real parsing of the format string : // B: Now the real parsing of the format string :
num_items=0; num_items=0;
i1 = 0; i1 = 0;
typename string_t::size_type i0 = i1; string_t::size_type i0 = i1;
bool special_things=false; bool special_things=false;
int cur_it=0; int cur_it=0;
while( (i1=buf.find(arg_mark,i1)) != string::npos ) while( (i1=buf.find(arg_mark,i1)) != string::npos )

View file

@ -16,8 +16,12 @@ AC_PATH_PROG(wget, wget)
AC_CHECK_LIB(pthread, pthread_mutex_init) AC_CHECK_LIB(pthread, pthread_mutex_init)
AM_CONFIG_HEADER([config.h]) AM_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile externals/Makefile src/Makefile scripts/Makefile AC_CONFIG_FILES([Makefile
corepkgs/Makefile corepkgs/fetchurl/Makefile externals/Makefile
corepkgs/nar/Makefile boost/Makefile boost/format/Makefile
doc/Makefile doc/manual/Makefile]) src/Makefile
scripts/Makefile
corepkgs/Makefile corepkgs/fetchurl/Makefile corepkgs/nar/Makefile
doc/Makefile doc/manual/Makefile
])
AC_OUTPUT AC_OUTPUT

View file

@ -1,22 +1,24 @@
bin_PROGRAMS = nix nix-hash fix bin_PROGRAMS = nix nix-hash fix
check_PROGRAMS = test check_PROGRAMS = test
AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I.. -I../externals/inst/include $(CXXFLAGS) AM_CXXFLAGS = -DSYSTEM=\"@host@\" -Wall -I.. -I../externals/inst/include $(CXXFLAGS)
AM_LDFLAGS = -L../externals/inst/lib -ldb_cxx -lATerm $(LDFLAGS) LDADD = -L../externals/inst/lib -ldb_cxx -lATerm -L../boost/format -lformat
nix_SOURCES = nix.cc dotgraph.cc nix_SOURCES = nix.cc dotgraph.cc
nix_LDADD = libshared.a libnix.a -ldb_cxx -lATerm nix_LDADD = libshared.a libnix.a $(LDADD)
nix_hash_SOURCES = nix-hash.cc nix_hash_SOURCES = nix-hash.cc
nix_hash_LDADD = libshared.a libnix.a -ldb_cxx -lATerm nix_hash_LDADD = libshared.a libnix.a $(LDADD)
fix_SOURCES = fix.cc fix_SOURCES = fix.cc
fix_LDADD = libshared.a libnix.a -ldb_cxx -lATerm fix_LDADD = libshared.a libnix.a $(LDADD)
TESTS = test TESTS = test
test_SOURCES = test.cc test_SOURCES = test.cc
test_LDADD = libshared.a libnix.a -ldb_cxx -lATerm test_LDADD = libshared.a libnix.a $(LDADD)
noinst_LIBRARIES = libnix.a libshared.a noinst_LIBRARIES = libnix.a libshared.a