summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--local.mk2
-rw-r--r--release.nix5
-rw-r--r--shell.nix3
-rw-r--r--src/boost/assert.hpp38
-rw-r--r--src/boost/format.hpp64
-rw-r--r--src/boost/format/exceptions.hpp96
-rw-r--r--src/boost/format/feed_args.hpp254
-rw-r--r--src/boost/format/format_class.hpp135
-rw-r--r--src/boost/format/format_fwd.hpp49
-rw-r--r--src/boost/format/format_implementation.cc256
-rw-r--r--src/boost/format/free_funcs.cc71
-rw-r--r--src/boost/format/group.hpp680
-rw-r--r--src/boost/format/internals.hpp167
-rw-r--r--src/boost/format/internals_fwd.hpp65
-rw-r--r--src/boost/format/local.mk7
-rw-r--r--src/boost/format/macros_default.hpp48
-rw-r--r--src/boost/format/parsing.cc454
-rw-r--r--src/boost/throw_exception.hpp47
-rw-r--r--src/libstore/build.cc6
-rw-r--r--src/libstore/sqlite.cc4
-rw-r--r--src/libstore/sqlite.hh2
-rw-r--r--tests/restricted.sh4
23 files changed, 13 insertions, 2445 deletions
diff --git a/Makefile b/Makefile
index c867823fc..c47603731 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
makefiles = \
local.mk \
- src/boost/format/local.mk \
src/libutil/local.mk \
src/libstore/local.mk \
src/libmain/local.mk \
diff --git a/local.mk b/local.mk
index 40a910991..5d7e0fb2e 100644
--- a/local.mk
+++ b/local.mk
@@ -10,5 +10,3 @@ GLOBAL_CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I
$(foreach i, config.h $(call rwildcard, src/lib*, *.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
-
-$(foreach i, $(call rwildcard, src/boost, *.hpp), $(eval $(call install-file-in, $(i), $(includedir)/nix/$(patsubst src/%/,%,$(dir $(i))), 0644)))
diff --git a/release.nix b/release.nix
index 0bbd966fa..2e9292955 100644
--- a/release.nix
+++ b/release.nix
@@ -1,5 +1,5 @@
{ nix ? builtins.fetchGit ./.
-, nixpkgs ? builtins.fetchGit https://github.com/NixOS/nixpkgs.git
+, nixpkgs ? builtins.fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-18.03"; }
, officialRelease ? false
, systems ? [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ]
}:
@@ -71,6 +71,7 @@ let
[ curl
bzip2 xz brotli
openssl pkgconfig sqlite boehmgc
+ boost
# Tests
git
@@ -192,7 +193,7 @@ let
doInstallCheck = true;
- lcovFilter = [ "*/boost/*" "*-tab.*" "*/nlohmann/*" "*/linenoise/*" ];
+ lcovFilter = [ "*-tab.*" "*/nlohmann/*" "*/linenoise/*" ];
# We call `dot', and even though we just use it to
# syntax-check generated dot files, it still requires some
diff --git a/shell.nix b/shell.nix
index d6ae5a552..09318dfd0 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,6 +1,6 @@
{ useClang ? false }:
-with import <nixpkgs> {};
+with import (builtins.fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-18.03"; }) {};
with import ./release-common.nix { inherit pkgs; };
@@ -18,6 +18,7 @@ with import ./release-common.nix { inherit pkgs; };
customMemoryManagement = false;
})
autoreconfHook
+ boost
# For nix-perl
perl
diff --git a/src/boost/assert.hpp b/src/boost/assert.hpp
deleted file mode 100644
index 754ebb954..000000000
--- a/src/boost/assert.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// boost/assert.hpp - BOOST_ASSERT(expr)
-//
-// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
-//
-// Permission to copy, use, modify, sell and distribute this software
-// is granted provided this copyright notice appears in all copies.
-// This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-//
-// Note: There are no include guards. This is intentional.
-//
-// See http://www.boost.org/libs/utility/assert.html for documentation.
-//
-
-#undef BOOST_ASSERT
-
-#if defined(BOOST_DISABLE_ASSERTS)
-
-# define BOOST_ASSERT(expr) ((void)0)
-
-#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
-
-#include <boost/current_function.hpp>
-
-namespace boost
-{
-
-void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
-
-} // namespace boost
-
-#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
-
-#else
-# include <assert.h>
-# define BOOST_ASSERT(expr) assert(expr)
-#endif
diff --git a/src/boost/format.hpp b/src/boost/format.hpp
deleted file mode 100644
index f965f0f33..000000000
--- a/src/boost/format.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// -*- C++ -*-
-// Boost general library 'format' ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream
-
-// ----------------------------------------------------------------------------
-// format.hpp : primary header
-// ----------------------------------------------------------------------------
-
-#ifndef BOOST_FORMAT_HPP
-#define BOOST_FORMAT_HPP
-
-#include <vector>
-#include <string>
-#include <sstream>
-#include <cassert>
-
-#if HAVE_LOCALE
-#include <locale>
-#else
-#define BOOST_NO_STD_LOCALE
-#define BOOST_NO_LOCALE_ISIDIGIT
-#include <cctype>
-#endif
-
-#include <boost/format/macros_default.hpp>
-
-
-// **** Forward declarations ----------------------------------
-#include <boost/format/format_fwd.hpp> // basic_format<Ch,Tr>, and other frontends
-#include <boost/format/internals_fwd.hpp> // misc forward declarations for internal use
-
-
-// **** Auxiliary structs (stream_format_state<Ch,Tr> , and format_item<Ch,Tr> )
-#include <boost/format/internals.hpp>
-
-// **** Format class interface --------------------------------
-#include <boost/format/format_class.hpp>
-
-// **** Exceptions -----------------------------------------------
-#include <boost/format/exceptions.hpp>
-
-// **** Implementation -------------------------------------------
-//#include <boost/format/format_implementation.hpp> // member functions
-
-#include <boost/format/group.hpp> // class for grouping arguments
-
-#include <boost/format/feed_args.hpp> // argument-feeding functions
-//#include <boost/format/parsing.hpp> // format-string parsing (member-)functions
-
-// **** Implementation of the free functions ----------------------
-//#include <boost/format/free_funcs.hpp>
-
-
-#endif // BOOST_FORMAT_HPP
diff --git a/src/boost/format/exceptions.hpp b/src/boost/format/exceptions.hpp
deleted file mode 100644
index a7641458c..000000000
--- a/src/boost/format/exceptions.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-// -*- C++ -*-
-// Boost general library 'format' ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream (also took its parsing code as basis for printf parsing)
-
-// ------------------------------------------------------------------------------
-// exceptions.hpp
-// ------------------------------------------------------------------------------
-
-
-#ifndef BOOST_FORMAT_EXCEPTIONS_HPP
-#define BOOST_FORMAT_EXCEPTIONS_HPP
-
-
-#include <stdexcept>
-
-
-namespace boost {
-
-namespace io {
-
-// **** exceptions -----------------------------------------------
-
-class format_error : public std::exception
-{
-public:
- format_error() { abort(); }
- virtual const char *what() const throw()
- {
- return "boost::format_error: "
- "format generic failure";
- }
-};
-
-class bad_format_string : public format_error
-{
-public:
- bad_format_string() { abort(); }
- virtual const char *what() const throw()
- {
- return "boost::bad_format_string: "
- "format-string is ill-formed";
- }
-};
-
-class too_few_args : public format_error
-{
-public:
- too_few_args() { abort(); }
- virtual const char *what() const throw()
- {
- return "boost::too_few_args: "
- "format-string refered to more arguments than were passed";
- }
-};
-
-class too_many_args : public format_error
-{
-public:
- too_many_args() { abort(); }
- virtual const char *what() const throw()
- {
- return "boost::too_many_args: "
- "format-string refered to less arguments than were passed";
- }
-};
-
-
-class out_of_range : public format_error
-{
-public:
- out_of_range() { abort(); }
- virtual const char *what() const throw()
- {
- return "boost::out_of_range: "
- "tried to refer to an argument (or item) number which is out of range, "
- "according to the format string.";
- }
-};
-
-
-} // namespace io
-
-} // namespace boost
-
-
-#endif // BOOST_FORMAT_EXCEPTIONS_HPP
diff --git a/src/boost/format/feed_args.hpp b/src/boost/format/feed_args.hpp
deleted file mode 100644
index cdd57fdf2..000000000
--- a/src/boost/format/feed_args.hpp
+++ /dev/null
@@ -1,254 +0,0 @@
-// -*- C++ -*-
-// Boost general library 'format' ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream
-
-// ----------------------------------------------------------------------------
-// feed_args.hpp : functions for processing each argument
-// (feed, feed_manip, and distribute)
-// ----------------------------------------------------------------------------
-
-
-#ifndef BOOST_FORMAT_FEED_ARGS_HPP
-#define BOOST_FORMAT_FEED_ARGS_HPP
-
-#include "boost/format/format_class.hpp"
-#include "boost/format/group.hpp"
-
-#include "boost/throw_exception.hpp"
-
-namespace boost {
-namespace io {
-namespace detail {
-namespace {
-
- inline
- void empty_buf(BOOST_IO_STD ostringstream & os) {
- static const std::string emptyStr;
- os.str(emptyStr);
- }
-
- void do_pad( std::string & s,
- std::streamsize w,
- const char c,
- std::ios::fmtflags f,
- bool center)
- __attribute__ ((unused));
-
- void do_pad( std::string & s,
- std::streamsize w,
- const char c,
- std::ios::fmtflags f,
- bool center)
- // applies centered / left / right padding to the string s.
- // Effects : string s is padded.
- {
- std::streamsize n=w-s.size();
- if(n<=0) {
- return;
- }
- if(center)
- {
- s.reserve(w); // allocate once for the 2 inserts
- const std::streamsize n1 = n /2, n0 = n - n1;
- s.insert(s.begin(), n0, c);
- s.append(n1, c);
- }
- else
- {
- if(f & std::ios::left) {
- s.append(n, c);
- }
- else {
- s.insert(s.begin(), n, c);
- }
- }
- } // -do_pad(..)
-
-
- template<class T> inline
- void put_head(BOOST_IO_STD ostream& , const T& ) {
- }
-
- template<class T> inline
- 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
- }
-
- template<class T> inline
- void put_last( BOOST_IO_STD ostream& os, const T& x ) {
- os << x ;
- }
-
- template<class T> inline
- void put_last( BOOST_IO_STD ostream& os, const group1<T>& x ) {
- os << group_last(x.a1_); // this selects the last element
- }
-
-#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
- template<class T> inline
- void put_head( BOOST_IO_STD ostream& , T& ) {
- }
-
- template<class T> inline
- void put_last( BOOST_IO_STD ostream& os, T& x ) {
- os << x ;
- }
-#endif
-
-
-
-
-template<class T>
-void put( T x,
- const format_item& specs,
- std::string & res,
- BOOST_IO_STD ostringstream& oss_ )
-{
- // does the actual conversion of x, with given params, into a string
- // using the *supplied* strinstream. (the stream state is important)
-
- typedef std::string string_t;
- typedef format_item format_item_t;
-
- stream_format_state prev_state(oss_);
-
- specs.state_.apply_on(oss_);
-
- // in case x is a group, apply the manip part of it,
- // in order to find width
- put_head( oss_, x );
- empty_buf( oss_);
-
- const std::streamsize w=oss_.width();
- const std::ios::fmtflags fl=oss_.flags();
- const bool internal = (fl & std::ios::internal) != 0;
- const bool two_stepped_padding = internal
- && ! ( specs.pad_scheme_ & format_item_t::spacepad )
- && specs.truncate_ < 0 ;
-
-
- if(! two_stepped_padding)
- {
- if(w>0) // handle simple padding via do_pad, not natively in stream
- oss_.width(0);
- put_last( oss_, x);
- res = oss_.str();
-
- if (specs.truncate_ >= 0)
- res.erase(specs.truncate_);
-
- // complex pads :
- if(specs.pad_scheme_ & format_item_t::spacepad)
- {
- if( res.size()==0 || ( res[0]!='+' && res[0]!='-' ))
- {
- res.insert(res.begin(), 1, ' '); // insert 1 space at pos 0
- }
- }
- if(w > 0) // need do_pad
- {
- do_pad(res,w,oss_.fill(), fl, (specs.pad_scheme_ & format_item_t::centered) !=0 );
- }
- }
- else // 2-stepped padding
- {
- put_last( oss_, x); // oss_.width() may result in padding.
- res = oss_.str();
-
- if (specs.truncate_ >= 0)
- res.erase(specs.truncate_);
-
- if( res.size() - w > 0)
- { // length w exceeded
- // either it was multi-output with first output padding up all width..
- // either it was one big arg and we are fine.
- empty_buf( oss_);
- oss_.width(0);
- put_last(oss_, x );
- string_t tmp = oss_.str(); // minimal-length output
- std::streamsize d;
- if( (d=w - tmp.size()) <=0 )
- {
- // minimal length is already >= w, so no padding (cool!)
- res.swap(tmp);
- }
- else
- { // hum.. we need to pad (it was necessarily multi-output)
- typedef typename string_t::size_type size_type;
- size_type i = 0;
- while( i<tmp.size() && tmp[i] == res[i] ) // find where we should pad.
- ++i;
- tmp.insert(i, static_cast<size_type>( d ), oss_.fill());
- res.swap( tmp );
- }
- }
- else
- { // okay, only one thing was printed and padded, so res is fine.
- }
- }
-
- prev_state.apply_on(oss_);
- empty_buf( oss_);
- oss_.clear();
-} // end- put(..)
-
-
-} // local namespace
-
-
-
-
-
-template<class T>
-void distribute(basic_format& self, T x)
- // call put(x, ..) on every occurence of the current argument :
-{
- if(self.cur_arg_ >= self.num_args_)
- {
- if( self.exceptions() & too_many_args_bit )
- boost::throw_exception(too_many_args()); // too many variables have been supplied !
- else return;
- }
- for(unsigned long i=0; i < self.items_.size(); ++i)
- {
- if(self.items_[i].argN_ == self.cur_arg_)
- {
- put<T> (x, self.items_[i], self.items_[i].res_, self.oss_ );
- }
- }
-}
-
-template<class T>
-basic_format& feed(basic_format& self, T x)
-{
- if(self.dumped_) self.clear();
- distribute<T> (self, x);
- ++self.cur_arg_;
- if(self.bound_.size() != 0)
- {
- while( self.cur_arg_ < self.num_args_ && self.bound_[self.cur_arg_] )
- ++self.cur_arg_;
- }
-
- // this arg is finished, reset the stream's format state
- self.state0_.apply_on(self.oss_);
- return self;
-}
-
-
-} // namespace detail
-} // namespace io
-} // namespace boost
-
-
-#endif // BOOST_FORMAT_FEED_ARGS_HPP
diff --git a/src/boost/format/format_class.hpp b/src/boost/format/format_class.hpp
deleted file mode 100644
index 6875623ac..000000000
--- a/src/boost/format/format_class.hpp
+++ /dev/null
@@ -1,135 +0,0 @@
-// -*- C++ -*-
-// Boost general library 'format' ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream (also took its parsing code as basis for printf parsing)
-
-// ------------------------------------------------------------------------------
-// format_class.hpp : class interface
-// ------------------------------------------------------------------------------
-
-
-#ifndef BOOST_FORMAT_CLASS_HPP
-#define BOOST_FORMAT_CLASS_HPP
-
-#include <vector>
-#include <string>
-
-#include <boost/format/format_fwd.hpp>
-#include <boost/format/internals_fwd.hpp>
-
-#include <boost/format/internals.hpp>
-
-namespace boost {
-
-class basic_format
-{
-public:
- typedef std::string string_t;
- typedef BOOST_IO_STD ostringstream internal_stream_t;
-private:
- typedef BOOST_IO_STD ostream stream_t;
- typedef io::detail::stream_format_state stream_format_state;
- typedef io::detail::format_item format_item_t;
-
-public:
- basic_format(const char* str);
- basic_format(const string_t& s);
-#ifndef BOOST_NO_STD_LOCALE
- basic_format(const char* str, const std::locale & loc);
- basic_format(const string_t& s, const std::locale & loc);
-#endif // no locale
- basic_format(const basic_format& x);
- basic_format& operator= (const basic_format& x);
-
- basic_format& clear(); // empty the string buffers (except bound arguments, see clear_binds() )
-
- // pass arguments through those operators :
- template<class T> basic_format& operator%(const T& x)
- {
- return io::detail::feed<const T&>(*this,x);
- }
-
-#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
- template<class T> basic_format& operator%(T& x)
- {
- return io::detail::feed<T&>(*this,x);
- }
-#endif
-
-
- // system for binding arguments :
- template<class T>
- basic_format& bind_arg(int argN, const T& val)
- {
- return io::detail::bind_arg_body(*this, argN, val);
- }
- basic_format& clear_bind(int argN);
- basic_format& clear_binds();
-
- // modify the params of a directive, by applying a manipulator :
- template<class T>
- basic_format& modify_item(int itemN, const T& manipulator)
- {
- return io::detail::modify_item_body(*this, itemN, manipulator) ;
- }
-
- // Choosing which errors will throw exceptions :
- unsigned char exceptions() const;
- unsigned char exceptions(unsigned char newexcept);
-
- // final output
- string_t str() const;
- friend BOOST_IO_STD ostream&
- operator<< ( BOOST_IO_STD ostream& , const basic_format& );
-
-
- template<class T> friend basic_format&
- io::detail::feed(basic_format&, T);
-
- template<class T> friend
- void io::detail::distribute(basic_format&, T);
-
- template<class T> friend
- basic_format& io::detail::modify_item_body(basic_format&, int, const T&);
-
- template<class T> friend
- basic_format& io::detail::bind_arg_body(basic_format&, int, const T&);
-
-// make the members private only if the friend templates are supported
-private:
-
- // flag bits, used for style_
- enum style_values { ordered = 1, // set only if all directives are positional directives
- special_needs = 4 };
-
- // parse the format string :
- void parse(const string_t&);
-
- int style_; // style of format-string : positional or not, etc
- int cur_arg_; // keep track of wich argument will come
- int num_args_; // number of expected arguments
- mutable bool dumped_; // true only after call to str() or <<
- std::vector<format_item_t> items_; // vector of directives (aka items)
- string_t prefix_; // piece of string to insert before first item
-
- std::vector<bool> bound_; // stores which arguments were bound
- // size = num_args OR zero
- internal_stream_t oss_; // the internal stream.
- stream_format_state state0_; // reference state for oss_
- unsigned char exceptions_;
-}; // class basic_format
-
-
-} // namespace boost
-
-
-#endif // BOOST_FORMAT_CLASS_HPP
diff --git a/src/boost/format/format_fwd.hpp b/src/boost/format/format_fwd.hpp
deleted file mode 100644
index 97c55f668..000000000
--- a/src/boost/format/format_fwd.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// -*- C++ -*-
-// Boost general library 'format' ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream (also took its parsing code as basis for printf parsing)
-
-// ------------------------------------------------------------------------------
-// format_fwd.hpp : forward declarations, for primary header format.hpp
-// ------------------------------------------------------------------------------
-
-#ifndef BOOST_FORMAT_FWD_HPP
-#define BOOST_FORMAT_FWD_HPP
-
-#include <string>
-#include <iosfwd>
-
-namespace boost {
-
-class basic_format;
-
-typedef basic_format format;
-
-namespace io {
-enum format_error_bits { bad_format_string_bit = 1,
- too_few_args_bit = 2, too_many_args_bit = 4,
- out_of_range_bit = 8,
- all_error_bits = 255, no_error_bits=0 };
-
-// Convertion: format to string
-std::string str(const basic_format& ) ;
-
-} // namespace io
-
-
-BOOST_IO_STD ostream&
-operator<<( BOOST_IO_STD ostream&, const basic_format&);
-
-
-} // namespace boost
-
-#endif // BOOST_FORMAT_FWD_HPP
diff --git a/src/boost/format/format_implementation.cc b/src/boost/format/format_implementation.cc
deleted file mode 100644
index aa191afe1..000000000
--- a/src/boost/format/format_implementation.cc
+++ /dev/null
@@ -1,256 +0,0 @@
-// -*- C++ -*-
-// Boost general library format ---------------------------
-// See http://www.boost.org for updates, documentation, and revision history.
-
-// (C) Samuel Krempp 2001
-// krempp@crans.ens-cachan.fr
-// Permission to copy, use, modify, sell and
-// distribute this software is granted provided this copyright notice appears
-// in all copies. This software is provided "as is" without express or implied
-// warranty, and with no claim as to its suitability for any purpose.
-
-// ideas taken from Rüdiger Loos's format class
-// and Karl Nelson's ofstream
-
-// ----------------------------------------------------------------------------
-// format_implementation.hpp Implementation of the basic_format class
-// ----------------------------------------------------------------------------
-
-
-#ifndef BOOST_FORMAT_IMPLEMENTATION_HPP
-#define BOOST_FORMAT_IMPLEMENTATION_HPP
-
-#include <boost/throw_exception.hpp>
-#include <boost/assert.hpp>
-#include <boost/format.hpp>
-
-namespace boost {
-
-// -------- format:: -------------------------------------------
-basic_format::basic_format(const char* str)
- : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
- items_(), oss_(), exceptions_(io::all_error_bits)
-{
- state0_.set_by_stream(oss_);
- string_t emptyStr;
- if( !str) str = emptyStr.c_str();
- parse( str );
-}
-
-#ifndef BOOST_NO_STD_LOCALE
-basic_format::basic_format(const char* str, const std::locale & loc)
- : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
- items_(), oss_(), exceptions_(io::all_error_bits)
-{
- oss_.imbue( loc );
- state0_.set_by_stream(oss_);
- string_t emptyStr;
- if( !str) str = emptyStr.c_str();
- parse( str );
-}
-
-basic_format::basic_format(const string_t& s, const std::locale & loc)
- : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
- items_(), oss_(), exceptions_(io::all_error_bits)
-{
- oss_.imbue( loc );
- state0_.set_by_stream(oss_);
- parse(s);
-}
-#endif //BOOST_NO_STD_LOCALE
-
-basic_format::basic_format(const string_t& s)
- : style_(0), cur_arg_(0), num_args_(0), dumped_(false),
- items_(), oss_(), exceptions_(io::all_error_bits)
-{
- state0_.set_by_stream(oss_);
- parse(s);
-}
-
-basic_format:: basic_format(const basic_format& x)
- : style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false),
- items_(x.items_), prefix_(x.prefix_), bound_(x.bound_),
- oss_(), // <- we obviously can't copy x.oss_
- state0_(x.state0_), exceptions_(x.exceptions_)
-{
- state0_.apply_on(oss_);
-}
-
-basic_format& basic_format::operator= (const basic_format& x)
-{
- if(this == &x)
- return *this;
- state0_ = x.state0_;
- state0_.apply_on(oss_);
-
- // plus all the other (trivial) assignments :
- exceptions_ = x.exceptions_;
- items_ = x.items_;
- prefix_ = x.prefix_;
- bound_=x.bound_;
- style_=x.style_;
- cur_arg_=x.cur_arg_;
- num_args_=x.num_args_;
- dumped_=x.dumped_;
- return *this;
-}
-
-
-unsigned char basic_format::exceptions() const
-{
- return exceptions_;
-}
-
-unsigned char basic_format::exceptions(unsigned char newexcept)
-{
- unsigned char swp = exceptions_;
- exceptions_ = newexcept;
- return swp;
-}
-
-
-basic_format& basic_format ::clear()
- // empty the string buffers (except bound arguments, see clear_binds() )
- // and make the format object ready for formatting a new set of arguments
-{
- BOOST_ASSERT( bound_.size()==0 || num_args_ == static_cast<int>(bound_.size()) );
-
- for(unsigned long i=0; i<items_.size(); ++i){
- items_[i].state_ = items_[i].ref_state_;
- // clear converted strings only if the corresponding argument is not bound :
- if( bound_.size()==0 || !bound_[ items_[i].argN_ ] ) items_[i].res_.resize(0);
- }
- cur_arg_=0; dumped_=false;
- // maybe first arg is bound:
- if(bound_.size() != 0)
- {
- while(cur_arg_ < num_args_ && bound_[cur_arg_] ) ++cur_arg_;
- }
- return *this;
-}
-
-basic_format& basic_format ::clear_binds()
- // cancel all bindings, and clear()
-{
- bound_.resize(0);
- clear();
- return *this;
-}
-
-basic_format& basic_format::clear_bind(int argN)
- // cancel the binding of ONE argument, and clear()
-{
- if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] )
- {
- if( exceptions() & io::out_of_range_bit )
- boost::throw_exception(io::out_of_range()); // arg not in range.
- else return *this;
- }
- bound_[argN-1]=false;
- clear();
- return *this;
-}
-
-
-
-std::string basic_format::str() const
-{
- dumped_=true;
- if(items_.size()==0)
- return prefix_;
- if( cur_arg_ < num_args_)
- if( exceptions() & io::too_few_args_bit )
- boost::throw_exception(io::too_few_args()); // not enough variables have been supplied !
-
- unsigned long sz = prefix_.size();
- unsigned long i;
- for(i=0; i < items_.size(); ++i)
- sz += items_[i].res_.size() + items_[i].appendix_.size();
- string_t res;
- res.reserve(sz);
-
- res += prefix_;
- for(i=0; i < items_.size(); ++i)
- {
- const format_item_t& item = items_[i];
- res += item.res_;
- if( item.argN_ == format_item_t::argN_tabulation)
- {
- BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation);
- std::streamsize n = item.state_.width_ - res.size();
- if( n > 0 )
- res.append( n, item.state_.fill_ );
- }
- res += item.appendix_;
- }
- return res;
-}
-
-namespace io {