Project import
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6f03604 --- /dev/null +++ b/Makefile
@@ -0,0 +1,155 @@ +# +# Copyright (c) 2010-2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file is the makefile for Boost, a collection of open +# source libraries that extend the functionality of the C++ standard +# library. +# + +BuildConfigSpecialized := No +BuildProductSpecialized := Yes + +include pre.mak + +PackageName := boost + +PackageExtension := tar.bz2 +PackageSeparator := _ + +PackagePatchArgs := -p1 + +PackageArchive := $(PackageName).$(PackageExtension) +PackageSourceDir := $(PackageName)$(PackageSeparator)$(PackageVersion) + +CleanPaths += $(PackageLicenseFile) + +TpsDir := sw/tps + +IcuDir := $(TpsDir)/icu +IcuSearchPath := $(call GenerateResultPaths,$(IcuDir),usr) + +PythonDir := $(TpsDir)/python +PythonSearchPath := $(call GenerateResultPaths,$(PythonDir),/) + +# For the short-term, we are always building with GCC even though the +# actual tool chain may be some repackaged version of GCC. So, just +# specify that. + +BoostToolset := gcc + +# We do not want versioned headers and libraries, so specify the +# 'system' layout. Also, we do not want all the various combinations +# of shared/static, release/debug, stripped/unstripped and +# non-threaded/threaded libraries, so just specify 'minimal'. + +BoostJamConfig += --layout=system \ + --build-type=minimal \ + -sICU_PATH=$(IcuSearchPath) \ + link=shared + +# If ForceLibStdCPP is set, tell boost to use libstdc++ instead of +# the compiler default +ifeq ($(call IsYes,$(ForceLibStdCPP)),Y) +BoostJamConfig += cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" +endif + + +BoostLibraries = filesystem \ + system \ + signals + +ifeq ($(BUILD_FEATURE_BOOST_PYTHON),1) +BoostLibraries += \ + python +endif + +BoostLibrariesList = $(subst $(Space),$(Comma),$(strip $(BoostLibraries))) + +BoostConfigure = $(call GenerateBuildPaths,bootstrap.sh) +BoostProjectConfig = $(call GenerateBuildPaths,project-config.jam) + +all: $(PackageDefaultGoal) + +# Generate the package license contents. + +$(PackageSourceDir)/LICENSE_1_0.txt: source + +$(PackageLicenseFile): $(PackageSourceDir)/LICENSE_1_0.txt + $(copy-result) + +# Extract the source from the archive and apply patches, if any. + +$(PackageSourceDir): $(PackageArchive) $(PackagePatchPaths) + $(expand-and-patch-package) + +# Prepare the sources. + +.PHONY: source +source: | $(PackageSourceDir) + +# Patch the sources, if necessary. + +.PHONY: patch +patch: source + +# Generate the package build makefile. + +$(BoostConfigure): | $(PackageSourceDir) $(BuildDirectory) + $(call create-links,$(CURDIR)/$(PackageSourceDir),$(BuildDirectory)) + +# Generate the build-specific makefile and user configuration. We have +# to post-process the generated user configuration since Boost's +# adominable build system has no other way to override the actual C++ +# compiler executable used (see http://goodliffe.blogspot.com/2008/05/ +# cross-compiling-boost.html and boost/docs/html/bbv2/ +# tasks.html#bbv2.tasks.crosscompile). + +$(BoostProjectConfig): $(BoostConfigure) + $(Verbose)cd $(BuildDirectory) && \ + ./bootstrap.sh \ + --prefix=$(ResultDirectory) \ + --with-toolset=$(BoostToolset) \ + --with-icu=$(IcuSearchPath) \ + --with-libraries=$(BoostLibrariesList) \ + --with-python-root=$(PythonSearchPath) + $(Verbose)$(SED) -e "s#^\([[:space:]]*using\)[[:space:]]\{1,\}\($(BoostToolset)\)[[:space:]]\{1,\};#\1 \2 : $(TargetProcArch) : $(CXX) $(CPPOPTFLAGS) ;#g" \ + < $(@) > $(@).N || $(RM) -f $(@) + $(Verbose)mv -f $(@) $(@).O + $(Verbose)mv -f $(@).N $(@) + +# Configure the source for building. + +.PHONY: configure +configure: source $(BoostProjectConfig) + +# Build the source. + +.PHONY: build +build: configure + $(Verbose)cd $(BuildDirectory) && \ + ./bjam $(JOBSFLAG) $(BoostJamConfig) + +# Stage the build to a temporary installation area. + +.PHONY: stage +stage: build | $(ResultDirectory) + $(Verbose)cd $(BuildDirectory) && \ + INSTALL="$(INSTALL) $(INSTALLFLAGS)" && \ + ./bjam $(JOBSFLAG) $(BoostJamConfig) \ + install --prefix=$(ResultDirectory) + +clean: + $(Verbose)$(RM) $(RMFLAGS) -r $(PackageSourceDir) + $(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory) + $(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory) + +include post.mak
diff --git a/boost.patches/boost-00.description b/boost.patches/boost-00.description new file mode 100644 index 0000000..40cbf45 --- /dev/null +++ b/boost.patches/boost-00.description
@@ -0,0 +1 @@ +This patch fixes https://svn.boost.org/trac/boost/ticket/4688
diff --git a/boost.patches/boost-00.patch b/boost.patches/boost-00.patch new file mode 100644 index 0000000..85362e4 --- /dev/null +++ b/boost.patches/boost-00.patch
@@ -0,0 +1,26 @@ +diff --git a/libs/filesystem/v2/src/v2_path.cpp b/libs/filesystem/v2/src/v2_path.cpp +index 7adeaff..027b299 100644 +--- a/libs/filesystem/v2/src/v2_path.cpp ++++ b/libs/filesystem/v2/src/v2_path.cpp +@@ -45,7 +45,7 @@ namespace + { + #if !defined(macintosh) && !defined(__APPLE__) && !defined(__APPLE_CC__) + // ISO C calls this "the locale-specific native environment": +- static std::locale lc(""); ++ static std::locale lc; + #else // Mac OS + // "All BSD system functions expect their string parameters to be in UTF-8 encoding + // and nothing else." +diff --git a/libs/filesystem/v3/src/path.cpp b/libs/filesystem/v3/src/path.cpp +index 7dc0b53..213ca36 100644 +--- a/libs/filesystem/v3/src/path.cpp ++++ b/libs/filesystem/v3/src/path.cpp +@@ -760,7 +760,7 @@ namespace + + # else + // ISO C calls this "the locale-specific native environment": +- return std::locale(""); ++ return std::locale(); + + # endif + }
diff --git a/boost.patches/boost-00.url b/boost.patches/boost-00.url new file mode 100644 index 0000000..42f770e --- /dev/null +++ b/boost.patches/boost-00.url
@@ -0,0 +1 @@ +https://svn.boost.org/trac/boost/raw-attachment/ticket/4688/boost_filesystem.patch
diff --git a/boost.patches/boost-01.description b/boost.patches/boost-01.description new file mode 100644 index 0000000..cc99764 --- /dev/null +++ b/boost.patches/boost-01.description
@@ -0,0 +1,5 @@ +This patch addresses upstream issues 5331 +<https://svn.boost.org/trac/boost/attachment/ticket/5331> and 6692 +<https://svn.boost.org/trac/boost/attachment/ticket/6692> by removing +the use of the deprecated swp{b} instructions on ARMv6 and ARMv7 +architectures, replacing them with the newer {ld,st}rex.
diff --git a/boost.patches/boost-01.patch b/boost.patches/boost-01.patch new file mode 100644 index 0000000..e556c4e --- /dev/null +++ b/boost.patches/boost-01.patch
@@ -0,0 +1,88 @@ +--- a/boost/smart_ptr/detail/spinlock_gcc_arm.hpp 2009-03-02 08:22:16.000000000 -0800 ++++ b/boost/smart_ptr/detail/spinlock_gcc_arm.hpp 2012-06-28 16:39:55.000000000 -0700 +@@ -2,7 +2,7 @@ + #define BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED + + // +-// Copyright (c) 2008 Peter Dimov ++// Copyright (c) 2008, 2011 Peter Dimov + // + // Distributed under the Boost Software License, Version 1.0. + // See accompanying file LICENSE_1_0.txt or copy at +@@ -11,6 +11,20 @@ + + #include <boost/smart_ptr/detail/yield_k.hpp> + ++#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) ++ ++# define BOOST_SP_ARM_BARRIER "dmb" ++ ++#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) ++ ++# define BOOST_SP_ARM_BARRIER "mcr p15, 0, r0, c7, c10, 5" ++ ++#else ++ ++# define BOOST_SP_ARM_BARRIER "" ++ ++#endif ++ + namespace boost + { + +@@ -29,12 +43,38 @@ + { + int r; + ++#if defined(__ARM_ARCH_6__) \ ++ || defined(__ARM_ARCH_6J__) \ ++ || defined(__ARM_ARCH_6K__) \ ++ || defined(__ARM_ARCH_6Z__) \ ++ || defined(__ARM_ARCH_6ZK__) \ ++ || defined(__ARM_ARCH_6T2__) \ ++ || defined(__ARM_ARCH_7__) \ ++ || defined(__ARM_ARCH_7A__) \ ++ || defined(__ARM_ARCH_7R__) \ ++ || defined(__ARM_ARCH_7M__) \ ++ || defined(__ARM_ARCH_7EM__) ++ + __asm__ __volatile__( +- "swp %0, %1, [%2]": ++ "ldrex %0, [%2]; \n" ++ "cmp %0, %1; \n" ++ "strexne %0, %1, [%2]; \n" ++ BOOST_SP_ARM_BARRIER : + "=&r"( r ): // outputs + "r"( 1 ), "r"( &v_ ): // inputs + "memory", "cc" ); + ++#else ++ ++ __asm__ __volatile__( ++ "swp %0, %1, [%2];\n" ++ BOOST_SP_ARM_BARRIER : ++ "=&r"( r ): // outputs ++ "r"( 1 ), "r"( &v_ ): // inputs ++ "memory", "cc" ); ++ ++#endif ++ + return r == 0; + } + +@@ -48,7 +88,7 @@ + + void unlock() + { +- __asm__ __volatile__( "" ::: "memory" ); ++ __asm__ __volatile__( BOOST_SP_ARM_BARRIER ::: "memory" ); + *const_cast< int volatile* >( &v_ ) = 0; + } + +@@ -82,4 +122,6 @@ + + #define BOOST_DETAIL_SPINLOCK_INIT {0} + ++#undef BOOST_SP_ARM_BARRIER ++ + #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ARM_HPP_INCLUDED
diff --git a/boost.patches/boost-02.description b/boost.patches/boost-02.description new file mode 100644 index 0000000..32ef535 --- /dev/null +++ b/boost.patches/boost-02.description
@@ -0,0 +1,3 @@ +This patch fixes various compilation errors and warnings when compiling using gcc 4.8.2 + +
diff --git a/boost.patches/boost-02.patch b/boost.patches/boost-02.patch new file mode 100644 index 0000000..66f0979 --- /dev/null +++ b/boost.patches/boost-02.patch
@@ -0,0 +1,126 @@ +--- a/boost/config/stdlib/libstdcpp3.hpp 2010-10-01 02:19:44.000000000 -0700 ++++ b/boost/config/stdlib/libstdcpp3.hpp 2014-05-31 04:07:43.998193374 -0700 +@@ -31,7 +31,8 @@ + + #ifdef __GLIBCXX__ // gcc 3.4 and greater: + # if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \ +- || defined(_GLIBCXX__PTHREADS) ++ || defined(_GLIBCXX__PTHREADS) \ ++ || defined(_GLIBCXX_HAS_GTHREADS) + // + // If the std lib has thread support turned on, then turn it on in Boost + // as well. We do this because some gcc-3.4 std lib headers define _REENTANT +--- a/boost/thread/xtime.hpp 2008-06-18 06:01:08.000000000 -0700 ++++ b/boost/thread/xtime.hpp 2014-05-31 04:07:44.098193379 -0700 +@@ -20,7 +20,7 @@ + + enum xtime_clock_types + { +- TIME_UTC=1 ++ TIME_UTC_=1 + // TIME_TAI, + // TIME_MONOTONIC, + // TIME_PROCESS, +@@ -68,7 +68,7 @@ + + inline int xtime_get(struct xtime* xtp, int clock_type) + { +- if (clock_type == TIME_UTC) ++ if (clock_type == TIME_UTC_) + { + *xtp=get_xtime(get_system_time()); + return clock_type; +--- a/libs/thread/src/pthread/thread.cpp 2010-10-29 16:27:00.000000000 -0700 ++++ b/libs/thread/src/pthread/thread.cpp 2014-05-31 04:07:50.302193645 -0700 +@@ -350,7 +350,7 @@ + cond.timed_wait(lock, xt); + # endif + xtime cur; +- xtime_get(&cur, TIME_UTC); ++ xtime_get(&cur, TIME_UTC_); + if (xtime_cmp(xt, cur) <= 0) + return; + } +@@ -365,7 +365,7 @@ + BOOST_VERIFY(!pthread_yield()); + # else + xtime xt; +- xtime_get(&xt, TIME_UTC); ++ xtime_get(&xt, TIME_UTC_); + sleep(xt); + # endif + } +--- a/libs/thread/src/pthread/timeconv.inl 2010-04-01 08:04:15.000000000 -0700 ++++ b/libs/thread/src/pthread/timeconv.inl 2014-05-31 04:07:50.302193645 -0700 +@@ -20,8 +20,8 @@ + inline void to_time(int milliseconds, boost::xtime& xt) + { + int res = 0; +- res = boost::xtime_get(&xt, boost::TIME_UTC); +- BOOST_ASSERT(res == boost::TIME_UTC); ++ res = boost::xtime_get(&xt, boost::TIME_UTC_); ++ BOOST_ASSERT(res == boost::TIME_UTC_); + + xt.sec += (milliseconds / MILLISECONDS_PER_SECOND); + xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) * +@@ -57,8 +57,8 @@ + { + boost::xtime cur; + int res = 0; +- res = boost::xtime_get(&cur, boost::TIME_UTC); +- BOOST_ASSERT(res == boost::TIME_UTC); ++ res = boost::xtime_get(&cur, boost::TIME_UTC_); ++ BOOST_ASSERT(res == boost::TIME_UTC_); + + if (boost::xtime_cmp(xt, cur) <= 0) + { +@@ -88,8 +88,8 @@ + { + boost::xtime cur; + int res = 0; +- res = boost::xtime_get(&cur, boost::TIME_UTC); +- BOOST_ASSERT(res == boost::TIME_UTC); ++ res = boost::xtime_get(&cur, boost::TIME_UTC_); ++ BOOST_ASSERT(res == boost::TIME_UTC_); + + if (boost::xtime_cmp(xt, cur) <= 0) + milliseconds = 0; +@@ -110,8 +110,8 @@ + { + boost::xtime cur; + int res = 0; +- res = boost::xtime_get(&cur, boost::TIME_UTC); +- BOOST_ASSERT(res == boost::TIME_UTC); ++ res = boost::xtime_get(&cur, boost::TIME_UTC_); ++ BOOST_ASSERT(res == boost::TIME_UTC_); + + if (boost::xtime_cmp(xt, cur) <= 0) + microseconds = 0; +--- a/boost/static_assert.hpp 2008-07-11 03:49:31.000000000 -0700 ++++ b/boost/static_assert.hpp 2014-06-07 07:32:29.365107458 -0700 +@@ -38,6 +38,15 @@ + # define BOOST_STATIC_ASSERT_BOOL_CAST(x) (bool)(x) + #endif + ++// ++// If the compiler warns about unused typedefs then enable this: ++// ++#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) ++# define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) ++#else ++# define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE ++#endif ++ + #ifdef BOOST_HAS_STATIC_ASSERT + # define BOOST_STATIC_ASSERT( B ) static_assert(B, #B) + #else +@@ -116,7 +125,7 @@ + #define BOOST_STATIC_ASSERT( B ) \ + typedef ::boost::static_assert_test<\ + sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >)>\ +- BOOST_JOIN(boost_static_assert_typedef_, __LINE__) ++ BOOST_JOIN(boost_static_assert_typedef_, __LINE__) BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE + #endif + + #else +
diff --git a/boost.patches/boost-50.description b/boost.patches/boost-50.description new file mode 100644 index 0000000..b4de134 --- /dev/null +++ b/boost.patches/boost-50.description
@@ -0,0 +1 @@ +This patch resolves compiler errors / warnings regarding shadow variables.
diff --git a/boost.patches/boost-50.patch b/boost.patches/boost-50.patch new file mode 100644 index 0000000..474e31f --- /dev/null +++ b/boost.patches/boost-50.patch
@@ -0,0 +1,110 @@ +--- a/boost/concept_check.hpp ++++ b/boost/concept_check.hpp +@@ -1014,11 +1014,11 @@ + c.swap(c); + } + +- void const_constraints(const C& c) { +- ci = c.begin(); +- ci = c.end(); +- n = c.size(); +- b = c.empty(); ++ void const_constraints(const C& constraint) { ++ ci = constraint.begin(); ++ ci = constraint.end(); ++ n = constraint.size(); ++ b = constraint.empty(); + } + + private: +--- a/boost/filesystem/v3/path.hpp 2010-10-16 06:09:25.000000000 -0700 ++++ b/boost/filesystem/v3/path.hpp 2011-05-14 16:54:35.927910801 -0700 +@@ -142,23 +142,23 @@ + } + + template <class InputIterator> +- path(InputIterator begin, InputIterator end) ++ path(InputIterator first, InputIterator last) + { +- if (begin != end) ++ if (first != last) + { + std::basic_string<typename std::iterator_traits<InputIterator>::value_type> +- s(begin, end); ++ s(first, last); + path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt()); + } + } + + template <class InputIterator> +- path(InputIterator begin, InputIterator end, const codecvt_type& cvt) ++ path(InputIterator first, InputIterator last, const codecvt_type& cvt) + { +- if (begin != end) ++ if (first != last) + { + std::basic_string<typename std::iterator_traits<InputIterator>::value_type> +- s(begin, end); ++ s(first, last); + path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt); + } + } +@@ -190,19 +190,19 @@ + } + + template <class InputIterator> +- path& assign(InputIterator begin, InputIterator end) ++ path& assign(InputIterator first, InputIterator last) + { +- return assign(begin, end, codecvt()); ++ return assign(first, last, codecvt()); + } + + template <class InputIterator> +- path& assign(InputIterator begin, InputIterator end, const codecvt_type& cvt) ++ path& assign(InputIterator first, InputIterator last, const codecvt_type& cvt) + { + m_pathname.clear(); +- if (begin != end) ++ if (first != last) + { + std::basic_string<typename std::iterator_traits<InputIterator>::value_type> +- s(begin, end); ++ s(first, last); + path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt); + } + return *this; +@@ -227,13 +227,13 @@ + path& append(Source const& source, const codecvt_type& cvt); + + template <class InputIterator> +- path& append(InputIterator begin, InputIterator end) ++ path& append(InputIterator first, InputIterator last) + { +- return append(begin, end, codecvt()); ++ return append(first, last, codecvt()); + } + + template <class InputIterator> +- path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt); ++ path& append(InputIterator first, InputIterator last, const codecvt_type& cvt); + + // ----- modifiers ----- + +@@ -612,13 +612,13 @@ + //--------------------------------------------------------------------------------------// + + template <class InputIterator> +- path& path::append(InputIterator begin, InputIterator end, const codecvt_type& cvt) ++ path& path::append(InputIterator first, InputIterator last, const codecvt_type& cvt) + { +- if (begin == end) ++ if (first == last) + return *this; + string_type::size_type sep_pos(m_append_separator_if_needed()); + std::basic_string<typename std::iterator_traits<InputIterator>::value_type> +- s(begin, end); ++ s(first, last); + path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt); + if (sep_pos) + m_erase_redundant_separator(sep_pos);
diff --git a/boost.patches/boost-51.description b/boost.patches/boost-51.description new file mode 100644 index 0000000..ab896a1 --- /dev/null +++ b/boost.patches/boost-51.description
@@ -0,0 +1 @@ +This patch applies upstream change set 67067 <https://svn.boost.org/trac/boost/changeset/67067> for issue 4930 <https://svn.boost.org/trac/boost/ticket/4930>.
diff --git a/boost.patches/boost-51.patch b/boost.patches/boost-51.patch new file mode 100644 index 0000000..a7ffbec --- /dev/null +++ b/boost.patches/boost-51.patch
@@ -0,0 +1,28 @@ +--- a/libs/filesystem/v2/src/v2_operations.cpp 2010-08-10 13:00:09.000000000 -0700 ++++ b/libs/filesystem/v2/src/v2_operations.cpp 2011-06-16 17:28:00.000000000 -0700 +@@ -1215,8 +1214,9 @@ + if ( ::stat( from_file_ph.c_str(), &from_stat ) != 0 ) + { return error_code( errno, system_category() ); } + +- int oflag = O_CREAT | O_WRONLY; +- if ( fail_if_exists ) oflag |= O_EXCL; ++ int oflag = O_CREAT | O_WRONLY | O_TRUNC; ++ if ( fail_if_exists ) ++ oflag |= O_EXCL; + if ( (outfile = ::open( to_file_ph.c_str(), oflag, from_stat.st_mode )) < 0 ) + { + int open_errno = errno; +--- a/libs/filesystem/v3/src/operations.cpp 2010-10-16 06:09:25.000000000 -0700 ++++ b/libs/filesystem/v3/src/operations.cpp 2011-06-16 17:28:00.000000000 -0700 +@@ -426,8 +433,9 @@ + if (::stat(from_p.c_str(), &from_stat)!= 0) + { return false; } + +- int oflag = O_CREAT | O_WRONLY; +- if (fail_if_exists)oflag |= O_EXCL; ++ int oflag = O_CREAT | O_WRONLY | O_TRUNC; ++ if (fail_if_exists) ++ oflag |= O_EXCL; + if ((outfile = ::open(to_p.c_str(), oflag, from_stat.st_mode))< 0) + { + int open_errno = errno;
diff --git a/boost.patches/boost-52.description b/boost.patches/boost-52.description new file mode 100644 index 0000000..98582d2 --- /dev/null +++ b/boost.patches/boost-52.description
@@ -0,0 +1 @@ +This patch resolves compiler errors / warnings regarding shadow variables in boost::numeric::ublas.
diff --git a/boost.patches/boost-52.patch b/boost.patches/boost-52.patch new file mode 100644 index 0000000..aeae509 --- /dev/null +++ b/boost.patches/boost-52.patch
@@ -0,0 +1,1948 @@ +diff -aruN a/boost/archive/basic_archive.hpp b/boost/archive/basic_archive.hpp +--- a/boost/archive/basic_archive.hpp 2010-11-06 09:31:31.000000000 -0700 ++++ b/boost/archive/basic_archive.hpp 2012-02-07 15:25:24.619334954 -0800 +@@ -254,7 +254,7 @@ + #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \ + class D : public T { \ + public: \ +- explicit D(const T t) : T(t){} \ ++ explicit D(const T t) : T(type){} \ + }; \ + /**/ + +diff -aruN a/boost/numeric/ublas/banded.hpp b/boost/numeric/ublas/banded.hpp +--- a/boost/numeric/ublas/banded.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/banded.hpp 2012-02-07 15:25:24.623735807 -0800 +@@ -63,16 +63,16 @@ + size1_ (0), size2_ (0), + lower_ (0), upper_ (0), data_ (0) {} + BOOST_UBLAS_INLINE +- banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0): ++ banded_matrix (size_type s1, size_type s2, size_type l = 0, size_type u = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), +- lower_ (lower), upper_ (upper), data_ ((std::max) (size1, size2) * (lower + 1 + upper)) { ++ size1_ (s1), size2_ (s2), ++ lower_ (l), upper_ (u), data_ ((std::max) (s1, s2) * (l + 1 + u)) { + } + BOOST_UBLAS_INLINE +- banded_matrix (size_type size1, size_type size2, size_type lower, size_type upper, const array_type &data): ++ banded_matrix (size_type s1, size_type s2, size_type l, size_type u, const array_type &d): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), +- lower_ (lower), upper_ (upper), data_ (data) {} ++ size1_ (s1), size2_ (s2), ++ lower_ (l), upper_ (u), data_ (d) {} + BOOST_UBLAS_INLINE + banded_matrix (const banded_matrix &m): + matrix_container<self_type> (), +@@ -80,10 +80,10 @@ + lower_ (m.lower_), upper_ (m.upper_), data_ (m.data_) {} + template<class AE> + BOOST_UBLAS_INLINE +- banded_matrix (const matrix_expression<AE> &ae, size_type lower = 0, size_type upper = 0): ++ banded_matrix (const matrix_expression<AE> &ae, size_type l = 0, size_type u = 0): + matrix_container<self_type> (), + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), +- lower_ (lower), upper_ (upper), ++ lower_ (l), upper_ (u), + data_ ((std::max) (size1_, size2_) * (lower_ + 1 + upper_)) { + matrix_assign<scalar_assign> (*this, ae); + } +@@ -118,27 +118,27 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0, bool preserve = true) { ++ void resize (size_type s1, size_type s2, size_type l = 0, size_type u = 0, bool preserve = true) { + if (preserve) { +- self_type temporary (size1, size2, lower, upper); ++ self_type temporary (s1, s2, l, u); + detail::matrix_resize_preserve<layout_type> (*this, temporary); + } + else { +- data ().resize ((std::max) (size1, size2) * (lower + 1 + upper)); +- size1_ = size1; +- size2_ = size2; +- lower_ = lower; +- upper_ = upper; ++ data ().resize ((std::max) (s1, s2) * (l + 1 + u)); ++ size1_ = s1; ++ size2_ = s2; ++ lower_ = l; ++ upper_ = u; + } + } + + BOOST_UBLAS_INLINE +- void resize_packed_preserve (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0) { +- size1_ = size1; +- size2_ = size2; +- lower_ = lower; +- upper_ = upper; +- data ().resize ((std::max) (size1, size2) * (lower + 1 + upper), value_type ()); ++ void resize_packed_preserve (size_type s1, size_type s2, size_type l = 0, size_type u = 0) { ++ size1_ = s1; ++ size2_ = s2; ++ lower_ = l; ++ upper_ = u; ++ data ().resize ((std::max) (size1, size2) * (l + 1 + u), value_type ()); + } + + // Element access +@@ -1082,9 +1082,9 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- banded_adaptor (matrix_type &data, size_type lower = 0, size_type upper = 0): ++ banded_adaptor (matrix_type &d, size_type l = 0, size_type u = 0): + matrix_expression<self_type> (), +- data_ (data), lower_ (lower), upper_ (upper) {} ++ data_ (d), lower_ (l), upper_ (u) {} + BOOST_UBLAS_INLINE + banded_adaptor (const banded_adaptor &m): + matrix_expression<self_type> (), +diff -aruN a/boost/numeric/ublas/detail/matrix_assign.hpp b/boost/numeric/ublas/detail/matrix_assign.hpp +--- a/boost/numeric/ublas/detail/matrix_assign.hpp 2010-10-19 00:01:35.000000000 -0700 ++++ b/boost/numeric/ublas/detail/matrix_assign.hpp 2012-02-07 15:25:24.623735807 -0800 +@@ -75,21 +75,21 @@ + if (it2 != it2_end && it2e != it2e_end) { + size_type it2_index = it2.index2 (), it2e_index = it2e.index2 (); + while (true) { +- difference_type compare = it2_index - it2e_index; +- if (compare == 0) { ++ difference_type compare2 = it2_index - it2e_index; ++ if (compare2 == 0) { + ++ it2, ++ it2e; + if (it2 != it2_end && it2e != it2e_end) { + it2_index = it2.index2 (); + it2e_index = it2e.index2 (); + } else + break; +- } else if (compare < 0) { +- increment (it2, it2_end, - compare); ++ } else if (compare2 < 0) { ++ increment (it2, it2_end, - compare2); + if (it2 != it2_end) + it2_index = it2.index2 (); + else + break; +- } else if (compare > 0) { ++ } else if (compare2 > 0) { + if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) + if (static_cast<value_type>(*it2e) != value_type/*zero*/()) + index.push_back (std::pair<size_type, size_type> (it2e.index1 (), it2e.index2 ())); +@@ -178,21 +178,21 @@ + if (it1 != it1_end && it1e != it1e_end) { + size_type it1_index = it1.index1 (), it1e_index = it1e.index1 (); + while (true) { +- difference_type compare = it1_index - it1e_index; +- if (compare == 0) { ++ difference_type compare2 = it1_index - it1e_index; ++ if (compare2 == 0) { + ++ it1, ++ it1e; + if (it1 != it1_end && it1e != it1e_end) { + it1_index = it1.index1 (); + it1e_index = it1e.index1 (); + } else + break; +- } else if (compare < 0) { +- increment (it1, it1_end, - compare); ++ } else if (compare2 < 0) { ++ increment (it1, it1_end, - compare2); + if (it1 != it1_end) + it1_index = it1.index1 (); + else + break; +- } else if (compare > 0) { ++ } else if (compare2 > 0) { + if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) + if (static_cast<value_type>(*it1e) != value_type/*zero*/()) + index.push_back (std::pair<size_type, size_type> (it1e.index1 (), it1e.index2 ())); +@@ -997,8 +997,8 @@ + if (it2 != it2_end && it2e != it2e_end) { + size_type it2_index = it2.index2 (), it2e_index = it2e.index2 (); + while (true) { +- difference_type compare = it2_index - it2e_index; +- if (compare == 0) { ++ difference_type compare2 = it2_index - it2e_index; ++ if (compare2 == 0) { + functor_type::apply (*it2, *it2e); + ++ it2, ++ it2e; + if (it2 != it2_end && it2e != it2e_end) { +@@ -1006,18 +1006,18 @@ + it2e_index = it2e.index2 (); + } else + break; +- } else if (compare < 0) { ++ } else if (compare2 < 0) { + if (!functor_type::computed) { + functor_type::apply (*it2, expr_value_type/*zero*/()); + ++ it2; + } else +- increment (it2, it2_end, - compare); ++ increment (it2, it2_end, - compare2); + if (it2 != it2_end) + it2_index = it2.index2 (); + else + break; +- } else if (compare > 0) { +- increment (it2e, it2e_end, compare); ++ } else if (compare2 > 0) { ++ increment (it2e, it2e_end, compare2); + if (it2e != it2e_end) + it2e_index = it2e.index2 (); + else +@@ -1118,8 +1118,8 @@ + if (it1 != it1_end && it1e != it1e_end) { + size_type it1_index = it1.index1 (), it1e_index = it1e.index1 (); + while (true) { +- difference_type compare = it1_index - it1e_index; +- if (compare == 0) { ++ difference_type compare2 = it1_index - it1e_index; ++ if (compare2 == 0) { + functor_type::apply (*it1, *it1e); + ++ it1, ++ it1e; + if (it1 != it1_end && it1e != it1e_end) { +@@ -1127,18 +1127,18 @@ + it1e_index = it1e.index1 (); + } else + break; +- } else if (compare < 0) { ++ } else if (compare2 < 0) { + if (!functor_type::computed) { + functor_type::apply (*it1, expr_value_type/*zero*/()); // zeroing + ++ it1; + } else +- increment (it1, it1_end, - compare); ++ increment (it1, it1_end, - compare2); + if (it1 != it1_end) + it1_index = it1.index1 (); + else + break; +- } else if (compare > 0) { +- increment (it1e, it1e_end, compare); ++ } else if (compare2 > 0) { ++ increment (it1e, it1e_end, compare2); + if (it1e != it1e_end) + it1e_index = it1e.index1 (); + else +@@ -1386,8 +1386,8 @@ + if (it2 != it2_end && it2e != it2e_end) { + size_type it2_index = it2.index2 (), it2e_index = it2e.index2 (); + while (true) { +- difference_type compare = it2_index - it2e_index; +- if (compare == 0) { ++ difference_type compare2 = it2_index - it2e_index; ++ if (compare2 == 0) { + functor_type::apply (*it2, *it2e); + ++ it2, ++ it2e; + if (it2 != it2_end && it2e != it2e_end) { +@@ -1395,14 +1395,14 @@ + it2e_index = it2e.index2 (); + } else + break; +- } else if (compare < 0) { +- increment (it2, it2_end, - compare); ++ } else if (compare2 < 0) { ++ increment (it2, it2_end, - compare2); + if (it2 != it2_end) + it2_index = it2.index2 (); + else + break; +- } else if (compare > 0) { +- increment (it2e, it2e_end, compare); ++ } else if (compare2 > 0) { ++ increment (it2e, it2e_end, compare2); + if (it2e != it2e_end) + it2e_index = it2e.index2 (); + else +@@ -1511,8 +1511,8 @@ + if (it1 != it1_end && it1e != it1e_end) { + size_type it1_index = it1.index1 (), it1e_index = it1e.index1 (); + while (true) { +- difference_type compare = it1_index - it1e_index; +- if (compare == 0) { ++ difference_type compare2 = it1_index - it1e_index; ++ if (compare2 == 0) { + functor_type::apply (*it1, *it1e); + ++ it1, ++ it1e; + if (it1 != it1_end && it1e != it1e_end) { +@@ -1520,14 +1520,14 @@ + it1e_index = it1e.index1 (); + } else + break; +- } else if (compare < 0) { +- increment (it1, it1_end, - compare); ++ } else if (compare2 < 0) { ++ increment (it1, it1_end, - compare2); + if (it1 != it1_end) + it1_index = it1.index1 (); + else + break; +- } else if (compare > 0) { +- increment (it1e, it1e_end, compare); ++ } else if (compare2 > 0) { ++ increment (it1e, it1e_end, compare2); + if (it1e != it1e_end) + it1e_index = it1e.index1 (); + else +diff -aruN a/boost/numeric/ublas/hermitian.hpp b/boost/numeric/ublas/hermitian.hpp +--- a/boost/numeric/ublas/hermitian.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/hermitian.hpp 2012-02-07 15:25:24.627228060 -0800 +@@ -284,14 +284,14 @@ + size_ (BOOST_UBLAS_SAME (size, size)), data_ (triangular_type::packed_size (layout_type (), size, size)) { + } + BOOST_UBLAS_INLINE +- hermitian_matrix (size_type size1, size_type size2): ++ hermitian_matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size_ (BOOST_UBLAS_SAME (size1, size2)), data_ (triangular_type::packed_size (layout_type (), size1, size2)) { ++ size_ (BOOST_UBLAS_SAME (s1, s2)), data_ (triangular_type::packed_size (layout_type (), s1, s2)) { + } + BOOST_UBLAS_INLINE +- hermitian_matrix (size_type size, const array_type &data): ++ hermitian_matrix (size_type s, const array_type &d): + matrix_container<self_type> (), +- size_ (size), data_ (data) {} ++ size_ (s), data_ (d) {} + BOOST_UBLAS_INLINE + hermitian_matrix (const hermitian_matrix &m): + matrix_container<self_type> (), +@@ -338,8 +338,8 @@ + } + } + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { +- resize (BOOST_UBLAS_SAME (size1, size2), preserve); ++ void resize (size_type s1, size_type s2, bool preserve = true) { ++ resize (BOOST_UBLAS_SAME (s1, s2), preserve); + } + BOOST_UBLAS_INLINE + void resize_packed_preserve (size_type size) { +@@ -1192,9 +1192,9 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- hermitian_adaptor (matrix_type &data): ++ hermitian_adaptor (matrix_type &d): + matrix_expression<self_type> (), +- data_ (data) { ++ data_ (d) { + BOOST_UBLAS_CHECK (data_.size1 () == data_.size2 (), bad_size ()); + } + BOOST_UBLAS_INLINE +@@ -1508,11 +1508,11 @@ + it1_begin_ (), it1_end_ (), it1_ (), + it2_begin_ (), it2_end_ (), it2_ () {} + BOOST_UBLAS_INLINE +- const_iterator1 (const self_type &m, int begin, int end, ++ const_iterator1 (const self_type &m, int b, int e, + const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end, + const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end): + container_const_reference<self_type> (m), +- begin_ (begin), end_ (end), current_ (begin), ++ begin_ (b), end_ (e), current_ (b), + it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_), + it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) { + if (current_ == 0 && it1_ == it1_end_) +@@ -1962,11 +1962,11 @@ + it1_begin_ (), it1_end_ (), it1_ (), + it2_begin_ (), it2_end_ (), it2_ () {} + BOOST_UBLAS_INLINE +- const_iterator2 (const self_type &m, int begin, int end, ++ const_iterator2 (const self_type &m, int b, int e, + const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end, + const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end): + container_const_reference<self_type> (m), +- begin_ (begin), end_ (end), current_ (begin), ++ begin_ (b), end_ (e), current_ (b), + it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_), + it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) { + if (current_ == 0 && it1_ == it1_end_) +diff -aruN a/boost/numeric/ublas/matrix_expression.hpp b/boost/numeric/ublas/matrix_expression.hpp +--- a/boost/numeric/ublas/matrix_expression.hpp 2009-10-06 16:31:22.000000000 -0700 ++++ b/boost/numeric/ublas/matrix_expression.hpp 2012-02-07 15:25:24.627228060 -0800 +@@ -1918,39 +1918,39 @@ + // Sparse specializations + BOOST_UBLAS_INLINE + void increment (sparse_bidirectional_iterator_tag) { +- size_type index1 = (*this) ().size1 (); ++ size_type temp_index1 = (*this) ().size1 (); + if (it1_ != it1_end_) { + if (it1_.index1 () <= i_) + ++ it1_; + if (it1_ != it1_end_) +- index1 = it1_.index1 (); ++ temp_index1 = it1_.index1 (); + } +- size_type index2 = (*this) ().size1 (); ++ size_type temp_index2 = (*this) ().size1 (); + if (it2_ != it2_end_) + if (it2_.index1 () <= i_) + ++ it2_; + if (it2_ != it2_end_) { +- index2 = it2_.index1 (); ++ temp_index2 = it2_.index1 (); + } +- i_ = (std::min) (index1, index2); ++ i_ = (std::min) (temp_index1, temp_index2); + } + BOOST_UBLAS_INLINE + void decrement (sparse_bidirectional_iterator_tag) { +- size_type index1 = (*this) ().size1 (); ++ size_type temp_index1 = (*this) ().size1 (); + if (it1_ != it1_end_) { + if (i_ <= it1_.index1 ()) + -- it1_; + if (it1_ != it1_end_) +- index1 = it1_.index1 (); ++ temp_index1 = it1_.index1 (); + } +- size_type index2 = (*this) ().size1 (); ++ size_type temp_index2 = (*this) ().size1 (); + if (it2_ != it2_end_) { + if (i_ <= it2_.index1 ()) + -- it2_; + if (it2_ != it2_end_) +- index2 = it2_.index1 (); ++ temp_index2 = it2_.index1 (); + } +- i_ = (std::max) (index1, index2); ++ i_ = (std::max) (temp_index1, temp_index2); + } + BOOST_UBLAS_INLINE + void increment (sparse_bidirectional_iterator_tag, difference_type n) { +@@ -2233,39 +2233,39 @@ + // Sparse specializations + BOOST_UBLAS_INLINE + void increment (sparse_bidirectional_iterator_tag) { +- size_type index1 = (*this) ().size2 (); ++ size_type temp_index1 = (*this) ().size2 (); + if (it1_ != it1_end_) { + if (it1_.index2 () <= j_) + ++ it1_; + if (it1_ != it1_end_) + index1 = it1_.index2 (); + } +- size_type index2 = (*this) ().size2 (); ++ size_type temp_index2 = (*this) ().size2 (); + if (it2_ != it2_end_) { + if (it2_.index2 () <= j_) + ++ it2_; + if (it2_ != it2_end_) + index2 = it2_.index2 (); + } +- j_ = (std::min) (index1, index2); ++ j_ = (std::min) (temp_index1, temp_index2); + } + BOOST_UBLAS_INLINE + void decrement (sparse_bidirectional_iterator_tag) { +- size_type index1 = (*this) ().size2 (); ++ size_type temp_index1 = (*this) ().size2 (); + if (it1_ != it1_end_) { + if (j_ <= it1_.index2 ()) + -- it1_; + if (it1_ != it1_end_) + index1 = it1_.index2 (); + } +- size_type index2 = (*this) ().size2 (); ++ size_type temp_index2 = (*this) ().size2 (); + if (it2_ != it2_end_) { + if (j_ <= it2_.index2 ()) + -- it2_; + if (it2_ != it2_end_) + index2 = it2_.index2 (); + } +- j_ = (std::max) (index1, index2); ++ j_ = (std::max) (temp_index1, temp_index2); + } + BOOST_UBLAS_INLINE + void increment (sparse_bidirectional_iterator_tag, difference_type n) { +diff -aruN a/boost/numeric/ublas/matrix.hpp b/boost/numeric/ublas/matrix.hpp +--- a/boost/numeric/ublas/matrix.hpp 2010-10-19 00:01:35.000000000 -0700 ++++ b/boost/numeric/ublas/matrix.hpp 2012-02-07 15:25:24.631348942 -0800 +@@ -126,9 +126,9 @@ + * \param size2 number of columns + */ + BOOST_UBLAS_INLINE +- matrix (size_type size1, size_type size2): ++ matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2)) { ++ size1_ (s1), size2_ (s2), data_ (layout_type::storage_size (s1, s2)) { + } + + /** Dense matrix constructor with defined size a initial value for all the matrix elements +@@ -136,9 +136,9 @@ + * \param size2 number of columns + * \param init initial value assigned to all elements + */ +- matrix (size_type size1, size_type size2, const value_type &init): ++ matrix (size_type s1, size_type s2, const value_type &init): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) { ++ size1_ (s1), size2_ (s2), data_ (layout_type::storage_size (s1, s2), init) { + } + + /** Dense matrix constructor with defined size and an initial data array +@@ -147,9 +147,9 @@ + * \param data array to copy into the matrix. Must have the same dimension as the matrix + */ + BOOST_UBLAS_INLINE +- matrix (size_type size1, size_type size2, const array_type &data): ++ matrix (size_type s1, size_type s2, const array_type &d): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (data) {} ++ size1_ (s1), size2_ (s2), data_ (d) {} + + /** Copy-constructor of a dense matrix + * \param m is a dense matrix +@@ -212,15 +212,15 @@ + * \param preserve a boolean to say if one wants the data to be preserved during the resizing. Default is true. + */ + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + if (preserve) { +- self_type temporary (size1, size2); ++ self_type temporary (s1, s2); + detail::matrix_resize_preserve<layout_type> (*this, temporary); + } + else { +- data ().resize (layout_type::storage_size (size1, size2)); +- size1_ = size1; +- size2_ = size2; ++ data ().resize (layout_type::storage_size (s1, s2)); ++ size1_ = s1; ++ size2_ = s2; + } + } + +@@ -1186,10 +1186,10 @@ + matrix_container<self_type> (), + size1_ (0), size2_ (0), data_ (1) {} + BOOST_UBLAS_INLINE +- vector_of_vector (size_type size1, size_type size2): ++ vector_of_vector (size_type s1, size_type s2): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (1) { +- resize (size1, size2, true); ++ size1_ (s1), size2_ (s2), data_ (1) { ++ resize (s1, s2, true); + } + BOOST_UBLAS_INLINE + vector_of_vector (const vector_of_vector &m): +@@ -1227,18 +1227,18 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { +- size1_ = size1; +- size2_ = size2; ++ void resize (size_type s1, size_type s2, bool preserve = true) { ++ size1_ = s1; ++ size2_ = s2; + if (preserve) +- data ().resize (layout_type::size_M (size1, size2) + 1, typename array_type::value_type ()); ++ data ().resize (layout_type::size_M (s1, s2) + 1, typename array_type::value_type ()); + else +- data ().resize (layout_type::size_M (size1, size2) + 1); +- for (size_type k = 0; k < layout_type::size_M (size1, size2); ++ k) { ++ data ().resize (layout_type::size_M (s1, s2) + 1); ++ for (size_type k = 0; k < layout_type::size_M (s1, s2); ++ k) { + if (preserve) +- data () [k].resize (layout_type::size_m (size1, size2), value_type ()); ++ data () [k].resize (layout_type::size_m (s1, s2), value_type ()); + else +- data () [k].resize (layout_type::size_m (size1, size2)); ++ data () [k].resize (layout_type::size_m (s1, s2)); + } + } + +@@ -2171,9 +2171,9 @@ + matrix_container<self_type> (), + size1_ (size), size2_ (size) {} + BOOST_UBLAS_INLINE +- zero_matrix (size_type size1, size_type size2): ++ zero_matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2) {} ++ size1_ (s1), size2_ (s2) {} + BOOST_UBLAS_INLINE + zero_matrix (const zero_matrix &m): + matrix_container<self_type> (), +@@ -2196,9 +2196,9 @@ + size2_ = size; + } + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool /*preserve*/ = true) { +- size1_ = size1; +- size2_ = size2; ++ void resize (size_type s1, size_type s2, bool /*preserve*/ = true) { ++ size1_ = s1; ++ size2_ = s2; + } + + // Element access +@@ -2558,9 +2558,9 @@ + matrix_container<self_type> (), + size1_ (size), size2_ (size), size_common_ ((std::min) (size1_, size2_)) {} + BOOST_UBLAS_INLINE +- identity_matrix (size_type size1, size_type size2): ++ identity_matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), size_common_ ((std::min) (size1_, size2_)) {} ++ size1_ (s1), size2_ (s2), size_common_ ((std::min) (size1_, size2_)) {} + BOOST_UBLAS_INLINE + identity_matrix (const identity_matrix &m): + matrix_container<self_type> (), +@@ -2584,9 +2584,9 @@ + size_common_ = ((std::min)(size1_, size2_)); + } + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool /*preserve*/ = true) { +- size1_ = size1; +- size2_ = size2; ++ void resize (size_type s1, size_type s2, bool /*preserve*/ = true) { ++ size1_ = s1; ++ size2_ = s2; + size_common_ = ((std::min)(size1_, size2_)); + } + +@@ -2970,9 +2970,9 @@ + matrix_container<self_type> (), + size1_ (0), size2_ (0), value_ () {} + BOOST_UBLAS_INLINE +- scalar_matrix (size_type size1, size_type size2, const value_type &value = value_type(1)): ++ scalar_matrix (size_type s1, size_type s2, const value_type &value = value_type(1)): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), value_ (value) {} ++ size1_ (s1), size2_ (s2), value_ (value) {} + BOOST_UBLAS_INLINE + scalar_matrix (const scalar_matrix &m): + matrix_container<self_type> (), +@@ -2990,9 +2990,9 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool /*preserve*/ = true) { +- size1_ = size1; +- size2_ = size2; ++ void resize (size_type s1, size_type s2, bool /*preserve*/ = true) { ++ size1_ = s1; ++ size2_ = s2; + } + + // Element access +@@ -3446,8 +3446,8 @@ + size1_ (N), size2_ (M) /* , data_ () */ { + } + BOOST_UBLAS_INLINE +- c_matrix (size_type size1, size_type size2): +- size1_ (size1), size2_ (size2) /* , data_ () */ { ++ c_matrix (size_type s1, size_type s2): ++ size1_ (s1), size2_ (s2) /* , data_ () */ { + if (size1_ > N || size2_ > M) + bad_size ().raise (); + } +@@ -3487,14 +3487,14 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { +- if (size1 > N || size2 > M) ++ void resize (size_type s1, size_type s2, bool preserve = true) { ++ if (s1 > N || s2 > M) + bad_size ().raise (); + if (preserve) { +- self_type temporary (size1, size2); ++ self_type temporary (s1, s2); + // Common elements to preserve +- const size_type size1_min = (std::min) (size1, size1_); +- const size_type size2_min = (std::min) (size2, size2_); ++ const size_type size1_min = (std::min) (s1, size1_); ++ const size_type size2_min = (std::min) (s2, size2_); + for (size_type i = 0; i != size1_min; ++i) { // indexing copy over major + for (size_type j = 0; j != size2_min; ++j) { + temporary.data_[i][j] = data_[i][j]; +@@ -3503,8 +3503,8 @@ + assign_temporary (temporary); + } + else { +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + } + } + +diff -aruN a/boost/numeric/ublas/matrix_proxy.hpp b/boost/numeric/ublas/matrix_proxy.hpp +--- a/boost/numeric/ublas/matrix_proxy.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/matrix_proxy.hpp 2012-02-07 15:25:24.631348942 -0800 +@@ -51,8 +51,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_row (matrix_type &data, size_type i): +- data_ (data), i_ (i) { ++ matrix_row (matrix_type &d, size_type i): ++ data_ (d), i_ (i) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (i_ < data_.size1 (), bad_index ()); + } +@@ -508,8 +508,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_column (matrix_type &data, size_type j): +- data_ (data), j_ (j) { ++ matrix_column (matrix_type &d, size_type j): ++ data_ (d), j_ (j) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (j_ < data_.size2 (), bad_index ()); + } +@@ -965,8 +965,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_vector_range (matrix_type &data, const range_type &r1, const range_type &r2): +- data_ (data), r1_ (r1.preprocess (data.size1 ())), r2_ (r2.preprocess (data.size2 ())) { ++ matrix_vector_range (matrix_type &d, const range_type &r1, const range_type &r2): ++ data_ (d), r1_ (r1.preprocess (d.size1 ())), r2_ (r2.preprocess (d.size2 ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (r1_.start () <= data_.size1 () && + // r1_.start () + r1_.size () <= data_.size1 (), bad_index ()); +@@ -1421,8 +1421,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_vector_slice (matrix_type &data, const slice_type &s1, const slice_type &s2): +- data_ (data), s1_ (s1.preprocess (data.size1 ())), s2_ (s2.preprocess (data.size2 ())) { ++ matrix_vector_slice (matrix_type &d, const slice_type &s1, const slice_type &s2): ++ data_ (d), s1_ (s1.preprocess (d.size1 ())), s2_ (s2.preprocess (d.size2 ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (s1_.start () <= data_.size1 () && + // s1_.start () + s1_.stride () * (s1_.size () - (s1_.size () > 0)) <= data_.size1 (), bad_index ()); +@@ -1886,11 +1886,11 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_vector_indirect (matrix_type &data, size_type size): +- data_ (data), ia1_ (size), ia2_ (size) {} ++ matrix_vector_indirect (matrix_type &d, size_type s): ++ data_ (d), ia1_ (s), ia2_ (s) {} + BOOST_UBLAS_INLINE +- matrix_vector_indirect (matrix_type &data, const indirect_array_type &ia1, const indirect_array_type &ia2): +- data_ (data), ia1_ (ia1), ia2_ (ia2) { ++ matrix_vector_indirect (matrix_type &d, const indirect_array_type &ia1, const indirect_array_type &ia2): ++ data_ (d), ia1_ (ia1), ia2_ (ia2) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (ia1_.size () == ia2_.size (), bad_size ()); + } +@@ -2351,8 +2351,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_range (matrix_type &data, const range_type &r1, const range_type &r2): +- data_ (data), r1_ (r1.preprocess (data.size1 ())), r2_ (r2.preprocess (data.size2 ())) { ++ matrix_range (matrix_type &d, const range_type &r1, const range_type &r2): ++ data_ (d), r1_ (r1.preprocess (d.size1 ())), r2_ (r2.preprocess (d.size2 ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (r1_.start () <= data_.size1 () && + // r1_.start () + r1_.size () <= data_.size1 (), bad_index ()); +@@ -2360,8 +2360,8 @@ + // r2_.start () + r2_.size () <= data_.size2 (), bad_index ()); + } + BOOST_UBLAS_INLINE +- matrix_range (const matrix_closure_type &data, const range_type &r1, const range_type &r2, int): +- data_ (data), r1_ (r1.preprocess (data.size1 ())), r2_ (r2.preprocess (data.size2 ())) { ++ matrix_range (const matrix_closure_type &d, const range_type &r1, const range_type &r2, int): ++ data_ (d), r1_ (r1.preprocess (d.size1 ())), r2_ (r2.preprocess (d.size2 ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (r1_.start () <= data_.size1 () && + // r1_.start () + r1_.size () <= data_.size1 (), bad_index ()); +@@ -3255,8 +3255,8 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_slice (matrix_type &data, const slice_type &s1, const slice_type &s2): +- data_ (data), s1_ (s1.preprocess (data.size1 ())), s2_ (s2.preprocess (data.size2 ())) { ++ matrix_slice (matrix_type &d, const slice_type &s1, const slice_type &s2): ++ data_ (d), s1_ (s1.preprocess (d.size1 ())), s2_ (s2.preprocess (d.size2 ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (s1_.start () <= data_.size1 () && + // s1_.start () + s1_.stride () * (s1_.size () - (s1_.size () > 0)) <= data_.size1 (), bad_index ()); +@@ -3264,8 +3264,8 @@ + // s2_.start () + s2_.stride () * (s2_.size () - (s2_.size () > 0)) <= data_.size2 (), bad_index ()); + } + BOOST_UBLAS_INLINE +- matrix_slice (const matrix_closure_type &data, const slice_type &s1, const slice_type &s2, int): +- data_ (data), s1_ (s1.preprocess (data.size1 ())), s2_ (s2.preprocess (data.size2 ())) { ++ matrix_slice (const matrix_closure_type &d, const slice_type &s1, const slice_type &s2, int): ++ data_ (d), s1_ (s1.preprocess (d.size1 ())), s2_ (s2.preprocess (d.size2 ())) { + // Early checking of preconditions. + // BOOST_UBLAS_CHECK (s1_.start () <= data_.size1 () && + // s1_.start () + s1_.stride () * (s1_.size () - (s1_.size () > 0)) <= data_.size1 (), bad_index ()); +@@ -4213,14 +4213,14 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- matrix_indirect (matrix_type &data, size_type size1, size_type size2): +- data_ (data), ia1_ (size1), ia2_ (size2) {} ++ matrix_indirect (matrix_type &d, size_type s1, size_type s2): ++ data_ (d), ia1_ (s1), ia2_ (s2) {} + BOOST_UBLAS_INLINE +- matrix_indirect (matrix_type &data, const indirect_array_type &ia1, const indirect_array_type &ia2): +- data_ (data), ia1_ (ia1.preprocess (data.size1 ())), ia2_ (ia2.preprocess (data.size2 ())) {} ++ matrix_indirect (matrix_type &d, const indirect_array_type &ia1, const indirect_array_type &ia2): ++ data_ (d), ia1_ (ia1.preprocess (d.size1 ())), ia2_ (ia2.preprocess (d.size2 ())) {} + BOOST_UBLAS_INLINE +- matrix_indirect (const matrix_closure_type &data, const indirect_array_type &ia1, const indirect_array_type &ia2, int): +- data_ (data), ia1_ (ia1.preprocess (data.size1 ())), ia2_ (ia2.preprocess (data.size2 ())) {} ++ matrix_indirect (const matrix_closure_type &d, const indirect_array_type &ia1, const indirect_array_type &ia2, int): ++ data_ (d), ia1_ (ia1.preprocess (d.size1 ())), ia2_ (ia2.preprocess (d.size2 ())) {} + + // Accessors + BOOST_UBLAS_INLINE +diff -aruN a/boost/numeric/ublas/matrix_sparse.hpp b/boost/numeric/ublas/matrix_sparse.hpp +--- a/boost/numeric/ublas/matrix_sparse.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/matrix_sparse.hpp 2012-02-07 15:25:24.635307503 -0800 +@@ -300,9 +300,9 @@ + matrix_container<self_type> (), + size1_ (0), size2_ (0), data_ () {} + BOOST_UBLAS_INLINE +- mapped_matrix (size_type size1, size_type size2, size_type non_zeros = 0): ++ mapped_matrix (size_type s1, size_type s2, size_type non_zeros = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ () { ++ size1_ (s1), size2_ (s2), data_ () { + detail::map_reserve (data (), restrict_capacity (non_zeros)); + } + BOOST_UBLAS_INLINE +@@ -358,11 +358,11 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + // FIXME preserve unimplemented + BOOST_UBLAS_CHECK (!preserve, internal_logic ()); +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + data ().clear (); + } + +@@ -1373,9 +1373,9 @@ + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); + } + BOOST_UBLAS_INLINE +- mapped_vector_of_mapped_vector (size_type size1, size_type size2, size_type non_zeros = 0): ++ mapped_vector_of_mapped_vector (size_type s1, size_type s2, size_type non_zeros = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ () { ++ size1_ (s1), size2_ (s2), data_ () { + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); + } + BOOST_UBLAS_INLINE +@@ -1427,11 +1427,11 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + // FIXME preserve unimplemented + BOOST_UBLAS_CHECK (!preserve, internal_logic ()); +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + data ().clear (); + data () [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); + } +@@ -2666,9 +2666,9 @@ + storage_invariants (); + } + BOOST_UBLAS_INLINE +- compressed_matrix (size_type size1, size_type size2, size_type non_zeros = 0): ++ compressed_matrix (size_type s1, size_type s2, size_type non_zeros = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), capacity_ (restrict_capacity (non_zeros)), ++ size1_ (s1), size2_ (s2), capacity_ (restrict_capacity (non_zeros)), + filled1_ (1), filled2_ (0), + index1_data_ (layout_type::size_M (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { + index1_data_ [filled1_ - 1] = k_based (filled2_); +@@ -2764,9 +2764,9 @@ + return value_data_; + } + BOOST_UBLAS_INLINE +- void set_filled (const array_size_type& filled1, const array_size_type& filled2) { +- filled1_ = filled1; +- filled2_ = filled2; ++ void set_filled (const array_size_type& f1, const array_size_type& f2) { ++ filled1_ = f1; ++ filled2_ = f2; + storage_invariants (); + } + BOOST_UBLAS_INLINE +@@ -2802,11 +2802,11 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + // FIXME preserve unimplemented + BOOST_UBLAS_CHECK (!preserve, internal_logic ()); +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + capacity_ = restrict_capacity (capacity_); + filled1_ = 1; + filled2_ = 0; +@@ -4045,9 +4045,9 @@ + storage_invariants (); + } + BOOST_UBLAS_INLINE +- coordinate_matrix (size_type size1, size_type size2, array_size_type non_zeros = 0): ++ coordinate_matrix (size_type s1, size_type s2, array_size_type non_zeros = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), capacity_ (restrict_capacity (non_zeros)), ++ size1_ (s1), size2_ (s2), capacity_ (restrict_capacity (non_zeros)), + filled_ (0), sorted_filled_ (filled_), sorted_ (true), + index1_data_ (capacity_), index2_data_ (capacity_), value_data_ (capacity_) { + storage_invariants (); +@@ -4111,13 +4111,13 @@ + return value_data_; + } + BOOST_UBLAS_INLINE +- void set_filled (const array_size_type &filled) { ++ void set_filled (const array_size_type &f) { + // Make sure that storage_invariants() succeeds +- if (sorted_ && filled < filled_) +- sorted_filled_ = filled; ++ if (sorted_ && f < filled_) ++ sorted_filled_ = f; + else +- sorted_ = (sorted_filled_ == filled); +- filled_ = filled; ++ sorted_ = (sorted_filled_ == f); ++ filled_ = f; + storage_invariants (); + } + BOOST_UBLAS_INLINE +@@ -4144,11 +4144,11 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + // FIXME preserve unimplemented + BOOST_UBLAS_CHECK (!preserve, internal_logic ()); +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + capacity_ = restrict_capacity (capacity_); + index1_data_.resize (capacity_); + index2_data_.resize (capacity_); +@@ -4403,21 +4403,21 @@ + std::inplace_merge (ita.begin (), iunsorted, ita.end ()); + + // sum duplicates with += and remove +- array_size_type filled = 0; ++ array_size_type f = 0; + for (array_size_type i = 1; i < filled_; ++ i) { +- if (index1_data_ [filled] != index1_data_ [i] || +- index2_data_ [filled] != index2_data_ [i]) { +- ++ filled; +- if (filled != i) { +- index1_data_ [filled] = index1_data_ [i]; +- index2_data_ [filled] = index2_data_ [i]; +- value_data_ [filled] = value_data_ [i]; ++ if (index1_data_ [f] != index1_data_ [i] || ++ index2_data_ [f] != index2_data_ [i]) { ++ ++ f; ++ if (f != i) { ++ index1_data_ [f] = index1_data_ [i]; ++ index2_data_ [f] = index2_data_ [i]; ++ value_data_ [f] = value_data_ [i]; + } + } else { +- value_data_ [filled] += value_data_ [i]; ++ value_data_ [f] += value_data_ [i]; + } + } +- filled_ = filled + 1; ++ filled_ = f + 1; + sorted_filled_ = filled_; + sorted_ = true; + storage_invariants (); +diff -aruN a/boost/numeric/ublas/storage.hpp b/boost/numeric/ublas/storage.hpp +--- a/boost/numeric/ublas/storage.hpp 2010-04-06 13:09:04.000000000 -0700 ++++ b/boost/numeric/ublas/storage.hpp 2012-02-07 15:25:24.635307503 -0800 +@@ -62,8 +62,8 @@ + data_ = 0; + } + explicit BOOST_UBLAS_INLINE +- unbounded_array (size_type size, const ALLOC &a = ALLOC()): +- alloc_(a), size_ (size) { ++ unbounded_array (size_type s, const ALLOC &a = ALLOC()): ++ alloc_(a), size_ (s) { + if (size_) { + data_ = alloc_.allocate (size_); + if (! detail::has_trivial_constructor<T>::value) { +@@ -76,8 +76,8 @@ + } + // No value initialised, but still be default constructed + BOOST_UBLAS_INLINE +- unbounded_array (size_type size, const value_type &init, const ALLOC &a = ALLOC()): +- alloc_ (a), size_ (size) { ++ unbounded_array (size_type s, const value_type &init, const ALLOC &a = ALLOC()): ++ alloc_ (a), size_ (s) { + if (size_) { + data_ = alloc_.allocate (size_); + std::uninitialized_fill (begin(), end(), init); +@@ -113,33 +113,33 @@ + // Resizing + private: + BOOST_UBLAS_INLINE +- void resize_internal (const size_type size, const value_type init, const bool preserve) { +- if (size != size_) { ++ void resize_internal (const size_type s, const value_type init, const bool preserve) { ++ if (s != size_) { + pointer p_data = data_; +- if (size) { +- data_ = alloc_.allocate (size); ++ if (s) { ++ data_ = alloc_.allocate (s); + if (preserve) { + pointer si = p_data; + pointer di = data_; +- if (size < size_) { +- for (; di != data_ + size; ++di) { ++ if (s < size_) { ++ for (; di != data_ + s; ++di) { + alloc_.construct (di, *si); + ++si; + } + } + else { +- for (pointer si = p_data; si != p_data + size_; ++si) { +- alloc_.construct (di, *si); ++ for (pointer si2 = p_data; si2 != p_data + size_; ++si) { ++ alloc_.construct (di, *si2); + ++di; + } +- for (; di != data_ + size; ++di) { ++ for (; di != data_ + s; ++di) { + alloc_.construct (di, init); + } + } + } + else { + if (! detail::has_trivial_constructor<T>::value) { +- for (pointer di = data_; di != data_ + size; ++di) ++ for (pointer di = data_; di != data_ + s; ++di) + alloc_.construct (di, value_type()); + } + } +@@ -153,19 +153,19 @@ + alloc_.deallocate (p_data, size_); + } + +- if (!size) ++ if (!s) + data_ = 0; +- size_ = size; ++ size_ = s; + } + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size) { +- resize_internal (size, value_type (), false); ++ void resize (size_type s) { ++ resize_internal (s, value_type (), false); + } + BOOST_UBLAS_INLINE +- void resize (size_type size, value_type init) { +- resize_internal (size, init, true); ++ void resize (size_type s, value_type init) { ++ resize_internal (s, init, true); + } + + // Random Access Container +@@ -318,14 +318,14 @@ + size_ (0) /*, data_ ()*/ { // size 0 - use bounded_vector to default construct with size N + } + explicit BOOST_UBLAS_INLINE +- bounded_array (size_type size): +- size_ (size) /*, data_ ()*/ { ++ bounded_array (size_type s): ++ size_ (s) /*, data_ ()*/ { + BOOST_UBLAS_CHECK (size_ <= N, bad_size ()); + // data_ (an array) elements are already default constructed + } + BOOST_UBLAS_INLINE +- bounded_array (size_type size, const value_type &init): +- size_ (size) /*, data_ ()*/ { ++ bounded_array (size_type s, const value_type &init): ++ size_ (s) /*, data_ ()*/ { + BOOST_UBLAS_CHECK (size_ <= N, bad_size ()); + // ISSUE elements should be value constructed here, but we must fill instead as already default constructed + std::fill (begin(), end(), init) ; +@@ -339,16 +339,16 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size) { +- BOOST_UBLAS_CHECK (size <= N, bad_size ()); +- size_ = size; ++ void resize (size_type s) { ++ BOOST_UBLAS_CHECK (s <= N, bad_size ()); ++ size_ = s; + } + BOOST_UBLAS_INLINE +- void resize (size_type size, value_type init) { +- BOOST_UBLAS_CHECK (size <= N, bad_size ()); +- if (size > size_) +- std::fill (data_ + size_, data_ + size, init); +- size_ = size; ++ void resize (size_type s, value_type init) { ++ BOOST_UBLAS_CHECK (s <= N, bad_size ()); ++ if (s > size_) ++ std::fill (data_ + size_, data_ + s, init); ++ size_ = s; + } + + // Random Access Container +@@ -489,17 +489,17 @@ + size_ (0), own_ (true), data_ (new value_type [0]) { + } + explicit BOOST_UBLAS_INLINE +- array_adaptor (size_type size): +- size_ (size), own_ (true), data_ (new value_type [size]) { ++ array_adaptor (size_type s): ++ size_ (s), own_ (true), data_ (new value_type [s]) { + } + BOOST_UBLAS_INLINE +- array_adaptor (size_type size, const value_type &init): +- size_ (size), own_ (true), data_ (new value_type [size]) { ++ array_adaptor (size_type s, const value_type &init): ++ size_ (s), own_ (true), data_ (new value_type [s]) { + std::fill (data_, data_ + size_, init); + } + BOOST_UBLAS_INLINE +- array_adaptor (size_type size, pointer data): +- size_ (size), own_ (false), data_ (data) {} ++ array_adaptor (size_type s, pointer d): ++ size_ (s), own_ (false), data_ (d) {} + BOOST_UBLAS_INLINE + array_adaptor (const array_adaptor &a): + storage_array<self_type> (), +@@ -516,26 +516,26 @@ + // Resizing + private: + BOOST_UBLAS_INLINE +- void resize_internal (size_type size, value_type init, bool preserve = true) { +- if (size != size_) { +- pointer data = new value_type [size]; ++ void resize_internal (size_type s, value_type init, bool preserve = true) { ++ if (s != size_) { ++ pointer data = new value_type [s]; + if (preserve) { +- std::copy (data_, data_ + (std::min) (size, size_), data); +- std::fill (data + (std::min) (size, size_), data + size, init); ++ std::copy (data_, data_ + (std::min) (s, size_), data); ++ std::fill (data + (std::min) (s, size_), data + s, init); + } + if (own_) + delete [] data_; +- size_ = size; ++ size_ = s; + own_ = true; + data_ = data; + } + } + BOOST_UBLAS_INLINE +- void resize_internal (size_type size, pointer data, value_type init, bool preserve = true) { ++ void resize_internal (size_type s, pointer data, value_type init, bool preserve = true) { + if (data != data_) { + if (preserve) { +- std::copy (data_, data_ + (std::min) (size, size_), data); +- std::fill (data + (std::min) (size, size_), data + size, init); ++ std::copy (data_, data_ + (std::min) (s, size_), data); ++ std::fill (data + (std::min) (s, size_), data + s, init); + } + if (own_) + delete [] data_; +@@ -543,26 +543,26 @@ + data_ = data; + } + else { +- std::fill (data + (std::min) (size, size_), data + size, init); ++ std::fill (data + (std::min) (s, size_), data + s, init); + } +- size_ = size; ++ size_ = s; + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size) { +- resize_internal (size, value_type (), false); ++ void resize (size_type s) { ++ resize_internal (s, value_type (), false); + } + BOOST_UBLAS_INLINE +- void resize (size_type size, value_type init) { +- resize_internal (size, init, true); ++ void resize (size_type s, value_type init) { ++ resize_internal (s, init, true); + } + BOOST_UBLAS_INLINE +- void resize (size_type size, pointer data) { +- resize_internal (size, data, value_type (), false); ++ void resize (size_type s, pointer data) { ++ resize_internal (s, data, value_type (), false); + } + BOOST_UBLAS_INLINE +- void resize (size_type size, pointer data, value_type init) { +- resize_internal (size, data, init, true); ++ void resize (size_type s, pointer data, value_type init) { ++ resize_internal (s, data, init, true); + } + + BOOST_UBLAS_INLINE +@@ -882,9 +882,9 @@ + basic_range (): + start_ (0), size_ (0) {} + BOOST_UBLAS_INLINE +- basic_range (size_type start, size_type stop): +- start_ (start), size_ (stop - start) { +- BOOST_UBLAS_CHECK (start_ <= stop, bad_index ()); ++ basic_range (size_type in_start, size_type in_stop): ++ start_ (in_start), size_ (in_stop - in_start) { ++ BOOST_UBLAS_CHECK (start_ <= in_stop, bad_index ()); + } + + BOOST_UBLAS_INLINE +@@ -1055,10 +1055,10 @@ + } + + BOOST_UBLAS_INLINE +- basic_range preprocess (size_type size) const { ++ basic_range preprocess (size_type s) const { + if (this != &all_) + return *this; +- return basic_range (0, size); ++ return basic_range (0, s); + } + static + BOOST_UBLAS_INLINE +@@ -1094,8 +1094,8 @@ + basic_slice (): + start_ (0), stride_ (0), size_ (0) {} + BOOST_UBLAS_INLINE +- basic_slice (size_type start, difference_type stride, size_type size): +- start_ (start), stride_ (stride), size_ (size) {} ++ basic_slice (size_type in_start, difference_type in_stride, size_type in_size): ++ start_ (in_start), stride_ (in_stride), size_ (in_size) {} + + BOOST_UBLAS_INLINE + size_type start () const { +@@ -1274,10 +1274,10 @@ + } + + BOOST_UBLAS_INLINE +- basic_slice preprocess (size_type size) const { ++ basic_slice preprocess (size_type s) const { + if (this != &all_) + return *this; +- return basic_slice (0, 1, size); ++ return basic_slice (0, 1, s); + } + static + BOOST_UBLAS_INLINE +@@ -1316,11 +1316,11 @@ + indirect_array (): + size_ (), data_ () {} + explicit BOOST_UBLAS_INLINE +- indirect_array (size_type size): +- size_ (size), data_ (size) {} ++ indirect_array (size_type s): ++ size_ (s), data_ (s) {} + BOOST_UBLAS_INLINE +- indirect_array (size_type size, const array_type &data): +- size_ (size), data_ (data) {} ++ indirect_array (size_type s, const array_type &d): ++ size_ (s), data_ (d) {} + BOOST_UBLAS_INLINE + indirect_array (pointer start, pointer stop): + size_ (stop - start), data_ (stop - start) { +@@ -1376,27 +1376,27 @@ + BOOST_UBLAS_INLINE + indirect_array compose (const basic_range<size_type, difference_type> &r) const { + BOOST_UBLAS_CHECK (r.start () + r.size () <= size_, bad_size ()); +- array_type data (r.size ()); ++ array_type local_data (r.size ()); + for (size_type i = 0; i < r.size (); ++ i) +- data [i] = data_ [r.start () + i]; +- return indirect_array (r.size (), data); ++ local_data [i] = data_ [r.start () + i]; ++ return indirect_array (r.size (), local_data); + } + BOOST_UBLAS_INLINE + indirect_array compose (const basic_slice<size_type, difference_type> &s) const { + BOOST_UBLAS_CHECK (s.start () + s.stride () * (s.size () - (s.size () > 0)) <= size (), bad_size ()); +- array_type data (s.size ()); ++ array_type local_data (s.size ()); + for (size_type i = 0; i < s.size (); ++ i) +- data [i] = data_ [s.start () + s.stride () * i]; +- return indirect_array (s.size (), data); ++ local_data [i] = data_ [s.start () + s.stride () * i]; ++ return indirect_array (s.size (), local_data); + } + BOOST_UBLAS_INLINE + indirect_array compose (const indirect_array &ia) const { +- array_type data (ia.size_); ++ array_type local_data (ia.size_); + for (size_type i = 0; i < ia.size_; ++ i) { + BOOST_UBLAS_CHECK (ia.data_ [i] <= size_, bad_size ()); +- data [i] = data_ [ia.data_ [i]]; ++ local_data [i] = data_ [ia.data_ [i]]; + } +- return indirect_array (ia.size_, data); ++ return indirect_array (ia.size_, local_data); + } + + // Comparison +@@ -1534,11 +1534,11 @@ + } + + BOOST_UBLAS_INLINE +- indirect_array preprocess (size_type size) const { ++ indirect_array preprocess (size_type s) const { + if (this != &all_) + return *this; +- indirect_array ia (size); +- for (size_type i = 0; i < size; ++ i) ++ indirect_array ia (s); ++ for (size_type i = 0; i < s; ++ i) + ia (i) = i; + return ia; + } +@@ -1666,8 +1666,8 @@ + typedef const value_type const_reference; + + BOOST_UBLAS_INLINE +- index_pair_array(size_type size, V1& data1, V2& data2) : +- size_(size),data1_(data1),data2_(data2) {} ++ index_pair_array(size_type s, V1& data1, V2& data2) : ++ size_(s),data1_(data1),data2_(data2) {} + + BOOST_UBLAS_INLINE + size_type size() const { +@@ -1841,8 +1841,8 @@ + typedef const value_type const_reference; + + BOOST_UBLAS_INLINE +- index_triple_array(size_type size, V1& data1, V2& data2, V3& data3) : +- size_(size),data1_(data1),data2_(data2),data3_(data3) {} ++ index_triple_array(size_type s, V1& data1, V2& data2, V3& data3) : ++ size_(s),data1_(data1),data2_(data2),data3_(data3) {} + + BOOST_UBLAS_INLINE + size_type size() const { +diff -aruN a/boost/numeric/ublas/storage_sparse.hpp b/boost/numeric/ublas/storage_sparse.hpp +--- a/boost/numeric/ublas/storage_sparse.hpp 2009-03-09 13:24:11.000000000 -0700 ++++ b/boost/numeric/ublas/storage_sparse.hpp 2012-02-07 15:25:24.635307503 -0800 +@@ -263,38 +263,38 @@ + private: + // Resizing - implicitly exposses uninitialized (but default constructed) mapped_type + BOOST_UBLAS_INLINE +- void resize (size_type size) { ++ void resize (size_type s) { + BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); +- if (size > capacity_) { +- const size_type capacity = size << 1; +- BOOST_UBLAS_CHECK (capacity, internal_logic ()); +- pointer data = alloc_.allocate (capacity); +- std::uninitialized_copy (data_, data_ + (std::min) (size, size_), data); +- std::uninitialized_fill (data + (std::min) (size, size_), data + capacity, value_type ()); ++ if (s > capacity_) { ++ const size_type cap = s << 1; ++ BOOST_UBLAS_CHECK (cap, internal_logic ()); ++ pointer data = alloc_.allocate (cap); ++ std::uninitialized_copy (data_, data_ + (std::min) (s, size_), data); ++ std::uninitialized_fill (data + (std::min) (s, size_), data + cap, value_type ()); + + if (capacity_) { + std::for_each (data_, data_ + capacity_, static_destroy); + alloc_.deallocate (data_, capacity_); + } +- capacity_ = capacity; ++ capacity_ = cap; + data_ = data; + } +- size_ = size; ++ size_ = s; + BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); + } + public: + + // Reserving + BOOST_UBLAS_INLINE +- void reserve (size_type capacity) { ++ void reserve (size_type cap) { + BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); + // Reduce capacity_ if size_ allows +- BOOST_UBLAS_CHECK (capacity >= size_, bad_size ()); ++ BOOST_UBLAS_CHECK (cap >= size_, bad_size ()); + pointer data; +- if (capacity) { +- data = alloc_.allocate (capacity); ++ if (cap) { ++ data = alloc_.allocate (cap); + std::uninitialized_copy (data_, data_ + size_, data); +- std::uninitialized_fill (data + size_, data + capacity, value_type ()); ++ std::uninitialized_fill (data + size_, data + cap, value_type ()); + } + else + data = 0; +@@ -303,7 +303,7 @@ + std::for_each (data_, data_ + capacity_, static_destroy); + alloc_.deallocate (data_, capacity_); + } +- capacity_ = capacity; ++ capacity_ = cap; + data_ = data; + BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); + } +diff -aruN a/boost/numeric/ublas/symmetric.hpp b/boost/numeric/ublas/symmetric.hpp +--- a/boost/numeric/ublas/symmetric.hpp 2009-10-06 16:53:19.000000000 -0700 ++++ b/boost/numeric/ublas/symmetric.hpp 2012-02-07 15:25:24.635307503 -0800 +@@ -76,14 +76,14 @@ + size_ (BOOST_UBLAS_SAME (size, size)), data_ (triangular_type::packed_size (layout_type (), size, size)) { + } + BOOST_UBLAS_INLINE +- symmetric_matrix (size_type size1, size_type size2): ++ symmetric_matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size_ (BOOST_UBLAS_SAME (size1, size2)), data_ (triangular_type::packed_size (layout_type (), size1, size2)) { ++ size_ (BOOST_UBLAS_SAME (s1, s2)), data_ (triangular_type::packed_size (layout_type (), s1, s2)) { + } + BOOST_UBLAS_INLINE +- symmetric_matrix (size_type size, const array_type &data): ++ symmetric_matrix (size_type size, const array_type &d): + matrix_container<self_type> (), +- size_ (size), data_ (data) {} ++ size_ (size), data_ (d) {} + BOOST_UBLAS_INLINE + symmetric_matrix (const symmetric_matrix &m): + matrix_container<self_type> (), +@@ -130,8 +130,8 @@ + } + } + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { +- resize (BOOST_UBLAS_SAME (size1, size2), preserve); ++ void resize (size_type s1, size_type s2, bool preserve = true) { ++ resize (BOOST_UBLAS_SAME (s1, s2), preserve); + } + BOOST_UBLAS_INLINE + void resize_packed_preserve (size_type size) { +@@ -944,9 +944,9 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- symmetric_adaptor (matrix_type &data): ++ symmetric_adaptor (matrix_type &d): + matrix_expression<self_type> (), +- data_ (data) { ++ data_ (d) { + BOOST_UBLAS_CHECK (data_.size1 () == data_.size2 (), bad_size ()); + } + BOOST_UBLAS_INLINE +@@ -1201,11 +1201,11 @@ + it1_begin_ (), it1_end_ (), it1_ (), + it2_begin_ (), it2_end_ (), it2_ () {} + BOOST_UBLAS_INLINE +- const_iterator1 (const self_type &m, int begin, int end, ++ const_iterator1 (const self_type &m, int b, int e, + const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end, + const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end): + container_const_reference<self_type> (m), +- begin_ (begin), end_ (end), current_ (begin), ++ begin_ (b), end_ (e), current_ (b), + it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_), + it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) { + if (current_ == 0 && it1_ == it1_end_) +@@ -1648,11 +1648,11 @@ + it1_begin_ (), it1_end_ (), it1_ (), + it2_begin_ (), it2_end_ (), it2_ () {} + BOOST_UBLAS_INLINE +- const_iterator2 (const self_type &m, int begin, int end, ++ const_iterator2 (const self_type &m, int b, int e, + const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end, + const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end): + container_const_reference<self_type> (m), +- begin_ (begin), end_ (end), current_ (begin), ++ begin_ (b), end_ (e), current_ (b), + it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_), + it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) { + if (current_ == 0 && it1_ == it1_end_) +diff -aruN a/boost/numeric/ublas/triangular.hpp b/boost/numeric/ublas/triangular.hpp +--- a/boost/numeric/ublas/triangular.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/triangular.hpp 2012-02-07 15:25:24.639286239 -0800 +@@ -106,14 +106,14 @@ + matrix_container<self_type> (), + size1_ (0), size2_ (0), data_ (0) {} + BOOST_UBLAS_INLINE +- triangular_matrix (size_type size1, size_type size2): ++ triangular_matrix (size_type s1, size_type s2): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (triangular_type::packed_size (layout_type (), size1, size2)) { ++ size1_ (s1), size2_ (s2), data_ (triangular_type::packed_size (layout_type (), s1, s2)) { + } + BOOST_UBLAS_INLINE +- triangular_matrix (size_type size1, size_type size2, const array_type &data): ++ triangular_matrix (size_type s1, size_type s2, const array_type &d): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (data) {} ++ size1_ (s1), size2_ (s2), data_ (d) {} + BOOST_UBLAS_INLINE + triangular_matrix (const triangular_matrix &m): + matrix_container<self_type> (), +@@ -149,21 +149,21 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + if (preserve) { +- self_type temporary (size1, size2); ++ self_type temporary (s1, s2); + detail::matrix_resize_preserve<layout_type, triangular_type> (*this, temporary); + } + else { +- data ().resize (triangular_type::packed_size (layout_type (), size1, size2)); +- size1_ = size1; +- size2_ = size2; ++ data ().resize (triangular_type::packed_size (layout_type (), s1, s2)); ++ size1_ = s1; ++ size2_ = s2; + } + } + BOOST_UBLAS_INLINE +- void resize_packed_preserve (size_type size1, size_type size2) { +- size1_ = size1; +- size2_ = size2; ++ void resize_packed_preserve (size_type s1, size_type s2) { ++ size1_ = s1; ++ size2_ = s2; + data ().resize (triangular_type::packed_size (layout_type (), size1_, size2_), value_type ()); + } + +@@ -996,9 +996,9 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- triangular_adaptor (matrix_type &data): ++ triangular_adaptor (matrix_type &d): + matrix_expression<self_type> (), +- data_ (data) {} ++ data_ (d) {} + BOOST_UBLAS_INLINE + triangular_adaptor (const triangular_adaptor &m): + matrix_expression<self_type> (), +diff -aruN a/boost/numeric/ublas/vector.hpp b/boost/numeric/ublas/vector.hpp +--- a/boost/numeric/ublas/vector.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/vector.hpp 2012-02-07 15:25:24.639286239 -0800 +@@ -72,9 +72,9 @@ + /// By default, its elements are initialized to 0. + /// \param size initial size of the vector + explicit BOOST_UBLAS_INLINE +- vector (size_type size): ++ vector (size_type s): + vector_container<self_type> (), +- data_ (size) { ++ data_ (s) { + } + + /// \brief Constructor of a vector by copying from another container +@@ -83,25 +83,25 @@ + /// \param data container of type \c A + /// \todo remove this definition because \c size is not used + BOOST_UBLAS_INLINE +- vector (size_type size, const array_type &data): ++ vector (size_type s, const array_type &d): + vector_container<self_type> (), +- data_ (data) {} ++ data_ (d) {} + + /// \brief Constructor of a vector by copying from another container + /// This type has the generic name \c array_typ within the vector definition. + /// \param data container of type \c A + BOOST_UBLAS_INLINE +- vector (const array_type &data): ++ vector (const array_type &d): + vector_container<self_type> (), +- data_ (data) {} ++ data_ (d) {} + + /// \brief Constructor of a vector with a predefined size and a unique initial value + /// \param size of the vector + /// \param init value to assign to each element of the vector + BOOST_UBLAS_INLINE +- vector (size_type size, const value_type &init): ++ vector (size_type s, const value_type &init): + vector_container<self_type> (), +- data_ (size, init) {} ++ data_ (s, init) {} + + /// \brief Copy-constructor of a vector + /// \param v is the vector to be duplicated +@@ -175,11 +175,11 @@ + /// \param size new size of the vector + /// \param preserve if true, keep values + BOOST_UBLAS_INLINE +- void resize (size_type size, bool preserve = true) { ++ void resize (size_type s, bool preserve = true) { + if (preserve) +- data ().resize (size, typename A::value_type ()); ++ data ().resize (s, typename A::value_type ()); + else +- data ().resize (size); ++ data ().resize (s); + } + + // --------------- +@@ -900,9 +900,9 @@ + vector_container<self_type> (), + size_ (0) {} + explicit BOOST_UBLAS_INLINE +- zero_vector (size_type size): ++ zero_vector (size_type s): + vector_container<self_type> (), +- size_ (size) {} ++ size_ (s) {} + BOOST_UBLAS_INLINE + zero_vector (const zero_vector &v): + vector_container<self_type> (), +@@ -916,8 +916,8 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size, bool /*preserve*/ = true) { +- size_ = size; ++ void resize (size_type s, bool /*preserve*/ = true) { ++ size_ = s; + } + + // Element support +@@ -1110,9 +1110,9 @@ + /// \param size is the dimension of the vector + /// \param index is the order of the vector + BOOST_UBLAS_INLINE +- explicit unit_vector (size_type size, size_type index = 0): ++ explicit unit_vector (size_type s, size_type i = 0): + vector_container<self_type> (), +- size_ (size), index_ (index) {} ++ size_ (s), index_ (i) {} + + /// \brief Copy-constructor + BOOST_UBLAS_INLINE +@@ -1141,8 +1141,8 @@ + /// \brief Resize the vector. The values are preserved by default (i.e. the index does not change) + /// \param size is the new size of the vector + BOOST_UBLAS_INLINE +- void resize (size_type size, bool /*preserve*/ = true) { +- size_ = size; ++ void resize (size_type s, bool /*preserve*/ = true) { ++ size_ = s; + } + + // Element support +@@ -1352,9 +1352,9 @@ + vector_container<self_type> (), + size_ (0), value_ () {} + BOOST_UBLAS_INLINE +- explicit scalar_vector (size_type size, const value_type &value = value_type(1)): ++ explicit scalar_vector (size_type s, const value_type &value = value_type(1)): + vector_container<self_type> (), +- size_ (size), value_ (value) {} ++ size_ (s), value_ (value) {} + BOOST_UBLAS_INLINE + scalar_vector (const scalar_vector &v): + vector_container<self_type> (), +@@ -1368,8 +1368,8 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size, bool /*preserve*/ = true) { +- size_ = size; ++ void resize (size_type s, bool /*preserve*/ = true) { ++ size_ = s; + } + + // Element support +@@ -1594,8 +1594,8 @@ + c_vector (): + size_ (N) /* , data_ () */ {} + explicit BOOST_UBLAS_INLINE +- c_vector (size_type size): +- size_ (size) /* , data_ () */ { ++ c_vector (size_type s): ++ size_ (s) /* , data_ () */ { + if (size_ > N) + bad_size ().raise (); + } +@@ -1631,10 +1631,10 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size, bool preserve = true) { +- if (size > N) ++ void resize (size_type s, bool preserve = true) { ++ if (s > N) + bad_size ().raise (); +- size_ = size; ++ size_ = s; + } + + // Element support +diff -aruN a/boost/numeric/ublas/vector_of_vector.hpp b/boost/numeric/ublas/vector_of_vector.hpp +--- a/boost/numeric/ublas/vector_of_vector.hpp 2007-11-25 10:07:19.000000000 -0800 ++++ b/boost/numeric/ublas/vector_of_vector.hpp 2012-02-07 15:25:24.639286239 -0800 +@@ -66,9 +66,9 @@ + storage_invariants (); + } + BOOST_UBLAS_INLINE +- generalized_vector_of_vector (size_type size1, size_type size2, size_type non_zeros = 0): ++ generalized_vector_of_vector (size_type s1, size_type s2, size_type non_zeros = 0): + matrix_container<self_type> (), +- size1_ (size1), size2_ (size2), data_ (layout_type::size_M (size1_, size2_) + 1) { ++ size1_ (s1), size2_ (s2), data_ (layout_type::size_M (size1_, size2_) + 1) { + const size_type sizeM = layout_type::size_M (size1_, size2_); + const size_type sizem = layout_type::size_m (size1_, size2_); + for (size_type i = 0; i < sizeM; ++ i) // create size1 vector elements +@@ -132,10 +132,10 @@ + + // Resizing + BOOST_UBLAS_INLINE +- void resize (size_type size1, size_type size2, bool preserve = true) { ++ void resize (size_type s1, size_type s2, bool preserve = true) { + const size_type oldM = layout_type::size_M (size1_, size2_); +- size1_ = size1; +- size2_ = size2; ++ size1_ = s1; ++ size2_ = s2; + const size_type sizeM = layout_type::size_M (size1_, size2_); + const size_type sizem = layout_type::size_m (size1_, size2_); + data ().resize (sizeM + 1, preserve); +diff -aruN a/boost/numeric/ublas/vector_proxy.hpp b/boost/numeric/ublas/vector_proxy.hpp +--- a/boost/numeric/ublas/vector_proxy.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/vector_proxy.hpp 2012-02-07 15:25:24.639286239 -0800 +@@ -59,15 +59,15 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- vector_range (vector_type &data, const range_type &r): +- data_ (data), r_ (r.preprocess (data.size ())) { ++ vector_range (vector_type &d, const range_type &r): ++ data_ (d), r_ (r.preprocess (d.size ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (r_.start () <= data_.size () && + // r_.start () + r_.size () <= data_.size (), bad_index ()); + } + BOOST_UBLAS_INLINE +- vector_range (const vector_closure_type &data, const range_type &r, bool): +- data_ (data), r_ (r.preprocess (data.size ())) { ++ vector_range (const vector_closure_type &d, const range_type &r, bool): ++ data_ (d), r_ (r.preprocess (d.size ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (r_.start () <= data_.size () && + // r_.start () + r_.size () <= data_.size (), bad_index ()); +@@ -614,15 +614,15 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- vector_slice (vector_type &data, const slice_type &s): +- data_ (data), s_ (s.preprocess (data.size ())) { ++ vector_slice (vector_type &d, const slice_type &s): ++ data_ (d), s_ (s.preprocess (d.size ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (s_.start () <= data_.size () && + // s_.start () + s_.stride () * (s_.size () - (s_.size () > 0)) <= data_.size (), bad_index ()); + } + BOOST_UBLAS_INLINE +- vector_slice (const vector_closure_type &data, const slice_type &s, int): +- data_ (data), s_ (s.preprocess (data.size ())) { ++ vector_slice (const vector_closure_type &d, const slice_type &s, int): ++ data_ (d), s_ (s.preprocess (d.size ())) { + // Early checking of preconditions here. + // BOOST_UBLAS_CHECK (s_.start () <= data_.size () && + // s_.start () + s_.stride () * (s_.size () - (s_.size () > 0)) <= data_.size (), bad_index ()); +@@ -1159,14 +1159,14 @@ + + // Construction and destruction + BOOST_UBLAS_INLINE +- vector_indirect (vector_type &data, size_type size): +- data_ (data), ia_ (size) {} ++ vector_indirect (vector_type &d, size_type s): ++ data_ (d), ia_ (s) {} + BOOST_UBLAS_INLINE +- vector_indirect (vector_type &data, const indirect_array_type &ia): +- data_ (data), ia_ (ia.preprocess (data.size ())) {} ++ vector_indirect (vector_type &d, const indirect_array_type &ia): ++ data_ (d), ia_ (ia.preprocess (d.size ())) {} + BOOST_UBLAS_INLINE +- vector_indirect (const vector_closure_type &data, const indirect_array_type &ia, int): +- data_ (data), ia_ (ia.preprocess (data.size ())) {} ++ vector_indirect (const vector_closure_type &d, const indirect_array_type &ia, int): ++ data_ (d), ia_ (ia.preprocess (d.size ())) {} + + // Accessors + BOOST_UBLAS_INLINE +diff -aruN a/boost/numeric/ublas/vector_sparse.hpp b/boost/numeric/ublas/vector_sparse.hpp +--- a/boost/numeric/ublas/vector_sparse.hpp 2010-07-04 23:06:24.000000000 -0700 ++++ b/boost/numeric/ublas/vector_sparse.hpp 2012-02-07 15:25:24.639286239 -0800 +@@ -309,9 +309,9 @@ + vector_container<self_type> (), + size_ (0), data_ () {} + BOOST_UBLAS_INLINE +- mapped_vector (size_type size, size_type non_zeros = 0): ++ mapped_vector (size_type s, size_type non_zeros = 0): + vector_container<self_type> (), +- size_ (size), data_ () { ++ size_ (s), data_ () { + detail::map_reserve (data(), restrict_capacity (non_zeros)); + } + BOOST_UBLAS_INLINE +@@ -360,8 +360,8 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size, bool preserve = true) { +- size_ = size; ++ void resize (size_type s, bool preserve = true) { ++ size_ = s; + if (preserve) { + data ().erase (data ().lower_bound(size_), data ().end()); + } +@@ -832,9 +832,9 @@ + storage_invariants (); + } + explicit BOOST_UBLAS_INLINE +- compressed_vector (size_type size, size_type non_zeros = 0): ++ compressed_vector (size_type s, size_type non_zeros = 0): + vector_container<self_type> (), +- size_ (size), capacity_ (restrict_capacity (non_zeros)), filled_ (0), ++ size_ (s), capacity_ (restrict_capacity (non_zeros)), filled_ (0), + index_data_ (capacity_), value_data_ (capacity_) { + storage_invariants (); + } +@@ -887,8 +887,8 @@ + return value_data_; + } + BOOST_UBLAS_INLINE +- void set_filled (const typename index_array_type::size_type & filled) { +- filled_ = filled; ++ void set_filled (const typename index_array_type::size_type & f) { ++ filled_ = f; + storage_invariants (); + } + BOOST_UBLAS_INLINE +@@ -910,14 +910,14 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size, bool preserve = true) { +- size_ = size; ++ void resize (size_type s, bool preserve = true) { ++ size_ = s; + capacity_ = restrict_capacity (capacity_); + if (preserve) { + index_data_. resize (capacity_, size_type ()); + value_data_. resize (capacity_, value_type ()); + filled_ = (std::min) (capacity_, filled_); +- while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= size)) { ++ while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= s)) { + --filled_; + } + } +@@ -1473,9 +1473,9 @@ + storage_invariants (); + } + explicit BOOST_UBLAS_INLINE +- coordinate_vector (size_type size, size_type non_zeros = 0): ++ coordinate_vector (size_type s, size_type non_zeros = 0): + vector_container<self_type> (), +- size_ (size), capacity_ (restrict_capacity (non_zeros)), ++ size_ (s), capacity_ (restrict_capacity (non_zeros)), + filled_ (0), sorted_filled_ (filled_), sorted_ (true), + index_data_ (capacity_), value_data_ (capacity_) { + storage_invariants (); +@@ -1531,9 +1531,9 @@ + return value_data_; + } + BOOST_UBLAS_INLINE +- void set_filled (const typename index_array_type::size_type &sorted, const typename index_array_type::size_type &filled) { ++ void set_filled (const typename index_array_type::size_type &sorted, const typename index_array_type::size_type &f) { + sorted_filled_ = sorted; +- filled_ = filled; ++ filled_ = f; + storage_invariants (); + } + BOOST_UBLAS_INLINE +@@ -1556,16 +1556,16 @@ + } + public: + BOOST_UBLAS_INLINE +- void resize (size_type size, bool preserve = true) { ++ void resize (size_type s, bool preserve = true) { + if (preserve) + sort (); // remove duplicate elements. +- size_ = size; ++ size_ = s; + capacity_ = restrict_capacity (capacity_); + if (preserve) { + index_data_. resize (capacity_, size_type ()); + value_data_. resize (capacity_, value_type ()); + filled_ = (std::min) (capacity_, filled_); +- while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= size)) { ++ while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= s)) { + --filled_; + } + } +@@ -1813,19 +1813,19 @@ + std::inplace_merge (ipa.begin (), iunsorted, ipa.end ()); + + // sum duplicates with += and remove +- size_type filled = 0; ++ size_type f = 0; + for (size_type i = 1; i < filled_; ++ i) { +- if (index_data_ [filled] != index_data_ [i]) { +- ++ filled; +- if (filled != i) { +- index_data_ [filled] = index_data_ [i]; +- value_data_ [filled] = value_data_ [i]; ++ if (index_data_ [f] != index_data_ [i]) { ++ ++ f; ++ if (f != i) { ++ index_data_ [f] = index_data_ [i]; ++ value_data_ [f] = value_data_ [i]; + } + } else { +- value_data_ [filled] += value_data_ [i]; ++ value_data_ [f] += value_data_ [i]; + } + } +- filled_ = filled + 1; ++ filled_ = f + 1; + sorted_filled_ = filled_; + sorted_ = true; + storage_invariants ();
diff --git a/boost.patches/boost-53.description b/boost.patches/boost-53.description new file mode 100644 index 0000000..a8c9afd --- /dev/null +++ b/boost.patches/boost-53.description
@@ -0,0 +1,3 @@ +Fix compiler warnings triggered by -Wunused-local-typedefs. Some of this was taken +from here https://svn.boost.org/trac/boost/ticket/8546 and some was fixed by looking +at the build log.
diff --git a/boost.patches/boost-53.patch b/boost.patches/boost-53.patch new file mode 100644 index 0000000..552e5a2 --- /dev/null +++ b/boost.patches/boost-53.patch
@@ -0,0 +1,158 @@ +diff -Naur a/boost/algorithm/string/detail/finder.hpp b/boost/algorithm/string/detail/finder.hpp +--- a/boost/algorithm/string/detail/finder.hpp 2009-09-13 12:10:55.000000000 -0700 ++++ b/boost/algorithm/string/detail/finder.hpp 2015-04-15 09:02:18.683944124 -0700 +@@ -142,7 +142,6 @@ + ForwardIteratorT End, + std::forward_iterator_tag ) const + { +- typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + first_finder_type first_finder( +@@ -263,7 +262,6 @@ + ForwardIteratorT End, + unsigned int N) const + { +- typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + // Sanity check +@@ -298,7 +296,6 @@ + ForwardIteratorT End, + unsigned int N) const + { +- typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + // Sanity check +@@ -362,7 +359,6 @@ + unsigned int N, + std::random_access_iterator_tag ) + { +- typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) +@@ -436,7 +432,6 @@ + unsigned int N, + std::random_access_iterator_tag ) + { +- typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) +diff -Naur a/boost/bind/arg.hpp b/boost/bind/arg.hpp +--- a/boost/bind/arg.hpp 2007-11-25 10:07:19.000000000 -0800 ++++ b/boost/bind/arg.hpp 2015-04-15 09:02:18.683944124 -0700 +@@ -34,7 +34,6 @@ + template< class T > arg( T const & /* t */ ) + { + // static assert I == is_placeholder<T>::value +- typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ]; + } + }; + +diff -Naur a/boost/concept/detail/general.hpp b/boost/concept/detail/general.hpp +--- a/boost/concept/detail/general.hpp 2010-06-08 12:31:13.000000000 -0700 ++++ b/boost/concept/detail/general.hpp 2015-04-15 09:02:18.683944124 -0700 +@@ -12,6 +12,15 @@ + # include <boost/mpl/if.hpp> + # endif + ++ ++// If the compiler warns about unused typedefs then enable this: ++// ++#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) ++# define BOOST_CONCEPT_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) ++#else ++# define BOOST_CONCEPT_ASSERT_UNUSED_ATTRIBUTE ++#endif ++ + // This implementation works on Comeau and GCC, all the way back to + // 2.95 + namespace boost { namespace concepts { +@@ -68,7 +77,7 @@ + # define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \ + typedef ::boost::concepts::detail::instantiate< \ + &::boost::concepts::requirement_<ModelFnPtr>::failed> \ +- BOOST_PP_CAT(boost_concept_check,__LINE__) ++ BOOST_PP_CAT(boost_concept_check,__LINE__) BOOST_CONCEPT_ASSERT_UNUSED_ATTRIBUTE + + }} + +diff -Naur a/boost/ptr_container/detail/move.hpp b/boost/ptr_container/detail/move.hpp +--- a/boost/ptr_container/detail/move.hpp 2008-03-22 14:45:55.000000000 -0700 ++++ b/boost/ptr_container/detail/move.hpp 2015-04-15 09:02:18.699944284 -0700 +@@ -20,7 +20,7 @@ + template<typename Ptr> + class move_source { + public: +- move_source(Ptr& ptr) : ptr_(ptr) {} ++ move_source(Ptr& ptrArg) : ptr_(ptrArg) {} + Ptr& ptr() const { return ptr_; } + private: + Ptr& ptr_; +diff -Naur a/boost/ptr_container/detail/reversible_ptr_container.hpp b/boost/ptr_container/detail/reversible_ptr_container.hpp +--- a/boost/ptr_container/detail/reversible_ptr_container.hpp 2009-04-05 12:55:59.000000000 -0700 ++++ b/boost/ptr_container/detail/reversible_ptr_container.hpp 2015-04-15 09:02:18.699944284 -0700 +@@ -278,9 +278,9 @@ + + private: + template< class ForwardIterator > +- ForwardIterator advance( ForwardIterator begin, size_type n ) ++ ForwardIterator advance( ForwardIterator beginArg, size_type n ) + { +- ForwardIterator iter = begin; ++ ForwardIterator iter = beginArg; + std::advance( iter, n ); + return iter; + } +diff -Naur a/boost/ptr_container/detail/static_move_ptr.hpp b/boost/ptr_container/detail/static_move_ptr.hpp +--- a/boost/ptr_container/detail/static_move_ptr.hpp 2008-03-22 14:45:55.000000000 -0700 ++++ b/boost/ptr_container/detail/static_move_ptr.hpp 2015-04-15 09:02:18.699944284 -0700 +@@ -151,7 +151,7 @@ + deleter_const_reference get_deleter() const { return impl_.second(); } + private: + template<typename TT, typename DD> +- void check(const static_move_ptr<TT, DD>& ptr) ++ void check(const static_move_ptr<TT, DD>& ptrArg) + { + typedef move_ptrs::is_smart_ptr_convertible<TT, T> convertible; + BOOST_STATIC_ASSERT(convertible::value); +diff -Naur a/boost/ptr_container/exception.hpp b/boost/ptr_container/exception.hpp +--- a/boost/ptr_container/exception.hpp 2008-03-22 14:45:55.000000000 -0700 ++++ b/boost/ptr_container/exception.hpp 2015-04-15 09:02:18.699944284 -0700 +@@ -24,7 +24,7 @@ + { + const char* what_; + public: +- bad_ptr_container_operation( const char* what ) : what_( what ) ++ bad_ptr_container_operation( const char* whatArg ) : what_( whatArg ) + { } + + virtual const char* what() const throw() +@@ -38,7 +38,7 @@ + class bad_index : public bad_ptr_container_operation + { + public: +- bad_index( const char* what ) : bad_ptr_container_operation( what ) ++ bad_index( const char* whatArg ) : bad_ptr_container_operation( whatArg ) + { } + }; + +diff -Naur a/boost/system/error_code.hpp b/boost/system/error_code.hpp +--- a/boost/system/error_code.hpp 2010-07-06 03:47:30.000000000 -0700 ++++ b/boost/system/error_code.hpp 2015-04-15 09:02:18.695944245 -0700 +@@ -211,9 +211,9 @@ + inline const error_category & get_system_category() { return system_category(); } + inline const error_category & get_generic_category() { return generic_category(); } + inline const error_category & get_posix_category() { return generic_category(); } +- static const error_category & posix_category = generic_category(); +- static const error_category & errno_ecat = generic_category(); +- static const error_category & native_ecat = system_category(); ++ //static const error_category & posix_category = generic_category(); ++ //static const error_category & errno_ecat = generic_category(); ++ //static const error_category & native_ecat = system_category(); + # endif + + // class error_condition -----------------------------------------------//
diff --git a/boost.patches/boost-54.description b/boost.patches/boost-54.description new file mode 100644 index 0000000..679dc8c --- /dev/null +++ b/boost.patches/boost-54.description
@@ -0,0 +1 @@ +Fix compiler shadowed declaration warnings in uuid_io
diff --git a/boost.patches/boost-54.patch b/boost.patches/boost-54.patch new file mode 100644 index 0000000..12718e7 --- /dev/null +++ b/boost.patches/boost-54.patch
@@ -0,0 +1,12 @@ +diff -aruN boost_1_45_0/boost/uuid/uuid_io.hpp boost_1_45_0.N/boost/uuid/uuid_io.hpp +--- boost_1_45_0/boost/uuid/uuid_io.hpp 2010-07-12 17:37:17.000000000 -0700 ++++ boost_1_45_0.N/boost/uuid/uuid_io.hpp 2015-04-28 17:59:01.600615207 -0700 +@@ -59,7 +59,7 @@ + } + + if (flags & std::ios_base::left) { +- for (std::streamsize i=uuid_width; i<width; i++) { ++ for (std::streamsize j=uuid_width; j<width; j++) { + os << fill; + } + }
diff --git a/boost.tar.bz2 b/boost.tar.bz2 new file mode 100644 index 0000000..e824653 --- /dev/null +++ b/boost.tar.bz2 Binary files differ
diff --git a/boost.url b/boost.url new file mode 100644 index 0000000..75502b2 --- /dev/null +++ b/boost.url
@@ -0,0 +1 @@ +http://download.sourceforge.net/boost/boost_1_45_0.tar.bz2
diff --git a/boost.version b/boost.version new file mode 100644 index 0000000..37918b8 --- /dev/null +++ b/boost.version
@@ -0,0 +1 @@ +1_45_0
diff --git a/boost_1_45_0/INSTALL b/boost_1_45_0/INSTALL new file mode 100644 index 0000000..0f669e6 --- /dev/null +++ b/boost_1_45_0/INSTALL
@@ -0,0 +1,8 @@ +See ./index.html for information about this release. The "Getting Started" +section is a useful starting place. + +--------------------------- +Copyright Beman Dawes, 2008 + +Distributed under the Boost Software License, Version 1.0. +See ./LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt \ No newline at end of file
diff --git a/boost_1_45_0/Jamroot b/boost_1_45_0/Jamroot new file mode 100644 index 0000000..978c5e0 --- /dev/null +++ b/boost_1_45_0/Jamroot
@@ -0,0 +1,757 @@ +# Copyright Vladimir Prus 2002-2006. +# Copyright Dave Abrahams 2005-2006. +# Copyright Rene Rivera 2005-2007. +# Copyright Douglas Gregor 2005. +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Usage: +# +# bjam [options] [properties] [install|stage] +# +# Builds and installs Boost. +# +# Targets and Related Options: +# +# install Install headers and compiled library files to the +# ======= configured locations (below). +# +# --prefix=<PREFIX> Install architecture independent files here. +# Default; C:\Boost on Win32 +# Default; /usr/local on Unix. Linux, etc. +# +# --exec-prefix=<EPREFIX> Install architecture dependent files here. +# Default; <PREFIX> +# +# --libdir=<DIR> Install library files here. +# Default; <EPREFIX>/lib +# +# --includedir=<HDRDIR> Install header files here. +# Default; <PREFIX>/include +# +# stage Build and install only compiled library files +# ===== to the stage directory. +# +# --stagedir=<STAGEDIR> Install library files here +# Default; ./stage +# +# Other Options: +# +# --build-type=<type> Build the specified pre-defined set of variations +# of the libraries. Note, that which variants get +# built depends on what each library supports. +# +# minimal (default) - Builds a minimal set of +# variants. On Windows, these are static +# multithreaded libraries in debug and release +# modes, using shared runtime. On Linux, these +# are static and shared multithreaded libraries +# in release mode. +# +# complete - Build all possible variations. +# +# --build-dir=DIR Build in this location instead of building +# within the distribution tree. Recommended! +# +# --show-libraries Displays the list of Boost libraries that require +# build and installation steps, then exit. +# +# --layout=<layout> Determines whether to choose library names +# and header locations such that multiple +# versions of Boost or multiple compilers can +# be used on the same system. +# +# versioned - Names of boost binaries +# include the Boost version number, name and +# version of the compiler and encoded build +# properties. Boost headers are installed in a +# subdirectory of <HDRDIR> whose name contains +# the Boost version number. +# +# tagged -- Names of boost binaries include the +# encoded build properties such as variant and +# threading, but do not including compiler name +# and version, or Boost version. This option is +# useful if you build several variants of Boost, +# using the same compiler. +# +# system - Binaries names do not include the +# Boost version number or the name and version +# number of the compiler. Boost headers are +# installed directly into <HDRDIR>. This option +# is intended for system integrators who are +# building distribution packages. +# +# The default value is 'versioned' on Windows, and +# 'system' on Unix. +# +# --buildid=ID Adds the specified ID to the name of built +# libraries. The default is to not add anything. +# +# --python-buildid=ID Adds the specified ID to the name of built +# libraries that depend on Python. The default +# is to not add anything. This ID is added in +# addition t --buildid. +# +# +# --help This message. +# +# --with-<library> Build and install the specified <library> +# If this option is used, only libraries +# specified using this option will be built. +# +# --without-<library> Do not build, stage, or install the specified +# <library>. By default, all libraries are built. +# +# Properties: +# +# toolset=toolset Indicates the toolset to build with. +# +# variant=debug|release Select the build variant +# +# link=static|shared Whether to build static or shared libraries +# +# threading=single|multi Whether to build single or multithreaded binaries +# +# runtime-link=static|shared +# Whether to link to static or shared C and C++ runtime. +# + +# TODO: +# - handle boost version +# - handle python options such as pydebug + +import generate ; +import modules ; +import set ; +import stage ; +import package ; +import path ; +import common ; +import os ; +import regex ; +import errors ; +import "class" : new ; +import common ; +import sequence ; +import symlink ; +import targets ; +import project ; +import option ; +import xsltproc ; +import build-system ; +import configure ; + +path-constant BOOST_ROOT : . ; +constant BOOST_VERSION : 1.45.0 ; +constant BOOST_JAMROOT_MODULE : $(__name__) ; + +local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] + ; +if $(version-tag[3]) = 0 +{ + version-tag = $(version-tag[1-2]) ; +} + +constant BOOST_VERSION_TAG : $(version-tag:J="_") ; + +# Option to choose how many variants to build. The default is "minimal". +local build-type = [ MATCH "^--build-type=(.*)" : [ modules.peek : ARGV ] ] ; +build-type ?= minimal ; +if ! ( $(build-type) in minimal complete ) +{ + ECHO "The value of the --build-type option should be either 'complete' or 'minimal'" ; + EXIT ; +} + +rule handle-static-runtime ( properties * ) +{ + # Using static runtime with shared libraries is impossible on Linux, + # and dangerous on Windows. Therefore, we disallow it. This might + # be drastic, but it was disabled for a while with nobody complaining. + + # For CW, static runtime is needed so that std::locale works. + if <link>shared in $(properties) && <runtime-link>static in $(properties) && + ! ( <toolset>cw in $(properties) ) + { + ECHO "error: link=shared together with runtime-link=static is not allowed" ; + ECHO "error: such property combination is either impossible " ; + ECHO "error: or too dangerious to be of any use" ; + EXIT ; + } +} + + +project boost + : requirements <include>. + # Disable auto-linking for all targets here, primarily because it caused + # troubles with V2. + <define>BOOST_ALL_NO_LIB=1 + # Used to encode variant in target name. See the 'tag' rule below. + <tag>@$(__name__).tag + <conditional>@handle-static-runtime + # The standard library Sun compilers use by default has no chance + # of working with Boost. Override it. + <toolset>sun:<stdlib>sun-stlport + # Comeau does not support shared lib + <toolset>como:<link>static + <toolset>como-linux:<define>_GNU_SOURCE=1 + # When building docs within Boost, we want the standard Boost style + <xsl:param>boost.defaults=Boost + : usage-requirements <include>. + : build-dir bin.v2 + ; + + +# Setup convenient aliases for all libraries. + +all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] + [ glob libs/*/build/Jamfile ] ] + ; + +all-libraries = [ sequence.unique $(all-libraries) ] ; +# The function_types library has a Jamfile, but it's used for maintenance +# purposes, there's no library to build and install. +all-libraries = [ set.difference $(all-libraries) : function_types ] ; + +configure.register-components $(all-libraries) ; + +local rule explicit-alias ( id : targets + ) +{ + alias $(id) : $(targets) ; + explicit $(id) ; +} + + +# First, the complicated libraries: where the target name in Jamfile is +# different from its directory name. +explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ; +explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ; +explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ; +explicit-alias bgl-vis : libs/graps/build//bgl-vis ; +explicit-alias serialization : libs/serialization/build//boost_serialization ; +explicit-alias wserialization : libs/serialization/build//boost_wserialization ; +for local l in $(all-libraries) +{ + if ! $(l) in test graph serialization + { + explicit-alias $(l) : libs/$(l)/build//boost_$(l) ; + } +} + +alias headers : : : : <include>. ; + + +# Decides which libraries are to be installed by looking at --with-<library> +# --without-<library> arguments. Returns the list of directories under "libs" +# which must be built and installed. +# +rule libraries-to-install ( existing-libraries * ) +{ + local argv = [ modules.peek : ARGV ] ; + local with-parameter = [ MATCH --with-(.*) : $(argv) ] ; + local without-parameter = [ MATCH --without-(.*) : $(argv) ] ; + + if ! $(with-parameter) && ! $(without-parameter) + { + # Nothing is specified on command line. See if maybe + # project-config.jam has some choices. + local project-config-libs = [ modules.peek project-config : libraries ] ; + with-parameter = [ MATCH --with-(.*) : $(project-config-libs) ] ; + without-parameter = [ MATCH --without-(.*) : $(project-config-libs) ] ; + } + + # Do some checks. + if $(with-parameter) && $(without-parameter) + { + ECHO "error: both --with-<library> and --without-<library> specified" ; + EXIT ; + } + + local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ; + if $(wrong) + { + ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ; + EXIT ; + } + local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ; + if $(wrong) + { + ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ; + EXIT ; + } + + if $(with-parameter) + { + return [ set.intersection $(existing-libraries) : $(with-parameter) ] ; + } + else + { + return [ set.difference $(existing-libraries) : $(without-parameter) ] ; + } +} + + +# What kind of layout are we doing? +layout = [ option.get layout : "" ] ; +# On Windows, we used versioned layout by default in order to +# be compatible with autolink. On other systems, we use system +# layout which is what every other program uses. Note that windows +# check is static, and won't +if ! $(layout) +{ + if [ modules.peek : NT ] + { + layout = versioned ; + } + else + { + layout = system ; + } +} +layout-$(layout) = true ; + +if $(layout) = system && $(build-type) = complete +{ + ECHO "error: Cannot use --layout=system with --build-type complete." ; + ECHO "error: Please used either --layout=versioned or --layout=tagged " ; + ECHO "error: if you wish to build multiple variants." ; + if ! [ modules.peek : NT ] + { + ECHO "error: Note that --layout=system is default on Unix starting with Boost 1.40." ; + } + EXIT ; +} + +# Possible stage only location. +local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ; +stage-locate ?= stage ; +path-constant BOOST_STAGE_LOCATE : $(stage-locate) ; + + +# Python location. +local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] + ] ; +PYTHON_ROOT ?= $(python-root) ; + + +# Select the libraries to install. +libraries = [ libraries-to-install $(all-libraries) ] ; +configure.components-building $(libraries) ; + +if --show-libraries in [ modules.peek : ARGV ] +{ + ECHO "The following libraries require building:" ; + for local l in $(libraries) + { + ECHO " - $(l)" ; + } + EXIT ; +} + +# Custom build ID. +local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ; +if $(build-id) +{ + constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ; +} + +# Python build id (only for Python libraries) +local python-id = [ MATCH "^--python-buildid=(.*)" : [ modules.peek : ARGV ] ] ; +if $(python-id) +{ + constant PYTHON_ID : [ regex.replace $(python-id) "[*\\/:.\"\']" "_" ] ; +} + +# This rule is called by Boost.Build to determine the name of target. We use it +# to encode the build variant, compiler name and boost version in the target +# name. +# +rule tag ( name : type ? : property-set ) +{ + if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB + { + local result ; + if $(layout) = versioned + { + result = [ common.format-name + <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG) + -$(BUILD_ID) + : $(name) : $(type) : $(property-set) ] ; + } + else if $(layout) = tagged + { + result = [ common.format-name + <base> <threading> <runtime> + -$(BUILD_ID) + : $(name) : $(type) : $(property-set) ] ; + } + else if $(layout) = system + { + result = [ common.format-name + <base> + -$(BUILD_ID) + : $(name) : $(type) : $(property-set) ] ; + } + else + { + ECHO "error: invalid layout '$(layout)'" ; + EXIT ; + } + + # Optionally add version suffix. On NT, library with version suffix + # will not be recognized by linkers. On CYGWIN, we get strage + # duplicate symbol errors when library is generated with version + # suffix. On OSX, version suffix is not needed -- the linker expects + # the libFoo.1.2.3.dylib format. AIX linkers do not accept version + # suffixes either. Pgi compilers can not accept library with version + # suffix. + if $(type) = SHARED_LIB && + ( ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix ) && + ! ( [ $(property-set).get <toolset> ] in pgi ) ) + { + result = $(result).$(BOOST_VERSION) ; + } + + return $(result) ; + } +} + + +# Install to system location. + +install-requirements = <install-source-root>$(BOOST_ROOT)/boost ; + +if $(layout-versioned) +{ + install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ; +} +else +{ + install-requirements += <install-header-subdir>boost ; +} +if [ modules.peek : NT ] +{ + install-requirements += <install-default-prefix>C:/Boost ; +} +else if [ modules.peek : UNIX ] +{ + install-requirements += <install-default-prefix>/usr/local ; +} + +local headers = + # The .SUNWCCh files are present in tr1 include directory and have to be installed, + # see http://lists.boost.org/Archives/boost/2007/05/121430.php + [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ] + [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ] + [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ] + ; + +# Complete install. +package.install install-proper + : $(install-requirements) <install-no-version-symlinks>on + : + : libs/$(libraries)/build + : $(headers) + ; +explicit install-proper ; + +# Install just library. +install stage-proper + : libs/$(libraries)/build + : <location>$(stage-locate)/lib + <install-dependencies>on <install-type>LIB + <install-no-version-symlinks>on + ; +explicit stage-proper ; + + +if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] ) +{ + rule make-unversioned-links ( project name ? : property-set : sources * ) + { + local result ; + local filtered ; + local pattern ; + local nt = [ modules.peek : NT ] ; + + # Collect the libraries that have the version number in 'filtered'. + for local s in $(sources) + { + local m ; + if $(nt) + { + m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ; + } + else + { + m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" : + [ $(s).name ] ] ; + } + if $(m) + { + filtered += $(s) ; + } + } + + # Create links without version. + for local s in $(filtered) + { + local name = [ $(s).name ] ; + local ea = [ $(s).action ] ; + local ep = [ $(ea).properties ] ; + local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ; + + local noversion-file ; + if $(nt) + { + noversion-file = [ MATCH "(.*)-[0-9_]+(.*[.]lib)" : $(name) ] ; + } + else + { + noversion-file = + [ MATCH "(.*)-[0-9_]+(.*[.]so)[.0-9]*" : $(name) ] + [ MATCH "(.*)-[0-9_]+(.*[.]dylib)" : $(name) ] + [ MATCH "(.*)-[0-9_]+(.*[.]a)" : $(name) ] + [ MATCH "(.*)-[0-9_]+(.*[.]dll[.]a)" : $(name) ] ; + } + + local new-name = + $(noversion-file[1])$(noversion-file[2]) ; + result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project) + : $(a) ] ; + + } + return $(result) ; + } + + generate stage-unversioned : stage-proper : + <generating-rule>@make-unversioned-links ; + explicit stage-unversioned ; + + generate install-unversioned : install-proper : + <generating-rule>@make-unversioned-links ; + explicit install-unversioned ; +} +else +{ + # Create do-nothing aliases. + alias stage-unversioned ; + explicit stage-unversioned ; + alias install-unversioned ; + explicit install-unversioned ; +} + +# This is a special metatarget class that handles the --build-type=complete +# option. +class top-level-target : alias-target-class +{ + import modules ; + import errors ; + + rule __init__ ( name : project : sources * : requirements * + : default-build * : usage-requirements * ) + { + alias-target-class.__init__ $(name) : $(project) : $(sources) : + $(requirements) : $(default-build) : $(usage-requirements) ; + + local m = [ $(project).project-module ] ; + self.build-type = [ modules.peek $(m) : build-type ] ; + # On Linux, we build release variant by default, since few users will + # ever want to debug C++ Boost libraries, and there's no ABI + # incompatibility between debug and release variants. We build + # shared and static libraries since that's what most packages + # seem to provide (.so in libfoo and .a in libfoo-dev). + self.minimal-properties = [ property-set.create + <variant>release <threading>multi <link>shared <link>static <runtime-link>shared ] ; + # On Windows, new IDE projects use: + # + # runtime-link=dynamic, threading=multi, variant=(debug|release) + # + # and in addition, C++ Boost's autolink defaults to static linking. + self.minimal-properties-win = [ property-set.create + <variant>debug <variant>release <threading>multi <link>static <runtime-link>shared ] ; + + self.complete-properties = [ property-set.create + <variant>debug <variant>release + <threading>single <threading>multi + <link>shared <link>static + <runtime-link>shared <runtime-link>static ] ; + } + + rule generate ( property-set ) + { + local x = [ modules.peek : top-level-targets ] ; + x += $(self.name) ; + modules.poke : top-level-targets : $(x) ; + if $(self.build-type) = minimal + { + local expanded ; + + local os = [ $(property-set).get <target-os> ] ; + # Because we completely override parent's 'generate' + # we need to check for default value of feature ourself. + if ! $(os) + { + os = [ feature.defaults <target-os> ] ; + os = $(os:G=) ; + } + + if $(os) = windows + { + expanded = [ targets.apply-default-build $(property-set) + : $(self.minimal-properties-win) ] ; + } + else + { + expanded = [ targets.apply-default-build $(property-set) + : $(self.minimal-properties) ] ; + } + return [ build-multiple $(expanded) ] ; + } + else if $(self.build-type) = complete + { + local expanded = [ targets.apply-default-build $(property-set) + : $(self.complete-properties) ] ; + + # Filter inappopriate combinations + local filtered ; + for local p in $(expanded) + { + # See comment in handle-static-runtime regarding this logic. + if [ $(p).get <link> ] = shared && [ $(p).get <runtime-link> ] = static + && [ $(p).get <toolset> ] != cw + { + # Skip this + } + else + { + filtered += $(p) ; + } + } + return [ build-multiple $(filtered) ] ; + } + else + { + errors.error "Unknown build type" ; + } + } + + rule build-multiple ( property-sets * ) + { + local usage-requirements = [ property-set.empty ] ; + local result ; + for local p in $(property-sets) + { + local r = [ alias-target-class.generate $(p) ] ; + if $(r) + { + usage-requirements = [ $(usage-requirements).add $(r[1]) ] ; + result += $(r[2-]) ; + } + } + return $(usage-requirements) [ sequence.unique $(result) ] ; + } + +} + +targets.create-metatarget top-level-target : [ project.current ] + : install + : install-proper install-unversioned + ; +targets.create-metatarget top-level-target : [ project.current ] + : stage + : stage-proper stage-unversioned + ; + +explicit install ; +explicit stage ; + +stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ; + +# This target is built by default, and will forward to 'stage' +# after producing some explanations. +targets.create-metatarget top-level-target : [ project.current ] + : forward + : explain stage + ; + + +message explain : +"\nBuilding the Boost C++ Libraries.\n\n" ; +explicit explain ; + +rule pre-build ( ) +{ + local tl = [ modules.peek : top-level-targets ] ; + if stage in $(tl) || install in $(tl) + { + # FIXME: remove if when Boost regression tests use trunk + # bjam. + if PAD in [ RULENAMES ] + { + configure.print-component-configuration ; + } + } +} +IMPORT $(__name__) : pre-build : : $(__name__).pre-build ; +build-system.set-pre-build-hook $(__name__).pre-build ; + +rule post-build ( ok ? ) +{ + if forward in [ modules.peek : top-level-targets ] + { + if $(ok) + { + ECHO +"\n\nThe Boost C++ Libraries were successfully built! + +The following directory should be added to compiler include paths: + + $(BOOST_ROOT) + +The following directory should be added to linker library paths: + + $(stage-abs) +" ; + } + } +} +IMPORT $(__name__) : post-build : : $(__name__).post-build ; +build-system.set-post-build-hook $(__name__).post-build ; + +# This rule should be called from libraries' Jamfiles and will create two +# targets, "install" and "stage", that will install or stage that library. The +# --prefix option is respected, but --with and --without options, naturally, are +# ignored. +# +# - libraries -- list of library targets to install. +# +rule boost-install ( libraries * ) +{ + package.install install + : <dependency>/boost//install-proper-headers $(install-requirements) + : # No binaries + : $(libraries) + : # No headers, it is handled by the dependency. + ; + + install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ; + + local c = [ project.current ] ; + local project-module = [ $(c).project-module ] ; + module $(project-module) + { + explicit stage ; + explicit install ; + } +} + + +# Make project ids of all libraries known. +for local l in $(all-libraries) +{ + use-project /boost/$(l) : libs/$(l)/build ; +}
diff --git a/boost_1_45_0/LICENSE_1_0.txt b/boost_1_45_0/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/boost_1_45_0/LICENSE_1_0.txt
@@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.
diff --git a/boost_1_45_0/boost-build.jam b/boost_1_45_0/boost-build.jam new file mode 100644 index 0000000..8b87754 --- /dev/null +++ b/boost_1_45_0/boost-build.jam
@@ -0,0 +1,17 @@ +# Copyright (C) 2002-2003 David Abrahams. +# Copyright (C) 2002-2003 Vladimir Prus. +# Copyright (C) 2003,2007 Rene Rivera. +# Use, modification and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# This is the initial file loaded by Boost Jam when run from any Boost library +# folder. It allows us to choose which Boost Build installation to use for +# building Boost libraries. Unless explicitly selected using a command-line +# option, the version included with the Boost library distribution is used (as +# opposed to any other Boost Build version installed on the user's sytem). + +BOOST_ROOT = $(.boost-build-file:D) ; +BOOST_BUILD = [ MATCH --boost-build=(.*) : $(ARGV) ] ; +BOOST_BUILD ?= tools/build/v2 ; +boost-build $(BOOST_BUILD) ;
diff --git a/boost_1_45_0/boost.css b/boost_1_45_0/boost.css new file mode 100644 index 0000000..986c405 --- /dev/null +++ b/boost_1_45_0/boost.css
@@ -0,0 +1,66 @@ +/*============================================================================= + Copyright 2002 William E. Kempf + Distributed under the Boost Software License, Version 1.0. (See accompany- + ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +H1 +{ + FONT-SIZE: 200%; + COLOR: #00008B; +} +H2 +{ + FONT-SIZE: 150%; +} +H3 +{ + FONT-SIZE: 125%; +} +H4 +{ + FONT-SIZE: 108%; +} +BODY +{ + FONT-SIZE: 100%; + BACKGROUND-COLOR: #ffffff; + COLOR: #000000; +} +PRE +{ + MARGIN-LEFT: 2em; + FONT-FAMILY: Courier, + monospace; +} +CODE +{ + FONT-FAMILY: Courier, + monospace; +} +CODE.as_pre +{ + white-space: pre; +} +.index +{ + TEXT-ALIGN: left; +} +.page-index +{ + TEXT-ALIGN: left; +} +.definition +{ + TEXT-ALIGN: left; +} +.footnote +{ + FONT-SIZE: 66%; + VERTICAL-ALIGN: super; + TEXT-DECORATION: none; +} +.function-semantics +{ + CLEAR: left; +} \ No newline at end of file
diff --git a/boost_1_45_0/boost.png b/boost_1_45_0/boost.png new file mode 100644 index 0000000..b4d51fc --- /dev/null +++ b/boost_1_45_0/boost.png Binary files differ
diff --git a/boost_1_45_0/boost/accumulators/accumulators.hpp b/boost_1_45_0/boost/accumulators/accumulators.hpp new file mode 100644 index 0000000..55ee2f9 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/accumulators.hpp
@@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file accumulators.hpp +/// Includes all of the Accumulators Framework +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_ACCUMULATORS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_ACCUMULATORS_HPP_EAN_28_10_2005 + +#include <boost/accumulators/framework/accumulator_set.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/external.hpp> +#include <boost/accumulators/framework/features.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/parameters/weight.hpp> +#include <boost/accumulators/framework/parameters/weights.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/droppable_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/value_accumulator.hpp> + +#endif
diff --git a/boost_1_45_0/boost/accumulators/accumulators_fwd.hpp b/boost_1_45_0/boost/accumulators/accumulators_fwd.hpp new file mode 100644 index 0000000..d5ca5c2 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/accumulators_fwd.hpp
@@ -0,0 +1,216 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulators_fwd.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 + +#include <boost/config.hpp> +#include <boost/mpl/apply_fwd.hpp> // for mpl::na +#include <boost/mpl/limits/vector.hpp> +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +#ifndef BOOST_ACCUMULATORS_MAX_FEATURES + /// The maximum number of accumulators that may be put in an accumulator_set. + /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20). +# define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE +#endif + +#if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE +# error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE +#endif + +#ifndef BOOST_ACCUMULATORS_MAX_ARGS + /// The maximum number of arguments that may be specified to an accumulator_set's + /// accumulation function. Defaults to 15. +# define BOOST_ACCUMULATORS_MAX_ARGS 15 +#endif + +#if BOOST_WORKAROUND(__GNUC__, == 3) \ + || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306)) +# define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS +#endif + +#ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS +# include <boost/utility/enable_if.hpp> +# include <boost/type_traits/is_const.hpp> +# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\ + , typename boost::disable_if<boost::is_const<T> >::type * = 0 +#else +# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T) +#endif + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// Named parameters tags +// +namespace tag +{ + struct sample; + struct weight; + struct accumulator; + struct weights; +} + +/////////////////////////////////////////////////////////////////////////////// +// User-level features +// +namespace tag +{ + template<typename ValueType, typename Tag> + struct value; + + template<typename Tag> + struct value_tag; + + template<typename Referent, typename Tag> + struct reference; + + template<typename Tag> + struct reference_tag; + + template<typename Type, typename Tag = void, typename AccumulatorSet = void> + struct external; + + template<typename Feature> + struct droppable; +} + +template<typename Accumulator> +struct droppable_accumulator_base; + +template<typename Accumulator> +struct droppable_accumulator; + +template<typename Accumulator> +struct with_cached_result; + +template<typename Sample, typename Features, typename Weight = void> +struct accumulator_set; + +template<typename Feature> +struct extractor; + +template<typename Feature> +struct feature_of; + +template<typename Feature> +struct as_feature; + +template<typename Feature> +struct as_weighted_feature; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct depends_on; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct features; + +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type const & +find_accumulator(AccumulatorSet const &acc); + +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type::result_type +extract_result(AccumulatorSet const &acc); + +template<typename Feature, typename AccumulatorSet, typename A1> +typename mpl::apply<AccumulatorSet, Feature>::type::result_type +extract_result(AccumulatorSet const &acc, A1 const &a1); + +// ... other overloads generated by Boost.Preprocessor: + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \ + template< \ + typename Feature \ + , typename AccumulatorSet \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename mpl::apply<AccumulatorSet, Feature>::type::result_type \ + extract_result( \ + AccumulatorSet const &acc \ + BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ + ); + +/// INTERNAL ONLY +/// +BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD + , _ +) + +#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED +template<typename Feature, typename AccumulatorSet, typename A1, typename A2 ...> +typename mpl::apply<AccumulatorSet, Feature>::type::result_type +extract_result(AccumulatorSet const &acc, A1 const &a1, A2 const &a2 ...); +#endif + +namespace impl +{ + using namespace numeric::operators; + + template<typename Accumulator, typename Tag> + struct external_impl; +} + +namespace detail +{ + template<typename Accumulator> + struct feature_tag; + + template<typename Feature, typename Sample, typename Weight> + struct to_accumulator; + + struct accumulator_set_base; + + template<typename T> + struct is_accumulator_set; + + inline void ignore_variable(void const *) {} + + #define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X)\ + namespace detail { inline void BOOST_PP_CAT(ignore_, X)() { boost::accumulators::detail::ignore_variable(&X); } } +} + +}} // namespace boost::accumulators + +// For defining boost::parameter keywords that can be inherited from to +// get a nested, class-scoped keyword with the requested alias +#define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \ + namespace tag_namespace \ + { \ + template<int Dummy = 0> \ + struct name ## _ \ + { \ + static char const* keyword_name() \ + { \ + return #name; \ + } \ + static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \ + }; \ + template<int Dummy> \ + ::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \ + ::boost::parameter::keyword<name ## _<Dummy> >::get(); \ + typedef name ## _ <> name; \ + } \ + namespace \ + { \ + ::boost::parameter::keyword<tag_namespace::name> &name = \ + ::boost::parameter::keyword<tag_namespace::name>::get(); \ + } + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulator_base.hpp b/boost_1_45_0/boost/accumulators/framework/accumulator_base.hpp new file mode 100644 index 0000000..52c520d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulator_base.hpp
@@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_base.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/joint_view.hpp> +#include <boost/mpl/single_view.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/empty_sequence.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + typedef void void_; +} + +/////////////////////////////////////////////////////////////////////////////// +// dont_care +// +struct dont_care +{ + template<typename Args> + dont_care(Args const &) + { + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// accumulator_base +// +struct accumulator_base +{ + // hidden if defined in derived classes + detail::void_ operator ()(dont_care) + { + } + + typedef mpl::false_ is_droppable; + + detail::void_ add_ref(dont_care) + { + } + + detail::void_ drop(dont_care) + { + } + + detail::void_ on_drop(dont_care) + { + } +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulator_concept.hpp b/boost_1_45_0/boost/accumulators/framework/accumulator_concept.hpp new file mode 100644 index 0000000..492357e --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulator_concept.hpp
@@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_concept.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 + +#include <boost/concept_check.hpp> + +namespace boost { namespace accumulators +{ + +template<typename Stat> +struct accumulator_concept +{ + void constraints() + { + // TODO: define the stat concept + } + + Stat stat; +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulator_set.hpp b/boost_1_45_0/boost/accumulators/framework/accumulator_set.hpp new file mode 100644 index 0000000..ed1ceb1 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulator_set.hpp
@@ -0,0 +1,401 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_set.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 + +#include <boost/version.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/protect.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_base_and_derived.hpp> +#include <boost/parameter/parameters.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/droppable_accumulator.hpp> +#include <boost/fusion/include/any.hpp> +#include <boost/fusion/include/find_if.hpp> +#include <boost/fusion/include/for_each.hpp> +#include <boost/fusion/include/filter_view.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + /////////////////////////////////////////////////////////////////////////////// + // accumulator_visitor + // wrap a boost::parameter argument pack in a Fusion extractor object + template<typename Args> + struct accumulator_visitor + { + explicit accumulator_visitor(Args const &a) + : args(a) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &accumulator) const + { + accumulator(this->args); + } + + private: + accumulator_visitor &operator =(accumulator_visitor const &); + Args const &args; + }; + + template<typename Args> + inline accumulator_visitor<Args> const make_accumulator_visitor(Args const &args) + { + return accumulator_visitor<Args>(args); + } + + typedef + parameter::parameters< + parameter::required<tag::accumulator> + , parameter::optional<tag::sample> + // ... and others which are not specified here... + > + accumulator_params; + + /////////////////////////////////////////////////////////////////////////////// + // accumulator_set_base + struct accumulator_set_base + { + }; + + /////////////////////////////////////////////////////////////////////////////// + // is_accumulator_set + template<typename T> + struct is_accumulator_set + : is_base_and_derived<accumulator_set_base, T> + { + }; + +} // namespace detail + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list +#endif + +/////////////////////////////////////////////////////////////////////////////// +/// \brief A set of accumulators. +/// +/// accumulator_set resolves the dependencies between features and ensures that +/// the accumulators in the set are updated in the proper order. +/// +/// acccumulator_set provides a general mechanism to visit the accumulators +/// in the set in order, with or without a filter. You can also fetch a reference +/// to an accumulator that corresponds to a feature. +/// +template<typename Sample, typename Features, typename Weight> +struct accumulator_set + : detail::accumulator_set_base +{ + typedef Sample sample_type; ///< The type of the samples that will be accumulated + typedef Features features_type; ///< An MPL sequence of the features that should be accumulated. + typedef Weight weight_type; ///< The type of the weight parameter. Must be a scalar. Defaults to void. + + /// INTERNAL ONLY + /// + typedef + typename detail::make_accumulator_tuple< + Features + , Sample + , Weight + >::type + accumulators_mpl_vector; + + // generate a fusion::list of accumulators + /// INTERNAL ONLY + /// + typedef + typename detail::meta::make_acc_list< + accumulators_mpl_vector + >::type + accumulators_type; + + /// INTERNAL ONLY + /// + //BOOST_MPL_ASSERT((mpl::is_sequence<accumulators_type>)); + + /////////////////////////////////////////////////////////////////////////////// + /// default-construct all contained accumulators + accumulator_set() + : accumulators( + detail::make_acc_list( + accumulators_mpl_vector() + , detail::accumulator_params()(*this) + ) + ) + { + // Add-ref the Features that the user has specified + this->template visit_if<detail::contains_feature_of_<Features> >( + detail::make_add_ref_visitor(detail::accumulator_params()(*this)) + ); + } + + /// \overload + /// + /// \param a1 Optional named parameter to be passed to all the accumulators + template<typename A1> + explicit accumulator_set(A1 const &a1) + : accumulators( + detail::make_acc_list( + accumulators_mpl_vector() + , detail::accumulator_params()(*this, a1) + ) + ) + { + // Add-ref the Features that the user has specified + this->template visit_if<detail::contains_feature_of_<Features> >( + detail::make_add_ref_visitor(detail::accumulator_params()(*this)) + ); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR(z, n, _) \ + template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \ + accumulator_set(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \ + : accumulators( \ + detail::make_acc_list( \ + accumulators_mpl_vector() \ + , detail::accumulator_params()( \ + *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ + ) \ + ) \ + ) \ + { \ + /* Add-ref the Features that the user has specified */ \ + this->template visit_if<detail::contains_feature_of_<Features> >( \ + detail::make_add_ref_visitor(detail::accumulator_params()(*this)) \ + ); \ + } + + /// INTERNAL ONLY + /// + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename A1, typename A2, ...> + accumulator_set(A1 const &a1, A2 const &a2, ...); + #endif + + // ... other overloads generated by Boost.Preprocessor below ... + + /////////////////////////////////////////////////////////////////////////////// + /// Visitation + /// \param func UnaryFunction which is invoked with each accumulator in turn. + template<typename UnaryFunction> + void visit(UnaryFunction const &func) + { + fusion::for_each(this->accumulators, func); + } + + /////////////////////////////////////////////////////////////////////////////// + /// Conditional visitation + /// \param func UnaryFunction which is invoked with each accumulator in turn, + /// provided the accumulator satisfies the MPL predicate FilterPred. + template<typename FilterPred, typename UnaryFunction> + void visit_if(UnaryFunction const &func) + { + fusion::filter_view<accumulators_type, FilterPred> filtered_accs(this->accumulators); + fusion::for_each(filtered_accs, func); + } + + /////////////////////////////////////////////////////////////////////////////// + /// The return type of the operator() overloads is void. + typedef void result_type; + + /////////////////////////////////////////////////////////////////////////////// + /// Accumulation + /// \param a1 Optional named parameter to be passed to all the accumulators + void operator ()() + { + this->visit( + detail::make_accumulator_visitor( + detail::accumulator_params()(*this) + ) + ); + } + + template<typename A1> + void operator ()(A1 const &a1) + { + this->visit( + detail::make_accumulator_visitor( + detail::accumulator_params()(*this, a1) + ) + ); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP(z, n, _) \ + template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \ + void operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \ + { \ + this->visit( \ + detail::make_accumulator_visitor( \ + detail::accumulator_params()( \ + *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ + ) \ + ) \ + ); \ + } + + /// INTERNAL ONLY + /// + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename A1, typename A2, ...> + void operator ()(A1 const &a1, A2 const &a2, ...); + #endif + + /////////////////////////////////////////////////////////////////////////////// + /// Extraction + template<typename Feature> + struct apply + : fusion::result_of::value_of< + typename fusion::result_of::find_if< + accumulators_type + , detail::matches_feature<Feature> + >::type + > + { + }; + + /////////////////////////////////////////////////////////////////////////////// + /// Extraction + template<typename Feature> + typename apply<Feature>::type &extract() + { + return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators); + } + + /// \overload + template<typename Feature> + typename apply<Feature>::type const &extract() const + { + return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators); + } + + /////////////////////////////////////////////////////////////////////////////// + /// Drop + template<typename Feature> + void drop() + { + // You can only drop the features that you have specified explicitly + typedef typename apply<Feature>::type the_accumulator; + BOOST_MPL_ASSERT((detail::contains_feature_of<Features, the_accumulator>)); + + typedef + typename feature_of<typename as_feature<Feature>::type>::type + the_feature; + + (*fusion::find_if<detail::matches_feature<Feature> >(this->accumulators)) + .drop(detail::accumulator_params()(*this)); + + // Also drop accumulators that this feature depends on + typedef typename the_feature::dependencies dependencies; + this->template visit_if<detail::contains_feature_of_<dependencies> >( + detail::make_drop_visitor(detail::accumulator_params()(*this)) + ); + } + +private: + + accumulators_type accumulators; +}; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +/////////////////////////////////////////////////////////////////////////////// +// find_accumulator +// find an accumulator in an accumulator_set corresponding to a feature +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type & +find_accumulator(AccumulatorSet &acc BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(AccumulatorSet)) +{ + return acc.template extract<Feature>(); +} + +/// \overload +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type const & +find_accumulator(AccumulatorSet const &acc) +{ + return acc.template extract<Feature>(); +} + +/////////////////////////////////////////////////////////////////////////////// +// extract_result +// extract a result from an accumulator set +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN(z, n, _) \ + template< \ + typename Feature \ + , typename AccumulatorSet \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename mpl::apply<AccumulatorSet, Feature>::type::result_type \ + extract_result( \ + AccumulatorSet const &acc \ + BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ + ) \ + { \ + return find_accumulator<Feature>(acc).result( \ + detail::accumulator_params()( \ + acc \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ + ) \ + ); \ + } + +BOOST_PP_REPEAT( + BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN + , _ +) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp b/boost_1_45_0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp new file mode 100644 index 0000000..c0f512f --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp
@@ -0,0 +1,317 @@ +/////////////////////////////////////////////////////////////////////////////// +// droppable_accumulator.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 + +#include <new> +#include <boost/assert.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/aligned_storage.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_of +#include <boost/accumulators/framework/parameters/accumulator.hpp> // for accumulator + +namespace boost { namespace accumulators +{ + + template<typename Accumulator> + struct droppable_accumulator; + + namespace detail + { + /////////////////////////////////////////////////////////////////////////////// + // add_ref_visitor + // a fusion function object for add_ref'ing accumulators + template<typename Args> + struct add_ref_visitor + { + explicit add_ref_visitor(Args const &args) + : args_(args) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &acc) const + { + typedef typename Accumulator::feature_tag::dependencies dependencies; + + acc.add_ref(this->args_); + + // Also add_ref accumulators that this feature depends on + this->args_[accumulator].template + visit_if<detail::contains_feature_of_<dependencies> >( + *this + ); + } + + private: + add_ref_visitor &operator =(add_ref_visitor const &); + Args const &args_; + }; + + template<typename Args> + add_ref_visitor<Args> make_add_ref_visitor(Args const &args) + { + return add_ref_visitor<Args>(args); + } + + /////////////////////////////////////////////////////////////////////////////// + // drop_visitor + // a fusion function object for dropping accumulators + template<typename Args> + struct drop_visitor + { + explicit drop_visitor(Args const &args) + : args_(args) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &acc) const + { + if(typename Accumulator::is_droppable()) + { + typedef typename Accumulator::feature_tag::dependencies dependencies; + + acc.drop(this->args_); + // Also drop accumulators that this feature depends on + this->args_[accumulator].template + visit_if<detail::contains_feature_of_<dependencies> >( + *this + ); + } + } + + private: + drop_visitor &operator =(drop_visitor const &); + Args const &args_; + }; + + template<typename Args> + drop_visitor<Args> make_drop_visitor(Args const &args) + { + return drop_visitor<Args>(args); + } + } + + ////////////////////////////////////////////////////////////////////////// + // droppable_accumulator_base + template<typename Accumulator> + struct droppable_accumulator_base + : Accumulator + { + typedef droppable_accumulator_base base; + typedef mpl::true_ is_droppable; + typedef typename Accumulator::result_type result_type; + + template<typename Args> + droppable_accumulator_base(Args const &args) + : Accumulator(args) + , ref_count_(0) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + if(!this->is_dropped()) + { + this->Accumulator::operator ()(args); + } + } + + template<typename Args> + void add_ref(Args const &) + { + ++this->ref_count_; + } + + template<typename Args> + void drop(Args const &args) + { + BOOST_ASSERT(0 < this->ref_count_); + if(1 == this->ref_count_) + { + static_cast<droppable_accumulator<Accumulator> *>(this)->on_drop(args); + } + --this->ref_count_; + } + + bool is_dropped() const + { + return 0 == this->ref_count_; + } + + private: + int ref_count_; + }; + + ////////////////////////////////////////////////////////////////////////// + // droppable_accumulator + // this can be specialized for any type that needs special handling + template<typename Accumulator> + struct droppable_accumulator + : droppable_accumulator_base<Accumulator> + { + template<typename Args> + droppable_accumulator(Args const &args) + : droppable_accumulator::base(args) + { + } + }; + + ////////////////////////////////////////////////////////////////////////// + // with_cached_result + template<typename Accumulator> + struct with_cached_result + : Accumulator + { + typedef typename Accumulator::result_type result_type; + + template<typename Args> + with_cached_result(Args const &args) + : Accumulator(args) + , cache() + { + } + + with_cached_result(with_cached_result const &that) + : Accumulator(*static_cast<Accumulator const *>(&that)) + , cache() + { + if(that.has_result()) + { + this->set(that.get()); + } + } + + ~with_cached_result() + { + // Since this is a base class of droppable_accumulator_base, + // this destructor is called before any of droppable_accumulator_base's + // members get cleaned up, including is_dropped, so the following + // call to has_result() is valid. + if(this->has_result()) + { + this->get().~result_type(); + } + } + + template<typename Args> + void on_drop(Args const &args) + { + // cache the result at the point this calcuation was dropped + BOOST_ASSERT(!this->has_result()); + this->set(this->Accumulator::result(args)); + } + + template<typename Args> + result_type result(Args const &args) const + { + return this->has_result() ? this->get() : this->Accumulator::result(args); + } + + private: + with_cached_result &operator =(with_cached_result const &); + + void set(result_type const &r) + { + ::new(this->cache.address()) result_type(r); + } + + result_type const &get() const + { + return *static_cast<result_type const *>(this->cache.address()); + } + + bool has_result() const + { + typedef with_cached_result<Accumulator> this_type; + typedef droppable_accumulator_base<this_type> derived_type; + return static_cast<derived_type const *>(this)->is_dropped(); + } + + aligned_storage<sizeof(result_type)> cache; + }; + + namespace tag + { + template<typename Feature> + struct as_droppable + { + typedef droppable<Feature> type; + }; + + template<typename Feature> + struct as_droppable<droppable<Feature> > + { + typedef droppable<Feature> type; + }; + + ////////////////////////////////////////////////////////////////////////// + // droppable + template<typename Feature> + struct droppable + : as_feature<Feature>::type + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename feature_type::dependencies tmp_dependencies_; + + typedef + typename mpl::transform< + typename feature_type::dependencies + , as_droppable<mpl::_1> + >::type + dependencies; + + struct impl + { + template<typename Sample, typename Weight> + struct apply + { + typedef + droppable_accumulator< + typename mpl::apply2<typename feature_type::impl, Sample, Weight>::type + > + type; + }; + }; + }; + } + + // make droppable<tag::feature(modifier)> work + template<typename Feature> + struct as_feature<tag::droppable<Feature> > + { + typedef tag::droppable<typename as_feature<Feature>::type> type; + }; + + // make droppable<tag::mean> work with non-void weights (should become + // droppable<tag::weighted_mean> + template<typename Feature> + struct as_weighted_feature<tag::droppable<Feature> > + { + typedef tag::droppable<typename as_weighted_feature<Feature>::type> type; + }; + + // for the purposes of feature-based dependency resolution, + // droppable<Foo> provides the same feature as Foo + template<typename Feature> + struct feature_of<tag::droppable<Feature> > + : feature_of<Feature> + { + }; + + // Note: Usually, the extractor is pulled into the accumulators namespace with + // a using directive, not the tag. But the droppable<> feature doesn't have an + // extractor, so we can put the droppable tag in the accumulators namespace + // without fear of a name conflict. + using tag::droppable; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulators/external_accumulator.hpp b/boost_1_45_0/boost/accumulators/framework/accumulators/external_accumulator.hpp new file mode 100644 index 0000000..71dce42 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulators/external_accumulator.hpp
@@ -0,0 +1,108 @@ +/////////////////////////////////////////////////////////////////////////////// +// external_accumulator.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp> + +namespace boost { namespace accumulators { namespace impl +{ + + ////////////////////////////////////////////////////////////////////////// + // external_impl + /// INTERNAL ONLY + /// + template<typename Accumulator, typename Tag> + struct external_impl + : accumulator_base + { + typedef typename Accumulator::result_type result_type; + typedef typename detail::feature_tag<Accumulator>::type feature_tag; + + external_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]); + } + + private: + + template<typename Args> + static result_type extract_(Args const &args, int) + { + // No named parameter passed to the extractor. Maybe the external + // feature is held by reference<>. + extractor<feature_tag> extract; + return extract(accumulators::reference_tag<Tag>(args)); + } + + template<typename Args, typename AccumulatorSet> + static result_type extract_(Args const &, AccumulatorSet const &acc) + { + // OK, a named parameter for this external feature was passed to the + // extractor, so use that. + extractor<feature_tag> extract; + return extract(acc); + } + }; + +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // external + template<typename Feature, typename Tag, typename AccumulatorSet> + struct external + : depends_on<reference<AccumulatorSet, Tag> > + { + typedef + accumulators::impl::external_impl< + detail::to_accumulator<Feature, mpl::_1, mpl::_2> + , Tag + > + impl; + }; + + template<typename Feature, typename Tag> + struct external<Feature, Tag, void> + : depends_on<> + { + typedef + accumulators::impl::external_impl< + detail::to_accumulator<Feature, mpl::_1, mpl::_2> + , Tag + > + impl; + }; +} + +// for the purposes of feature-based dependency resolution, +// external_accumulator<Feature, Tag> provides the same feature as Feature +template<typename Feature, typename Tag, typename AccumulatorSet> +struct feature_of<tag::external<Feature, Tag, AccumulatorSet> > + : feature_of<Feature> +{ +}; + +// Note: Usually, the extractor is pulled into the accumulators namespace with +// a using directive, not the tag. But the external<> feature doesn't have an +// extractor, so we can put the external tag in the accumulators namespace +// without fear of a name conflict. +using tag::external; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulators/reference_accumulator.hpp b/boost_1_45_0/boost/accumulators/framework/accumulators/reference_accumulator.hpp new file mode 100644 index 0000000..bf4252c --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulators/reference_accumulator.hpp
@@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////////// +// reference_accumulator.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 + +#include <boost/ref.hpp> +#include <boost/mpl/always.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + ////////////////////////////////////////////////////////////////////////// + // reference_accumulator_impl + // + template<typename Referent, typename Tag> + struct reference_accumulator_impl + : accumulator_base + { + typedef Referent &result_type; + + template<typename Args> + reference_accumulator_impl(Args const &args) + : ref(args[parameter::keyword<Tag>::get()]) + { + } + + result_type result(dont_care) const + { + return this->ref; + } + + private: + reference_wrapper<Referent> ref; + }; +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // reference_tag + template<typename Tag> + struct reference_tag + { + }; + + ////////////////////////////////////////////////////////////////////////// + // reference + template<typename Referent, typename Tag> + struct reference + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::reference_accumulator_impl<Referent, Tag> > impl; + }; +} + +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference, (typename)(typename)) + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference_tag, (typename)) +} + +using extract::reference; +using extract::reference_tag; + +// Map all reference<V,T> features to reference_tag<T> so +// that references can be extracted using reference_tag<T> +// without specifying the referent type. +template<typename ValueType, typename Tag> +struct feature_of<tag::reference<ValueType, Tag> > + : feature_of<tag::reference_tag<Tag> > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/accumulators/value_accumulator.hpp b/boost_1_45_0/boost/accumulators/framework/accumulators/value_accumulator.hpp new file mode 100644 index 0000000..02bf7f3 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/accumulators/value_accumulator.hpp
@@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////////// +// value_accumulator.hpp +// +// Copyright 2005 Eric Niebler, Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 + +#include <boost/mpl/always.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + ////////////////////////////////////////////////////////////////////////// + // value_accumulator_impl + template<typename ValueType, typename Tag> + struct value_accumulator_impl + : accumulator_base + { + typedef ValueType result_type; + + template<typename Args> + value_accumulator_impl(Args const &args) + : val(args[parameter::keyword<Tag>::get()]) + { + } + + result_type result(dont_care) const + { + return this->val; + } + + private: + ValueType val; + }; + +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // value_tag + template<typename Tag> + struct value_tag + { + }; + + ////////////////////////////////////////////////////////////////////////// + // value + template<typename ValueType, typename Tag> + struct value + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl; + }; +} + +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename)) + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename)) +} + +using extract::value; +using extract::value_tag; + +// Map all value<V,T> features to value_tag<T> so +// that values can be extracted using value_tag<T> +// without specifying the value type. +template<typename ValueType, typename Tag> +struct feature_of<tag::value<ValueType, Tag> > + : feature_of<tag::value_tag<Tag> > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/depends_on.hpp b/boost_1_45_0/boost/accumulators/framework/depends_on.hpp new file mode 100644 index 0000000..76087b0 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/depends_on.hpp
@@ -0,0 +1,411 @@ +/////////////////////////////////////////////////////////////////////////////// +// depends_on.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 + +#include <boost/version.hpp> +#include <boost/mpl/end.hpp> +#include <boost/mpl/map.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/sort.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/remove.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/inherit.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/transform.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/insert_range.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/inherit_linearly.hpp> +#include <boost/type_traits/is_base_and_derived.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/facilities/intercept.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/fusion/include/next.hpp> +#include <boost/fusion/include/equal_to.hpp> +#include <boost/fusion/include/value_of.hpp> +#include <boost/fusion/include/mpl.hpp> +#include <boost/fusion/include/end.hpp> +#include <boost/fusion/include/begin.hpp> +#include <boost/fusion/include/cons.hpp> + +namespace boost { namespace accumulators +{ + /////////////////////////////////////////////////////////////////////////// + // as_feature + template<typename Feature> + struct as_feature + { + typedef Feature type; + }; + + /////////////////////////////////////////////////////////////////////////// + // weighted_feature + template<typename Feature> + struct as_weighted_feature + { + typedef Feature type; + }; + + /////////////////////////////////////////////////////////////////////////// + // feature_of + template<typename Feature> + struct feature_of + { + typedef Feature type; + }; + + namespace detail + { + /////////////////////////////////////////////////////////////////////////// + // feature_tag + template<typename Accumulator> + struct feature_tag + { + typedef typename Accumulator::feature_tag type; + }; + + template<typename Feature> + struct undroppable + { + typedef Feature type; + }; + + template<typename Feature> + struct undroppable<tag::droppable<Feature> > + { + typedef Feature type; + }; + + // For the purpose of determining whether one feature depends on another, + // disregard whether the feature is droppable or not. + template<typename A, typename B> + struct is_dependent_on + : is_base_and_derived< + typename undroppable<B>::type + , typename undroppable<A>::type + > + {}; + + template<typename Features> + struct depends_on_base + : mpl::inherit_linearly< + typename mpl::sort<Features, is_dependent_on<mpl::_1, mpl::_2> >::type + // Don't inherit multiply from a feature + , mpl::if_< + is_dependent_on<mpl::_1, mpl::_2> + , mpl::_1 + , mpl::inherit<mpl::_1, mpl::_2> + > + >::type + { + }; + } + + /////////////////////////////////////////////////////////////////////////// + /// depends_on + template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)> + struct depends_on + : detail::depends_on_base< + typename mpl::transform< + mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> + , as_feature<mpl::_1> + >::type + > + { + typedef mpl::false_ is_weight_accumulator; + typedef + typename mpl::transform< + mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> + , as_feature<mpl::_1> + >::type + dependencies; + }; + + namespace detail + { + template<typename Feature> + struct matches_feature + { + template<typename Accumulator> + struct apply + : is_same< + typename feature_of<typename as_feature<Feature>::type>::type + , typename feature_of<typename as_feature<typename feature_tag<Accumulator>::type>::type>::type + > + {}; + }; + + template<typename Features, typename Accumulator> + struct contains_feature_of + { + typedef + mpl::transform_view<Features, feature_of<as_feature<mpl::_> > > + features_list; + + typedef + typename feature_of<typename feature_tag<Accumulator>::type>::type + the_feature; + + typedef + typename mpl::contains<features_list, the_feature>::type + type; + }; + + // This is to work around a bug in early versions of Fusion which caused + // a compile error if contains_feature_of<List, mpl::_> is used as a + // predicate to fusion::find_if + template<typename Features> + struct contains_feature_of_ + { + template<typename Accumulator> + struct apply + : contains_feature_of<Features, Accumulator> + {}; + }; + + template< + typename First + , typename Last + , bool is_empty = fusion::result_of::equal_to<First, Last>::value + > + struct build_acc_list; + + template<typename First, typename Last> + struct build_acc_list<First, Last, true> + { + typedef fusion::nil type; + + template<typename Args> + static fusion::nil + call(Args const &, First const&, Last const&) + { + return fusion::nil(); + } + }; + + template<typename First, typename Last> + struct build_acc_list<First, Last, false> + { + typedef + build_acc_list<typename fusion::result_of::next<First>::type, Last> + next_build_acc_list; + + typedef fusion::cons< + typename fusion::result_of::value_of<First>::type + , typename next_build_acc_list::type> + type; + + template<typename Args> + static type + call(Args const &args, First const& f, Last const& l) + { + return type(args, next_build_acc_list::call(args, fusion::next(f), l)); + } + }; + + namespace meta + { + template<typename Sequence> + struct make_acc_list + : build_acc_list< + typename fusion::result_of::begin<Sequence>::type + , typename fusion::result_of::end<Sequence>::type + > + {}; + } + + template<typename Sequence, typename Args> + typename meta::make_acc_list<Sequence>::type + make_acc_list(Sequence const &seq, Args const &args) + { + return meta::make_acc_list<Sequence>::call(args, fusion::begin(seq), fusion::end(seq)); + } + + /////////////////////////////////////////////////////////////////////////// + // checked_as_weighted_feature + template<typename Feature> + struct checked_as_weighted_feature + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename as_weighted_feature<feature_type>::type type; + // weighted and non-weighted flavors should provide the same feature. + BOOST_MPL_ASSERT(( + is_same< + typename feature_of<feature_type>::type + , typename feature_of<type>::type + > + )); + }; + + /////////////////////////////////////////////////////////////////////////// + // as_feature_list + template<typename Features, typename Weight> + struct as_feature_list + : mpl::transform_view<Features, checked_as_weighted_feature<mpl::_1> > + { + }; + + template<typename Features> + struct as_feature_list<Features, void> + : mpl::transform_view<Features, as_feature<mpl::_1> > + { + }; + + /////////////////////////////////////////////////////////////////////////// + // accumulator_wrapper + template<typename Accumulator, typename Feature> + struct accumulator_wrapper + : Accumulator + { + typedef Feature feature_tag; + + accumulator_wrapper(accumulator_wrapper const &that) + : Accumulator(*static_cast<Accumulator const *>(&that)) + { + } + + template<typename Args> + accumulator_wrapper(Args const &args) + : Accumulator(args) + { + } + }; + + /////////////////////////////////////////////////////////////////////////// + // to_accumulator + template<typename Feature, typename Sample, typename Weight> + struct to_accumulator + { + typedef + accumulator_wrapper< + typename mpl::apply2<typename Feature::impl, Sample, Weight>::type + , Feature + > + type; + }; + + template<typename Feature, typename Sample, typename Weight, typename Tag, typename AccumulatorSet> + struct to_accumulator<Feature, Sample, tag::external<Weight, Tag, AccumulatorSet> > + { + BOOST_MPL_ASSERT((is_same<Tag, void>)); + BOOST_MPL_ASSERT((is_same<AccumulatorSet, void>)); + + typedef + accumulator_wrapper< + typename mpl::apply2<typename Feature::impl, Sample, Weight>::type + , Feature + > + accumulator_type; + + typedef + typename mpl::if_< + typename Feature::is_weight_accumulator + , accumulator_wrapper<impl::external_impl<accumulator_type, tag::weights>, Feature> + , accumulator_type + >::type + type; + }; + + // BUGBUG work around a MPL bug wrt map insertion + template<typename FeatureMap, typename Feature> + struct insert_feature + : mpl::eval_if< + mpl::has_key<FeatureMap, typename feature_of<Feature>::type> + , mpl::identity<FeatureMap> + , mpl::insert<FeatureMap, mpl::pair<typename feature_of<Feature>::type, Feature> > + > + { + }; + + template<typename FeatureMap, typename Feature, typename Weight> + struct insert_dependencies + : mpl::fold< + as_feature_list<typename Feature::dependencies, Weight> + , FeatureMap + , insert_dependencies< + insert_feature<mpl::_1, mpl::_2> + , mpl::_2 + , Weight + > + > + { + }; + + template<typename FeatureMap, typename Features, typename Weight> + struct insert_sequence + : mpl::fold< // BUGBUG should use insert_range, but doesn't seem to work for maps + as_feature_list<Features, Weight> + , FeatureMap + , insert_feature<mpl::_1, mpl::_2> + > + { + }; + + template<typename Features, typename Sample, typename Weight> + struct make_accumulator_tuple + { + typedef + typename mpl::fold< + as_feature_list<Features, Weight> + , mpl::map0<> + , mpl::if_< + mpl::is_sequence<mpl::_2> + , insert_sequence<mpl::_1, mpl::_2, Weight> + , insert_feature<mpl::_1, mpl::_2> + > + >::type + feature_map; + + // for each element in the map, add its dependencies also + typedef + typename mpl::fold< + feature_map + , feature_map + , insert_dependencies<mpl::_1, mpl::second<mpl::_2>, Weight> + >::type + feature_map_with_dependencies; + + // turn the map into a vector so we can sort it + typedef + typename mpl::insert_range< + mpl::vector<> + , mpl::end<mpl::vector<> >::type + , mpl::transform_view<feature_map_with_dependencies, mpl::second<mpl::_1> > + >::type + feature_vector_with_dependencies; + + // sort the features according to which is derived from which + typedef + typename mpl::sort< + feature_vector_with_dependencies + , is_dependent_on<mpl::_2, mpl::_1> + >::type + sorted_feature_vector; + + // From the vector of features, construct a vector of accumulators + typedef + typename mpl::transform< + sorted_feature_vector + , to_accumulator<mpl::_1, Sample, Weight> + >::type + type; + }; + + } // namespace detail + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/external.hpp b/boost_1_45_0/boost/accumulators/framework/external.hpp new file mode 100644 index 0000000..dbd5d91 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/external.hpp
@@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +// external.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 + +#include <boost/mpl/apply.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> + +//namespace boost { namespace accumulators +//{ +// +///////////////////////////////////////////////////////////////////////////////// +//// external +//// +//template<typename Type> +//struct external +//{ +//}; +// +//}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/extractor.hpp b/boost_1_45_0/boost/accumulators/framework/extractor.hpp new file mode 100644 index 0000000..98281ce --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/extractor.hpp
@@ -0,0 +1,229 @@ +/////////////////////////////////////////////////////////////////////////////// +// extractor.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 + +#include <boost/preprocessor/tuple/rem.hpp> +#include <boost/preprocessor/array/size.hpp> +#include <boost/preprocessor/array/data.hpp> +#include <boost/preprocessor/array/elem.hpp> +#include <boost/preprocessor/seq/to_array.hpp> +#include <boost/preprocessor/seq/transform.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +#include <boost/parameter/binding.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + template<typename AccumulatorSet, typename Feature> + struct accumulator_set_result + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename mpl::apply<AccumulatorSet, feature_type>::type::result_type type; + }; + + template<typename Args, typename Feature> + struct argument_pack_result + : accumulator_set_result< + typename remove_reference< + typename parameter::binding<Args, tag::accumulator>::type + >::type + , Feature + > + { + }; + + template<typename A, typename Feature> + struct extractor_result + : mpl::eval_if< + detail::is_accumulator_set<A> + , accumulator_set_result<A, Feature> + , argument_pack_result<A, Feature> + > + { + }; + + template<typename Feature, typename AccumulatorSet> + typename extractor_result<AccumulatorSet, Feature>::type + do_extract(AccumulatorSet const &acc, mpl::true_) + { + typedef typename as_feature<Feature>::type feature_type; + return extract_result<feature_type>(acc); + } + + template<typename Feature, typename Args> + typename extractor_result<Args, Feature>::type + do_extract(Args const &args, mpl::false_) + { + typedef typename as_feature<Feature>::type feature_type; + return find_accumulator<feature_type>(args[accumulator]).result(args); + } + +} // namespace detail + + +/////////////////////////////////////////////////////////////////////////////// +/// Extracts the result associated with Feature from the specified accumulator_set. +template<typename Feature> +struct extractor +{ + typedef extractor<Feature> this_type; + + /// The result meta-function for determining the return type of the extractor + template<typename F> + struct result; + + template<typename A1> + struct result<this_type(A1)> + : detail::extractor_result<A1, Feature> + { + }; + + /// Extract the result associated with Feature from the accumulator set + /// \param acc The accumulator set object from which to extract the result + template<typename Arg1> + typename detail::extractor_result<Arg1, Feature>::type + operator ()(Arg1 const &arg1) const + { + // Arg1 could be an accumulator_set or an argument pack containing + // an accumulator_set. Dispatch accordingly. + return detail::do_extract<Feature>(arg1, detail::is_accumulator_set<Arg1>()); + } + + /// \overload + /// + /// \param a1 Optional named parameter to be passed to the accumulator's result() function. + template<typename AccumulatorSet, typename A1> + typename detail::extractor_result<AccumulatorSet, Feature>::type + operator ()(AccumulatorSet const &acc, A1 const &a1) const + { + BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>)); + typedef typename as_feature<Feature>::type feature_type; + return extract_result<feature_type>(acc, a1); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#define BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP(z, n, _) \ + template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \ + struct result<this_type(BOOST_PP_ENUM_PARAMS_Z(z, n, A))> \ + : detail::extractor_result<A1, Feature> \ + {}; \ + template< \ + typename AccumulatorSet \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename detail::extractor_result<AccumulatorSet, Feature>::type \ + operator ()( \ + AccumulatorSet const &acc \ + BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ + ) const \ + { \ + BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>)); \ + typedef typename as_feature<Feature>::type feature_type; \ + return extract_result<feature_type>(acc BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a));\ + } + + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename AccumulatorSet, typename A1, typename A2, ...> + typename detail::extractor_result<AccumulatorSet, Feature>::type + operator ()(AccumulatorSet const &acc, A1 const &a1, A2 const &a2, ...); + #endif +}; + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \ + BOOST_PP_TUPLE_REM_CTOR(BOOST_PP_ARRAY_SIZE(Array), BOOST_PP_ARRAY_DATA(Array)) + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_SEQ_REM(Seq) \ + BOOST_ACCUMULATORS_ARRAY_REM(BOOST_PP_SEQ_TO_ARRAY(Seq)) + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_ARGS_OP(s, data, elem) \ + T ## s + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_PARAMS_OP(s, data, elem) \ + elem T ## s + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ + Tag::Feature< \ + BOOST_ACCUMULATORS_SEQ_REM( \ + BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_ARGS_OP, ~, ParamsSeq) \ + ) \ + > + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL(z, n, Tag, Feature, ParamsSeq) \ + template< \ + BOOST_ACCUMULATORS_SEQ_REM( \ + BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_PARAMS_OP, ~, ParamsSeq) \ + ) \ + , typename Arg1 \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename boost::accumulators::detail::extractor_result< \ + Arg1 \ + , BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ + >::type \ + Feature(Arg1 const &arg1 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) ) \ + { \ + typedef BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) feature_type; \ + return boost::accumulators::extractor<feature_type>()( \ + arg1 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a)); \ + } + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN(z, n, _) \ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL( \ + z \ + , n \ + , BOOST_PP_ARRAY_ELEM(0, _) \ + , BOOST_PP_ARRAY_ELEM(1, _) \ + , BOOST_PP_ARRAY_ELEM(2, _) \ + ) + +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(Tag, Feature, ParamSeq) \ + BOOST_PP_REPEAT( \ + BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) \ + , BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN \ + , (3, (Tag, Feature, ParamSeq)) \ + ) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/features.hpp b/boost_1_45_0/boost/accumulators/framework/features.hpp new file mode 100644 index 0000000..21cae00 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/features.hpp
@@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// features.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005 +#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005 + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// features +// +template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)> +struct features + : mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/parameters/accumulator.hpp b/boost_1_45_0/boost/accumulators/framework/parameters/accumulator.hpp new file mode 100644 index 0000000..30e4b0d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/parameters/accumulator.hpp
@@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, accumulator) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/parameters/sample.hpp b/boost_1_45_0/boost/accumulators/framework/parameters/sample.hpp new file mode 100644 index 0000000..9bfb665 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/parameters/sample.hpp
@@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////// +// sample.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, sample) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/parameters/weight.hpp b/boost_1_45_0/boost/accumulators/framework/parameters/weight.hpp new file mode 100644 index 0000000..86f133b --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/parameters/weight.hpp
@@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////// +// weight.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +// The weight of a single sample +BOOST_PARAMETER_KEYWORD(tag, weight) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/framework/parameters/weights.hpp b/boost_1_45_0/boost/accumulators/framework/parameters/weights.hpp new file mode 100644 index 0000000..85b9e2f --- /dev/null +++ b/boost_1_45_0/boost/accumulators/framework/parameters/weights.hpp
@@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////// +// weights.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +// The weight accumulator +BOOST_PARAMETER_KEYWORD(tag, weights) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/function1.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/function1.hpp new file mode 100644 index 0000000..282eb1e --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/function1.hpp
@@ -0,0 +1,75 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_DETAIL_FUNCTION1_DWA200655_HPP +# define BOOST_DETAIL_FUNCTION1_DWA200655_HPP + +# include <boost/concept_check.hpp> +# include <boost/type_traits/remove_reference.hpp> +# include <boost/type_traits/add_const.hpp> +# include <boost/mpl/apply.hpp> + +namespace boost { namespace detail { + +// A utility for creating unary function objects that play nicely with +// boost::result_of and that handle the forwarding problem. +// +// mpl::apply<F, A0>::type is expected to be a stateless function +// object that accepts an argument of type A0&. It is also expected +// to have a nested ::result_type identical to its return type. +template<typename F> +struct function1 +{ + template<typename Signature> + struct result + {}; + + template<typename This, typename A0> + struct result<This(A0)> + { + // How adding const to arguments handles rvalues. + // + // if A0 is arg0 is represents actual argument + // -------- ------- -------------------------- + // T const & T const const T lvalue + // T & T non-const T lvalue + // T const T const const T rvalue + // T T const non-const T rvalue + typedef typename remove_reference< + typename add_const< A0 >::type + >::type arg0; + + typedef typename mpl::apply1<F, arg0>::type impl; + typedef typename impl::result_type type; + }; + + // Handles mutable lvalues + template<typename A0> + typename result<function1(A0 &)>::type + operator ()(A0 &a0) const + { + typedef typename result<function1(A0 &)>::impl impl; + typedef typename result<function1(A0 &)>::type type; + typedef A0 &arg0; + BOOST_CONCEPT_ASSERT((UnaryFunction<impl, type, arg0>)); + //boost::function_requires<UnaryFunctionConcept<impl, type, arg0> >(); + return impl()(a0); + } + + // Handles const lvalues and all rvalues + template<typename A0> + typename result<function1(A0 const &)>::type + operator ()(A0 const &a0) const + { + typedef typename result<function1(A0 const &)>::impl impl; + typedef typename result<function1(A0 const &)>::type type; + typedef A0 const &arg0; + BOOST_CONCEPT_ASSERT((UnaryFunction<impl, type, arg0>)); + //boost::function_requires<UnaryFunctionConcept<impl, type, arg0> >(); + return impl()(a0); + } +}; + +}} // namespace boost::detail + +#endif // BOOST_DETAIL_FUNCTION1_DWA200655_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/function2.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/function2.hpp new file mode 100644 index 0000000..daf3c4d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/function2.hpp
@@ -0,0 +1,10 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_DETAIL_FUNCTION2_DWA200655_HPP +# define BOOST_DETAIL_FUNCTION2_DWA200655_HPP + +# define args (2) +# include <boost/accumulators/numeric/detail/function_n.hpp> + +#endif // BOOST_DETAIL_FUNCTION2_DWA200655_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/function3.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/function3.hpp new file mode 100644 index 0000000..175e4d5 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/function3.hpp
@@ -0,0 +1,10 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_DETAIL_FUNCTION3_DWA2006514_HPP +# define BOOST_DETAIL_FUNCTION3_DWA2006514_HPP + +# define args (3) +# include <boost/accumulators/numeric/detail/function_n.hpp> + +#endif // BOOST_DETAIL_FUNCTION3_DWA2006514_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/function4.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/function4.hpp new file mode 100644 index 0000000..a0d7108 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/function4.hpp
@@ -0,0 +1,10 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_DETAIL_FUNCTION4_DWA2006514_HPP +# define BOOST_DETAIL_FUNCTION4_DWA2006514_HPP + +# define args (4) +# include <boost/accumulators/numeric/detail/function_n.hpp> + +#endif // BOOST_DETAIL_FUNCTION4_DWA2006514_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/function_n.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/function_n.hpp new file mode 100644 index 0000000..47c42ed --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/function_n.hpp
@@ -0,0 +1,148 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// #include guards intentionally disabled. +// #ifndef BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP +// # define BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP + +#include <boost/mpl/void.hpp> +#include <boost/mpl/apply.hpp> + +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/seq/fold_left.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/for_each_i.hpp> +#include <boost/preprocessor/seq/for_each_product.hpp> +#include <boost/preprocessor/seq/size.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/remove_reference.hpp> + +namespace boost { namespace detail { + +# define BOOST_DETAIL_default_arg(z, n, _) \ + typedef mpl::void_ BOOST_PP_CAT(arg, n); + +# define BOOST_DETAIL_function_arg(z, n, _) \ + typedef typename remove_reference< \ + typename add_const< BOOST_PP_CAT(A, n) >::type \ + >::type BOOST_PP_CAT(arg, n); + +#define BOOST_DETAIL_cat_arg_counts(s, state, n) \ + BOOST_PP_IF( \ + n \ + , BOOST_PP_CAT(state, BOOST_PP_CAT(_, n)) \ + , state \ + ) \ + /**/ + +#define function_name \ + BOOST_PP_SEQ_FOLD_LEFT( \ + BOOST_DETAIL_cat_arg_counts \ + , BOOST_PP_CAT(function, BOOST_PP_SEQ_HEAD(args)) \ + , BOOST_PP_SEQ_TAIL(args)(0) \ + ) \ + /**/ + +template<typename F> +struct function_name +{ + BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , BOOST_DETAIL_default_arg + , ~ + ) + + template<typename Signature> + struct result {}; + +#define BOOST_DETAIL_function_result(r, _, n) \ + template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A)> \ + struct result<This(BOOST_PP_ENUM_PARAMS(n, A))> \ + { \ + BOOST_PP_REPEAT(n, BOOST_DETAIL_function_arg, ~) \ + typedef \ + typename BOOST_PP_CAT(mpl::apply, BOOST_MPL_LIMIT_METAFUNCTION_ARITY)<\ + F \ + BOOST_PP_ENUM_TRAILING_PARAMS( \ + BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ + , arg \ + ) \ + >::type \ + impl; \ + typedef typename impl::result_type type; \ + }; \ + /**/ + + BOOST_PP_SEQ_FOR_EACH(BOOST_DETAIL_function_result, _, args) + +# define arg_type(r, _, i, is_const) \ + BOOST_PP_COMMA_IF(i) BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & + +# define result_(r, n, constness) \ + typename result< \ + function_name( \ + BOOST_PP_SEQ_FOR_EACH_I_R(r, arg_type, ~, constness) \ + ) \ + > \ + /**/ + +# define param(r, _, i, is_const) BOOST_PP_COMMA_IF(i) \ + BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & BOOST_PP_CAT(x, i) + +# define param_list(r, n, constness) \ + BOOST_PP_SEQ_FOR_EACH_I_R(r, param, ~, constness) + +# define call_operator(r, constness) \ + template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), typename A)> \ + result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::type \ + operator ()( param_list(r, BOOST_PP_SEQ_SIZE(constness), constness) ) const \ + { \ + typedef result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::impl impl; \ + return impl()(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), x)); \ + } \ + /**/ + +# define const_if0 +# define const_if1 const + +# define bits(z, n, _) ((0)(1)) + +# define gen_operator(r, _, n) \ + BOOST_PP_SEQ_FOR_EACH_PRODUCT_R( \ + r \ + , call_operator \ + , BOOST_PP_REPEAT(n, bits, ~) \ + ) \ + /**/ + + BOOST_PP_SEQ_FOR_EACH( + gen_operator + , ~ + , args + ) + +# undef bits +# undef const_if1 +# undef const_if0 +# undef call_operator +# undef param_list +# undef param +# undef result_ +# undef default_ +# undef arg_type +# undef gen_operator +# undef function_name + +# undef args +}; + +}} // namespace boost::detail + +//#endif // BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/detail/pod_singleton.hpp b/boost_1_45_0/boost/accumulators/numeric/detail/pod_singleton.hpp new file mode 100644 index 0000000..317d85f --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/detail/pod_singleton.hpp
@@ -0,0 +1,20 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP +# define BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP + +namespace boost { namespace detail { + +template<typename T> +struct pod_singleton +{ + static T instance; +}; + +template<typename T> +T pod_singleton<T>::instance; + +}} // namespace boost::detail + +#endif // BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP
diff --git a/boost_1_45_0/boost/accumulators/numeric/functional.hpp b/boost_1_45_0/boost/accumulators/numeric/functional.hpp new file mode 100644 index 0000000..9d955db --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/functional.hpp
@@ -0,0 +1,490 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file functional.hpp +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 + +#include <limits> +#include <functional> +#include <boost/mpl/if.hpp> +#include <boost/mpl/and.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_empty.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_floating_point.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/typeof/typeof.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> +#include <boost/accumulators/numeric/detail/function1.hpp> +#include <boost/accumulators/numeric/detail/function2.hpp> +#include <boost/accumulators/numeric/detail/pod_singleton.hpp> + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VECTOR_SUPPORT +# include <boost/accumulators/numeric/functional/vector.hpp> +#endif + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VALARRAY_SUPPORT +# include <boost/accumulators/numeric/functional/valarray.hpp> +#endif + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_COMPLEX_SUPPORT +# include <boost/accumulators/numeric/functional/complex.hpp> +#endif + +/// INTERNAL ONLY +/// +#define BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED + +#ifdef BOOST_NUMERIC_FUNCTIONAL_DOXYGEN_INVOKED +// Hack to make Doxygen show the inheritance relationships +/// INTERNAL ONLY +/// +namespace std +{ + /// INTERNAL ONLY + /// + template<class Arg, class Ret> struct unary_function {}; + /// INTERNAL ONLY + /// + template<class Left, class Right, class Ret> struct binary_function {}; +} +#endif + +namespace boost { namespace numeric +{ + namespace functional + { + /// INTERNAL ONLY + /// + template<typename A0, typename A1> + struct are_integral + : mpl::and_<is_integral<A0>, is_integral<A1> > + {}; + + template<typename Left, typename Right> + struct left_ref + { + typedef Left &type; + }; + + namespace detail + { + template<typename T> + T &lvalue_of(); + } + } + + // TODO: handle complex weight, valarray, MTL vectors + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(Name, Op) \ + namespace functional \ + { \ + template<typename Arg> \ + struct result_of_ ## Name \ + { \ + BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ + nested \ + , Op boost::numeric::functional::detail::lvalue_of<Arg>() \ + ) \ + typedef typename nested::type type; \ + }; \ + template<typename Arg, typename EnableIf> \ + struct Name ## _base \ + : std::unary_function< \ + typename remove_const<Arg>::type \ + , typename result_of_ ## Name<Arg>::type \ + > \ + { \ + typename result_of_ ## Name<Arg>::type operator ()(Arg &arg) const \ + { \ + return Op arg; \ + } \ + }; \ + template<typename Arg, typename ArgTag> \ + struct Name \ + : Name ## _base<Arg, void> \ + {}; \ + } \ + namespace op \ + { \ + struct Name \ + : boost::detail::function1<functional::Name<_, functional::tag<_> > > \ + {}; \ + } \ + namespace \ + { \ + op::Name const &Name = boost::detail::pod_singleton<op::Name>::instance; \ + } \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(Name, Op, RetType) \ + namespace functional \ + { \ + template<typename Left, typename Right, typename EnableIf> \ + struct result_of_ ## Name \ + { \ + RetType(Left, Op, Right) \ + }; \ + template<typename Left, typename Right, typename EnableIf> \ + struct Name ## _base \ + : std::binary_function< \ + typename remove_const<Left>::type \ + , typename remove_const<Right>::type \ + , typename result_of_ ## Name<Left, Right>::type \ + > \ + { \ + typename result_of_ ## Name<Left, Right>::type \ + operator ()(Left &left, Right &right) const \ + { \ + return left Op right; \ + } \ + }; \ + template<typename Left, typename Right, typename LeftTag, typename RightTag> \ + struct Name \ + : Name ## _base<Left, Right, void> \ + {}; \ + } \ + namespace op \ + { \ + struct Name \ + : boost::detail::function2< \ + functional::Name<_1, _2, functional::tag<_1>, functional::tag<_2> > \ + > \ + {}; \ + } \ + namespace \ + { \ + op::Name const &Name = boost::detail::pod_singleton<op::Name>::instance; \ + } \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEDUCED(Left, Op, Right) \ + BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ + nested \ + , boost::numeric::functional::detail::lvalue_of<Left>() Op \ + boost::numeric::functional::detail::lvalue_of<Right>() \ + ) \ + typedef typename nested::type type; \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_LEFT(Left, Op, Right) \ + typedef Left &type; \ + /**/ + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus, +, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus, -, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies, *, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides, /, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus, %, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater, >, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater_equal, >=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less, <, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less_equal, <=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(equal_to, ==, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(not_equal_to, !=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(assign, =, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus_assign, +=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus_assign, -=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies_assign, *=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides_assign, /=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus_assign, %=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_plus, +) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_minus, -) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(complement, ~) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(logical_not, !) + +#undef BOOST_NUMERIC_FUNCTIONAL_LEFT +#undef BOOST_NUMERIC_FUNCTIONAL_DEDUCED +#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP +#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP + + namespace functional + { + template<typename Left, typename Right, typename EnableIf> + struct min_assign_base + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + if(numeric::less(right, left)) + { + left = right; + } + } + }; + + template<typename Left, typename Right, typename EnableIf> + struct max_assign_base + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + if(numeric::greater(right, left)) + { + left = right; + } + } + }; + + template<typename Left, typename Right, typename EnableIf> + struct average_base + : functional::divides<Left, Right> + {}; + + // partial specialization that promotes the arguments to double for + // integral division. + template<typename Left, typename Right> + struct average_base<Left, Right, typename enable_if<are_integral<Left, Right> >::type> + : functional::divides<double const, double const> + {}; + + template<typename To, typename From, typename EnableIf> + struct promote_base + : std::unary_function<From, To> + { + To operator ()(From &from) const + { + return from; + } + }; + + template<typename ToFrom> + struct promote_base<ToFrom, ToFrom, void> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) + { + return tofrom; + } + }; + + template<typename Arg, typename EnableIf> + struct as_min_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return (std::numeric_limits<typename remove_const<Arg>::type>::min)(); + } + }; + + template<typename Arg> + struct as_min_base<Arg, typename enable_if<is_floating_point<Arg> >::type> + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return -(std::numeric_limits<typename remove_const<Arg>::type>::max)(); + } + }; + + template<typename Arg, typename EnableIf> + struct as_max_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return (std::numeric_limits<typename remove_const<Arg>::type>::max)(); + } + }; + + template<typename Arg, typename EnableIf> + struct as_zero_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return numeric::zero<typename remove_const<Arg>::type>::value; + } + }; + + template<typename Arg, typename EnableIf> + struct as_one_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return numeric::one<typename remove_const<Arg>::type>::value; + } + }; + + template<typename To, typename From, typename ToTag, typename FromTag> + struct promote + : promote_base<To, From, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct min_assign + : min_assign_base<Left, Right, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct max_assign + : max_assign_base<Left, Right, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct average + : average_base<Left, Right, void> + {}; + + template<typename Arg, typename Tag> + struct as_min + : as_min_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_max + : as_max_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_zero + : as_zero_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_one + : as_one_base<Arg, void> + {}; + } + + namespace op + { + template<typename To> + struct promote + : boost::detail::function1<functional::promote<To, _, typename functional::tag<To>::type, functional::tag<_> > > + {}; + + struct min_assign + : boost::detail::function2<functional::min_assign<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct max_assign + : boost::detail::function2<functional::max_assign<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct average + : boost::detail::function2<functional::average<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct as_min + : boost::detail::function1<functional::as_min<_, functional::tag<_> > > + {}; + + struct as_max + : boost::detail::function1<functional::as_max<_, functional::tag<_> > > + {}; + + struct as_zero + : boost::detail::function1<functional::as_zero<_, functional::tag<_> > > + {}; + + struct as_one + : boost::detail::function1<functional::as_one<_, functional::tag<_> > > + {}; + } + + namespace + { + op::min_assign const &min_assign = boost::detail::pod_singleton<op::min_assign>::instance; + op::max_assign const &max_assign = boost::detail::pod_singleton<op::max_assign>::instance; + op::average const &average = boost::detail::pod_singleton<op::average>::instance; + op::as_min const &as_min = boost::detail::pod_singleton<op::as_min>::instance; + op::as_max const &as_max = boost::detail::pod_singleton<op::as_max>::instance; + op::as_zero const &as_zero = boost::detail::pod_singleton<op::as_zero>::instance; + op::as_one const &as_one = boost::detail::pod_singleton<op::as_one>::instance; + } + + /////////////////////////////////////////////////////////////////////////////// + // promote + template<typename To, typename From> + typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type + promote(From &from) + { + return functional::promote<To, From>()(from); + } + + template<typename To, typename From> + typename mpl::if_<is_same<To const, From const>, To const &, To const>::type + promote(From const &from) + { + return functional::promote<To const, From const>()(from); + } + + template<typename T> + struct default_ + { + typedef default_ type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return default_::value; + } + }; + + template<typename T> + T const default_<T>::value = T(); + + template<typename T> + struct one + { + typedef one type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return one::value; + } + }; + + template<typename T> + T const one<T>::value = T(1); + + template<typename T> + struct zero + { + typedef zero type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return zero::value; + } + }; + + template<typename T> + T const zero<T>::value = T(); + + template<typename T> + struct one_or_default + : mpl::if_<is_empty<T>, default_<T>, one<T> >::type + {}; + + template<typename T> + struct zero_or_default + : mpl::if_<is_empty<T>, default_<T>, zero<T> >::type + {}; + +}} // namespace boost::numeric + +#endif
diff --git a/boost_1_45_0/boost/accumulators/numeric/functional/complex.hpp b/boost_1_45_0/boost/accumulators/numeric/functional/complex.hpp new file mode 100644 index 0000000..ea8c033 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/functional/complex.hpp
@@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file complex.hpp +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 +#define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <complex> +#include <boost/mpl/or.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/typeof/std/complex.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric { namespace operators +{ + // So that the stats compile when Sample type is std::complex + template<typename T, typename U> + typename + disable_if< + mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> > + , std::complex<T> + >::type + operator *(std::complex<T> ri, U const &u) + { + // BUGBUG promote result to typeof(T()*u) ? + return ri *= static_cast<T>(u); + } + + template<typename T, typename U> + typename + disable_if< + mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> > + , std::complex<T> + >::type + operator /(std::complex<T> ri, U const &u) + { + // BUGBUG promote result to typeof(T()*u) ? + return ri /= static_cast<T>(u); + } + +}}} // namespace boost::numeric::operators + +namespace boost { namespace numeric +{ + namespace detail + { + template<typename T> + struct one_complex + { + static std::complex<T> const value; + }; + + template<typename T> + std::complex<T> const one_complex<T>::value + = std::complex<T>(numeric::one<T>::value, numeric::one<T>::value); + } + + /// INTERNAL ONLY + /// + template<typename T> + struct one<std::complex<T> > + : detail::one_complex<T> + { + typedef one type; + typedef std::complex<T> value_type; + operator value_type const & () const + { + return detail::one_complex<T>::value; + } + }; + +}} // namespace boost::numeric + +#endif
diff --git a/boost_1_45_0/boost/accumulators/numeric/functional/valarray.hpp b/boost_1_45_0/boost/accumulators/numeric/functional/valarray.hpp new file mode 100644 index 0000000..41766a0 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/functional/valarray.hpp
@@ -0,0 +1,360 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file valarray.hpp +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <valarray> +#include <functional> +#include <boost/assert.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/not.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/typeof/std/valarray.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric +{ + namespace operators + { + namespace acc_detail + { + template<typename Fun> + struct make_valarray + { + typedef std::valarray<typename Fun::result_type> type; + }; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> / Right where Right is a scalar and Right != Left. + template<typename Left, typename Right> + typename lazy_enable_if< + mpl::and_<is_scalar<Right>, mpl::not_<is_same<Left, Right> > > + , acc_detail::make_valarray<functional::divides<Left, Right> > + >::type + operator /(std::valarray<Left> const &left, Right const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> * Right where Right is a scalar and Right != Left. + template<typename Left, typename Right> + typename lazy_enable_if< + mpl::and_<is_scalar<Right>, mpl::not_<is_same<Left, Right> > > + , acc_detail::make_valarray<functional::multiplies<Left, Right> > + >::type + operator *(std::valarray<Left> const &left, Right const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> + valarray<Right> where Right != Left. + template<typename Left, typename Right> + typename lazy_disable_if< + is_same<Left, Right> + , acc_detail::make_valarray<functional::plus<Left, Right> > + >::type + operator +(std::valarray<Left> const &left, std::valarray<Right> const &right) + { + typedef typename functional::plus<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::plus(left[i], right[i]); + } + return result; + } + } + + namespace functional + { + struct std_valarray_tag; + + template<typename T> + struct tag<std::valarray<T> > + { + typedef std_valarray_tag type; + }; + + #ifdef __GLIBCXX__ + template<typename T, typename U> + struct tag<std::_Expr<T, U> > + { + typedef std_valarray_tag type; + }; + #endif + + /// INTERNAL ONLY + /// + // This is necessary because the GCC stdlib uses expression templates, and + // typeof(som-valarray-expression) is not an instance of std::valarray + #define BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(Name, Op) \ + template<typename Left, typename Right> \ + struct Name<Left, Right, std_valarray_tag, std_valarray_tag> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name< \ + typename Left::value_type \ + , typename Right::value_type \ + >::result_type \ + > \ + > \ + { \ + typedef typename Left::value_type left_value_type; \ + typedef typename Right::value_type right_value_type; \ + typedef \ + std::valarray< \ + typename Name<left_value_type, right_value_type>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return numeric::promote<std::valarray<left_value_type> >(left) \ + Op numeric::promote<std::valarray<right_value_type> >(right); \ + } \ + }; \ + template<typename Left, typename Right> \ + struct Name<Left, Right, std_valarray_tag, void> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name<typename Left::value_type, Right>::result_type \ + > \ + > \ + { \ + typedef typename Left::value_type left_value_type; \ + typedef \ + std::valarray< \ + typename Name<left_value_type, Right>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return numeric::promote<std::valarray<left_value_type> >(left) Op right;\ + } \ + }; \ + template<typename Left, typename Right> \ + struct Name<Left, Right, void, std_valarray_tag> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name<Left, typename Right::value_type>::result_type \ + > \ + > \ + { \ + typedef typename Right::value_type right_value_type; \ + typedef \ + std::valarray< \ + typename Name<Left, right_value_type>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return left Op numeric::promote<std::valarray<right_value_type> >(right);\ + } \ + }; + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(plus, +) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(minus, -) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(multiplies, *) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(divides, /) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(modulus, %) + + #undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP + + /////////////////////////////////////////////////////////////////////////////// + // element-wise min of std::valarray + template<typename Left, typename Right> + struct min_assign<Left, Right, std_valarray_tag, std_valarray_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::less(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise max of std::valarray + template<typename Left, typename Right> + struct max_assign<Left, Right, std_valarray_tag, std_valarray_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::greater(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + // partial specialization of numeric::average<> for std::valarray. + template<typename Left, typename Right, typename RightTag> + struct average<Left, Right, std_valarray_tag, RightTag> + : mpl::if_< + are_integral<typename Left::value_type, Right> + , divides<Left, double const> + , divides<Left, Right> + >::type + {}; + + // promote + template<typename To, typename From> + struct promote<To, From, std_valarray_tag, std_valarray_tag> + : std::unary_function<From, To> + { + To operator ()(From &arr) const + { + typename remove_const<To>::type res(arr.size()); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + res[i] = numeric::promote<typename To::value_type>(arr[i]); + } + return res; + } + }; + + template<typename ToFrom> + struct promote<ToFrom, ToFrom, std_valarray_tag, std_valarray_tag> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) const + { + return tofrom; + } + }; + + // for "promoting" a std::valarray<bool> to a bool, useful for + // comparing 2 valarrays for equality: + // if(numeric::promote<bool>(a == b)) + template<typename From> + struct promote<bool, From, void, std_valarray_tag> + : std::unary_function<From, bool> + { + bool operator ()(From &arr) const + { + BOOST_MPL_ASSERT((is_same<bool, typename From::value_type>)); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + if(!arr[i]) + { + return false; + } + } + return true; + } + }; + + template<typename From> + struct promote<bool const, From, void, std_valarray_tag> + : promote<bool, From, void, std_valarray_tag> + {}; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_min + template<typename T> + struct as_min<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_min(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_max + template<typename T> + struct as_max<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_max(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_zero + template<typename T> + struct as_zero<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_zero(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_one + template<typename T> + struct as_one<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_one(arr[0]), arr.size()); + } + }; + + } // namespace functional + +}} // namespace boost::numeric + +#endif +
diff --git a/boost_1_45_0/boost/accumulators/numeric/functional/vector.hpp b/boost_1_45_0/boost/accumulators/numeric/functional/vector.hpp new file mode 100644 index 0000000..cdb2342 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/functional/vector.hpp
@@ -0,0 +1,329 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file vector.hpp +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <vector> +#include <functional> +#include <boost/assert.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/not.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/typeof/std/vector.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric +{ + namespace operators + { + namespace acc_detail + { + template<typename Fun> + struct make_vector + { + typedef std::vector<typename Fun::result_type> type; + }; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> / Right where Right is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Right> + , acc_detail::make_vector<functional::divides<Left, Right> > + >::type + operator /(std::vector<Left> const &left, Right const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> / vector<Right>. + template<typename Left, typename Right> + std::vector<typename functional::divides<Left, Right>::result_type> + operator /(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> * Right where Right is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Right> + , acc_detail::make_vector<functional::multiplies<Left, Right> > + >::type + operator *(std::vector<Left> const &left, Right const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle Left * vector<Right> where Left is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Left> + , acc_detail::make_vector<functional::multiplies<Left, Right> > + >::type + operator *(Left const &left, std::vector<Right> const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(right.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left, right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> * vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::multiplies<Left, Right>::result_type> + operator *(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> + vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::plus<Left, Right>::result_type> + operator +(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::plus<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::plus(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> - vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::minus<Left, Right>::result_type> + operator -(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::minus<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::minus(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> += vector<Left> + template<typename Left> + std::vector<Left> & + operator +=(std::vector<Left> &left, std::vector<Left> const &right) + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + numeric::plus_assign(left[i], right[i]); + } + return left; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle -vector<Arg> + template<typename Arg> + std::vector<typename functional::unary_minus<Arg>::result_type> + operator -(std::vector<Arg> const &arg) + { + typedef typename functional::unary_minus<Arg>::result_type value_type; + std::vector<value_type> result(arg.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::unary_minus(arg[i]); + } + return result; + } + } + + namespace functional + { + struct std_vector_tag; + + template<typename T, typename Al> + struct tag<std::vector<T, Al> > + { + typedef std_vector_tag type; + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise min of std::vector + template<typename Left, typename Right> + struct min_assign<Left, Right, std_vector_tag, std_vector_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::less(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise max of std::vector + template<typename Left, typename Right> + struct max_assign<Left, Right, std_vector_tag, std_vector_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::greater(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + // partial specialization for std::vector. + template<typename Left, typename Right> + struct average<Left, Right, std_vector_tag, void> + : mpl::if_< + are_integral<typename Left::value_type, Right> + , divides<Left, double const> + , divides<Left, Right> + >::type + {}; + + // promote + template<typename To, typename From> + struct promote<To, From, std_vector_tag, std_vector_tag> + : std::unary_function<From, To> + { + To operator ()(From &arr) const + { + typename remove_const<To>::type res(arr.size()); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + res[i] = numeric::promote<typename To::value_type>(arr[i]); + } + return res; + } + }; + + template<typename ToFrom> + struct promote<ToFrom, ToFrom, std_vector_tag, std_vector_tag> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) const + { + return tofrom; + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_min + template<typename T> + struct as_min<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_min(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_max + template<typename T> + struct as_max<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_max(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_zero + template<typename T> + struct as_zero<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_zero(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_one + template<typename T> + struct as_one<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_one(arr[0])); + } + }; + + } // namespace functional + +}} // namespace boost::numeric + +#endif +
diff --git a/boost_1_45_0/boost/accumulators/numeric/functional_fwd.hpp b/boost_1_45_0/boost/accumulators/numeric/functional_fwd.hpp new file mode 100644 index 0000000..940d15b --- /dev/null +++ b/boost_1_45_0/boost/accumulators/numeric/functional_fwd.hpp
@@ -0,0 +1,221 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file functional_fwd.hpp +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 + +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_const.hpp> + +namespace boost { namespace numeric +{ + // For using directives -- this namespace may be re-opened elsewhere + namespace operators + {} + + namespace op + { + using mpl::_; + using mpl::_1; + using mpl::_2; + } + + namespace functional + { + using namespace operators; + + template<typename T> + struct tag + { + typedef void type; + }; + + template<typename T> + struct tag<T const> + : tag<T> + {}; + + template<typename T> + struct tag<T volatile> + : tag<T> + {}; + + template<typename T> + struct tag<T const volatile> + : tag<T> + {}; + + template<typename T> + struct static_; + + template<typename A0, typename A1> + struct are_integral; + } + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op) \ + namespace functional \ + { \ + template<typename Arg, typename EnableIf = void> \ + struct Name ## _base; \ + template<typename Arg, typename ArgTag = typename tag<Arg>::type> \ + struct Name; \ + } \ + namespace op \ + { \ + struct Name; \ + } \ + namespace \ + { \ + extern op::Name const &Name; \ + } + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name) \ + namespace functional \ + { \ + template<typename Left, typename Right, typename EnableIf = void> \ + struct result_of_ ## Name; \ + template<typename Left, typename Right, typename EnableIf = void> \ + struct Name ## _base; \ + template< \ + typename Left \ + , typename Right \ + , typename LeftTag = typename tag<Left>::type \ + , typename RightTag = typename tag<Right>::type \ + > \ + struct Name; \ + } \ + namespace op \ + { \ + struct Name; \ + } \ + namespace \ + { \ + extern op::Name const &Name; \ + } + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to) + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign) + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !) + +#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP +#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP + + + namespace functional + { + template<typename To, typename From, typename EnableIf = void> + struct promote_base; + template<typename Left, typename Right, typename EnableIf = void> + struct min_assign_base; + template<typename Left, typename Right, typename EnableIf = void> + struct max_assign_base; + template<typename Left, typename Right, typename EnableIf = void> + struct average_base; + template<typename Arg, typename EnableIf = void> + struct as_min_base; + template<typename Arg, typename EnableIf = void> + struct as_max_base; + template<typename Arg, typename EnableIf = void> + struct as_zero_base; + template<typename Arg, typename EnableIf = void> + struct as_one_base; + + template<typename To, typename From, typename ToTag = typename tag<To>::type, typename FromTag = typename tag<From>::type> + struct promote; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct min_assign; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct max_assign; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct average; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_min; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_max; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_zero; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_one; + } + + namespace op + { + template<typename To> + struct promote; + struct min_assign; + struct max_assign; + struct average; + struct as_min; + struct as_max; + struct as_zero; + struct as_one; + } + + namespace + { + extern op::min_assign const &min_assign; + extern op::max_assign const &max_assign; + extern op::average const &average; + extern op::as_min const &as_min; + extern op::as_max const &as_max; + extern op::as_zero const &as_zero; + extern op::as_one const &as_one; + } + + template<typename To, typename From> + typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type + promote(From &from); + + template<typename To, typename From> + typename mpl::if_<is_same<To const, From const>, To const &, To const>::type + promote(From const &from); + + template<typename T> + struct default_; + + template<typename T> + struct one; + + template<typename T> + struct zero; + + template<typename T> + struct one_or_default; + + template<typename T> + struct zero_or_default; + +}} // namespace boost::numeric + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics.hpp b/boost_1_45_0/boost/accumulators/statistics.hpp new file mode 100644 index 0000000..6f505c8 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics.hpp
@@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file statistics.hpp +/// Includes all of the Statistical Accumulators Library +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_HPP_EAN_01_17_2006 +#define BOOST_ACCUMULATORS_STATISTICS_HPP_EAN_01_17_2006 + +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/covariance.hpp> +#include <boost/accumulators/statistics/density.hpp> +#include <boost/accumulators/statistics/error_of.hpp> +#include <boost/accumulators/statistics/error_of_mean.hpp> +#include <boost/accumulators/statistics/extended_p_square.hpp> +#include <boost/accumulators/statistics/extended_p_square_quantile.hpp> +#include <boost/accumulators/statistics/kurtosis.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/statistics/median.hpp> +#include <boost/accumulators/statistics/min.hpp> +#include <boost/accumulators/statistics/moment.hpp> +#include <boost/accumulators/statistics/peaks_over_threshold.hpp> +#include <boost/accumulators/statistics/pot_tail_mean.hpp> +#include <boost/accumulators/statistics/pot_quantile.hpp> +#include <boost/accumulators/statistics/p_square_cumulative_distribution.hpp> +#include <boost/accumulators/statistics/p_square_quantile.hpp> +#include <boost/accumulators/statistics/skewness.hpp> +#include <boost/accumulators/statistics/stats.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_quantile.hpp> +#include <boost/accumulators/statistics/tail_mean.hpp> +#include <boost/accumulators/statistics/tail_variate.hpp> +#include <boost/accumulators/statistics/tail_variate_means.hpp> +#include <boost/accumulators/statistics/variance.hpp> +#include <boost/accumulators/statistics/weighted_covariance.hpp> +#include <boost/accumulators/statistics/weighted_density.hpp> +#include <boost/accumulators/statistics/weighted_kurtosis.hpp> +#include <boost/accumulators/statistics/weighted_extended_p_square.hpp> +#include <boost/accumulators/statistics/weighted_mean.hpp> +#include <boost/accumulators/statistics/weighted_median.hpp> +#include <boost/accumulators/statistics/weighted_moment.hpp> +#include <boost/accumulators/statistics/weighted_peaks_over_threshold.hpp> +#include <boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp> +#include <boost/accumulators/statistics/weighted_p_square_quantile.hpp> +#include <boost/accumulators/statistics/weighted_skewness.hpp> +#include <boost/accumulators/statistics/weighted_sum.hpp> +#include <boost/accumulators/statistics/weighted_tail_quantile.hpp> +#include <boost/accumulators/statistics/weighted_tail_mean.hpp> +#include <boost/accumulators/statistics/weighted_tail_variate_means.hpp> +#include <boost/accumulators/statistics/weighted_variance.hpp> +#include <boost/accumulators/statistics/with_error.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> +#include <boost/accumulators/statistics/variates/covariate.hpp> + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/count.hpp b/boost_1_45_0/boost/accumulators/statistics/count.hpp new file mode 100644 index 0000000..6d30b41 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/count.hpp
@@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////// +// count.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_COUNT_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_COUNT_HPP_EAN_28_10_2005 + +#include <boost/mpl/always.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // count_impl + struct count_impl + : accumulator_base + { + // for boost::result_of + typedef std::size_t result_type; + + count_impl(dont_care) + : cnt(0) + { + } + + void operator ()(dont_care) + { + ++this->cnt; + } + + result_type result(dont_care) const + { + return this->cnt; + } + + private: + std::size_t cnt; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::count +// +namespace tag +{ + struct count + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::count_impl> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::count +// +namespace extract +{ + extractor<tag::count> const count = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(count) +} + +using extract::count; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/covariance.hpp b/boost_1_45_0/boost/accumulators/statistics/covariance.hpp new file mode 100644 index 0000000..b34284b --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/covariance.hpp
@@ -0,0 +1,220 @@ +/////////////////////////////////////////////////////////////////////////////// +// covariance.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_COVARIANCE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_COVARIANCE_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <complex> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/range.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/numeric/ublas/io.hpp> +#include <boost/numeric/ublas/matrix.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/mean.hpp> + +namespace boost { namespace numeric +{ + namespace functional + { + struct std_vector_tag; + + /////////////////////////////////////////////////////////////////////////////// + // functional::outer_product + template<typename Left, typename Right, typename EnableIf = void> + struct outer_product_base + : functional::multiplies<Left, Right> + {}; + + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct outer_product + : outer_product_base<Left, Right, void> + {}; + + template<typename Left, typename Right> + struct outer_product<Left, Right, std_vector_tag, std_vector_tag> + : std::binary_function< + Left + , Right + , ublas::matrix< + typename functional::multiplies< + typename Left::value_type + , typename Right::value_type + >::result_type + > + > + { + typedef + ublas::matrix< + typename functional::multiplies< + typename Left::value_type + , typename Right::value_type + >::result_type + > + result_type; + + result_type + operator ()(Left & left, Right & right) const + { + std::size_t left_size = left.size(); + std::size_t right_size = right.size(); + result_type result(left_size, right_size); + for (std::size_t i = 0; i < left_size; ++i) + for (std::size_t j = 0; j < right_size; ++j) + result(i,j) = numeric::multiplies(left[i], right[j]); + return result; + } + }; + } + + namespace op + { + struct outer_product + : boost::detail::function2<functional::outer_product<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + } + + namespace + { + op::outer_product const &outer_product = boost::detail::pod_singleton<op::outer_product>::instance; + } + +}} + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // covariance_impl + // + /** + @brief Covariance Estimator + + An iterative Monte Carlo estimator for the covariance \f$\mathrm{Cov}(X,X')\f$, where \f$X\f$ is a sample + and \f$X'\f$ is a variate, is given by: + + \f[ + \hat{c}_n = \frac{n-1}{n} \hat{c}_{n-1} + \frac{1}{n-1}(X_n - \hat{\mu}_n)(X_n' - \hat{\mu}_n'),\quad n\ge2,\quad\hat{c}_1 = 0, + \f] + + \f$\hat{\mu}_n\f$ and \f$\hat{\mu}_n'\f$ being the means of the samples and variates. + */ + template<typename Sample, typename VariateType, typename VariateTag> + struct covariance_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type sample_type; + typedef typename numeric::functional::average<VariateType, std::size_t>::result_type variate_type; + // for boost::result_of + typedef typename numeric::functional::outer_product<sample_type, variate_type>::result_type result_type; + + template<typename Args> + covariance_impl(Args const &args) + : cov_( + numeric::outer_product( + numeric::average(args[sample | Sample()], (std::size_t)1) + , numeric::average(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1) + ) + ) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + if (cnt > 1) + { + extractor<tag::mean_of_variates<VariateType, VariateTag> > const some_mean_of_variates = {}; + + this->cov_ = this->cov_*(cnt-1.)/cnt + + numeric::outer_product( + some_mean_of_variates(args) - args[parameter::keyword<VariateTag>::get()] + , mean(args) - args[sample] + ) / (cnt-1.); + } + } + + result_type result(dont_care) const + { + return this->cov_; + } + + private: + result_type cov_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::covariance +// +namespace tag +{ + template<typename VariateType, typename VariateTag> + struct covariance + : depends_on<count, mean, mean_of_variates<VariateType, VariateTag> > + { + typedef accumulators::impl::covariance_impl<mpl::_1, VariateType, VariateTag> impl; + }; + + struct abstract_covariance + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::covariance +// +namespace extract +{ + extractor<tag::abstract_covariance> const covariance = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(covariance) +} + +using extract::covariance; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::covariance<VariateType, VariateTag> > + : feature_of<tag::abstract_covariance> +{ +}; + +// So that covariance can be automatically substituted with +// weighted_covariance when the weight parameter is non-void. +template<typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::covariance<VariateType, VariateTag> > +{ + typedef tag::weighted_covariance<VariateType, VariateTag> type; +}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::weighted_covariance<VariateType, VariateTag> > + : feature_of<tag::covariance<VariateType, VariateTag> > +{}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/density.hpp b/boost_1_45_0/boost/accumulators/statistics/density.hpp new file mode 100644 index 0000000..8835f47 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/density.hpp
@@ -0,0 +1,246 @@ + +/////////////////////////////////////////////////////////////////////////////// +// density.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_DENSITY_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_DENSITY_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <functional> +#include <boost/range.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/min.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// cache_size and num_bins named parameters +// +BOOST_PARAMETER_NESTED_KEYWORD(tag, density_cache_size, cache_size) +BOOST_PARAMETER_NESTED_KEYWORD(tag, density_num_bins, num_bins) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // density_impl + // density histogram + /** + @brief Histogram density estimator + + The histogram density estimator returns a histogram of the sample distribution. The positions and sizes of the bins + are determined using a specifiable number of cached samples (cache_size). The range between the minimum and the + maximum of the cached samples is subdivided into a specifiable number of bins (num_bins) of same size. Additionally, + an under- and an overflow bin is added to capture future under- and overflow samples. Once the bins are determined, + the cached samples and all subsequent samples are added to the correct bins. At the end, a range of std::pair is + return, where each pair contains the position of the bin (lower bound) and the samples count (normalized with the + total number of samples). + + @param density_cache_size Number of first samples used to determine min and max. + @param density_num_bins Number of bins (two additional bins collect under- and overflow samples). + */ + template<typename Sample> + struct density_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range<typename histogram_type::iterator> result_type; + + template<typename Args> + density_impl(Args const &args) + : cache_size(args[density_cache_size]) + , cache(cache_size) + , num_bins(args[density_num_bins]) + , samples_in_bin(num_bins + 2, 0.) + , bin_positions(num_bins + 2) + , histogram( + num_bins + 2 + , std::make_pair( + numeric::average(args[sample | Sample()],(std::size_t)1) + , numeric::average(args[sample | Sample()],(std::size_t)1) + ) + ) + , is_dirty(true) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty = true; + + std::size_t cnt = count(args); + + // Fill up cache with cache_size first samples + if (cnt <= this->cache_size) + { + this->cache[cnt - 1] = args[sample]; + } + + // Once cache_size samples have been accumulated, create num_bins bins of same size between + // the minimum and maximum of the cached samples as well as an under- and and an overflow bin. + // Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin). + if (cnt == this->cache_size) + { + float_type minimum = numeric::average((min)(args), (std::size_t)1); + float_type maximum = numeric::average((max)(args), (std::size_t)1); + float_type bin_size = numeric::average(maximum - minimum, this->num_bins ); + + // determine bin positions (their lower bounds) + for (std::size_t i = 0; i < this->num_bins + 2; ++i) + { + this->bin_positions[i] = minimum + (i - 1.) * bin_size; + } + + for (typename array_type::const_iterator iter = this->cache.begin(); iter != this->cache.end(); ++iter) + { + if (*iter < this->bin_positions[1]) + { + ++(this->samples_in_bin[0]); + } + else if (*iter >= this->bin_positions[this->num_bins + 1]) + { + ++(this->samples_in_bin[this->num_bins + 1]); + } + else + { + typename array_type::iterator it = std::upper_bound( + this->bin_positions.begin() + , this->bin_positions.end() + , *iter + ); + + std::size_t d = std::distance(this->bin_positions.begin(), it); + ++(this->samples_in_bin[d - 1]); + } + } + } + // Add each subsequent sample to the correct bin + else if (cnt > this->cache_size) + { + if (args[sample] < this->bin_positions[1]) + { + ++(this->samples_in_bin[0]); + } + else if (args[sample] >= this->bin_positions[this->num_bins + 1]) + { + ++(this->samples_in_bin[this->num_bins + 1]); + } + else + { + typename array_type::iterator it = std::upper_bound( + this->bin_positions.begin() + , this->bin_positions.end() + , args[sample] + ); + + std::size_t d = std::distance(this->bin_positions.begin(), it); + ++(this->samples_in_bin[d - 1]); + } + } + } + + /** + @pre The number of samples must meet or exceed the cache size + */ + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + // creates a vector of std::pair where each pair i holds + // the values bin_positions[i] (x-axis of histogram) and + // samples_in_bin[i] / cnt (y-axis of histogram). + + for (std::size_t i = 0; i < this->num_bins + 2; ++i) + { + this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::average(this->samples_in_bin[i], count(args))); + } + } + // returns a range of pairs + return make_iterator_range(this->histogram); + } + + private: + std::size_t cache_size; // number of cached samples + array_type cache; // cache to store the first cache_size samples + std::size_t num_bins; // number of bins + array_type samples_in_bin; // number of samples in each bin + array_type bin_positions; // lower bounds of bins + mutable histogram_type histogram; // histogram + mutable bool is_dirty; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::density +// +namespace tag +{ + struct density + : depends_on<count, min, max> + , density_cache_size + , density_num_bins + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::density_impl<mpl::_1> impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::density::cache_size named parameter + /// tag::density::num_bins named parameter + static boost::parameter::keyword<density_cache_size> const cache_size; + static boost::parameter::keyword<density_num_bins> const num_bins; + #endif + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::density +// +namespace extract +{ + extractor<tag::density> const density = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(density) +} + +using extract::density; + +// So that density can be automatically substituted +// with weighted_density when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::density> +{ + typedef tag::weighted_density type; +}; + +template<> +struct feature_of<tag::weighted_density> + : feature_of<tag::density> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/error_of.hpp b/boost_1_45_0/boost/accumulators/statistics/error_of.hpp new file mode 100644 index 0000000..a29da02 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/error_of.hpp
@@ -0,0 +1,99 @@ +/////////////////////////////////////////////////////////////////////////////// +// error_of.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_HPP_EAN_29_11_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /// INTERNAL ONLY + /// + template<typename Feature> + struct this_feature_has_no_error_calculation + : mpl::false_ + { + }; + + /////////////////////////////////////////////////////////////////////////////// + // error_of_impl + /// INTERNAL ONLY + /// + template<typename Sample, typename Feature> + struct error_of_impl + : accumulator_base + { + // TODO: specialize this on the specific features that have errors we're + // interested in. + BOOST_MPL_ASSERT((this_feature_has_no_error_calculation<Feature>)); + + // for boost::result_of + typedef int result_type; + + error_of_impl(dont_care) + { + } + + result_type result(dont_care) const + { + return 0; + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::error_of +// +namespace tag +{ + template<typename Feature> + struct error_of + : depends_on<Feature> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::error_of_impl<mpl::_1, Feature> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::error_of +// +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, error_of, (typename)) +} + +using extract::error_of; + +// make tag::error_of<tag::feature(modifier)> work +template<typename Feature> +struct as_feature<tag::error_of<Feature> > +{ + typedef tag::error_of<typename as_feature<Feature>::type> type; +}; + +// make error_of<tag::mean> work with non-void weights (should become +// error_of<tag::weighted_mean> +template<typename Feature> +struct as_weighted_feature<tag::error_of<Feature> > +{ + typedef tag::error_of<typename as_weighted_feature<Feature>::type> type; +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/error_of_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/error_of_mean.hpp new file mode 100644 index 0000000..9451d40 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/error_of_mean.hpp
@@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////// +// error_of.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006 +#define BOOST_ACCUMULATORS_STATISTICS_ERROR_OF_MEAN_HPP_EAN_27_03_2006 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/error_of.hpp> +#include <boost/accumulators/statistics/variance.hpp> +#include <boost/accumulators/statistics/count.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // error_of_mean_impl + template<typename Sample, typename Variance> + struct error_of_mean_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + error_of_mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + using namespace std; + extractor<Variance> const variance = {}; + return sqrt(numeric::average(variance(args), count(args) - 1)); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::error_of +// +namespace tag +{ + template<> + struct error_of<mean> + : depends_on<lazy_variance, count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::error_of_mean_impl<mpl::_1, lazy_variance> impl; + }; + + template<> + struct error_of<immediate_mean> + : depends_on<variance, count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::error_of_mean_impl<mpl::_1, variance> impl; + }; +} + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/extended_p_square.hpp b/boost_1_45_0/boost/accumulators/statistics/extended_p_square.hpp new file mode 100644 index 0000000..e8d4c04 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/extended_p_square.hpp
@@ -0,0 +1,293 @@ +/////////////////////////////////////////////////////////////////////////////// +// extended_p_square.hpp +// +// Copyright 2005 Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_HPP_DE_01_01_2006 + +#include <vector> +#include <functional> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/iterator/transform_iterator.hpp> +#include <boost/iterator/counting_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/times2_iterator.hpp> + +namespace boost { namespace accumulators +{ +/////////////////////////////////////////////////////////////////////////////// +// probabilities named parameter +// +BOOST_PARAMETER_NESTED_KEYWORD(tag, extended_p_square_probabilities, probabilities) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // extended_p_square_impl + // multiple quantile estimation + /** + @brief Multiple quantile estimation with the extended \f$P^2\f$ algorithm + + Extended \f$P^2\f$ algorithm for estimation of several quantiles without storing samples. + Assume that \f$m\f$ quantiles \f$\xi_{p_1}, \ldots, \xi_{p_m}\f$ are to be estimated. + Instead of storing the whole sample cumulative distribution, the algorithm maintains only + \f$m+2\f$ principal markers and \f$m+1\f$ middle markers, whose positions are updated + with each sample and whose heights are adjusted (if necessary) using a piecewise-parablic + formula. The heights of these central markers are the current estimates of the quantiles + and returned as an iterator range. + + For further details, see + + K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49, + Number 4 (October), 1986, p. 159-164. + + The extended \f$ P^2 \f$ algorithm generalizess the \f$ P^2 \f$ algorithm of + + R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param extended_p_square_probabilities A vector of quantile probabilities. + */ + template<typename Sample> + struct extended_p_square_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range< + detail::lvalue_index_iterator< + permutation_iterator< + typename array_type::const_iterator + , detail::times2_iterator + > + > + > result_type; + + template<typename Args> + extended_p_square_impl(Args const &args) + : probabilities( + boost::begin(args[extended_p_square_probabilities]) + , boost::end(args[extended_p_square_probabilities]) + ) + , heights(2 * probabilities.size() + 3) + , actual_positions(heights.size()) + , desired_positions(heights.size()) + , positions_increments(heights.size()) + { + std::size_t num_quantiles = this->probabilities.size(); + std::size_t num_markers = this->heights.size(); + + for(std::size_t i = 0; i < num_markers; ++i) + { + this->actual_positions[i] = i + 1; + } + + this->positions_increments[0] = 0.; + this->positions_increments[num_markers - 1] = 1.; + + for(std::size_t i = 0; i < num_quantiles; ++i) + { + this->positions_increments[2 * i + 2] = probabilities[i]; + } + + for(std::size_t i = 0; i <= num_quantiles; ++i) + { + this->positions_increments[2 * i + 1] = + 0.5 * (this->positions_increments[2 * i] + this->positions_increments[2 * i + 2]); + } + + for(std::size_t i = 0; i < num_markers; ++i) + { + this->desired_positions[i] = 1. + 2. * (num_quantiles + 1.) * this->positions_increments[i]; + } + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + // m+2 principal markers and m+1 middle markers + std::size_t num_markers = 2 * this->probabilities.size() + 3; + + // first accumulate num_markers samples + if(cnt <= num_markers) + { + this->heights[cnt - 1] = args[sample]; + + // complete the initialization of heights by sorting + if(cnt == num_markers) + { + std::sort(this->heights.begin(), this->heights.end()); + } + } + else + { + std::size_t sample_cell = 1; + + // find cell k = sample_cell such that heights[k-1] <= sample < heights[k] + if(args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + sample_cell = 1; + } + else if(args[sample] >= this->heights[num_markers - 1]) + { + this->heights[num_markers - 1] = args[sample]; + sample_cell = num_markers - 1; + } + else + { + typedef typename array_type::iterator iterator; + iterator it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // update actual positions of all markers above sample_cell index + for(std::size_t i = sample_cell; i < num_markers; ++i) + { + ++this->actual_positions[i]; + } + + // update desired positions of all markers + for(std::size_t i = 0; i < num_markers; ++i) + { + this->desired_positions[i] += this->positions_increments[i]; + } + + // adjust heights and actual positions of markers 1 to num_markers-2 if necessary + for(std::size_t i = 1; i <= num_markers - 2; ++i) + { + // offset to desired position + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i+1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i-1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i+1] - this->heights[i]) / dp; + float_type hm = (this->heights[i-1] - this->heights[i]) / dm; + + if((d >= 1 && dp > 1) || (d <= -1 && dm < -1)) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm)*hp + + (dp - sign_d) * hm); + + // try adjusting heights[i] using p-squared formula + if(this->heights[i - 1] < h && h < this->heights[i + 1]) + { + this->heights[i] = h; + } + else + { + // use linear formula + if(d > 0) + { + this->heights[i] += hp; + } + if(d < 0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + result_type result(dont_care) const + { + // for i in [1,probabilities.size()], return heights[i * 2] + detail::times2_iterator idx_begin = detail::make_times2_iterator(1); + detail::times2_iterator idx_end = detail::make_times2_iterator(this->probabilities.size() + 1); + + return result_type( + make_permutation_iterator(this->heights.begin(), idx_begin) + , make_permutation_iterator(this->heights.begin(), idx_end) + ); + } + + private: + array_type probabilities; // the quantile probabilities + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // d_i + array_type positions_increments; // f_i + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::extended_p_square +// +namespace tag +{ + struct extended_p_square + : depends_on<count> + , extended_p_square_probabilities + { + typedef accumulators::impl::extended_p_square_impl<mpl::_1> impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::extended_p_square::probabilities named paramter + static boost::parameter::keyword<tag::probabilities> const probabilities; + #endif + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::extended_p_square +// +namespace extract +{ + extractor<tag::extended_p_square> const extended_p_square = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square) +} + +using extract::extended_p_square; + +// So that extended_p_square can be automatically substituted with +// weighted_extended_p_square when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::extended_p_square> +{ + typedef tag::weighted_extended_p_square type; +}; + +template<> +struct feature_of<tag::weighted_extended_p_square> + : feature_of<tag::extended_p_square> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/extended_p_square_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/extended_p_square_quantile.hpp new file mode 100644 index 0000000..b6c008d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/extended_p_square_quantile.hpp
@@ -0,0 +1,319 @@ +/////////////////////////////////////////////////////////////////////////////// +// extended_p_square_quantile.hpp +// +// Copyright 2005 Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_EXTENDED_SINGLE_QUANTILE_HPP_DE_01_01_2006 + +#include <vector> +#include <functional> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/iterator/transform_iterator.hpp> +#include <boost/iterator/counting_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> +#include <boost/accumulators/statistics/extended_p_square.hpp> +#include <boost/accumulators/statistics/weighted_extended_p_square.hpp> +#include <boost/accumulators/statistics/times2_iterator.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // extended_p_square_quantile_impl + // single quantile estimation + /** + @brief Quantile estimation using the extended \f$P^2\f$ algorithm for weighted and unweighted samples + + Uses the quantile estimates calculated by the extended \f$P^2\f$ algorithm to compute + intermediate quantile estimates by means of quadratic interpolation. + + @param quantile_probability The probability of the quantile to be estimated. + */ + template<typename Sample, typename Impl1, typename Impl2> // Impl1: weighted/unweighted // Impl2: linear/quadratic + struct extended_p_square_quantile_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<float_type> array_type; + typedef iterator_range< + detail::lvalue_index_iterator< + permutation_iterator< + typename array_type::const_iterator + , detail::times2_iterator + > + > + > range_type; + // for boost::result_of + typedef float_type result_type; + + template<typename Args> + extended_p_square_quantile_impl(Args const &args) + : probabilities( + boost::begin(args[extended_p_square_probabilities]) + , boost::end(args[extended_p_square_probabilities]) + ) + { + } + + template<typename Args> + result_type result(Args const &args) const + { + typedef + typename mpl::if_< + is_same<Impl1, weighted> + , tag::weighted_extended_p_square + , tag::extended_p_square + >::type + extended_p_square_tag; + + extractor<extended_p_square_tag> const some_extended_p_square = {}; + + array_type heights(some_extended_p_square(args).size()); + std::copy(some_extended_p_square(args).begin(), some_extended_p_square(args).end(), heights.begin()); + + this->probability = args[quantile_probability]; + + typename array_type::const_iterator iter_probs = std::lower_bound(this->probabilities.begin(), this->probabilities.end(), this->probability); + std::size_t dist = std::distance(this->probabilities.begin(), iter_probs); + typename array_type::const_iterator iter_heights = heights.begin() + dist; + + // If this->probability is not in a valid range return NaN or throw exception + if (this->probability < *this->probabilities.begin() || this->probability > *(this->probabilities.end() - 1)) + { + if (std::numeric_limits<result_type>::has_quiet_NaN) + { + return std::numeric_limits<result_type>::quiet_NaN(); + } + else + { + std::ostringstream msg; + msg << "probability = " << this->probability << " is not in valid range ("; + msg << *this->probabilities.begin() << ", " << *(this->probabilities.end() - 1) << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return Sample(0); + } + + } + + if (*iter_probs == this->probability) + { + return heights[dist]; + } + else + { + result_type res; + + if (is_same<Impl2, linear>::value) + { + ///////////////////////////////////////////////////////////////////////////////// + // LINEAR INTERPOLATION + // + float_type p1 = *iter_probs; + float_type p0 = *(iter_probs - 1); + float_type h1 = *iter_heights; + float_type h0 = *(iter_heights - 1); + + float_type a = numeric::average(h1 - h0, p1 - p0); + float_type b = h1 - p1 * a; + + res = a * this->probability + b; + } + else + { + ///////////////////////////////////////////////////////////////////////////////// + // QUADRATIC INTERPOLATION + // + float_type p0, p1, p2; + float_type h0, h1, h2; + + if ( (dist == 1 || *iter_probs - this->probability <= this->probability - *(iter_probs - 1) ) && dist != this->probabilities.size() - 1 ) + { + p0 = *(iter_probs - 1); + p1 = *iter_probs; + p2 = *(iter_probs + 1); + h0 = *(iter_heights - 1); + h1 = *iter_heights; + h2 = *(iter_heights + 1); + } + else + { + p0 = *(iter_probs - 2); + p1 = *(iter_probs - 1); + p2 = *iter_probs; + h0 = *(iter_heights - 2); + h1 = *(iter_heights - 1); + h2 = *iter_heights; + } + + float_type hp21 = numeric::average(h2 - h1, p2 - p1); + float_type hp10 = numeric::average(h1 - h0, p1 - p0); + float_type p21 = numeric::average(p2 * p2 - p1 * p1, p2 - p1); + float_type p10 = numeric::average(p1 * p1 - p0 * p0, p1 - p0); + + float_type a = numeric::average(hp21 - hp10, p21 - p10); + float_type b = hp21 - a * p21; + float_type c = h2 - a * p2 * p2 - b * p2; + + res = a * this->probability * this-> probability + b * this->probability + c; + } + + return res; + } + + } + private: + + array_type probabilities; + mutable float_type probability; + + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::extended_p_square_quantile +// +namespace tag +{ + struct extended_p_square_quantile + : depends_on<extended_p_square> + { + typedef accumulators::impl::extended_p_square_quantile_impl<mpl::_1, unweighted, linear> impl; + }; + struct extended_p_square_quantile_quadratic + : depends_on<extended_p_square> + { + typedef accumulators::impl::extended_p_square_quantile_impl<mpl::_1, unweighted, quadratic> impl; + }; + struct weighted_extended_p_square_quantile + : depends_on<weighted_extended_p_square> + { + typedef accumulators::impl::extended_p_square_quantile_impl<mpl::_1, weighted, linear> impl; + }; + struct weighted_extended_p_square_quantile_quadratic + : depends_on<weighted_extended_p_square> + { + typedef accumulators::impl::extended_p_square_quantile_impl<mpl::_1, weighted, quadratic> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::extended_p_square_quantile +// extract::weighted_extended_p_square_quantile +// +namespace extract +{ + extractor<tag::extended_p_square_quantile> const extended_p_square_quantile = {}; + extractor<tag::extended_p_square_quantile_quadratic> const extended_p_square_quantile_quadratic = {}; + extractor<tag::weighted_extended_p_square_quantile> const weighted_extended_p_square_quantile = {}; + extractor<tag::weighted_extended_p_square_quantile_quadratic> const weighted_extended_p_square_quantile_quadratic = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(extended_p_square_quantile_quadratic) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square_quantile_quadratic) +} + +using extract::extended_p_square_quantile; +using extract::extended_p_square_quantile_quadratic; +using extract::weighted_extended_p_square_quantile; +using extract::weighted_extended_p_square_quantile_quadratic; + +// extended_p_square_quantile(linear) -> extended_p_square_quantile +template<> +struct as_feature<tag::extended_p_square_quantile(linear)> +{ + typedef tag::extended_p_square_quantile type; +}; + +// extended_p_square_quantile(quadratic) -> extended_p_square_quantile_quadratic +template<> +struct as_feature<tag::extended_p_square_quantile(quadratic)> +{ + typedef tag::extended_p_square_quantile_quadratic type; +}; + +// weighted_extended_p_square_quantile(linear) -> weighted_extended_p_square_quantile +template<> +struct as_feature<tag::weighted_extended_p_square_quantile(linear)> +{ + typedef tag::weighted_extended_p_square_quantile type; +}; + +// weighted_extended_p_square_quantile(quadratic) -> weighted_extended_p_square_quantile_quadratic +template<> +struct as_feature<tag::weighted_extended_p_square_quantile(quadratic)> +{ + typedef tag::weighted_extended_p_square_quantile_quadratic type; +}; + +// for the purposes of feature-based dependency resolution, +// extended_p_square_quantile and weighted_extended_p_square_quantile +// provide the same feature as quantile +template<> +struct feature_of<tag::extended_p_square_quantile> + : feature_of<tag::quantile> +{ +}; +template<> +struct feature_of<tag::extended_p_square_quantile_quadratic> + : feature_of<tag::quantile> +{ +}; +// So that extended_p_square_quantile can be automatically substituted with +// weighted_extended_p_square_quantile when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::extended_p_square_quantile> +{ + typedef tag::weighted_extended_p_square_quantile type; +}; + +template<> +struct feature_of<tag::weighted_extended_p_square_quantile> + : feature_of<tag::extended_p_square_quantile> +{ +}; + +// So that extended_p_square_quantile_quadratic can be automatically substituted with +// weighted_extended_p_square_quantile_quadratic when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::extended_p_square_quantile_quadratic> +{ + typedef tag::weighted_extended_p_square_quantile_quadratic type; +}; +template<> +struct feature_of<tag::weighted_extended_p_square_quantile_quadratic> + : feature_of<tag::extended_p_square_quantile_quadratic> +{ +}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/kurtosis.hpp b/boost_1_45_0/boost/accumulators/statistics/kurtosis.hpp new file mode 100644 index 0000000..4c5c23d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/kurtosis.hpp
@@ -0,0 +1,112 @@ +/////////////////////////////////////////////////////////////////////////////// +// kurtosis.hpp +// +// Copyright 2006 Olivier Gygi, Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_KURTOSIS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_KURTOSIS_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/statistics/moment.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // kurtosis_impl + /** + @brief Kurtosis estimation + + The kurtosis of a sample distribution is defined as the ratio of the 4th central moment and the square of the 2nd central + moment (the variance) of the samples, minus 3. The term \f$ -3 \f$ is added in order to ensure that the normal distribution + has zero kurtosis. The kurtosis can also be expressed by the simple moments: + + \f[ + \hat{g}_2 = + \frac + {\widehat{m}_n^{(4)}-4\widehat{m}_n^{(3)}\hat{\mu}_n+6\widehat{m}_n^{(2)}\hat{\mu}_n^2-3\hat{\mu}_n^4} + {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^2} - 3, + \f] + + where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the + \f$ n \f$ samples. + */ + template<typename Sample> + struct kurtosis_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, Sample>::result_type result_type; + + kurtosis_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average( + accumulators::moment<4>(args) + - 4. * accumulators::moment<3>(args) * mean(args) + + 6. * accumulators::moment<2>(args) * mean(args) * mean(args) + - 3. * mean(args) * mean(args) * mean(args) * mean(args) + , ( accumulators::moment<2>(args) - mean(args) * mean(args) ) + * ( accumulators::moment<2>(args) - mean(args) * mean(args) ) + ) - 3.; + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::kurtosis +// +namespace tag +{ + struct kurtosis + : depends_on<mean, moment<2>, moment<3>, moment<4> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::kurtosis_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::kurtosis +// +namespace extract +{ + extractor<tag::kurtosis> const kurtosis = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(kurtosis) +} + +using extract::kurtosis; + +// So that kurtosis can be automatically substituted with +// weighted_kurtosis when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::kurtosis> +{ + typedef tag::weighted_kurtosis type; +}; + +template<> +struct feature_of<tag::weighted_kurtosis> + : feature_of<tag::kurtosis> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/max.hpp b/boost_1_45_0/boost/accumulators/statistics/max.hpp new file mode 100644 index 0000000..820f659 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/max.hpp
@@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////// +// max.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // max_impl + template<typename Sample> + struct max_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + max_impl(Args const &args) + : max_(numeric::as_min(args[sample | Sample()])) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + numeric::max_assign(this->max_, args[sample]); + } + + result_type result(dont_care) const + { + return this->max_; + } + + private: + Sample max_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::max +// +namespace tag +{ + struct max + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::max_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::max +// +namespace extract +{ + extractor<tag::max> const max = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(max) +} + +using extract::max; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/mean.hpp b/boost_1_45_0/boost/accumulators/statistics/mean.hpp new file mode 100644 index 0000000..0b3ba5e --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/mean.hpp
@@ -0,0 +1,298 @@ +/////////////////////////////////////////////////////////////////////////////// +// mean.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_MEAN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MEAN_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // mean_impl + // lazy, by default + template<typename Sample, typename SumFeature> + struct mean_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + extractor<SumFeature> sum; + return numeric::average(sum(args), count(args)); + } + }; + + template<typename Sample, typename Tag> + struct immediate_mean_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + template<typename Args> + immediate_mean_impl(Args const &args) + : mean(numeric::average(args[sample | Sample()], numeric::one<std::size_t>::value)) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + this->mean = numeric::average( + (this->mean * (cnt - 1)) + args[parameter::keyword<Tag>::get()] + , cnt + ); + } + + result_type result(dont_care) const + { + return this->mean; + } + + private: + result_type mean; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::mean +// tag::immediate_mean +// tag::mean_of_weights +// tag::immediate_mean_of_weights +// tag::mean_of_variates +// tag::immediate_mean_of_variates +// +namespace tag +{ + struct mean + : depends_on<count, sum> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::mean_impl<mpl::_1, sum> impl; + }; + struct immediate_mean + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_mean_impl<mpl::_1, tag::sample> impl; + }; + struct mean_of_weights + : depends_on<count, sum_of_weights> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::mean_impl<mpl::_2, sum_of_weights> impl; + }; + struct immediate_mean_of_weights + : depends_on<count> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_mean_impl<mpl::_2, tag::weight> impl; + }; + template<typename VariateType, typename VariateTag> + struct mean_of_variates + : depends_on<count, sum_of_variates<VariateType, VariateTag> > + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::mean_impl<VariateType, sum_of_variates<VariateType, VariateTag> > > impl; + }; + template<typename VariateType, typename VariateTag> + struct immediate_mean_of_variates + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::immediate_mean_impl<VariateType, VariateTag> > impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::mean +// extract::mean_of_weights +// extract::mean_of_variates +// +namespace extract +{ + extractor<tag::mean> const mean = {}; + extractor<tag::mean_of_weights> const mean_of_weights = {}; + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, mean_of_variates, (typename)(typename)) + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean_of_weights) +} + +using extract::mean; +using extract::mean_of_weights; +using extract::mean_of_variates; + +// mean(lazy) -> mean +template<> +struct as_feature<tag::mean(lazy)> +{ + typedef tag::mean type; +}; + +// mean(immediate) -> immediate_mean +template<> +struct as_feature<tag::mean(immediate)> +{ + typedef tag::immediate_mean type; +}; + +// mean_of_weights(lazy) -> mean_of_weights +template<> +struct as_feature<tag::mean_of_weights(lazy)> +{ + typedef tag::mean_of_weights type; +}; + +// mean_of_weights(immediate) -> immediate_mean_of_weights +template<> +struct as_feature<tag::mean_of_weights(immediate)> +{ + typedef tag::immediate_mean_of_weights type; +}; + +// mean_of_variates<VariateType, VariateTag>(lazy) -> mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::mean_of_variates<VariateType, VariateTag>(lazy)> +{ + typedef tag::mean_of_variates<VariateType, VariateTag> type; +}; + +// mean_of_variates<VariateType, VariateTag>(immediate) -> immediate_mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::mean_of_variates<VariateType, VariateTag>(immediate)> +{ + typedef tag::immediate_mean_of_variates<VariateType, VariateTag> type; +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<> +struct feature_of<tag::immediate_mean> + : feature_of<tag::mean> +{ +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<> +struct feature_of<tag::immediate_mean_of_weights> + : feature_of<tag::mean_of_weights> +{ +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<typename VariateType, typename VariateTag> +struct feature_of<tag::immediate_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::mean_of_variates<VariateType, VariateTag> > +{ +}; + +// So that mean can be automatically substituted with +// weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::mean> +{ + typedef tag::weighted_mean type; +}; + +template<> +struct feature_of<tag::weighted_mean> + : feature_of<tag::mean> +{}; + +// So that immediate_mean can be automatically substituted with +// immediate_weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::immediate_mean> +{ + typedef tag::immediate_weighted_mean type; +}; + +template<> +struct feature_of<tag::immediate_weighted_mean> + : feature_of<tag::immediate_mean> +{}; + +// So that mean_of_weights<> can be automatically substituted with +// weighted_mean_of_variates<> when the weight parameter is non-void. +template<typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::mean_of_variates<VariateType, VariateTag> > +{ + typedef tag::weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::weighted_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::mean_of_variates<VariateType, VariateTag> > +{ +}; + +// So that immediate_mean_of_weights<> can be automatically substituted with +// immediate_weighted_mean_of_variates<> when the weight parameter is non-void. +template<typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::immediate_mean_of_variates<VariateType, VariateTag> > +{ + typedef tag::immediate_weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::immediate_weighted_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::immediate_mean_of_variates<VariateType, VariateTag> > +{ +}; + +//////////////////////////////////////////////////////////////////////////// +//// droppable_accumulator<mean_impl> +//// need to specialize droppable lazy mean to cache the result at the +//// point the accumulator is dropped. +///// INTERNAL ONLY +///// +//template<typename Sample, typename SumFeature> +//struct droppable_accumulator<impl::mean_impl<Sample, SumFeature> > +// : droppable_accumulator_base< +// with_cached_result<impl::mean_impl<Sample, SumFeature> > +// > +//{ +// template<typename Args> +// droppable_accumulator(Args const &args) +// : droppable_accumulator::base(args) +// { +// } +//}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/median.hpp b/boost_1_45_0/boost/accumulators/statistics/median.hpp new file mode 100644 index 0000000..13ebb28 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/median.hpp
@@ -0,0 +1,301 @@ +/////////////////////////////////////////////////////////////////////////////// +// median.hpp +// +// Copyright 2006 Eric Niebler, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_MEDIAN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MEDIAN_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/p_square_quantile.hpp> +#include <boost/accumulators/statistics/density.hpp> +#include <boost/accumulators/statistics/p_square_cumulative_distribution.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // median_impl + // + /** + @brief Median estimation based on the \f$P^2\f$ quantile estimator + + The \f$P^2\f$ algorithm is invoked with a quantile probability of 0.5. + */ + template<typename Sample> + struct median_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + median_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return p_square_quantile_for_median(args); + } + }; + /////////////////////////////////////////////////////////////////////////////// + // with_density_median_impl + // + /** + @brief Median estimation based on the density estimator + + The algorithm determines the bin in which the \f$0.5*cnt\f$-th sample lies, \f$cnt\f$ being + the total number of samples. It returns the approximate horizontal position of this sample, + based on a linear interpolation inside the bin. + */ + template<typename Sample> + struct with_density_median_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef iterator_range<typename histogram_type::iterator> range_type; + // for boost::result_of + typedef float_type result_type; + + template<typename Args> + with_density_median_impl(Args const &args) + : sum(numeric::average(args[sample | Sample()], (std::size_t)1)) + , is_dirty(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty = true; + } + + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + std::size_t cnt = count(args); + range_type histogram = density(args); + typename range_type::iterator it = histogram.begin(); + while (this->sum < 0.5 * cnt) + { + this->sum += it->second * cnt; + ++it; + } + --it; + float_type over = numeric::average(this->sum - 0.5 * cnt, it->second * cnt); + this->median = it->first * over + (it + 1)->first * (1. - over); + } + + return this->median; + } + + private: + mutable float_type sum; + mutable bool is_dirty; + mutable float_type median; + }; + + /////////////////////////////////////////////////////////////////////////////// + // with_p_square_cumulative_distribution_median_impl + // + /** + @brief Median estimation based on the \f$P^2\f$ cumulative distribution estimator + + The algorithm determines the first (leftmost) bin with a height exceeding 0.5. It + returns the approximate horizontal position of where the cumulative distribution + equals 0.5, based on a linear interpolation inside the bin. + */ + template<typename Sample> + struct with_p_square_cumulative_distribution_median_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef iterator_range<typename histogram_type::iterator> range_type; + // for boost::result_of + typedef float_type result_type; + + with_p_square_cumulative_distribution_median_impl(dont_care) + : is_dirty(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty = true; + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + range_type histogram = p_square_cumulative_distribution(args); + typename range_type::iterator it = histogram.begin(); + while (it->second < 0.5) + { + ++it; + } + float_type over = numeric::average(it->second - 0.5, it->second - (it - 1)->second); + this->median = it->first * over + (it + 1)->first * ( 1. - over ); + } + + return this->median; + } + private: + + mutable bool is_dirty; + mutable float_type median; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::median +// tag::with_densisty_median +// tag::with_p_square_cumulative_distribution_median +// +namespace tag +{ + struct median + : depends_on<p_square_quantile_for_median> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::median_impl<mpl::_1> impl; + }; + struct with_density_median + : depends_on<count, density> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::with_density_median_impl<mpl::_1> impl; + }; + struct with_p_square_cumulative_distribution_median + : depends_on<p_square_cumulative_distribution> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::with_p_square_cumulative_distribution_median_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::median +// extract::with_density_median +// extract::with_p_square_cumulative_distribution_median +// +namespace extract +{ + extractor<tag::median> const median = {}; + extractor<tag::with_density_median> const with_density_median = {}; + extractor<tag::with_p_square_cumulative_distribution_median> const with_p_square_cumulative_distribution_median = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(median) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_density_median) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(with_p_square_cumulative_distribution_median) +} + +using extract::median; +using extract::with_density_median; +using extract::with_p_square_cumulative_distribution_median; + +// median(with_p_square_quantile) -> median +template<> +struct as_feature<tag::median(with_p_square_quantile)> +{ + typedef tag::median type; +}; + +// median(with_density) -> with_density_median +template<> +struct as_feature<tag::median(with_density)> +{ + typedef tag::with_density_median type; +}; + +// median(with_p_square_cumulative_distribution) -> with_p_square_cumulative_distribution_median +template<> +struct as_feature<tag::median(with_p_square_cumulative_distribution)> +{ + typedef tag::with_p_square_cumulative_distribution_median type; +}; + +// for the purposes of feature-based dependency resolution, +// with_density_median and with_p_square_cumulative_distribution_median +// provide the same feature as median +template<> +struct feature_of<tag::with_density_median> + : feature_of<tag::median> +{ +}; + +template<> +struct feature_of<tag::with_p_square_cumulative_distribution_median> + : feature_of<tag::median> +{ +}; + +// So that median can be automatically substituted with +// weighted_median when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::median> +{ + typedef tag::weighted_median type; +}; + +template<> +struct feature_of<tag::weighted_median> + : feature_of<tag::median> +{ +}; + +// So that with_density_median can be automatically substituted with +// with_density_weighted_median when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::with_density_median> +{ + typedef tag::with_density_weighted_median type; +}; + +template<> +struct feature_of<tag::with_density_weighted_median> + : feature_of<tag::with_density_median> +{ +}; + +// So that with_p_square_cumulative_distribution_median can be automatically substituted with +// with_p_square_cumulative_distribution_weighted_median when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::with_p_square_cumulative_distribution_median> +{ + typedef tag::with_p_square_cumulative_distribution_weighted_median type; +}; + +template<> +struct feature_of<tag::with_p_square_cumulative_distribution_weighted_median> + : feature_of<tag::with_p_square_cumulative_distribution_median> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/min.hpp b/boost_1_45_0/boost/accumulators/statistics/min.hpp new file mode 100644 index 0000000..83943bd --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/min.hpp
@@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////// +// min.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_MIN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MIN_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // min_impl + template<typename Sample> + struct min_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + min_impl(Args const &args) + : min_(numeric::as_max(args[sample | Sample()])) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + numeric::min_assign(this->min_, args[sample]); + } + + result_type result(dont_care) const + { + return this->min_; + } + + private: + Sample min_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::min +// +namespace tag +{ + struct min + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::min_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::min +// +namespace extract +{ + extractor<tag::min> const min = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(min) +} + +using extract::min; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/moment.hpp b/boost_1_45_0/boost/accumulators/statistics/moment.hpp new file mode 100644 index 0000000..2042173 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/moment.hpp
@@ -0,0 +1,125 @@ +/////////////////////////////////////////////////////////////////////////////// +// moment.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_MOMENT_HPP_EAN_15_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MOMENT_HPP_EAN_15_11_2005 + +#include <boost/config/no_tr1/cmath.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> + +namespace boost { namespace numeric +{ + /// INTERNAL ONLY + /// + template<typename T> + T const &pow(T const &x, mpl::int_<1>) + { + return x; + } + + /// INTERNAL ONLY + /// + template<typename T, int N> + T pow(T const &x, mpl::int_<N>) + { + using namespace operators; + T y = numeric::pow(x, mpl::int_<N/2>()); + T z = y * y; + return (N % 2) ? (z * x) : z; + } +}} + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // moment_impl + template<typename N, typename Sample> + struct moment_impl + : accumulator_base // TODO: also depends_on sum of powers + { + BOOST_MPL_ASSERT_RELATION(N::value, >, 0); + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + template<typename Args> + moment_impl(Args const &args) + : sum(args[sample | Sample()]) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->sum += numeric::pow(args[sample], N()); + } + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average(this->sum, count(args)); + } + + private: + Sample sum; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::moment +// +namespace tag +{ + template<int N> + struct moment + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::moment_impl<mpl::int_<N>, mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::moment +// +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, moment, (int)) +} + +using extract::moment; + +// So that moment<N> can be automatically substituted with +// weighted_moment<N> when the weight parameter is non-void +template<int N> +struct as_weighted_feature<tag::moment<N> > +{ + typedef tag::weighted_moment<N> type; +}; + +template<int N> +struct feature_of<tag::weighted_moment<N> > + : feature_of<tag::moment<N> > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/p_square_cumulative_distribution.hpp b/boost_1_45_0/boost/accumulators/statistics/p_square_cumulative_distribution.hpp new file mode 100644 index 0000000..437469c --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/p_square_cumulative_distribution.hpp
@@ -0,0 +1,260 @@ +/////////////////////////////////////////////////////////////////////////////// +// p_square_cumulative_distribution.hpp +// +// Copyright 2005 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_DE_01_01_2006 + +#include <vector> +#include <functional> +#include <boost/parameter/keyword.hpp> +#include <boost/range.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> + +namespace boost { namespace accumulators +{ +/////////////////////////////////////////////////////////////////////////////// +// num_cells named parameter +// +BOOST_PARAMETER_NESTED_KEYWORD(tag, p_square_cumulative_distribution_num_cells, num_cells) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // p_square_cumulative_distribution_impl + // cumulative_distribution calculation (as histogram) + /** + @brief Histogram calculation of the cumulative distribution with the \f$P^2\f$ algorithm + + A histogram of the sample cumulative distribution is computed dynamically without storing samples + based on the \f$ P^2 \f$ algorithm. The returned histogram has a specifiable amount (num_cells) + equiprobable (and not equal-sized) cells. + + For further details, see + + R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param p_square_cumulative_distribution_num_cells. + */ + template<typename Sample> + struct p_square_cumulative_distribution_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<float_type> array_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + // for boost::result_of + typedef iterator_range<typename histogram_type::iterator> result_type; + + template<typename Args> + p_square_cumulative_distribution_impl(Args const &args) + : num_cells(args[p_square_cumulative_distribution_num_cells]) + , heights(num_cells + 1) + , actual_positions(num_cells + 1) + , desired_positions(num_cells + 1) + , positions_increments(num_cells + 1) + , histogram(num_cells + 1) + , is_dirty(true) + { + std::size_t b = this->num_cells; + + for (std::size_t i = 0; i < b + 1; ++i) + { + this->actual_positions[i] = i + 1.; + this->desired_positions[i] = i + 1.; + this->positions_increments[i] = numeric::average(i, b); + } + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty = true; + + std::size_t cnt = count(args); + std::size_t sample_cell = 1; // k + std::size_t b = this->num_cells; + + // accumulate num_cells + 1 first samples + if (cnt <= b + 1) + { + this->heights[cnt - 1] = args[sample]; + + // complete the initialization of heights by sorting + if (cnt == b + 1) + { + std::sort(this->heights.begin(), this->heights.end()); + } + } + else + { + // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values + if (args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + sample_cell = 1; + } + else if (this->heights[b] <= args[sample]) + { + this->heights[b] = args[sample]; + sample_cell = b; + } + else + { + typename array_type::iterator it; + it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // increment positions of markers above sample_cell + for (std::size_t i = sample_cell; i < b + 1; ++i) + { + ++this->actual_positions[i]; + } + + // update desired position of markers 2 to num_cells + 1 + // (desired position of first marker is always 1) + for (std::size_t i = 1; i < b + 1; ++i) + { + this->desired_positions[i] += this->positions_increments[i]; + } + + // adjust heights of markers 2 to num_cells if necessary + for (std::size_t i = 1; i < b; ++i) + { + // offset to desire position + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; + float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; + + if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + // try adjusting heights[i] using p-squared formula + float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); + + if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) + { + this->heights[i] = h; + } + else + { + // use linear formula + if (d>0) + { + this->heights[i] += hp; + } + if (d<0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + // creates a vector of std::pair where each pair i holds + // the values heights[i] (x-axis of histogram) and + // actual_positions[i] / cnt (y-axis of histogram) + + std::size_t cnt = count(args); + + for (std::size_t i = 0; i < this->histogram.size(); ++i) + { + this->histogram[i] = std::make_pair(this->heights[i], numeric::average(this->actual_positions[i], cnt)); + } + } + //return histogram; + return make_iterator_range(this->histogram); + } + + private: + std::size_t num_cells; // number of cells b + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // n'_i + array_type positions_increments; // dn'_i + mutable histogram_type histogram; // histogram + mutable bool is_dirty; + }; + +} // namespace detail + +/////////////////////////////////////////////////////////////////////////////// +// tag::p_square_cumulative_distribution +// +namespace tag +{ + struct p_square_cumulative_distribution + : depends_on<count> + , p_square_cumulative_distribution_num_cells + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::p_square_cumulative_distribution_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::p_square_cumulative_distribution +// +namespace extract +{ + extractor<tag::p_square_cumulative_distribution> const p_square_cumulative_distribution = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_cumulative_distribution) +} + +using extract::p_square_cumulative_distribution; + +// So that p_square_cumulative_distribution can be automatically substituted with +// weighted_p_square_cumulative_distribution when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::p_square_cumulative_distribution> +{ + typedef tag::weighted_p_square_cumulative_distribution type; +}; + +template<> +struct feature_of<tag::weighted_p_square_cumulative_distribution> + : feature_of<tag::p_square_cumulative_distribution> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/p_square_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/p_square_quantile.hpp new file mode 100644 index 0000000..844dfa7 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/p_square_quantile.hpp
@@ -0,0 +1,257 @@ +/////////////////////////////////////////////////////////////////////////////// +// p_square_quantile.hpp +// +// Copyright 2005 Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 + +#include <cmath> +#include <functional> +#include <boost/array.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // p_square_quantile_impl + // single quantile estimation + /** + @brief Single quantile estimation with the \f$P^2\f$ algorithm + + The \f$P^2\f$ algorithm estimates a quantile dynamically without storing samples. Instead of + storing the whole sample cumulative distribution, only five points (markers) are stored. The heights + of these markers are the minimum and the maximum of the samples and the current estimates of the + \f$(p/2)\f$-, \f$p\f$- and \f$(1+p)/2\f$-quantiles. Their positions are equal to the number + of samples that are smaller or equal to the markers. Each time a new samples is recorded, the + positions of the markers are updated and if necessary their heights are adjusted using a piecewise- + parabolic formula. + + For further details, see + + R. Jain and I. Chlamtac, The P^2 algorithmus fordynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param quantile_probability + */ + template<typename Sample, typename Impl> + struct p_square_quantile_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef array<float_type, 5> array_type; + // for boost::result_of + typedef float_type result_type; + + template<typename Args> + p_square_quantile_impl(Args const &args) + : p(is_same<Impl, for_median>::value ? 0.5 : args[quantile_probability | 0.5]) + , heights() + , actual_positions() + , desired_positions() + , positions_increments() + { + for(std::size_t i = 0; i < 5; ++i) + { + this->actual_positions[i] = i + 1; + } + + this->desired_positions[0] = 1.; + this->desired_positions[1] = 1. + 2. * this->p; + this->desired_positions[2] = 1. + 4. * this->p; + this->desired_positions[3] = 3. + 2. * this->p; + this->desired_positions[4] = 5.; + + this->positions_increments[0] = 0.; + this->positions_increments[1] = this->p / 2.; + this->positions_increments[2] = this->p; + this->positions_increments[3] = (1. + this->p) / 2.; + this->positions_increments[4] = 1.; + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + // accumulate 5 first samples + if(cnt <= 5) + { + this->heights[cnt - 1] = args[sample]; + + // complete the initialization of heights by sorting + if(cnt == 5) + { + std::sort(this->heights.begin(), this->heights.end()); + } + } + else + { + std::size_t sample_cell = 1; // k + + // find cell k such that heights[k-1] <= args[sample] < heights[k] and ajust extreme values + if (args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + sample_cell = 1; + } + else if (this->heights[4] <= args[sample]) + { + this->heights[4] = args[sample]; + sample_cell = 4; + } + else + { + typedef typename array_type::iterator iterator; + iterator it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // update positions of markers above sample_cell + for(std::size_t i = sample_cell; i < 5; ++i) + { + ++this->actual_positions[i]; + } + + // update desired positions of all markers + for(std::size_t i = 0; i < 5; ++i) + { + this->desired_positions[i] += this->positions_increments[i]; + } + + // adjust heights and actual positions of markers 1 to 3 if necessary + for(std::size_t i = 1; i <= 3; ++i) + { + // offset to desired positions + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; + float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; + + if((d >= 1. && dp > 1.) || (d <= -1. && dm < -1.)) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + // try adjusting heights[i] using p-squared formula + float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm) * hp + + (dp - sign_d) * hm); + + if(this->heights[i - 1] < h && h < this->heights[i + 1]) + { + this->heights[i] = h; + } + else + { + // use linear formula + if(d > 0) + { + this->heights[i] += hp; + } + if(d < 0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + result_type result(dont_care) const + { + return this->heights[2]; + } + + private: + float_type p; // the quantile probability p + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // n'_i + array_type positions_increments; // dn'_i + }; + +} // namespace detail + +/////////////////////////////////////////////////////////////////////////////// +// tag::p_square_quantile +// +namespace tag +{ + struct p_square_quantile + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::p_square_quantile_impl<mpl::_1, regular> impl; + }; + struct p_square_quantile_for_median + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::p_square_quantile_impl<mpl::_1, for_median> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::p_square_quantile +// extract::p_square_quantile_for_median +// +namespace extract +{ + extractor<tag::p_square_quantile> const p_square_quantile = {}; + extractor<tag::p_square_quantile_for_median> const p_square_quantile_for_median = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_quantile) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(p_square_quantile_for_median) +} + +using extract::p_square_quantile; +using extract::p_square_quantile_for_median; + +// So that p_square_quantile can be automatically substituted with +// weighted_p_square_quantile when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::p_square_quantile> +{ + typedef tag::weighted_p_square_quantile type; +}; + +template<> +struct feature_of<tag::weighted_p_square_quantile> + : feature_of<tag::p_square_quantile> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/parameters/quantile_probability.hpp b/boost_1_45_0/boost/accumulators/statistics/parameters/quantile_probability.hpp new file mode 100644 index 0000000..be68f89 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/parameters/quantile_probability.hpp
@@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////// +// quantile_probability.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_PARAMETERS_QUANTILE_PROBABILITY_HPP_EAN_03_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_PARAMETERS_QUANTILE_PROBABILITY_HPP_EAN_03_11_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, quantile_probability) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/peaks_over_threshold.hpp b/boost_1_45_0/boost/accumulators/statistics/peaks_over_threshold.hpp new file mode 100644 index 0000000..01f36f9 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/peaks_over_threshold.hpp
@@ -0,0 +1,401 @@ +/////////////////////////////////////////////////////////////////////////////// +// peaks_over_threshold.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <boost/config/no_tr1/cmath.hpp> // pow +#include <sstream> // stringstream +#include <stdexcept> // runtime_error +#include <boost/throw_exception.hpp> +#include <boost/range.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/tail.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// threshold_probability and threshold named parameters +// +BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_value, threshold_value) +BOOST_PARAMETER_NESTED_KEYWORD(tag, pot_threshold_probability, threshold_probability) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // peaks_over_threshold_impl + // works with an explicit threshold value and does not depend on order statistics + /** + @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation + + According to the theorem of Pickands-Balkema-de Haan, the distribution function \f$F_u(x)\f$ of + the excesses \f$x\f$ over some sufficiently high threshold \f$u\f$ of a distribution function \f$F(x)\f$ + may be approximated by a generalized Pareto distribution + \f[ + G_{\xi,\beta}(x) = + \left\{ + \begin{array}{ll} + \beta^{-1}\left(1+\frac{\xi x}{\beta}\right)^{-1/\xi-1} & \textrm{if }\xi\neq0\\ + \beta^{-1}\exp\left(-\frac{x}{\beta}\right) & \textrm{if }\xi=0, + \end{array} + \right. + \f] + with suitable parameters \f$\xi\f$ and \f$\beta\f$ that can be estimated, e.g., with the method of moments, cf. + Hosking and Wallis (1987), + \f[ + \begin{array}{lll} + \hat{\xi} & = & \frac{1}{2}\left[1-\frac{(\hat{\mu}-u)^2}{\hat{\sigma}^2}\right]\\ + \hat{\beta} & = & \frac{\hat{\mu}-u}{2}\left[\frac{(\hat{\mu}-u)^2}{\hat{\sigma}^2}+1\right], + \end{array} + \f] + \f$\hat{\mu}\f$ and \f$\hat{\sigma}^2\f$ being the empirical mean and variance of the samples over + the threshold \f$u\f$. Equivalently, the distribution function + \f$F_u(x-u)\f$ of the exceedances \f$x-u\f$ can be approximated by + \f$G_{\xi,\beta}(x-u)=G_{\xi,\beta,u}(x)\f$. Since for \f$x\geq u\f$ the distribution function \f$F(x)\f$ + can be written as + \f[ + F(x) = [1 - \P(X \leq u)]F_u(x - u) + \P(X \leq u) + \f] + and the probability \f$\P(X \leq u)\f$ can be approximated by the empirical distribution function + \f$F_n(u)\f$ evaluated at \f$u\f$, an estimator of \f$F(x)\f$ is given by + \f[ + \widehat{F}(x) = [1 - F_n(u)]G_{\xi,\beta,u}(x) + F_n(u). + \f] + It can be shown that \f$\widehat{F}(x)\f$ is a generalized + Pareto distribution \f$G_{\xi,\bar{\beta},\bar{u}}(x)\f$ with \f$\bar{\beta}=\beta[1-F_n(u)]^{\xi}\f$ + and \f$\bar{u}=u-\bar{\beta}\left\{[1-F_n(u)]^{-\xi}-1\right\}/\xi\f$. By inverting \f$\widehat{F}(x)\f$, + one obtains an estimator for the \f$\alpha\f$-quantile, + \f[ + \hat{q}_{\alpha} = \bar{u} + \frac{\bar{\beta}}{\xi}\left[(1-\alpha)^{-\xi}-1\right], + \f] + and similarly an estimator for the (coherent) tail mean, + \f[ + \widehat{CTM}_{\alpha} = \hat{q}_{\alpha} - \frac{\bar{\beta}}{\xi-1}(1-\alpha)^{-\xi}, + \f] + cf. McNeil and Frey (2000). + + Note that in case extreme values of the left tail are fitted, the distribution is mirrored with respect to the + \f$y\f$ axis such that the left tail can be treated as a right tail. The computed fit parameters thus define + the Pareto distribution that fits the mirrored left tail. When quantities like a quantile or a tail mean are + computed using the fit parameters obtained from the mirrored data, the result is mirrored back, yielding the + correct result. + + For further details, see + + J. R. M. Hosking and J. R. Wallis, Parameter and quantile estimation for the generalized Pareto distribution, + Technometrics, Volume 29, 1987, p. 339-349 + + A. J. McNeil and R. Frey, Estimation of Tail-Related Risk Measures for Heteroscedastic Financial Time Series: + an Extreme Value Approach, Journal of Empirical Finance, Volume 7, 2000, p. 271-300 + + @param quantile_probability + @param pot_threshold_value + */ + template<typename Sample, typename LeftRight> + struct peaks_over_threshold_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef boost::tuple<float_type, float_type, float_type> result_type; + // for left tail fitting, mirror the extreme values + typedef mpl::int_<is_same<LeftRight, left>::value ? -1 : 1> sign; + + template<typename Args> + peaks_over_threshold_impl(Args const &args) + : Nu_(0) + , mu_(sign::value * numeric::average(args[sample | Sample()], (std::size_t)1)) + , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) + , threshold_(sign::value * args[pot_threshold_value]) + , fit_parameters_(boost::make_tuple(0., 0., 0.)) + , is_dirty_(true) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty_ = true; + + if (sign::value * args[sample] > this->threshold_) + { + this->mu_ += args[sample]; + this->sigma2_ += args[sample] * args[sample]; + ++this->Nu_; + } + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty_) + { + this->is_dirty_ = false; + + std::size_t cnt = count(args); + + this->mu_ = sign::value * numeric::average(this->mu_, this->Nu_); + this->sigma2_ = numeric::average(this->sigma2_, this->Nu_); + this->sigma2_ -= this->mu_ * this->mu_; + + float_type threshold_probability = numeric::average(cnt - this->Nu_, cnt); + + float_type tmp = numeric::average(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_); + float_type xi_hat = 0.5 * ( 1. - tmp ); + float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp ); + float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat); + float_type u_bar = this->threshold_ - beta_bar * ( std::pow(1. - threshold_probability, -xi_hat) - 1.)/xi_hat; + this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); + } + + return this->fit_parameters_; + } + + private: + std::size_t Nu_; // number of samples larger than threshold + mutable float_type mu_; // mean of Nu_ largest samples + mutable float_type sigma2_; // variance of Nu_ largest samples + float_type threshold_; + mutable result_type fit_parameters_; // boost::tuple that stores fit parameters + mutable bool is_dirty_; + }; + + /////////////////////////////////////////////////////////////////////////////// + // peaks_over_threshold_prob_impl + // determines threshold from a given threshold probability using order statistics + /** + @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation + + @sa peaks_over_threshold_impl + + @param quantile_probability + @param pot_threshold_probability + */ + template<typename Sample, typename LeftRight> + struct peaks_over_threshold_prob_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef boost::tuple<float_type, float_type, float_type> result_type; + // for left tail fitting, mirror the extreme values + typedef mpl::int_<is_same<LeftRight, left>::value ? -1 : 1> sign; + + template<typename Args> + peaks_over_threshold_prob_impl(Args const &args) + : mu_(sign::value * numeric::average(args[sample | Sample()], (std::size_t)1)) + , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) + , threshold_probability_(args[pot_threshold_probability]) + , fit_parameters_(boost::make_tuple(0., 0., 0.)) + , is_dirty_(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty_ = true; + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty_) + { + this->is_dirty_ = false; + + std::size_t cnt = count(args); + + // the n'th cached sample provides an approximate threshold value u + std::size_t n = static_cast<std::size_t>( + std::ceil( + cnt * ( ( is_same<LeftRight, left>::value ) ? this->threshold_probability_ : 1. - this->threshold_probability_ ) + ) + ); + + // If n is in a valid range, return result, otherwise return NaN or throw exception + if ( n >= static_cast<std::size_t>(tail(args).size())) + { + if (std::numeric_limits<float_type>::has_quiet_NaN) + { + return boost::make_tuple( + std::numeric_limits<float_type>::quiet_NaN() + , std::numeric_limits<float_type>::quiet_NaN() + , std::numeric_limits<float_type>::quiet_NaN() + ); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return boost::make_tuple(Sample(0), Sample(0), Sample(0)); + } + } + else + { + float_type u = *(tail(args).begin() + n - 1) * sign::value; + + // compute mean and variance of samples above/under threshold value u + for (std::size_t i = 0; i < n; ++i) + { + mu_ += *(tail(args).begin() + i); + sigma2_ += *(tail(args).begin() + i) * (*(tail(args).begin() + i)); + } + + this->mu_ = sign::value * numeric::average(this->mu_, n); + this->sigma2_ = numeric::average(this->sigma2_, n); + this->sigma2_ -= this->mu_ * this->mu_; + + if (is_same<LeftRight, left>::value) + this->threshold_probability_ = 1. - this->threshold_probability_; + + float_type tmp = numeric::average(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_); + float_type xi_hat = 0.5 * ( 1. - tmp ); + float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp ); + float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat); + float_type u_bar = u - beta_bar * ( std::pow(1. - threshold_probability_, -xi_hat) - 1.)/xi_hat; + this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); + } + } + + return this->fit_parameters_; + } + + private: + mutable float_type mu_; // mean of samples above threshold u + mutable float_type sigma2_; // variance of samples above threshold u + mutable float_type threshold_probability_; + mutable result_type fit_parameters_; // boost::tuple that stores fit parameters + mutable bool is_dirty_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::peaks_over_threshold +// +namespace tag +{ + template<typename LeftRight> + struct peaks_over_threshold + : depends_on<count> + , pot_threshold_value + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::peaks_over_threshold_impl<mpl::_1, LeftRight> impl; + }; + + template<typename LeftRight> + struct peaks_over_threshold_prob + : depends_on<count, tail<LeftRight> > + , pot_threshold_probability + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::peaks_over_threshold_prob_impl<mpl::_1, LeftRight> impl; + }; + + struct abstract_peaks_over_threshold + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::peaks_over_threshold +// +namespace extract +{ + extractor<tag::abstract_peaks_over_threshold> const peaks_over_threshold = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(peaks_over_threshold) +} + +using extract::peaks_over_threshold; + +// peaks_over_threshold<LeftRight>(with_threshold_value) -> peaks_over_threshold<LeftRight> +template<typename LeftRight> +struct as_feature<tag::peaks_over_threshold<LeftRight>(with_threshold_value)> +{ + typedef tag::peaks_over_threshold<LeftRight> type; +}; + +// peaks_over_threshold<LeftRight>(with_threshold_probability) -> peaks_over_threshold_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::peaks_over_threshold<LeftRight>(with_threshold_probability)> +{ + typedef tag::peaks_over_threshold_prob<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::peaks_over_threshold<LeftRight> > + : feature_of<tag::abstract_peaks_over_threshold> +{ +}; + +template<typename LeftRight> +struct feature_of<tag::peaks_over_threshold_prob<LeftRight> > + : feature_of<tag::abstract_peaks_over_threshold> +{ +}; + +// So that peaks_over_threshold can be automatically substituted +// with weighted_peaks_over_threshold when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::peaks_over_threshold<LeftRight> > +{ + typedef tag::weighted_peaks_over_threshold<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_peaks_over_threshold<LeftRight> > + : feature_of<tag::peaks_over_threshold<LeftRight> > +{}; + +// So that peaks_over_threshold_prob can be automatically substituted +// with weighted_peaks_over_threshold_prob when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::peaks_over_threshold_prob<LeftRight> > +{ + typedef tag::weighted_peaks_over_threshold_prob<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_peaks_over_threshold_prob<LeftRight> > + : feature_of<tag::peaks_over_threshold_prob<LeftRight> > +{}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/pot_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/pot_quantile.hpp new file mode 100644 index 0000000..aceff8c --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/pot_quantile.hpp
@@ -0,0 +1,205 @@ +/////////////////////////////////////////////////////////////////////////////// +// pot_quantile.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_POT_QUANTILE_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <boost/parameter/keyword.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/peaks_over_threshold.hpp> +#include <boost/accumulators/statistics/weighted_peaks_over_threshold.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // pot_quantile_impl + // + /** + @brief Quantile Estimation based on Peaks over Threshold Method (for both left and right tails) + + Computes an estimate + \f[ + \hat{q}_{\alpha} = \bar{u} + \frac{\bar{\beta}}{\xi}\left[(1-\alpha)^{-\xi}-1\right] + \f] + for a right or left extreme quantile, \f$\bar[u]\f$, \f$\bar{\beta}\f$ and \f$\xi\f$ being the parameters of the + generalized Pareto distribution that approximates the right tail of the distribution (or the mirrored left tail, + in case the left tail is used). In the latter case, the result is mirrored back, yielding the correct result. + */ + template<typename Sample, typename Impl, typename LeftRight> + struct pot_quantile_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef float_type result_type; + + pot_quantile_impl(dont_care) + : sign_((is_same<LeftRight, left>::value) ? -1 : 1) + { + } + + template<typename Args> + result_type result(Args const &args) const + { + typedef + typename mpl::if_< + is_same<Impl, weighted> + , tag::weighted_peaks_over_threshold<LeftRight> + , tag::peaks_over_threshold<LeftRight> + >::type + peaks_over_threshold_tag; + + extractor<peaks_over_threshold_tag> const some_peaks_over_threshold = {}; + + float_type u_bar = some_peaks_over_threshold(args).template get<0>(); + float_type beta_bar = some_peaks_over_threshold(args).template get<1>(); + float_type xi_hat = some_peaks_over_threshold(args).template get<2>(); + + return this->sign_ * (u_bar + beta_bar/xi_hat * ( std::pow( + is_same<LeftRight, left>::value ? args[quantile_probability] : 1. - args[quantile_probability] + , -xi_hat + ) - 1.)); + } + + private: + short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::pot_quantile<> +// tag::pot_quantile_prob<> +// tag::weighted_pot_quantile<> +// tag::weighted_pot_quantile_prob<> +// +namespace tag +{ + template<typename LeftRight> + struct pot_quantile + : depends_on<peaks_over_threshold<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_quantile_impl<mpl::_1, unweighted, LeftRight> impl; + }; + template<typename LeftRight> + struct pot_quantile_prob + : depends_on<peaks_over_threshold_prob<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_quantile_impl<mpl::_1, unweighted, LeftRight> impl; + }; + template<typename LeftRight> + struct weighted_pot_quantile + : depends_on<weighted_peaks_over_threshold<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_quantile_impl<mpl::_1, weighted, LeftRight> impl; + }; + template<typename LeftRight> + struct weighted_pot_quantile_prob + : depends_on<weighted_peaks_over_threshold_prob<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_quantile_impl<mpl::_1, weighted, LeftRight> impl; + }; +} + +// pot_quantile<LeftRight>(with_threshold_value) -> pot_quantile<LeftRight> +template<typename LeftRight> +struct as_feature<tag::pot_quantile<LeftRight>(with_threshold_value)> +{ + typedef tag::pot_quantile<LeftRight> type; +}; + +// pot_quantile<LeftRight>(with_threshold_probability) -> pot_quantile_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::pot_quantile<LeftRight>(with_threshold_probability)> +{ + typedef tag::pot_quantile_prob<LeftRight> type; +}; + +// weighted_pot_quantile<LeftRight>(with_threshold_value) -> weighted_pot_quantile<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_pot_quantile<LeftRight>(with_threshold_value)> +{ + typedef tag::weighted_pot_quantile<LeftRight> type; +}; + +// weighted_pot_quantile<LeftRight>(with_threshold_probability) -> weighted_pot_quantile_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_pot_quantile<LeftRight>(with_threshold_probability)> +{ + typedef tag::weighted_pot_quantile_prob<LeftRight> type; +}; + +// for the purposes of feature-based dependency resolution, +// pot_quantile<LeftRight> and pot_quantile_prob<LeftRight> provide +// the same feature as quantile +template<typename LeftRight> +struct feature_of<tag::pot_quantile<LeftRight> > + : feature_of<tag::quantile> +{ +}; + +template<typename LeftRight> +struct feature_of<tag::pot_quantile_prob<LeftRight> > + : feature_of<tag::quantile> +{ +}; + +// So that pot_quantile can be automatically substituted +// with weighted_pot_quantile when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::pot_quantile<LeftRight> > +{ + typedef tag::weighted_pot_quantile<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_pot_quantile<LeftRight> > + : feature_of<tag::pot_quantile<LeftRight> > +{ +}; + +// So that pot_quantile_prob can be automatically substituted +// with weighted_pot_quantile_prob when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::pot_quantile_prob<LeftRight> > +{ + typedef tag::weighted_pot_quantile_prob<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_pot_quantile_prob<LeftRight> > + : feature_of<tag::pot_quantile_prob<LeftRight> > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/pot_tail_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/pot_tail_mean.hpp new file mode 100644 index 0000000..088ef98 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/pot_tail_mean.hpp
@@ -0,0 +1,211 @@ +/////////////////////////////////////////////////////////////////////////////// +// pot_tail_mean.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_POT_TAIL_MEAN_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_POT_TAIL_MEAN_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <boost/range.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/peaks_over_threshold.hpp> +#include <boost/accumulators/statistics/weighted_peaks_over_threshold.hpp> +#include <boost/accumulators/statistics/pot_quantile.hpp> +#include <boost/accumulators/statistics/tail_mean.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // pot_tail_mean_impl + // + /** + @brief Estimation of the (coherent) tail mean based on the peaks over threshold method (for both left and right tails) + + Computes an estimate for the (coherent) tail mean + \f[ + \widehat{CTM}_{\alpha} = \hat{q}_{\alpha} - \frac{\bar{\beta}}{\xi-1}(1-\alpha)^{-\xi}, + \f] + where \f$\bar[u]\f$, \f$\bar{\beta}\f$ and \f$\xi\f$ are the parameters of the + generalized Pareto distribution that approximates the right tail of the distribution (or the + mirrored left tail, in case the left tail is used). In the latter case, the result is mirrored + back, yielding the correct result. + */ + template<typename Sample, typename Impl, typename LeftRight> + struct pot_tail_mean_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef float_type result_type; + + pot_tail_mean_impl(dont_care) + : sign_((is_same<LeftRight, left>::value) ? -1 : 1) + { + } + + template<typename Args> + result_type result(Args const &args) const + { + typedef + typename mpl::if_< + is_same<Impl, weighted> + , tag::weighted_peaks_over_threshold<LeftRight> + , tag::peaks_over_threshold<LeftRight> + >::type + peaks_over_threshold_tag; + + typedef + typename mpl::if_< + is_same<Impl, weighted> + , tag::weighted_pot_quantile<LeftRight> + , tag::pot_quantile<LeftRight> + >::type + pot_quantile_tag; + + extractor<peaks_over_threshold_tag> const some_peaks_over_threshold = {}; + extractor<pot_quantile_tag> const some_pot_quantile = {}; + + float_type beta_bar = some_peaks_over_threshold(args).template get<1>(); + float_type xi_hat = some_peaks_over_threshold(args).template get<2>(); + + return some_pot_quantile(args) - this->sign_ * beta_bar/( xi_hat - 1. ) * std::pow( + is_same<LeftRight, left>::value ? args[quantile_probability] : 1. - args[quantile_probability] + , -xi_hat); + } + private: + short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result + }; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::pot_tail_mean +// tag::pot_tail_mean_prob +// +namespace tag +{ + template<typename LeftRight> + struct pot_tail_mean + : depends_on<peaks_over_threshold<LeftRight>, pot_quantile<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_tail_mean_impl<mpl::_1, unweighted, LeftRight> impl; + }; + template<typename LeftRight> + struct pot_tail_mean_prob + : depends_on<peaks_over_threshold_prob<LeftRight>, pot_quantile_prob<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_tail_mean_impl<mpl::_1, unweighted, LeftRight> impl; + }; + template<typename LeftRight> + struct weighted_pot_tail_mean + : depends_on<weighted_peaks_over_threshold<LeftRight>, weighted_pot_quantile<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_tail_mean_impl<mpl::_1, weighted, LeftRight> impl; + }; + template<typename LeftRight> + struct weighted_pot_tail_mean_prob + : depends_on<weighted_peaks_over_threshold_prob<LeftRight>, weighted_pot_quantile_prob<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::pot_tail_mean_impl<mpl::_1, weighted, LeftRight> impl; + }; +} + +// pot_tail_mean<LeftRight>(with_threshold_value) -> pot_tail_mean<LeftRight> +template<typename LeftRight> +struct as_feature<tag::pot_tail_mean<LeftRight>(with_threshold_value)> +{ + typedef tag::pot_tail_mean<LeftRight> type; +}; + +// pot_tail_mean<LeftRight>(with_threshold_probability) -> pot_tail_mean_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::pot_tail_mean<LeftRight>(with_threshold_probability)> +{ + typedef tag::pot_tail_mean_prob<LeftRight> type; +}; + +// weighted_pot_tail_mean<LeftRight>(with_threshold_value) -> weighted_pot_tail_mean<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_pot_tail_mean<LeftRight>(with_threshold_value)> +{ + typedef tag::weighted_pot_tail_mean<LeftRight> type; +}; + +// weighted_pot_tail_mean<LeftRight>(with_threshold_probability) -> weighted_pot_tail_mean_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_pot_tail_mean<LeftRight>(with_threshold_probability)> +{ + typedef tag::weighted_pot_tail_mean_prob<LeftRight> type; +}; + +// for the purposes of feature-based dependency resolution, +// pot_tail_mean<LeftRight> and pot_tail_mean_prob<LeftRight> provide +// the same feature as tail_mean +template<typename LeftRight> +struct feature_of<tag::pot_tail_mean<LeftRight> > + : feature_of<tag::tail_mean> +{ +}; + +template<typename LeftRight> +struct feature_of<tag::pot_tail_mean_prob<LeftRight> > + : feature_of<tag::tail_mean> +{ +}; + +// So that pot_tail_mean can be automatically substituted +// with weighted_pot_tail_mean when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::pot_tail_mean<LeftRight> > +{ + typedef tag::weighted_pot_tail_mean<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_pot_tail_mean<LeftRight> > + : feature_of<tag::pot_tail_mean<LeftRight> > +{ +}; + +// So that pot_tail_mean_prob can be automatically substituted +// with weighted_pot_tail_mean_prob when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::pot_tail_mean_prob<LeftRight> > +{ + typedef tag::weighted_pot_tail_mean_prob<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_pot_tail_mean_prob<LeftRight> > + : feature_of<tag::pot_tail_mean_prob<LeftRight> > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/rolling_count.hpp b/boost_1_45_0/boost/accumulators/statistics/rolling_count.hpp new file mode 100644 index 0000000..1e34f76 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/rolling_count.hpp
@@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////// +// rolling_count.hpp +// +// Copyright 2008 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008 +#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/rolling_window.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // rolling_count_impl + // returns the count of elements in the rolling window + template<typename Sample> + struct rolling_count_impl + : accumulator_base + { + typedef std::size_t result_type; + + rolling_count_impl(dont_care) + {} + + template<typename Args> + result_type result(Args const &args) const + { + return static_cast<std::size_t>(rolling_window_plus1(args).size()) - is_rolling_window_plus1_full(args); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::rolling_count +// +namespace tag +{ + struct rolling_count + : depends_on< rolling_window_plus1 > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::rolling_count_impl< mpl::_1 > impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::rolling_window::window_size named parameter + static boost::parameter::keyword<tag::rolling_window_size> const window_size; + #endif + }; +} // namespace tag + +/////////////////////////////////////////////////////////////////////////////// +// extract::rolling_count +// +namespace extract +{ + extractor<tag::rolling_count> const rolling_count = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_count) +} + +using extract::rolling_count; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/rolling_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/rolling_mean.hpp new file mode 100644 index 0000000..ddcbaa3 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/rolling_mean.hpp
@@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////// +// rolling_mean.hpp +// +// Copyright 2008 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008 +#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/rolling_sum.hpp> +#include <boost/accumulators/statistics/rolling_count.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // rolling_mean_impl + // returns the unshifted results from the shifted rolling window + template<typename Sample> + struct rolling_mean_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + rolling_mean_impl(dont_care) + {} + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average(rolling_sum(args), rolling_count(args)); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::rolling_mean +// +namespace tag +{ + struct rolling_mean + : depends_on< rolling_sum, rolling_count > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::rolling_mean_impl< mpl::_1 > impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::rolling_window::window_size named parameter + static boost::parameter::keyword<tag::rolling_window_size> const window_size; + #endif + }; +} // namespace tag + +/////////////////////////////////////////////////////////////////////////////// +// extract::rolling_mean +// +namespace extract +{ + extractor<tag::rolling_mean> const rolling_mean = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_mean) +} + +using extract::rolling_mean; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/rolling_sum.hpp b/boost_1_45_0/boost/accumulators/statistics/rolling_sum.hpp new file mode 100644 index 0000000..b41ab39 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/rolling_sum.hpp
@@ -0,0 +1,93 @@ +/////////////////////////////////////////////////////////////////////////////// +// rolling_sum.hpp +// +// Copyright 2008 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_SUM_HPP_EAN_26_12_2008 +#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_SUM_HPP_EAN_26_12_2008 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/rolling_window.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // rolling_sum_impl + // returns the sum of the samples in the rolling window + template<typename Sample> + struct rolling_sum_impl + : accumulator_base + { + typedef Sample result_type; + + template<typename Args> + rolling_sum_impl(Args const &args) + : sum_(args[sample | Sample()]) + {} + + template<typename Args> + void operator ()(Args const &args) + { + if(is_rolling_window_plus1_full(args)) + { + this->sum_ -= rolling_window_plus1(args).front(); + } + this->sum_ += args[sample]; + } + + template<typename Args> + result_type result(Args const &args) const + { + return this->sum_; + } + + private: + Sample sum_; + }; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::rolling_sum +// +namespace tag +{ + struct rolling_sum + : depends_on< rolling_window_plus1 > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::rolling_sum_impl< mpl::_1 > impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::rolling_window::window_size named parameter + static boost::parameter::keyword<tag::rolling_window_size> const window_size; + #endif + }; +} // namespace tag + +/////////////////////////////////////////////////////////////////////////////// +// extract::rolling_sum +// +namespace extract +{ + extractor<tag::rolling_sum> const rolling_sum = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_sum) +} + +using extract::rolling_sum; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/rolling_window.hpp b/boost_1_45_0/boost/accumulators/statistics/rolling_window.hpp new file mode 100644 index 0000000..d2f4b0d --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/rolling_window.hpp
@@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////// +// rolling_window.hpp +// +// Copyright 2008 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_WINDOW_HPP_EAN_26_12_2008 +#define BOOST_ACCUMULATORS_STATISTICS_ROLLING_WINDOW_HPP_EAN_26_12_2008 + +#include <cstddef> +#include <boost/version.hpp> +#include <boost/assert.hpp> +#include <boost/circular_buffer.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// tag::rolling_window::size named parameter +BOOST_PARAMETER_NESTED_KEYWORD(tag, rolling_window_size, window_size) + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // rolling_window_plus1_impl + // stores the latest N+1 samples, where N is specified at construction time + // with the rolling_window_size named parameter + template<typename Sample> + struct rolling_window_plus1_impl + : accumulator_base + { + typedef typename circular_buffer<Sample>::const_iterator const_iterator; + typedef iterator_range<const_iterator> result_type; + + template<typename Args> + rolling_window_plus1_impl(Args const & args) + : buffer_(args[rolling_window_size] + 1) + {} + + #if BOOST_VERSION < 103600 + // Before Boost 1.36, copying a circular buffer didn't copy + // it's capacity, and we need that behavior. + rolling_window_plus1_impl(rolling_window_plus1_impl const &that) + : buffer_(that.buffer_) + { + this->buffer_.set_capacity(that.buffer_.capacity()); + } + + rolling_window_plus1_impl &operator =(rolling_window_plus1_impl const &that) + { + this->buffer_ = that.buffer_; + this->buffer_.set_capacity(that.buffer_.capacity()); + } + #endif + + template<typename Args> + void operator ()(Args const &args) + { + this->buffer_.push_back(args[sample]); + } + + bool full() const + { + return this->buffer_.full(); + } + + // The result of a shifted rolling window is the range including + // everything except the most recently added element. + result_type result(dont_care) const + { + return result_type(this->buffer_.begin(), this->buffer_.end()); + } + + private: + circular_buffer<Sample> buffer_; + }; + + template<typename Args> + bool is_rolling_window_plus1_full(Args const &args) + { + return find_accumulator<tag::rolling_window_plus1>(args[accumulator]).full(); + } + + /////////////////////////////////////////////////////////////////////////////// + // rolling_window_impl + // stores the latest N samples, where N is specified at construction type + // with the rolling_window_size named parameter + template<typename Sample> + struct rolling_window_impl + : accumulator_base + { + typedef typename circular_buffer<Sample>::const_iterator const_iterator; + typedef iterator_range<const_iterator> result_type; + + rolling_window_impl(dont_care) + {} + + template<typename Args> + result_type result(Args const &args) const + { + return rolling_window_plus1(args).advance_begin(is_rolling_window_plus1_full(args)); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::rolling_window_plus1 +// tag::rolling_window +// +namespace tag +{ + struct rolling_window_plus1 + : depends_on<> + , tag::rolling_window_size + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::rolling_window_plus1_impl< mpl::_1 > impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::rolling_window::size named parameter + static boost::parameter::keyword<tag::rolling_window_size> const window_size; + #endif + }; + + struct rolling_window + : depends_on< rolling_window_plus1 > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::rolling_window_impl< mpl::_1 > impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::rolling_window::size named parameter + static boost::parameter::keyword<tag::rolling_window_size> const window_size; + #endif + }; + +} // namespace tag + +/////////////////////////////////////////////////////////////////////////////// +// extract::rolling_window_plus1 +// extract::rolling_window +// +namespace extract +{ + extractor<tag::rolling_window_plus1> const rolling_window_plus1 = {}; + extractor<tag::rolling_window> const rolling_window = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window_plus1) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_window) +} + +using extract::rolling_window_plus1; +using extract::rolling_window; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/skewness.hpp b/boost_1_45_0/boost/accumulators/statistics/skewness.hpp new file mode 100644 index 0000000..2e29018 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/skewness.hpp
@@ -0,0 +1,114 @@ +/////////////////////////////////////////////////////////////////////////////// +// skewness.hpp +// +// Copyright 2006 Olivier Gygi, Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_SKEWNESS_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/moment.hpp> +#include <boost/accumulators/statistics/mean.hpp> + + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // skewness_impl + /** + @brief Skewness estimation + + The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$ 3/2 \f$-th power + of the 2nd central moment (the variance) of the sampless 3. The skewness can also be expressed by the simple moments: + + \f[ + \hat{g}_1 = + \frac + {\widehat{m}_n^{(3)}-3\widehat{m}_n^{(2)}\hat{\mu}_n+2\hat{\mu}_n^3} + {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^{3/2}} + \f] + + where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the + \f$ n \f$ samples. + */ + template<typename Sample> + struct skewness_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, Sample>::result_type result_type; + + skewness_impl(dont_care) + { + } + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average( + accumulators::moment<3>(args) + - 3. * accumulators::moment<2>(args) * mean(args) + + 2. * mean(args) * mean(args) * mean(args) + , ( accumulators::moment<2>(args) - mean(args) * mean(args) ) + * std::sqrt( accumulators::moment<2>(args) - mean(args) * mean(args) ) + ); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::skewness +// +namespace tag +{ + struct skewness + : depends_on<mean, moment<2>, moment<3> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::skewness_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::skewness +// +namespace extract +{ + extractor<tag::skewness> const skewness = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(skewness) +} + +using extract::skewness; + +// So that skewness can be automatically substituted with +// weighted_skewness when the weight parameter is non-void +template<> +struct as_weighted_feature<tag::skewness> +{ + typedef tag::weighted_skewness type; +}; + +template<> +struct feature_of<tag::weighted_skewness> + : feature_of<tag::skewness> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/stats.hpp b/boost_1_45_0/boost/accumulators/statistics/stats.hpp new file mode 100644 index 0000000..22c4ede --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/stats.hpp
@@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file stats.hpp +/// Contains the stats<> template. +/// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_28_10_2005 + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +/// An MPL sequence of statistics. +template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Stat)> +struct stats + : mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Stat)> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/sum.hpp b/boost_1_45_0/boost/accumulators/statistics/sum.hpp new file mode 100644 index 0000000..126ce24 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/sum.hpp
@@ -0,0 +1,141 @@ +/////////////////////////////////////////////////////////////////////////////// +// sum.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_SUM_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_SUM_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/parameters/weight.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // sum_impl + template<typename Sample, typename Tag> + struct sum_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + sum_impl(Args const &args) + : sum(args[parameter::keyword<Tag>::get() | Sample()]) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + // what about overflow? + this->sum += args[parameter::keyword<Tag>::get()]; + } + + result_type result(dont_care) const + { + return this->sum; + } + + private: + + Sample sum; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::sum +// tag::sum_of_weights +// tag::sum_of_variates +// +namespace tag +{ + struct sum + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::sum_impl<mpl::_1, tag::sample> impl; + }; + + struct sum_of_weights + : depends_on<> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::sum_impl<mpl::_2, tag::weight> impl; + }; + + template<typename VariateType, typename VariateTag> + struct sum_of_variates + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::sum_impl<VariateType, VariateTag> > impl; + }; + + struct abstract_sum_of_variates + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::sum +// extract::sum_of_weights +// extract::sum_of_variates +// +namespace extract +{ + extractor<tag::sum> const sum = {}; + extractor<tag::sum_of_weights> const sum_of_weights = {}; + extractor<tag::abstract_sum_of_variates> const sum_of_variates = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates) +} + +using extract::sum; +using extract::sum_of_weights; +using extract::sum_of_variates; + +// So that mean can be automatically substituted with +// weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::sum> +{ + typedef tag::weighted_sum type; +}; + +template<> +struct feature_of<tag::weighted_sum> + : feature_of<tag::sum> +{}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::sum_of_variates<VariateType, VariateTag> > + : feature_of<tag::abstract_sum_of_variates> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/tail.hpp b/boost_1_45_0/boost/accumulators/statistics/tail.hpp new file mode 100644 index 0000000..159a9b6 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/tail.hpp
@@ -0,0 +1,334 @@ +/////////////////////////////////////////////////////////////////////////////// +// tail.hpp +// +// Copyright 2005 Eric Niebler, Michael Gauckler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_TAIL_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_TAIL_HPP_EAN_28_10_2005 + +#include <vector> +#include <functional> +#include <boost/assert.hpp> +#include <boost/range.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/iterator/reverse_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ +/////////////////////////////////////////////////////////////////////////////// +// cache_size named parameters +BOOST_PARAMETER_NESTED_KEYWORD(tag, right_tail_cache_size, cache_size) +BOOST_PARAMETER_NESTED_KEYWORD(tag, left_tail_cache_size, cache_size) + +namespace detail +{ + /////////////////////////////////////////////////////////////////////////////// + // tail_range + /// INTERNAL ONLY + /// + template<typename ElementIterator, typename IndexIterator> + struct tail_range + { + typedef boost::iterator_range< + boost::reverse_iterator<boost::permutation_iterator<ElementIterator, IndexIterator> > + > type; + }; + + /////////////////////////////////////////////////////////////////////////////// + // make_tail_range + /// INTERNAL ONLY + /// + template<typename ElementIterator, typename IndexIterator> + typename tail_range<ElementIterator, IndexIterator>::type + make_tail_range(ElementIterator elem_begin, IndexIterator index_begin, IndexIterator index_end) + { + return boost::make_iterator_range( + boost::make_reverse_iterator( + boost::make_permutation_iterator(elem_begin, index_end) + ) + , boost::make_reverse_iterator( + boost::make_permutation_iterator(elem_begin, index_begin) + ) + ); + } + + /////////////////////////////////////////////////////////////////////////////// + // stat_assign_visitor + /// INTERNAL ONLY + /// + template<typename Args> + struct stat_assign_visitor + { + stat_assign_visitor(Args const &a, std::size_t i) + : args(a) + , index(i) + { + } + + template<typename Stat> + void operator ()(Stat &stat) const + { + stat.assign(this->args, this->index); + } + + private: + stat_assign_visitor &operator =(stat_assign_visitor const &); + Args const &args; + std::size_t index; + }; + + /////////////////////////////////////////////////////////////////////////////// + // stat_assign + /// INTERNAL ONLY + /// + template<typename Args> + inline stat_assign_visitor<Args> const stat_assign(Args const &args, std::size_t index) + { + return stat_assign_visitor<Args>(args, index); + } + + /////////////////////////////////////////////////////////////////////////////// + // is_tail_variate_feature + /// INTERNAL ONLY + /// + template<typename Stat, typename LeftRight> + struct is_tail_variate_feature + : mpl::false_ + { + }; + + /// INTERNAL ONLY + /// + template<typename VariateType, typename VariateTag, typename LeftRight> + struct is_tail_variate_feature<tag::tail_variate<VariateType, VariateTag, LeftRight>, LeftRight> + : mpl::true_ + { + }; + + /// INTERNAL ONLY + /// + template<typename LeftRight> + struct is_tail_variate_feature<tag::tail_weights<LeftRight>, LeftRight> + : mpl::true_ + { + }; + +} // namespace detail + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // tail_impl + template<typename Sample, typename LeftRight> + struct tail_impl + : accumulator_base + { + // LeftRight must be either right or left + BOOST_MPL_ASSERT(( + mpl::or_<is_same<LeftRight, right>, is_same<LeftRight, left> > + )); + + typedef + typename mpl::if_< + is_same<LeftRight, right> + , numeric::functional::greater<Sample const, Sample const> + , numeric::functional::less<Sample const, Sample const> + >::type + predicate_type; + + // for boost::result_of + typedef typename detail::tail_range< + typename std::vector<Sample>::const_iterator + , std::vector<std::size_t>::iterator + >::type result_type; + + template<typename Args> + tail_impl(Args const &args) + : is_sorted(false) + , indices() + , samples(args[tag::tail<LeftRight>::cache_size], args[sample | Sample()]) + { + this->indices.reserve(this->samples.size()); + } + + tail_impl(tail_impl const &that) + : is_sorted(that.is_sorted) + , indices(that.indices) + , samples(that.samples) + { + this->indices.reserve(this->samples.size()); + } + + // This just stores the heap and the samples. + // In operator()() below, if we are adding a new sample + // to the sample cache, we force all the + // tail_variates to update also. (It's not + // good enough to wait for the accumulator_set to do it + // for us because then information about whether a sample + // was stored and where is lost, and would need to be + // queried at runtime, which would be slow.) This is + // implemented as a filtered visitation over the stats, + // which we can access because args[accumulator] gives us + // all the stats. + + template<typename Args> + void operator ()(Args const &args) + { + if(this->indices.size() < this->samples.size()) + { + this->indices.push_back(this->indices.size()); + this->assign(args, this->indices.back()); + } + else if(predicate_type()(args[sample], this->samples[this->indices[0]])) + { + std::pop_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); + this->assign(args, this->indices.back()); + } + } + + result_type result(dont_care) const + { + if(!this->is_sorted) + { + // Must use the same predicate here as in push_heap/pop_heap above. + std::sort_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); + // sort_heap puts elements in reverse order. Calling std::reverse + // turns the sorted sequence back into a valid heap. + std::reverse(this->indices.begin(), this->indices.end()); + this->is_sorted = true; + } + + return detail::make_tail_range( + this->samples.begin() + , this->indices.begin() + , this->indices.end() + ); + } + + private: + + struct is_tail_variate + { + template<typename T> + struct apply + : detail::is_tail_variate_feature< + typename detail::feature_tag<T>::type + , LeftRight + > + {}; + }; + + template<typename Args> + void assign(Args const &args, std::size_t index) + { + BOOST_ASSERT(index < this->samples.size()); + this->samples[index] = args[sample]; + std::push_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples)); + this->is_sorted = false; + // Tell the tail variates to store their values also + args[accumulator].template visit_if<is_tail_variate>(detail::stat_assign(args, index)); + } + + /////////////////////////////////////////////////////////////////////////////// + // + struct indirect_cmp + : std::binary_function<std::size_t, std::size_t, bool> + { + indirect_cmp(std::vector<Sample> const &s) + : samples(s) + { + } + + bool operator ()(std::size_t left, std::size_t right) const + { + return predicate_type()(this->samples[left], this->samples[right]); + } + + private: + indirect_cmp &operator =(indirect_cmp const &); + std::vector<Sample> const &samples; + }; + + mutable bool is_sorted; + mutable std::vector<std::size_t> indices; + std::vector<Sample> samples; + }; + +} // namespace impl + +// TODO The templatized tag::tail below should inherit from the correct named parameter. +// The following lines provide a workaround, but there must be a better way of doing this. +template<typename T> +struct tail_cache_size_named_arg +{ +}; +template<> +struct tail_cache_size_named_arg<left> + : tag::left_tail_cache_size +{ +}; +template<> +struct tail_cache_size_named_arg<right> + : tag::right_tail_cache_size +{ +}; + +/////////////////////////////////////////////////////////////////////////////// +// tag::tail<> +// +namespace tag +{ + template<typename LeftRight> + struct tail + : depends_on<> + , tail_cache_size_named_arg<LeftRight> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::tail_impl<mpl::_1, LeftRight> impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// tag::tail<LeftRight>::cache_size named parameter + static boost::parameter::keyword<tail_cache_size_named_arg<LeftRight> > const cache_size; + #endif + }; + + struct abstract_tail + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::tail +// +namespace extract +{ + extractor<tag::abstract_tail> const tail = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail) +} + +using extract::tail; + +template<typename LeftRight> +struct feature_of<tag::tail<LeftRight> > + : feature_of<tag::abstract_tail> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/tail_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/tail_mean.hpp new file mode 100644 index 0000000..323eeb0 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/tail_mean.hpp
@@ -0,0 +1,246 @@ +/////////////////////////////////////////////////////////////////////////////// +// tail_mean.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_TAIL_MEAN_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_TAIL_MEAN_HPP_DE_01_01_2006 + +#include <numeric> +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_quantile.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // coherent_tail_mean_impl + // + /** + @brief Estimation of the coherent tail mean based on order statistics (for both left and right tails) + + The coherent tail mean \f$\widehat{CTM}_{n,\alpha}(X)\f$ is equal to the non-coherent tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ + plus a correction term that ensures coherence in case of non-continuous distributions. + + \f[ + \widehat{CTM}_{n,\alpha}^{\mathrm{right}}(X) = \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) + + \frac{1}{\lceil n(1-\alpha)\rceil}\hat{q}_{n,\alpha}(X)\left(1 - \alpha - \frac{1}{n}\lceil n(1-\alpha)\rceil \right) + \f] + + \f[ + \widehat{CTM}_{n,\alpha}^{\mathrm{left}}(X) = \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) + + \frac{1}{\lceil n\alpha\rceil}\hat{q}_{n,\alpha}(X)\left(\alpha - \frac{1}{n}\lceil n\alpha\rceil \right) + \f] + */ + template<typename Sample, typename LeftRight> + struct coherent_tail_mean_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef float_type result_type; + + coherent_tail_mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + std::size_t cnt = count(args); + + std::size_t n = static_cast<std::size_t>( + std::ceil( + cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) + ) + ); + + extractor<tag::non_coherent_tail_mean<LeftRight> > const some_non_coherent_tail_mean = {}; + + return some_non_coherent_tail_mean(args) + + numeric::average(quantile(args), n) + * ( + ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] + - numeric::average(n, count(args)) + ); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // non_coherent_tail_mean_impl + // + /** + @brief Estimation of the (non-coherent) tail mean based on order statistics (for both left and right tails) + + An estimation of the non-coherent tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ is given by the mean of the + \f$\lceil n\alpha\rceil\f$ smallest samples (left tail) or the mean of the \f$\lceil n(1-\alpha)\rceil\f$ + largest samples (right tail), \f$n\f$ being the total number of samples and \f$\alpha\f$ the quantile level: + + \f[ + \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) = \frac{1}{\lceil n(1-\alpha)\rceil} \sum_{i=\lceil \alpha n \rceil}^n X_{i:n} + \f] + + \f[ + \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) = \frac{1}{\lceil n\alpha\rceil} \sum_{i=1}^{\lceil \alpha n \rceil} X_{i:n} + \f] + + It thus requires the caching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ + largest samples. + + @param quantile_probability + */ + template<typename Sample, typename LeftRight> + struct non_coherent_tail_mean_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef float_type result_type; + + non_coherent_tail_mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + std::size_t cnt = count(args); + + std::size_t n = static_cast<std::size_t>( + std::ceil( + cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) + ) + ); + + // If n is in a valid range, return result, otherwise return NaN or throw exception + if (n <= static_cast<std::size_t>(tail(args).size())) + return numeric::average( + std::accumulate( + tail(args).begin() + , tail(args).begin() + n + , Sample(0) + ) + , n + ); + else + { + if (std::numeric_limits<result_type>::has_quiet_NaN) + { + return std::numeric_limits<result_type>::quiet_NaN(); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return Sample(0); + } + } + } + }; + +} // namespace impl + + +/////////////////////////////////////////////////////////////////////////////// +// tag::coherent_tail_mean<> +// tag::non_coherent_tail_mean<> +// +namespace tag +{ + template<typename LeftRight> + struct coherent_tail_mean + : depends_on<count, quantile, non_coherent_tail_mean<LeftRight> > + { + typedef accumulators::impl::coherent_tail_mean_impl<mpl::_1, LeftRight> impl; + }; + + template<typename LeftRight> + struct non_coherent_tail_mean + : depends_on<count, tail<LeftRight> > + { + typedef accumulators::impl::non_coherent_tail_mean_impl<mpl::_1, LeftRight> impl; + }; + + struct abstract_non_coherent_tail_mean + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::non_coherent_tail_mean; +// extract::coherent_tail_mean; +// +namespace extract +{ + extractor<tag::abstract_non_coherent_tail_mean> const non_coherent_tail_mean = {}; + extractor<tag::tail_mean> const coherent_tail_mean = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(non_coherent_tail_mean) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(coherent_tail_mean) +} + +using extract::non_coherent_tail_mean; +using extract::coherent_tail_mean; + +// for the purposes of feature-based dependency resolution, +// coherent_tail_mean<LeftRight> provides the same feature as tail_mean +template<typename LeftRight> +struct feature_of<tag::coherent_tail_mean<LeftRight> > + : feature_of<tag::tail_mean> +{ +}; + +template<typename LeftRight> +struct feature_of<tag::non_coherent_tail_mean<LeftRight> > + : feature_of<tag::abstract_non_coherent_tail_mean> +{ +}; + +// So that non_coherent_tail_mean can be automatically substituted +// with weighted_non_coherent_tail_mean when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::non_coherent_tail_mean<LeftRight> > +{ + typedef tag::non_coherent_weighted_tail_mean<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::non_coherent_weighted_tail_mean<LeftRight> > + : feature_of<tag::non_coherent_tail_mean<LeftRight> > +{}; + +// NOTE that non_coherent_tail_mean cannot be feature-grouped with tail_mean, +// which is the base feature for coherent tail means, since (at least for +// non-continuous distributions) non_coherent_tail_mean is a different measure! + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/tail_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/tail_quantile.hpp new file mode 100644 index 0000000..d3b96b4 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/tail_quantile.hpp
@@ -0,0 +1,158 @@ +/////////////////////////////////////////////////////////////////////////////// +// tail_quantile.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_TAIL_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_TAIL_QUANTILE_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/config/no_tr1/cmath.hpp> // For ceil +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // tail_quantile_impl + // Tail quantile estimation based on order statistics + /** + @brief Tail quantile estimation based on order statistics (for both left and right tails) + + The estimation of a tail quantile \f$\hat{q}\f$ with level \f$\alpha\f$ based on order statistics requires the + chaching of at least the \f$\lceil n\alpha\rceil\f$ smallest or the \f$\lceil n(1-\alpha)\rceil\f$ largest samples, + \f$n\f$ being the total number of samples. The largest of the \f$\lceil n\alpha\rceil\f$ smallest samples or the + smallest of the \f$\lceil n(1-\alpha)\rceil\f$ largest samples provides an estimate for the quantile: + + \f[ + \hat{q}_{n,\alpha} = X_{\lceil \alpha n \rceil:n} + \f] + + @param quantile_probability + */ + template<typename Sample, typename LeftRight> + struct tail_quantile_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + tail_quantile_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + std::size_t cnt = count(args); + + std::size_t n = static_cast<std::size_t>( + std::ceil( + cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) + ) + ); + + // If n is in a valid range, return result, otherwise return NaN or throw exception + if ( n < static_cast<std::size_t>(tail(args).size())) + { + // Note that the cached samples of the left are sorted in ascending order, + // whereas the samples of the right tail are sorted in descending order + return *(boost::begin(tail(args)) + n - 1); + } + else + { + if (std::numeric_limits<result_type>::has_quiet_NaN) + { + return std::numeric_limits<result_type>::quiet_NaN(); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return Sample(0); + } + } + } + }; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::tail_quantile<> +// +namespace tag +{ + template<typename LeftRight> + struct tail_quantile + : depends_on<count, tail<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::tail_quantile_impl<mpl::_1, LeftRight> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::tail_quantile +// +namespace extract +{ + extractor<tag::quantile> const tail_quantile = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_quantile) +} + +using extract::tail_quantile; + +// for the purposes of feature-based dependency resolution, +// tail_quantile<LeftRight> provide the same feature as quantile +template<typename LeftRight> +struct feature_of<tag::tail_quantile<LeftRight> > + : feature_of<tag::quantile> +{ +}; + +// So that tail_quantile can be automatically substituted with +// weighted_tail_quantile when the weight parameter is non-void. +template<typename LeftRight> +struct as_weighted_feature<tag::tail_quantile<LeftRight> > +{ + typedef tag::weighted_tail_quantile<LeftRight> type; +}; + +template<typename LeftRight> +struct feature_of<tag::weighted_tail_quantile<LeftRight> > + : feature_of<tag::tail_quantile<LeftRight> > +{}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/tail_variate.hpp b/boost_1_45_0/boost/accumulators/statistics/tail_variate.hpp new file mode 100644 index 0000000..a9fc7d2 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/tail_variate.hpp
@@ -0,0 +1,141 @@ +/////////////////////////////////////////////////////////////////////////////// +// tail_variate.hpp +// +// Copyright 2005 Eric Niebler, Michael Gauckler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005 +#define BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005 + +#include <boost/range.hpp> +#include <boost/mpl/always.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/iterator/reverse_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // tail_variate_impl + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate_impl + : accumulator_base + { + // for boost::result_of + typedef + typename detail::tail_range< + typename std::vector<VariateType>::const_iterator + , std::vector<std::size_t>::iterator + >::type + result_type; + + template<typename Args> + tail_variate_impl(Args const &args) + : variates(args[tag::tail<LeftRight>::cache_size], args[parameter::keyword<VariateTag>::get() | VariateType()]) + { + } + + template<typename Args> + void assign(Args const &args, std::size_t index) + { + this->variates[index] = args[parameter::keyword<VariateTag>::get()]; + } + + template<typename Args> + result_type result(Args const &args) const + { + // getting the order result causes the indices vector to be sorted. + extractor<tag::tail<LeftRight> > const some_tail = {}; + return this->do_result(some_tail(args)); + } + + private: + template<typename TailRng> + result_type do_result(TailRng const &rng) const + { + return detail::make_tail_range( + this->variates.begin() + , rng.end().base().base() // the index iterator + , rng.begin().base().base() // (begin and end reversed because these are reverse iterators) + ); + } + + std::vector<VariateType> variates; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::tail_variate<> +// +namespace tag +{ + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate + : depends_on<tail<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::tail_variate_impl<VariateType, VariateTag, LeftRight> > impl; + }; + + struct abstract_tail_variate + : depends_on<> + { + }; + + template<typename LeftRight> + struct tail_weights + : depends_on<tail<LeftRight> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::tail_variate_impl<mpl::_2, tag::weight, LeftRight> impl; + }; + + struct abstract_tail_weights + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::tail_variate +// extract::tail_weights +// +namespace extract +{ + extractor<tag::abstract_tail_variate> const tail_variate = {}; + extractor<tag::abstract_tail_weights> const tail_weights = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_weights) +} + +using extract::tail_variate; +using extract::tail_weights; + +template<typename VariateType, typename VariateTag, typename LeftRight> +struct feature_of<tag::tail_variate<VariateType, VariateTag, LeftRight> > + : feature_of<tag::abstract_tail_variate> +{ +}; + +template<typename LeftRight> +struct feature_of<tag::tail_weights<LeftRight> > +{ + typedef tag::abstract_tail_weights type; +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/tail_variate_means.hpp b/boost_1_45_0/boost/accumulators/statistics/tail_variate_means.hpp new file mode 100644 index 0000000..98991e2 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/tail_variate_means.hpp
@@ -0,0 +1,258 @@ +/////////////////////////////////////////////////////////////////////////////// +// tail_variate_means.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 + +#include <numeric> +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_variate.hpp> +#include <boost/accumulators/statistics/tail_mean.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /** + @brief Estimation of the absolute and relative tail variate means (for both left and right tails) + + For all \f$j\f$-th variates associated to the \f$\lceil n(1-\alpha)\rceil\f$ largest samples (or the + \f$\lceil n(1-\alpha)\rceil\f$ smallest samples in case of the left tail), the absolute tail means + \f$\widehat{ATM}_{n,\alpha}(X, j)\f$ are computed and returned as an iterator range. Alternatively, + the relative tail means \f$\widehat{RTM}_{n,\alpha}(X, j)\f$ are returned, which are the absolute + tail means normalized with the (non-coherent) sample tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$. + + \f[ + \widehat{ATM}_{n,\alpha}^{\mathrm{right}}(X, j) = + \frac{1}{\lceil n(1-\alpha) \rceil} + \sum_{i=\lceil \alpha n \rceil}^n \xi_{j,i} + \f] + + \f[ + \widehat{ATM}_{n,\alpha}^{\mathrm{left}}(X, j) = + \frac{1}{\lceil n\alpha \rceil} + \sum_{i=1}^{\lceil n\alpha \rceil} \xi_{j,i} + \f] + + \f[ + \widehat{RTM}_{n,\alpha}^{\mathrm{right}}(X, j) = + \frac{\sum_{i=\lceil n\alpha \rceil}^n \xi_{j,i}} + {\lceil n(1-\alpha)\rceil\widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X)} + \f] + + \f[ + \widehat{RTM}_{n,\alpha}^{\mathrm{left}}(X, j) = + \frac{\sum_{i=1}^{\lceil n\alpha \rceil} \xi_{j,i}} + {\lceil n\alpha\rceil\widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X)} + \f] + */ + + /////////////////////////////////////////////////////////////////////////////// + // tail_variate_means_impl + // by default: absolute tail_variate_means + template<typename Sample, typename Impl, typename LeftRight, typename VariateTag> + struct tail_variate_means_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range<typename array_type::iterator> result_type; + + tail_variate_means_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + std::size_t cnt = count(args); + + std::size_t n = static_cast<std::size_t>( + std::ceil( + cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) + ) + ); + + std::size_t num_variates = tail_variate(args).begin()->size(); + + this->tail_means_.clear(); + this->tail_means_.resize(num_variates, Sample(0)); + + // If n is in a valid range, return result, otherwise return NaN or throw exception + if (n < static_cast<std::size_t>(tail(args).size())) + { + this->tail_means_ = std::accumulate( + tail_variate(args).begin() + , tail_variate(args).begin() + n + , this->tail_means_ + , numeric::plus + ); + + float_type factor = n * ( (is_same<Impl, relative>::value) ? non_coherent_tail_mean(args) : 1. ); + + std::transform( + this->tail_means_.begin() + , this->tail_means_.end() + , this->tail_means_.begin() + , std::bind2nd(std::divides<float_type>(), factor) + ); + } + else + { + if (std::numeric_limits<float_type>::has_quiet_NaN) + { + std::fill( + this->tail_means_.begin() + , this->tail_means_.end() + , std::numeric_limits<float_type>::quiet_NaN() + ); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + } + } + return make_iterator_range(this->tail_means_); + } + + private: + + mutable array_type tail_means_; + + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::absolute_tail_variate_means +// tag::relative_tail_variate_means +// +namespace tag +{ + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_tail_variate_means + : depends_on<count, non_coherent_tail_mean<LeftRight>, tail_variate<VariateType, VariateTag, LeftRight> > + { + typedef accumulators::impl::tail_variate_means_impl<mpl::_1, absolute, LeftRight, VariateTag> impl; + }; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_tail_variate_means + : depends_on<count, non_coherent_tail_mean<LeftRight>, tail_variate<VariateType, VariateTag, LeftRight> > + { + typedef accumulators::impl::tail_variate_means_impl<mpl::_1, relative, LeftRight, VariateTag> impl; + }; + struct abstract_absolute_tail_variate_means + : depends_on<> + { + }; + struct abstract_relative_tail_variate_means + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::tail_variate_means +// extract::relative_tail_variate_means +// +namespace extract +{ + extractor<tag::abstract_absolute_tail_variate_means> const tail_variate_means = {}; + extractor<tag::abstract_relative_tail_variate_means> const relative_tail_variate_means = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate_means) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(relative_tail_variate_means) +} + +using extract::tail_variate_means; +using extract::relative_tail_variate_means; + +// tail_variate_means<LeftRight, VariateType, VariateTag>(absolute) -> absolute_tail_variate_means<LeftRight, VariateType, VariateTag> +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_feature<tag::tail_variate_means<LeftRight, VariateType, VariateTag>(absolute)> +{ + typedef tag::absolute_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +// tail_variate_means<LeftRight, VariateType, VariateTag>(relative) ->relative_tail_variate_means<LeftRight, VariateType, VariateTag> +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_feature<tag::tail_variate_means<LeftRight, VariateType, VariateTag>(relative)> +{ + typedef tag::relative_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +// Provides non-templatized extractor +template<typename LeftRight, typename VariateType, typename VariateTag> +struct feature_of<tag::absolute_tail_variate_means<LeftRight, VariateType, VariateTag> > + : feature_of<tag::abstract_absolute_tail_variate_means> +{ +}; + +// Provides non-templatized extractor +template<typename LeftRight, typename VariateType, typename VariateTag> +struct feature_of<tag::relative_tail_variate_means<LeftRight, VariateType, VariateTag> > + : feature_of<tag::abstract_relative_tail_variate_means> +{ +}; + +// So that absolute_tail_means can be automatically substituted +// with absolute_weighted_tail_means when the weight parameter is non-void. +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::absolute_tail_variate_means<LeftRight, VariateType, VariateTag> > +{ + typedef tag::absolute_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +template<typename LeftRight, typename VariateType, typename VariateTag> +struct feature_of<tag::absolute_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> > + : feature_of<tag::absolute_tail_variate_means<LeftRight, VariateType, VariateTag> > +{ +}; + +// So that relative_tail_means can be automatically substituted +// with relative_weighted_tail_means when the weight parameter is non-void. +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::relative_tail_variate_means<LeftRight, VariateType, VariateTag> > +{ + typedef tag::relative_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +template<typename LeftRight, typename VariateType, typename VariateTag> +struct feature_of<tag::relative_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> > + : feature_of<tag::relative_tail_variate_means<LeftRight, VariateType, VariateTag> > +{ +}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/times2_iterator.hpp b/boost_1_45_0/boost/accumulators/statistics/times2_iterator.hpp new file mode 100644 index 0000000..211a46e --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/times2_iterator.hpp
@@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////// +// times2_iterator.hpp +// +// Copyright 2006 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006 + +#include <functional> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/iterator/transform_iterator.hpp> +#include <boost/iterator/counting_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + typedef transform_iterator< + std::binder1st<std::multiplies<std::size_t> > + , counting_iterator<std::size_t> + > times2_iterator; + + inline times2_iterator make_times2_iterator(std::size_t i) + { + return make_transform_iterator( + make_counting_iterator(i) + , std::bind1st(std::multiplies<std::size_t>(), 2) + ); + } + + + /////////////////////////////////////////////////////////////////////////////// + // lvalue_index_iterator + template<typename Base> + struct lvalue_index_iterator + : Base + { + lvalue_index_iterator(Base base) + : Base(base) + { + } + + typename Base::reference operator [](typename Base::difference_type n) const + { + return *(*this + n); + } + }; +} // namespace detail + +}} + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/variance.hpp b/boost_1_45_0/boost/accumulators/statistics/variance.hpp new file mode 100644 index 0000000..81807a2 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/variance.hpp
@@ -0,0 +1,236 @@ +/////////////////////////////////////////////////////////////////////////////// +// variance.hpp +// +// Copyright 2005 Daniel Egloff, Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_VARIANCE_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_VARIANCE_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/statistics/moment.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + //! Lazy calculation of variance. + /*! + Default sample variance implementation based on the second moment \f$ M_n^{(2)} \f$ moment<2>, mean and count. + \f[ + \sigma_n^2 = M_n^{(2)} - \mu_n^2. + \f] + where + \f[ + \mu_n = \frac{1}{n} \sum_{i = 1}^n x_i. + \f] + is the estimate of the sample mean and \f$n\f$ is the number of samples. + */ + template<typename Sample, typename MeanFeature> + struct lazy_variance_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + lazy_variance_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + extractor<MeanFeature> mean; + result_type tmp = mean(args); + return accumulators::moment<2>(args) - tmp * tmp; + } + }; + + //! Iterative calculation of variance. + /*! + Iterative calculation of sample variance \f$\sigma_n^2\f$ according to the formula + \f[ + \sigma_n^2 = \frac{1}{n} \sum_{i = 1}^n (x_i - \mu_n)^2 = \frac{n-1}{n} \sigma_{n-1}^2 + \frac{1}{n-1}(x_n - \mu_n)^2. + \f] + where + \f[ + \mu_n = \frac{1}{n} \sum_{i = 1}^n x_i. + \f] + is the estimate of the sample mean and \f$n\f$ is the number of samples. + + Note that the sample variance is not defined for \f$n <= 1\f$. + + A simplification can be obtained by the approximate recursion + \f[ + \sigma_n^2 \approx \frac{n-1}{n} \sigma_{n-1}^2 + \frac{1}{n}(x_n - \mu_n)^2. + \f] + because the difference + \f[ + \left(\frac{1}{n-1} - \frac{1}{n}\right)(x_n - \mu_n)^2 = \frac{1}{n(n-1)}(x_n - \mu_n)^2. + \f] + converges to zero as \f$n \rightarrow \infty\f$. However, for small \f$ n \f$ the difference + can be non-negligible. + */ + template<typename Sample, typename MeanFeature, typename Tag> + struct variance_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + template<typename Args> + variance_impl(Args const &args) + : variance(numeric::average(args[sample | Sample()], numeric::one<std::size_t>::value)) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + if(cnt > 1) + { + extractor<MeanFeature> mean; + result_type tmp = args[parameter::keyword<Tag>::get()] - mean(args); + this->variance = + numeric::average(this->variance * (cnt - 1), cnt) + + numeric::average(tmp * tmp, cnt - 1); + } + } + + result_type result(dont_care) const + { + return this->variance; + } + + private: + result_type variance; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::variance +// tag::immediate_variance +// +namespace tag +{ + struct lazy_variance + : depends_on<moment<2>, mean> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::lazy_variance_impl<mpl::_1, mean> impl; + }; + + struct variance + : depends_on<count, immediate_mean> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::variance_impl<mpl::_1, mean, sample> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::lazy_variance +// extract::variance +// +namespace extract +{ + extractor<tag::lazy_variance> const lazy_variance = {}; + extractor<tag::variance> const variance = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_variance) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(variance) +} + +using extract::lazy_variance; +using extract::variance; + +// variance(lazy) -> lazy_variance +template<> +struct as_feature<tag::variance(lazy)> +{ + typedef tag::lazy_variance type; +}; + +// variance(immediate) -> variance +template<> +struct as_feature<tag::variance(immediate)> +{ + typedef tag::variance type; +}; + +// for the purposes of feature-based dependency resolution, +// immediate_variance provides the same feature as variance +template<> +struct feature_of<tag::lazy_variance> + : feature_of<tag::variance> +{ +}; + +// So that variance can be automatically substituted with +// weighted_variance when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::variance> +{ + typedef tag::weighted_variance type; +}; + +// for the purposes of feature-based dependency resolution, +// weighted_variance provides the same feature as variance +template<> +struct feature_of<tag::weighted_variance> + : feature_of<tag::variance> +{ +}; + +// So that immediate_variance can be automatically substituted with +// immediate_weighted_variance when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::lazy_variance> +{ + typedef tag::lazy_weighted_variance type; +}; + +// for the purposes of feature-based dependency resolution, +// immediate_weighted_variance provides the same feature as immediate_variance +template<> +struct feature_of<tag::lazy_weighted_variance> + : feature_of<tag::lazy_variance> +{ +}; + +//////////////////////////////////////////////////////////////////////////// +//// droppable_accumulator<variance_impl> +//// need to specialize droppable lazy variance to cache the result at the +//// point the accumulator is dropped. +///// INTERNAL ONLY +///// +//template<typename Sample, typename MeanFeature> +//struct droppable_accumulator<impl::variance_impl<Sample, MeanFeature> > +// : droppable_accumulator_base< +// with_cached_result<impl::variance_impl<Sample, MeanFeature> > +// > +//{ +// template<typename Args> +// droppable_accumulator(Args const &args) +// : droppable_accumulator::base(args) +// { +// } +//}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/variates/covariate.hpp b/boost_1_45_0/boost/accumulators/statistics/variates/covariate.hpp new file mode 100644 index 0000000..eeb4835 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/variates/covariate.hpp
@@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////// +// weight.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_VARIATES_COVARIATE_HPP_EAN_03_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_VARIATES_COVARIATE_HPP_EAN_03_11_2005 + +#include <boost/parameter/keyword.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, covariate1) +BOOST_PARAMETER_KEYWORD(tag, covariate2) + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_covariance.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_covariance.hpp new file mode 100644 index 0000000..83585b1 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_covariance.hpp
@@ -0,0 +1,133 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_covariance.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_COVARIANCE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_COVARIANCE_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <complex> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/range.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/numeric/ublas/io.hpp> +#include <boost/numeric/ublas/matrix.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/covariance.hpp> // for numeric::outer_product() and type traits +#include <boost/accumulators/statistics/weighted_mean.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_covariance_impl + // + /** + @brief Weighted Covariance Estimator + + An iterative Monte Carlo estimator for the weighted covariance \f$\mathrm{Cov}(X,X')\f$, where \f$X\f$ is a sample + and \f$X'\f$ a variate, is given by: + + \f[ + \hat{c}_n = \frac{\bar{w}_n-w_n}{\bar{w}_n} \hat{c}_{n-1} + \frac{w_n}{\bar{w}_n-w_n}(X_n - \hat{\mu}_n)(X_n' - \hat{\mu}_n'), + \quad n\ge2,\quad\hat{c}_1 = 0, + \f] + + \f$\hat{\mu}_n\f$ and \f$\hat{\mu}_n'\f$ being the weighted means of the samples and variates and + \f$\bar{w}_n\f$ the sum of the \f$n\f$ first weights \f$w_i\f$. + */ + template<typename Sample, typename Weight, typename VariateType, typename VariateTag> + struct weighted_covariance_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::average<Sample, std::size_t>::result_type>::result_type weighted_sample_type; + typedef typename numeric::functional::multiplies<Weight, typename numeric::functional::average<VariateType, std::size_t>::result_type>::result_type weighted_variate_type; + // for boost::result_of + typedef typename numeric::functional::outer_product<weighted_sample_type, weighted_variate_type>::result_type result_type; + + template<typename Args> + weighted_covariance_impl(Args const &args) + : cov_( + numeric::outer_product( + numeric::average(args[sample | Sample()], (std::size_t)1) + * numeric::one<Weight>::value + , numeric::average(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1) + * numeric::one<Weight>::value + ) + ) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + if (cnt > 1) + { + extractor<tag::weighted_mean_of_variates<VariateType, VariateTag> > const some_weighted_mean_of_variates = {}; + + this->cov_ = this->cov_ * (sum_of_weights(args) - args[weight]) / sum_of_weights(args) + + numeric::outer_product( + some_weighted_mean_of_variates(args) - args[parameter::keyword<VariateTag>::get()] + , weighted_mean(args) - args[sample] + ) * args[weight] / (sum_of_weights(args) - args[weight]); + } + } + + result_type result(dont_care) const + { + return this->cov_; + } + + private: + result_type cov_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_covariance +// +namespace tag +{ + template<typename VariateType, typename VariateTag> + struct weighted_covariance + : depends_on<count, sum_of_weights, weighted_mean, weighted_mean_of_variates<VariateType, VariateTag> > + { + typedef accumulators::impl::weighted_covariance_impl<mpl::_1, mpl::_2, VariateType, VariateTag> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_covariance +// +namespace extract +{ + extractor<tag::abstract_covariance> const weighted_covariance = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_covariance) +} + +using extract::weighted_covariance; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_density.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_density.hpp new file mode 100644 index 0000000..68dc639 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_density.hpp
@@ -0,0 +1,221 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_density.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_DENSITY_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_DENSITY_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <functional> +#include <boost/range.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/min.hpp> +#include <boost/accumulators/statistics/density.hpp> // for named parameters density_cache_size and density_num_bins + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_density_impl + // density histogram for weighted samples + /** + @brief Histogram density estimator for weighted samples + + The histogram density estimator returns a histogram of the sample distribution. The positions and sizes of the bins + are determined using a specifiable number of cached samples (cache_size). The range between the minimum and the + maximum of the cached samples is subdivided into a specifiable number of bins (num_bins) of same size. Additionally, + an under- and an overflow bin is added to capture future under- and overflow samples. Once the bins are determined, + the cached samples and all subsequent samples are added to the correct bins. At the end, a range of std::pair is + returned, where each pair contains the position of the bin (lower bound) and the sum of the weights (normalized with the + sum of all weights). + + @param density_cache_size Number of first samples used to determine min and max. + @param density_num_bins Number of bins (two additional bins collect under- and overflow samples). + */ + template<typename Sample, typename Weight> + struct weighted_density_impl + : accumulator_base + { + typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range<typename histogram_type::iterator> result_type; + + template<typename Args> + weighted_density_impl(Args const &args) + : cache_size(args[density_cache_size]) + , cache(cache_size) + , num_bins(args[density_num_bins]) + , samples_in_bin(num_bins + 2, 0.) + , bin_positions(num_bins + 2) + , histogram( + num_bins + 2 + , std::make_pair( + numeric::average(args[sample | Sample()],(std::size_t)1) + , numeric::average(args[sample | Sample()],(std::size_t)1) + ) + ) + , is_dirty(true) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty = true; + + std::size_t cnt = count(args); + + // Fill up cache with cache_size first samples + if (cnt <= this->cache_size) + { + this->cache[cnt - 1] = std::make_pair(args[sample], args[weight]); + } + + // Once cache_size samples have been accumulated, create num_bins bins of same size between + // the minimum and maximum of the cached samples as well as an under- and an overflow bin. + // Store their lower bounds (bin_positions) and fill the bins with the cached samples (samples_in_bin). + if (cnt == this->cache_size) + { + float_type minimum = numeric::average((min)(args),(std::size_t)1); + float_type maximum = numeric::average((max)(args),(std::size_t)1); + float_type bin_size = numeric::average(maximum - minimum, this->num_bins); + + // determine bin positions (their lower bounds) + for (std::size_t i = 0; i < this->num_bins + 2; ++i) + { + this->bin_positions[i] = minimum + (i - 1.) * bin_size; + } + + for (typename histogram_type::const_iterator iter = this->cache.begin(); iter != this->cache.end(); ++iter) + { + if (iter->first < this->bin_positions[1]) + { + this->samples_in_bin[0] += iter->second; + } + else if (iter->first >= this->bin_positions[this->num_bins + 1]) + { + this->samples_in_bin[this->num_bins + 1] += iter->second; + } + else + { + typename array_type::iterator it = std::upper_bound( + this->bin_positions.begin() + , this->bin_positions.end() + , iter->first + ); + + std::size_t d = std::distance(this->bin_positions.begin(), it); + this->samples_in_bin[d - 1] += iter->second; + } + } + } + // Add each subsequent sample to the correct bin + else if (cnt > this->cache_size) + { + if (args[sample] < this->bin_positions[1]) + { + this->samples_in_bin[0] += args[weight]; + } + else if (args[sample] >= this->bin_positions[this->num_bins + 1]) + { + this->samples_in_bin[this->num_bins + 1] += args[weight]; + } + else + { + typename array_type::iterator it = std::upper_bound( + this->bin_positions.begin() + , this->bin_positions.end() + , args[sample] + ); + + std::size_t d = std::distance(this->bin_positions.begin(), it); + this->samples_in_bin[d - 1] += args[weight]; + } + } + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + // creates a vector of std::pair where each pair i holds + // the values bin_positions[i] (x-axis of histogram) and + // samples_in_bin[i] / cnt (y-axis of histogram). + + for (std::size_t i = 0; i < this->num_bins + 2; ++i) + { + this->histogram[i] = std::make_pair(this->bin_positions[i], numeric::average(this->samples_in_bin[i], sum_of_weights(args))); + } + } + + // returns a range of pairs + return make_iterator_range(this->histogram); + } + + private: + std::size_t cache_size; // number of cached samples + histogram_type cache; // cache to store the first cache_size samples with their weights as std::pair + std::size_t num_bins; // number of bins + array_type samples_in_bin; // number of samples in each bin + array_type bin_positions; // lower bounds of bins + mutable histogram_type histogram; // histogram + mutable bool is_dirty; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_density +// +namespace tag +{ + struct weighted_density + : depends_on<count, sum_of_weights, min, max> + , density_cache_size + , density_num_bins + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_density_impl<mpl::_1, mpl::_2> impl; + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + static boost::parameter::keyword<density_cache_size> const cache_size; + static boost::parameter::keyword<density_num_bins> const num_bins; + #endif + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_density +// +namespace extract +{ + extractor<tag::density> const weighted_density = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_density) +} + +using extract::weighted_density; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_extended_p_square.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_extended_p_square.hpp new file mode 100644 index 0000000..7d7f38c --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_extended_p_square.hpp
@@ -0,0 +1,290 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_extended_p_square.hpp +// +// Copyright 2005 Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_EXTENDED_P_SQUARE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_EXTENDED_P_SQUARE_HPP_DE_01_01_2006 + +#include <vector> +#include <functional> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/iterator/transform_iterator.hpp> +#include <boost/iterator/counting_iterator.hpp> +#include <boost/iterator/permutation_iterator.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/times2_iterator.hpp> +#include <boost/accumulators/statistics/extended_p_square.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_extended_p_square_impl + // multiple quantile estimation with weighted samples + /** + @brief Multiple quantile estimation with the extended \f$P^2\f$ algorithm for weighted samples + + This version of the extended \f$P^2\f$ algorithm extends the extended \f$P^2\f$ algorithm to + support weighted samples. The extended \f$P^2\f$ algorithm dynamically estimates several + quantiles without storing samples. Assume that \f$m\f$ quantiles + \f$\xi_{p_1}, \ldots, \xi_{p_m}\f$ are to be estimated. Instead of storing the whole sample + cumulative distribution, the algorithm maintains only \f$m+2\f$ principal markers and + \f$m+1\f$ middle markers, whose positions are updated with each sample and whose heights + are adjusted (if necessary) using a piecewise-parablic formula. The heights of the principal + markers are the current estimates of the quantiles and are returned as an iterator range. + + For further details, see + + K. E. E. Raatikainen, Simultaneous estimation of several quantiles, Simulation, Volume 49, + Number 4 (October), 1986, p. 159-164. + + The extended \f$ P^2 \f$ algorithm generalizess the \f$ P^2 \f$ algorithm of + + R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param extended_p_square_probabilities A vector of quantile probabilities. + */ + template<typename Sample, typename Weight> + struct weighted_extended_p_square_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range< + detail::lvalue_index_iterator< + permutation_iterator< + typename array_type::const_iterator + , detail::times2_iterator + > + > + > result_type; + + template<typename Args> + weighted_extended_p_square_impl(Args const &args) + : probabilities( + boost::begin(args[extended_p_square_probabilities]) + , boost::end(args[extended_p_square_probabilities]) + ) + , heights(2 * probabilities.size() + 3) + , actual_positions(heights.size()) + , desired_positions(heights.size()) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + std::size_t sample_cell = 1; // k + std::size_t num_quantiles = this->probabilities.size(); + + // m+2 principal markers and m+1 middle markers + std::size_t num_markers = 2 * num_quantiles + 3; + + // first accumulate num_markers samples + if(cnt <= num_markers) + { + this->heights[cnt - 1] = args[sample]; + this->actual_positions[cnt - 1] = args[weight]; + + // complete the initialization of heights (and actual_positions) by sorting + if(cnt == num_markers) + { + // TODO: we need to sort the initial samples (in heights) in ascending order and + // sort their weights (in actual_positions) the same way. The following lines do + // it, but there must be a better and more efficient way of doing this. + typename array_type::iterator it_begin, it_end, it_min; + + it_begin = this->heights.begin(); + it_end = this->heights.end(); + + std::size_t pos = 0; + + while (it_begin != it_end) + { + it_min = std::min_element(it_begin, it_end); + std::size_t d = std::distance(it_begin, it_min); + std::swap(*it_begin, *it_min); + std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); + ++it_begin; + ++pos; + } + + // calculate correct initial actual positions + for (std::size_t i = 1; i < num_markers; ++i) + { + actual_positions[i] += actual_positions[i - 1]; + } + } + } + else + { + if(args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + this->actual_positions[0] = args[weight]; + sample_cell = 1; + } + else if(args[sample] >= this->heights[num_markers - 1]) + { + this->heights[num_markers - 1] = args[sample]; + sample_cell = num_markers - 1; + } + else + { + // find cell k = sample_cell such that heights[k-1] <= sample < heights[k] + + typedef typename array_type::iterator iterator; + iterator it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // update actual position of all markers above sample_cell + for(std::size_t i = sample_cell; i < num_markers; ++i) + { + this->actual_positions[i] += args[weight]; + } + + // compute desired positions + { + this->desired_positions[0] = this->actual_positions[0]; + this->desired_positions[num_markers - 1] = sum_of_weights(args); + this->desired_positions[1] = (sum_of_weights(args) - this->actual_positions[0]) * probabilities[0] + / 2. + this->actual_positions[0]; + this->desired_positions[num_markers - 2] = (sum_of_weights(args) - this->actual_positions[0]) + * (probabilities[num_quantiles - 1] + 1.) + / 2. + this->actual_positions[0]; + + for (std::size_t i = 0; i < num_quantiles; ++i) + { + this->desired_positions[2 * i + 2] = (sum_of_weights(args) - this->actual_positions[0]) + * probabilities[i] + this->actual_positions[0]; + } + + for (std::size_t i = 1; i < num_quantiles; ++i) + { + this->desired_positions[2 * i + 1] = (sum_of_weights(args) - this->actual_positions[0]) + * (probabilities[i - 1] + probabilities[i]) + / 2. + this->actual_positions[0]; + } + } + + // adjust heights and actual_positions of markers 1 to num_markers - 2 if necessary + for (std::size_t i = 1; i <= num_markers - 2; ++i) + { + // offset to desired position + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; + float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; + + if((d >= 1 && dp > 1) || (d <= -1 && dm < -1)) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + float_type h = this->heights[i] + sign_d / (dp - dm) * ((sign_d - dm)*hp + (dp - sign_d) * hm); + + // try adjusting heights[i] using p-squared formula + if(this->heights[i - 1] < h && h < this->heights[i + 1]) + { + this->heights[i] = h; + } + else + { + // use linear formula + if(d > 0) + { + this->heights[i] += hp; + } + if(d < 0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + result_type result(dont_care) const + { + // for i in [1,probabilities.size()], return heights[i * 2] + detail::times2_iterator idx_begin = detail::make_times2_iterator(1); + detail::times2_iterator idx_end = detail::make_times2_iterator(this->probabilities.size() + 1); + + return result_type( + make_permutation_iterator(this->heights.begin(), idx_begin) + , make_permutation_iterator(this->heights.begin(), idx_end) + ); + } + + private: + array_type probabilities; // the quantile probabilities + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // d_i + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_extended_p_square +// +namespace tag +{ + struct weighted_extended_p_square + : depends_on<count, sum_of_weights> + , extended_p_square_probabilities + { + typedef accumulators::impl::weighted_extended_p_square_impl<mpl::_1, mpl::_2> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_extended_p_square +// +namespace extract +{ + extractor<tag::weighted_extended_p_square> const weighted_extended_p_square = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_extended_p_square) +} + +using extract::weighted_extended_p_square; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_kurtosis.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_kurtosis.hpp new file mode 100644 index 0000000..d51db5c --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_kurtosis.hpp
@@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_kurtosis.hpp +// +// Copyright 2006 Olivier Gygi, Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_KURTOSIS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_KURTOSIS_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/weighted_moment.hpp> +#include <boost/accumulators/statistics/weighted_mean.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_kurtosis_impl + /** + @brief Kurtosis estimation for weighted samples + + The kurtosis of a sample distribution is defined as the ratio of the 4th central moment and the square of the 2nd central + moment (the variance) of the samples, minus 3. The term \f$ -3 \f$ is added in order to ensure that the normal distribution + has zero kurtosis. The kurtosis can also be expressed by the simple moments: + + \f[ + \hat{g}_2 = + \frac + {\widehat{m}_n^{(4)}-4\widehat{m}_n^{(3)}\hat{\mu}_n+6\widehat{m}_n^{(2)}\hat{\mu}_n^2-3\hat{\mu}_n^4} + {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^2} - 3, + \f] + + where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the + \f$ n \f$ samples. + + The kurtosis estimator for weighted samples is formally identical to the estimator for unweighted samples, except that + the weighted counterparts of all measures it depends on are to be taken. + */ + template<typename Sample, typename Weight> + struct weighted_kurtosis_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, weighted_sample>::result_type result_type; + + weighted_kurtosis_impl(dont_care) + { + } + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average( + accumulators::weighted_moment<4>(args) + - 4. * accumulators::weighted_moment<3>(args) * weighted_mean(args) + + 6. * accumulators::weighted_moment<2>(args) * weighted_mean(args) * weighted_mean(args) + - 3. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) + , ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) + * ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) + ) - 3.; + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_kurtosis +// +namespace tag +{ + struct weighted_kurtosis + : depends_on<weighted_mean, weighted_moment<2>, weighted_moment<3>, weighted_moment<4> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_kurtosis_impl<mpl::_1, mpl::_2> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_kurtosis +// +namespace extract +{ + extractor<tag::weighted_kurtosis> const weighted_kurtosis = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_kurtosis) +} + +using extract::weighted_kurtosis; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_mean.hpp new file mode 100644 index 0000000..c8d6513 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_mean.hpp
@@ -0,0 +1,189 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_mean.hpp +// +// Copyright 2006 Eric Niebler, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEAN_HPP_EAN_03_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEAN_HPP_EAN_03_11_2005 + +#include <boost/mpl/assert.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/weights.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/statistics/weighted_sum.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_mean_impl + // lazy, by default + template<typename Sample, typename Weight, typename Tag> + struct weighted_mean_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type; + + weighted_mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + typedef + typename mpl::if_< + is_same<Tag, tag::sample> + , tag::weighted_sum + , tag::weighted_sum_of_variates<Sample, Tag> + >::type + weighted_sum_tag; + + extractor<weighted_sum_tag> const some_weighted_sum = {}; + + return numeric::average(some_weighted_sum(args), sum_of_weights(args)); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // immediate_weighted_mean_impl + // immediate + template<typename Sample, typename Weight, typename Tag> + struct immediate_weighted_mean_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type; + + template<typename Args> + immediate_weighted_mean_impl(Args const &args) + : mean( + numeric::average( + args[parameter::keyword<Tag>::get() | Sample()] + * numeric::one<Weight>::value + , numeric::one<Weight>::value + ) + ) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + // Matthias: + // need to pass the argument pack since the weight might be an external + // accumulator set passed as a named parameter + Weight w_sum = sum_of_weights(args); + Weight w = args[weight]; + weighted_sample const &s = args[parameter::keyword<Tag>::get()] * w; + this->mean = numeric::average(this->mean * (w_sum - w) + s, w_sum); + } + + result_type result(dont_care) const + { + return this->mean; + } + + private: + result_type mean; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_mean +// tag::immediate_weighted_mean +// +namespace tag +{ + struct weighted_mean + : depends_on<sum_of_weights, weighted_sum> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_mean_impl<mpl::_1, mpl::_2, tag::sample> impl; + }; + struct immediate_weighted_mean + : depends_on<sum_of_weights> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_weighted_mean_impl<mpl::_1, mpl::_2, tag::sample> impl; + }; + template<typename VariateType, typename VariateTag> + struct weighted_mean_of_variates + : depends_on<sum_of_weights, weighted_sum_of_variates<VariateType, VariateTag> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_mean_impl<VariateType, mpl::_2, VariateTag> impl; + }; + template<typename VariateType, typename VariateTag> + struct immediate_weighted_mean_of_variates + : depends_on<sum_of_weights> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_weighted_mean_impl<VariateType, mpl::_2, VariateTag> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_mean +// extract::weighted_mean_of_variates +// +namespace extract +{ + extractor<tag::mean> const weighted_mean = {}; + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, weighted_mean_of_variates, (typename)(typename)) + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_mean) +} + +using extract::weighted_mean; +using extract::weighted_mean_of_variates; + +// weighted_mean(lazy) -> weighted_mean +template<> +struct as_feature<tag::weighted_mean(lazy)> +{ + typedef tag::weighted_mean type; +}; + +// weighted_mean(immediate) -> immediate_weighted_mean +template<> +struct as_feature<tag::weighted_mean(immediate)> +{ + typedef tag::immediate_weighted_mean type; +}; + +// weighted_mean_of_variates<VariateType, VariateTag>(lazy) -> weighted_mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::weighted_mean_of_variates<VariateType, VariateTag>(lazy)> +{ + typedef tag::weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +// weighted_mean_of_variates<VariateType, VariateTag>(immediate) -> immediate_weighted_mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::weighted_mean_of_variates<VariateType, VariateTag>(immediate)> +{ + typedef tag::immediate_weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_median.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_median.hpp new file mode 100644 index 0000000..46880c8 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_median.hpp
@@ -0,0 +1,237 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_median.hpp +// +// Copyright 2006 Eric Niebler, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEDIAN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MEDIAN_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/median.hpp> +#include <boost/accumulators/statistics/weighted_p_square_quantile.hpp> +#include <boost/accumulators/statistics/weighted_density.hpp> +#include <boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_median_impl + // + /** + @brief Median estimation for weighted samples based on the \f$P^2\f$ quantile estimator + + The \f$P^2\f$ algorithm for weighted samples is invoked with a quantile probability of 0.5. + */ + template<typename Sample> + struct weighted_median_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type; + + weighted_median_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return weighted_p_square_quantile_for_median(args); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // with_density_weighted_median_impl + // + /** + @brief Median estimation for weighted samples based on the density estimator + + The algorithm determines the bin in which the \f$0.5*cnt\f$-th sample lies, \f$cnt\f$ being + the total number of samples. It returns the approximate horizontal position of this sample, + based on a linear interpolation inside the bin. + */ + template<typename Sample> + struct with_density_weighted_median_impl + : accumulator_base + { + typedef typename numeric::functional::average<Sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef iterator_range<typename histogram_type::iterator> range_type; + // for boost::result_of + typedef float_type result_type; + + template<typename Args> + with_density_weighted_median_impl(Args const &args) + : sum(numeric::average(args[sample | Sample()], (std::size_t)1)) + , is_dirty(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty = true; + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + std::size_t cnt = count(args); + range_type histogram = weighted_density(args); + typename range_type::iterator it = histogram.begin(); + while (this->sum < 0.5 * cnt) + { + this->sum += it->second * cnt; + ++it; + } + --it; + float_type over = numeric::average(this->sum - 0.5 * cnt, it->second * cnt); + this->median = it->first * over + (it + 1)->first * ( 1. - over ); + } + + return this->median; + } + + private: + mutable float_type sum; + mutable bool is_dirty; + mutable float_type median; + }; + + /////////////////////////////////////////////////////////////////////////////// + // with_p_square_cumulative_distribution_weighted_median_impl + // + /** + @brief Median estimation for weighted samples based on the \f$P^2\f$ cumulative distribution estimator + + The algorithm determines the first (leftmost) bin with a height exceeding 0.5. It + returns the approximate horizontal position of where the cumulative distribution + equals 0.5, based on a linear interpolation inside the bin. + */ + template<typename Sample, typename Weight> + struct with_p_square_cumulative_distribution_weighted_median_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef iterator_range<typename histogram_type::iterator> range_type; + // for boost::result_of + typedef float_type result_type; + + with_p_square_cumulative_distribution_weighted_median_impl(dont_care) + : is_dirty(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty = true; + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + range_type histogram = weighted_p_square_cumulative_distribution(args); + typename range_type::iterator it = histogram.begin(); + while (it->second < 0.5) + { + ++it; + } + float_type over = numeric::average(it->second - 0.5, it->second - (it - 1)->second); + this->median = it->first * over + (it + 1)->first * ( 1. - over ); + } + + return this->median; + } + private: + mutable bool is_dirty; + mutable float_type median; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_median +// tag::with_density_weighted_median +// tag::with_p_square_cumulative_distribution_weighted_median +// +namespace tag +{ + struct weighted_median + : depends_on<weighted_p_square_quantile_for_median> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_median_impl<mpl::_1> impl; + }; + struct with_density_weighted_median + : depends_on<count, weighted_density> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::with_density_weighted_median_impl<mpl::_1> impl; + }; + struct with_p_square_cumulative_distribution_weighted_median + : depends_on<weighted_p_square_cumulative_distribution> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::with_p_square_cumulative_distribution_weighted_median_impl<mpl::_1, mpl::_2> impl; + }; + +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_median +// +namespace extract +{ + extractor<tag::median> const weighted_median = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_median) +} + +using extract::weighted_median; +// weighted_median(with_p_square_quantile) -> weighted_median +template<> +struct as_feature<tag::weighted_median(with_p_square_quantile)> +{ + typedef tag::weighted_median type; +}; + +// weighted_median(with_density) -> with_density_weighted_median +template<> +struct as_feature<tag::weighted_median(with_density)> +{ + typedef tag::with_density_weighted_median type; +}; + +// weighted_median(with_p_square_cumulative_distribution) -> with_p_square_cumulative_distribution_weighted_median +template<> +struct as_feature<tag::weighted_median(with_p_square_cumulative_distribution)> +{ + typedef tag::with_p_square_cumulative_distribution_weighted_median type; +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_moment.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_moment.hpp new file mode 100644 index 0000000..f49c362 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_moment.hpp
@@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_moment.hpp +// +// Copyright 2006, Eric Niebler, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MOMENT_HPP_EAN_15_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_MOMENT_HPP_EAN_15_11_2005 + +#include <boost/config/no_tr1/cmath.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/moment.hpp> // for pow() +#include <boost/accumulators/statistics/sum.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_moment_impl + template<typename N, typename Sample, typename Weight> + struct weighted_moment_impl + : accumulator_base // TODO: also depends_on sum of powers + { + BOOST_MPL_ASSERT_RELATION(N::value, >, 0); + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type; + + template<typename Args> + weighted_moment_impl(Args const &args) + : sum(args[sample | Sample()] * numeric::one<Weight>::value) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->sum += args[weight] * numeric::pow(args[sample], N()); + } + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average(this->sum, sum_of_weights(args)); + } + + private: + weighted_sample sum; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_moment +// +namespace tag +{ + template<int N> + struct weighted_moment + : depends_on<count, sum_of_weights> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_moment_impl<mpl::int_<N>, mpl::_1, mpl::_2> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_moment +// +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, weighted_moment, (int)) +} + +using extract::weighted_moment; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp new file mode 100644 index 0000000..290f090 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_cumulative_distribution.hpp
@@ -0,0 +1,262 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_p_square_cumulative_distribution.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_CUMULATIVE_DISTRIBUTION_HPP_DE_01_01_2006 + +#include <vector> +#include <functional> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/range.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/p_square_cumulative_distribution.hpp> // for named parameter p_square_cumulative_distribution_num_cells + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_p_square_cumulative_distribution_impl + // cumulative distribution calculation (as histogram) + /** + @brief Histogram calculation of the cumulative distribution with the \f$P^2\f$ algorithm for weighted samples + + A histogram of the sample cumulative distribution is computed dynamically without storing samples + based on the \f$ P^2 \f$ algorithm for weighted samples. The returned histogram has a specifiable + amount (num_cells) equiprobable (and not equal-sized) cells. + + Note that applying importance sampling results in regions to be more and other regions to be less + accurately estimated than without importance sampling, i.e., with unweighted samples. + + For further details, see + + R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param p_square_cumulative_distribution_num_cells + */ + template<typename Sample, typename Weight> + struct weighted_p_square_cumulative_distribution_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + typedef std::vector<std::pair<float_type, float_type> > histogram_type; + typedef std::vector<float_type> array_type; + // for boost::result_of + typedef iterator_range<typename histogram_type::iterator> result_type; + + template<typename Args> + weighted_p_square_cumulative_distribution_impl(Args const &args) + : num_cells(args[p_square_cumulative_distribution_num_cells]) + , heights(num_cells + 1) + , actual_positions(num_cells + 1) + , desired_positions(num_cells + 1) + , histogram(num_cells + 1) + , is_dirty(true) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty = true; + + std::size_t cnt = count(args); + std::size_t sample_cell = 1; // k + std::size_t b = this->num_cells; + + // accumulate num_cells + 1 first samples + if (cnt <= b + 1) + { + this->heights[cnt - 1] = args[sample]; + this->actual_positions[cnt - 1] = args[weight]; + + // complete the initialization of heights by sorting + if (cnt == b + 1) + { + //std::sort(this->heights.begin(), this->heights.end()); + + // TODO: we need to sort the initial samples (in heights) in ascending order and + // sort their weights (in actual_positions) the same way. The following lines do + // it, but there must be a better and more efficient way of doing this. + typename array_type::iterator it_begin, it_end, it_min; + + it_begin = this->heights.begin(); + it_end = this->heights.end(); + + std::size_t pos = 0; + + while (it_begin != it_end) + { + it_min = std::min_element(it_begin, it_end); + std::size_t d = std::distance(it_begin, it_min); + std::swap(*it_begin, *it_min); + std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); + ++it_begin; + ++pos; + } + + // calculate correct initial actual positions + for (std::size_t i = 1; i < b; ++i) + { + this->actual_positions[i] += this->actual_positions[i - 1]; + } + } + } + else + { + // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values + if (args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + this->actual_positions[0] = args[weight]; + sample_cell = 1; + } + else if (this->heights[b] <= args[sample]) + { + this->heights[b] = args[sample]; + sample_cell = b; + } + else + { + typename array_type::iterator it; + it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // increment positions of markers above sample_cell + for (std::size_t i = sample_cell; i < b + 1; ++i) + { + this->actual_positions[i] += args[weight]; + } + + // determine desired marker positions + for (std::size_t i = 1; i < b + 1; ++i) + { + this->desired_positions[i] = this->actual_positions[0] + + numeric::average((i-1) * (sum_of_weights(args) - this->actual_positions[0]), b); + } + + // adjust heights of markers 2 to num_cells if necessary + for (std::size_t i = 1; i < b; ++i) + { + // offset to desire position + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; + float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; + + if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + // try adjusting heights[i] using p-squared formula + float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); + + if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) + { + this->heights[i] = h; + } + else + { + // use linear formula + if (d>0) + { + this->heights[i] += hp; + } + if (d<0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty) + { + this->is_dirty = false; + + // creates a vector of std::pair where each pair i holds + // the values heights[i] (x-axis of histogram) and + // actual_positions[i] / sum_of_weights (y-axis of histogram) + + for (std::size_t i = 0; i < this->histogram.size(); ++i) + { + this->histogram[i] = std::make_pair(this->heights[i], numeric::average(this->actual_positions[i], sum_of_weights(args))); + } + } + + return make_iterator_range(this->histogram); + } + + private: + std::size_t num_cells; // number of cells b + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // n'_i + mutable histogram_type histogram; // histogram + mutable bool is_dirty; + }; + +} // namespace detail + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_p_square_cumulative_distribution +// +namespace tag +{ + struct weighted_p_square_cumulative_distribution + : depends_on<count, sum_of_weights> + , p_square_cumulative_distribution_num_cells + { + typedef accumulators::impl::weighted_p_square_cumulative_distribution_impl<mpl::_1, mpl::_2> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_p_square_cumulative_distribution +// +namespace extract +{ + extractor<tag::weighted_p_square_cumulative_distribution> const weighted_p_square_cumulative_distribution = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_cumulative_distribution) +} + +using extract::weighted_p_square_cumulative_distribution; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_quantile.hpp new file mode 100644 index 0000000..4e0d4ef --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_p_square_quantile.hpp
@@ -0,0 +1,254 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_p_square_quantile.hpp +// +// Copyright 2005 Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006 + +#include <functional> +#include <boost/array.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl { + /////////////////////////////////////////////////////////////////////////////// + // weighted_p_square_quantile_impl + // single quantile estimation with weighted samples + /** + @brief Single quantile estimation with the \f$P^2\f$ algorithm for weighted samples + + This version of the \f$P^2\f$ algorithm extends the \f$P^2\f$ algorithm to support weighted samples. + The \f$P^2\f$ algorithm estimates a quantile dynamically without storing samples. Instead of + storing the whole sample cumulative distribution, only five points (markers) are stored. The heights + of these markers are the minimum and the maximum of the samples and the current estimates of the + \f$(p/2)\f$-, \f$p\f$ - and \f$(1+p)/2\f$ -quantiles. Their positions are equal to the number + of samples that are smaller or equal to the markers. Each time a new sample is added, the + positions of the markers are updated and if necessary their heights are adjusted using a piecewise- + parabolic formula. + + For further details, see + + R. Jain and I. Chlamtac, The P^2 algorithmus for dynamic calculation of quantiles and + histograms without storing observations, Communications of the ACM, + Volume 28 (October), Number 10, 1985, p. 1076-1085. + + @param quantile_probability + */ + template<typename Sample, typename Weight, typename Impl> + struct weighted_p_square_quantile_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + typedef array<float_type, 5> array_type; + // for boost::result_of + typedef float_type result_type; + + template<typename Args> + weighted_p_square_quantile_impl(Args const &args) + : p(is_same<Impl, for_median>::value ? 0.5 : args[quantile_probability | 0.5]) + , heights() + , actual_positions() + , desired_positions() + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + // accumulate 5 first samples + if (cnt <= 5) + { + this->heights[cnt - 1] = args[sample]; + + // In this initialization phase, actual_positions stores the weights of the + // inital samples that are needed at the end of the initialization phase to + // compute the correct initial positions of the markers. + this->actual_positions[cnt - 1] = args[weight]; + + // complete the initialization of heights and actual_positions by sorting + if (cnt == 5) + { + // TODO: we need to sort the initial samples (in heights) in ascending order and + // sort their weights (in actual_positions) the same way. The following lines do + // it, but there must be a better and more efficient way of doing this. + typename array_type::iterator it_begin, it_end, it_min; + + it_begin = this->heights.begin(); + it_end = this->heights.end(); + + std::size_t pos = 0; + + while (it_begin != it_end) + { + it_min = std::min_element(it_begin, it_end); + std::size_t d = std::distance(it_begin, it_min); + std::swap(*it_begin, *it_min); + std::swap(this->actual_positions[pos], this->actual_positions[pos + d]); + ++it_begin; + ++pos; + } + + // calculate correct initial actual positions + for (std::size_t i = 1; i < 5; ++i) + { + this->actual_positions[i] += this->actual_positions[i - 1]; + } + } + } + else + { + std::size_t sample_cell = 1; // k + + // find cell k such that heights[k-1] <= args[sample] < heights[k] and adjust extreme values + if (args[sample] < this->heights[0]) + { + this->heights[0] = args[sample]; + this->actual_positions[0] = args[weight]; + sample_cell = 1; + } + else if (this->heights[4] <= args[sample]) + { + this->heights[4] = args[sample]; + sample_cell = 4; + } + else + { + typedef typename array_type::iterator iterator; + iterator it = std::upper_bound( + this->heights.begin() + , this->heights.end() + , args[sample] + ); + + sample_cell = std::distance(this->heights.begin(), it); + } + + // increment positions of markers above sample_cell + for (std::size_t i = sample_cell; i < 5; ++i) + { + this->actual_positions[i] += args[weight]; + } + + // update desired positions for all markers + this->desired_positions[0] = this->actual_positions[0]; + this->desired_positions[1] = (sum_of_weights(args) - this->actual_positions[0]) + * this->p/2. + this->actual_positions[0]; + this->desired_positions[2] = (sum_of_weights(args) - this->actual_positions[0]) + * this->p + this->actual_positions[0]; + this->desired_positions[3] = (sum_of_weights(args) - this->actual_positions[0]) + * (1. + this->p)/2. + this->actual_positions[0]; + this->desired_positions[4] = sum_of_weights(args); + + // adjust height and actual positions of markers 1 to 3 if necessary + for (std::size_t i = 1; i <= 3; ++i) + { + // offset to desired positions + float_type d = this->desired_positions[i] - this->actual_positions[i]; + + // offset to next position + float_type dp = this->actual_positions[i + 1] - this->actual_positions[i]; + + // offset to previous position + float_type dm = this->actual_positions[i - 1] - this->actual_positions[i]; + + // height ds + float_type hp = (this->heights[i + 1] - this->heights[i]) / dp; + float_type hm = (this->heights[i - 1] - this->heights[i]) / dm; + + if ( ( d >= 1. && dp > 1. ) || ( d <= -1. && dm < -1. ) ) + { + short sign_d = static_cast<short>(d / std::abs(d)); + + // try adjusting heights[i] using p-squared formula + float_type h = this->heights[i] + sign_d / (dp - dm) * ( (sign_d - dm) * hp + (dp - sign_d) * hm ); + + if ( this->heights[i - 1] < h && h < this->heights[i + 1] ) + { + this->heights[i] = h; + } + else + { + // use linear formula + if (d>0) + { + this->heights[i] += hp; + } + if (d<0) + { + this->heights[i] -= hm; + } + } + this->actual_positions[i] += sign_d; + } + } + } + } + + result_type result(dont_care) const + { + return this->heights[2]; + } + + private: + float_type p; // the quantile probability p + array_type heights; // q_i + array_type actual_positions; // n_i + array_type desired_positions; // n'_i + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_p_square_quantile +// +namespace tag +{ + struct weighted_p_square_quantile + : depends_on<count, sum_of_weights> + { + typedef accumulators::impl::weighted_p_square_quantile_impl<mpl::_1, mpl::_2, regular> impl; + }; + struct weighted_p_square_quantile_for_median + : depends_on<count, sum_of_weights> + { + typedef accumulators::impl::weighted_p_square_quantile_impl<mpl::_1, mpl::_2, for_median> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_p_square_quantile +// extract::weighted_p_square_quantile_for_median +// +namespace extract +{ + extractor<tag::weighted_p_square_quantile> const weighted_p_square_quantile = {}; + extractor<tag::weighted_p_square_quantile_for_median> const weighted_p_square_quantile_for_median = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_quantile) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_p_square_quantile_for_median) +} + +using extract::weighted_p_square_quantile; +using extract::weighted_p_square_quantile_for_median; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp new file mode 100644 index 0000000..6d3017b --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp
@@ -0,0 +1,288 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_peaks_over_threshold.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_PEAKS_OVER_THRESHOLD_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <numeric> +#include <functional> +#include <boost/range.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> +#include <boost/accumulators/statistics/peaks_over_threshold.hpp> // for named parameters pot_threshold_value and pot_threshold_probability +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/tail_variate.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // weighted_peaks_over_threshold_impl + // works with an explicit threshold value and does not depend on order statistics of weighted samples + /** + @brief Weighted Peaks over Threshold Method for Weighted Quantile and Weighted Tail Mean Estimation + + @sa peaks_over_threshold_impl + + @param quantile_probability + @param pot_threshold_value + */ + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Weight, Sample>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef boost::tuple<float_type, float_type, float_type> result_type; + + template<typename Args> + weighted_peaks_over_threshold_impl(Args const &args) + : sign_((is_same<LeftRight, left>::value) ? -1 : 1) + , mu_(sign_ * numeric::average(args[sample | Sample()], (std::size_t)1)) + , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) + , w_sum_(numeric::average(args[weight | Weight()], (std::size_t)1)) + , threshold_(sign_ * args[pot_threshold_value]) + , fit_parameters_(boost::make_tuple(0., 0., 0.)) + , is_dirty_(true) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + this->is_dirty_ = true; + + if (this->sign_ * args[sample] > this->threshold_) + { + this->mu_ += args[weight] * args[sample]; + this->sigma2_ += args[weight] * args[sample] * args[sample]; + this->w_sum_ += args[weight]; + } + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty_) + { + this->is_dirty_ = false; + + this->mu_ = this->sign_ * numeric::average(this->mu_, this->w_sum_); + this->sigma2_ = numeric::average(this->sigma2_, this->w_sum_); + this->sigma2_ -= this->mu_ * this->mu_; + + float_type threshold_probability = numeric::average(sum_of_weights(args) - this->w_sum_, sum_of_weights(args)); + + float_type tmp = numeric::average(( this->mu_ - this->threshold_ )*( this->mu_ - this->threshold_ ), this->sigma2_); + float_type xi_hat = 0.5 * ( 1. - tmp ); + float_type beta_hat = 0.5 * ( this->mu_ - this->threshold_ ) * ( 1. + tmp ); + float_type beta_bar = beta_hat * std::pow(1. - threshold_probability, xi_hat); + float_type u_bar = this->threshold_ - beta_bar * ( std::pow(1. - threshold_probability, -xi_hat) - 1.)/xi_hat; + this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); + } + + return this->fit_parameters_; + } + + private: + short sign_; // for left tail fitting, mirror the extreme values + mutable float_type mu_; // mean of samples above threshold + mutable float_type sigma2_; // variance of samples above threshold + mutable float_type w_sum_; // sum of weights of samples above threshold + float_type threshold_; + mutable result_type fit_parameters_; // boost::tuple that stores fit parameters + mutable bool is_dirty_; + }; + + /////////////////////////////////////////////////////////////////////////////// + // weighted_peaks_over_threshold_prob_impl + // determines threshold from a given threshold probability using order statistics + /** + @brief Peaks over Threshold Method for Quantile and Tail Mean Estimation + + @sa weighted_peaks_over_threshold_impl + + @param quantile_probability + @param pot_threshold_probability + */ + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_prob_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Weight, Sample>::result_type weighted_sample; + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type float_type; + // for boost::result_of + typedef boost::tuple<float_type, float_type, float_type> result_type; + + template<typename Args> + weighted_peaks_over_threshold_prob_impl(Args const &args) + : sign_((is_same<LeftRight, left>::value) ? -1 : 1) + , mu_(sign_ * numeric::average(args[sample | Sample()], (std::size_t)1)) + , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) + , threshold_probability_(args[pot_threshold_probability]) + , fit_parameters_(boost::make_tuple(0., 0., 0.)) + , is_dirty_(true) + { + } + + void operator ()(dont_care) + { + this->is_dirty_ = true; + } + + template<typename Args> + result_type result(Args const &args) const + { + if (this->is_dirty_) + { + this->is_dirty_ = false; + + float_type threshold = sum_of_weights(args) + * ( ( is_same<LeftRight, left>::value ) ? this->threshold_probability_ : 1. - this->threshold_probability_ ); + + std::size_t n = 0; + Weight sum = Weight(0); + + while (sum < threshold) + { + if (n < static_cast<std::size_t>(tail_weights(args).size())) + { + mu_ += *(tail_weights(args).begin() + n) * *(tail(args).begin() + n); + sigma2_ += *(tail_weights(args).begin() + n) * *(tail(args).begin() + n) * (*(tail(args).begin() + n)); + sum += *(tail_weights(args).begin() + n); + n++; + } + else + { + if (std::numeric_limits<float_type>::has_quiet_NaN) + { + return boost::make_tuple( + std::numeric_limits<float_type>::quiet_NaN() + , std::numeric_limits<float_type>::quiet_NaN() + , std::numeric_limits<float_type>::quiet_NaN() + ); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return boost::make_tuple(Sample(0), Sample(0), Sample(0)); + } + } + } + + float_type u = *(tail(args).begin() + n - 1) * this->sign_; + + + this->mu_ = this->sign_ * numeric::average(this->mu_, sum); + this->sigma2_ = numeric::average(this->sigma2_, sum); + this->sigma2_ -= this->mu_ * this->mu_; + + if (is_same<LeftRight, left>::value) + this->threshold_probability_ = 1. - this->threshold_probability_; + + float_type tmp = numeric::average(( this->mu_ - u )*( this->mu_ - u ), this->sigma2_); + float_type xi_hat = 0.5 * ( 1. - tmp ); + float_type beta_hat = 0.5 * ( this->mu_ - u ) * ( 1. + tmp ); + float_type beta_bar = beta_hat * std::pow(1. - threshold_probability_, xi_hat); + float_type u_bar = u - beta_bar * ( std::pow(1. - threshold_probability_, -xi_hat) - 1.)/xi_hat; + this->fit_parameters_ = boost::make_tuple(u_bar, beta_bar, xi_hat); + + } + + return this->fit_parameters_; + } + + private: + short sign_; // for left tail fitting, mirror the extreme values + mutable float_type mu_; // mean of samples above threshold u + mutable float_type sigma2_; // variance of samples above threshold u + mutable float_type threshold_probability_; + mutable result_type fit_parameters_; // boost::tuple that stores fit parameters + mutable bool is_dirty_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_peaks_over_threshold +// +namespace tag +{ + template<typename LeftRight> + struct weighted_peaks_over_threshold + : depends_on<sum_of_weights> + , pot_threshold_value + { + /// INTERNAL ONLY + typedef accumulators::impl::weighted_peaks_over_threshold_impl<mpl::_1, mpl::_2, LeftRight> impl; + }; + + template<typename LeftRight> + struct weighted_peaks_over_threshold_prob + : depends_on<sum_of_weights, tail_weights<LeftRight> > + , pot_threshold_probability + { + /// INTERNAL ONLY + typedef accumulators::impl::weighted_peaks_over_threshold_prob_impl<mpl::_1, mpl::_2, LeftRight> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_peaks_over_threshold +// +namespace extract +{ + extractor<tag::abstract_peaks_over_threshold> const weighted_peaks_over_threshold = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_peaks_over_threshold) +} + +using extract::weighted_peaks_over_threshold; + +// weighted_peaks_over_threshold<LeftRight>(with_threshold_value) -> weighted_peaks_over_threshold<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_peaks_over_threshold<LeftRight>(with_threshold_value)> +{ + typedef tag::weighted_peaks_over_threshold<LeftRight> type; +}; + +// weighted_peaks_over_threshold<LeftRight>(with_threshold_probability) -> weighted_peaks_over_threshold_prob<LeftRight> +template<typename LeftRight> +struct as_feature<tag::weighted_peaks_over_threshold<LeftRight>(with_threshold_probability)> +{ + typedef tag::weighted_peaks_over_threshold_prob<LeftRight> type; +}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_skewness.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_skewness.hpp new file mode 100644 index 0000000..6ccbc45 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_skewness.hpp
@@ -0,0 +1,101 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_skewness.hpp +// +// Copyright 2006 Olivier Gygi, Daniel Egloff. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SKEWNESS_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/weighted_moment.hpp> +#include <boost/accumulators/statistics/weighted_mean.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_skewness_impl + /** + @brief Skewness estimation for weighted samples + + The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the \f$ 3/2 \f$-th power $ + of the 2nd central moment (the variance) of the samples. The skewness can also be expressed by the simple moments: + + \f[ + \hat{g}_1 = + \frac + {\widehat{m}_n^{(3)}-3\widehat{m}_n^{(2)}\hat{\mu}_n+2\hat{\mu}_n^3} + {\left(\widehat{m}_n^{(2)} - \hat{\mu}_n^{2}\right)^{3/2}} + \f] + + where \f$ \widehat{m}_n^{(i)} \f$ are the \f$ i \f$-th moment and \f$ \hat{\mu}_n \f$ the mean (first moment) of the + \f$ n \f$ samples. + + The skewness estimator for weighted samples is formally identical to the estimator for unweighted samples, except that + the weighted counterparts of all measures it depends on are to be taken. + */ + template<typename Sample, typename Weight> + struct weighted_skewness_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, weighted_sample>::result_type result_type; + + weighted_skewness_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return numeric::average( + accumulators::weighted_moment<3>(args) + - 3. * accumulators::weighted_moment<2>(args) * weighted_mean(args) + + 2. * weighted_mean(args) * weighted_mean(args) * weighted_mean(args) + , ( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) + * std::sqrt( accumulators::weighted_moment<2>(args) - weighted_mean(args) * weighted_mean(args) ) + ); + } + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_skewness +// +namespace tag +{ + struct weighted_skewness + : depends_on<weighted_mean, weighted_moment<2>, weighted_moment<3> > + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_skewness_impl<mpl::_1, mpl::_2> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_skewness +// +namespace extract +{ + extractor<tag::weighted_skewness> const weighted_skewness = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_skewness) +} + +using extract::weighted_skewness; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_sum.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_sum.hpp new file mode 100644 index 0000000..2715390 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_sum.hpp
@@ -0,0 +1,116 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_sum.hpp +// +// Copyright 2006 Eric Niebler, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/parameters/weight.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_sum_impl + template<typename Sample, typename Weight, typename Tag> + struct weighted_sum_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + + // for boost::result_of + typedef weighted_sample result_type; + + template<typename Args> + weighted_sum_impl(Args const &args) + : weighted_sum_( + args[parameter::keyword<Tag>::get() | Sample()] + * numeric::one<Weight>::value + ) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + // what about overflow? + this->weighted_sum_ += args[parameter::keyword<Tag>::get()] * args[weight]; + } + + result_type result(dont_care) const + { + return this->weighted_sum_; + } + + private: + + weighted_sample weighted_sum_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_sum +// +namespace tag +{ + struct weighted_sum + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_sum_impl<mpl::_1, mpl::_2, tag::sample> impl; + }; + + template<typename VariateType, typename VariateTag> + struct weighted_sum_of_variates + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_sum_impl<VariateType, mpl::_2, VariateTag> impl; + }; + + struct abstract_weighted_sum_of_variates + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_sum +// +namespace extract +{ + extractor<tag::weighted_sum> const weighted_sum = {}; + extractor<tag::abstract_weighted_sum_of_variates> const weighted_sum_of_variates = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_of_variates) +} + +using extract::weighted_sum; +using extract::weighted_sum_of_variates; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::weighted_sum_of_variates<VariateType, VariateTag> > + : feature_of<tag::abstract_weighted_sum_of_variates> +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_tail_mean.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_mean.hpp new file mode 100644 index 0000000..5bdee8a --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_mean.hpp
@@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_tail_mean.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_MEAN_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_MEAN_HPP_DE_01_01_2006 + +#include <numeric> +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_mean.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // coherent_weighted_tail_mean_impl + // + // TODO + + /////////////////////////////////////////////////////////////////////////////// + // non_coherent_weighted_tail_mean_impl + // + /** + @brief Estimation of the (non-coherent) weighted tail mean based on order statistics (for both left and right tails) + + + + An estimation of the non-coherent, weighted tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$ is given by the weighted mean + of the + + \f[ + \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} + \f] + + smallest samples (left tail) or the weighted mean of the + + \f[ + n + 1 - \rho = n + 1 - \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\} + \f] + + largest samples (right tail) above a quantile \f$\hat{q}_{\alpha}\f$ of level \f$\alpha\f$, \f$n\f$ being the total number of sample + and \f$\bar{w}_n\f$ the sum of all \f$n\f$ weights: + + \f[ + \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X) = \frac{\sum_{i=1}^{\lambda} w_i X_{i:n}}{\sum_{i=1}^{\lambda} w_i}, + \f] + + \f[ + \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X) = \frac{\sum_{i=\rho}^n w_i X_{i:n}}{\sum_{i=\rho}^n w_i}. + \f] + + @param quantile_probability + */ + template<typename Sample, typename Weight, typename LeftRight> + struct non_coherent_weighted_tail_mean_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, std::size_t>::result_type result_type; + + non_coherent_weighted_tail_mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + float_type threshold = sum_of_weights(args) + * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); + + std::size_t n = 0; + Weight sum = Weight(0); + + while (sum < threshold) + { + if (n < static_cast<std::size_t>(tail_weights(args).size())) + { + sum += *(tail_weights(args).begin() + n); + n++; + } + else + { + if (std::numeric_limits<result_type>::has_quiet_NaN) + { + return std::numeric_limits<result_type>::quiet_NaN(); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return result_type(0); + } + } + } + + return numeric::average( + std::inner_product( + tail(args).begin() + , tail(args).begin() + n + , tail_weights(args).begin() + , weighted_sample(0) + ) + , sum + ); + } + }; + +} // namespace impl + + +/////////////////////////////////////////////////////////////////////////////// +// tag::non_coherent_weighted_tail_mean<> +// +namespace tag +{ + template<typename LeftRight> + struct non_coherent_weighted_tail_mean + : depends_on<sum_of_weights, tail_weights<LeftRight> > + { + typedef accumulators::impl::non_coherent_weighted_tail_mean_impl<mpl::_1, mpl::_2, LeftRight> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::non_coherent_weighted_tail_mean; +// +namespace extract +{ + extractor<tag::abstract_non_coherent_tail_mean> const non_coherent_weighted_tail_mean = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(non_coherent_weighted_tail_mean) +} + +using extract::non_coherent_weighted_tail_mean; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_tail_quantile.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_quantile.hpp new file mode 100644 index 0000000..88c32d1 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_quantile.hpp
@@ -0,0 +1,146 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_tail_quantile.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_QUANTILE_HPP_DE_01_01_2006 + +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_quantile.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // weighted_tail_quantile_impl + // Tail quantile estimation based on order statistics of weighted samples + /** + @brief Tail quantile estimation based on order statistics of weighted samples (for both left and right tails) + + An estimator \f$\hat{q}\f$ of tail quantiles with level \f$\alpha\f$ based on order statistics + \f$X_{1:n} \leq X_{2:n} \leq\dots\leq X_{n:n}\f$ of weighted samples are given by \f$X_{\lambda:n}\f$ (left tail) + and \f$X_{\rho:n}\f$ (right tail), where + + \f[ + \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} + \f] + + and + + \f[ + \rho = \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\}, + \f] + + \f$n\f$ being the number of samples and \f$\bar{w}_n\f$ the sum of all weights. + + @param quantile_probability + */ + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_tail_quantile_impl + : accumulator_base + { + typedef typename numeric::functional::average<Weight, std::size_t>::result_type float_type; + // for boost::result_of + typedef Sample result_type; + + weighted_tail_quantile_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + float_type threshold = sum_of_weights(args) + * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); + + std::size_t n = 0; + Weight sum = Weight(0); + + while (sum < threshold) + { + if (n < static_cast<std::size_t>(tail_weights(args).size())) + { + sum += *(tail_weights(args).begin() + n); + n++; + } + else + { + if (std::numeric_limits<result_type>::has_quiet_NaN) + { + return std::numeric_limits<result_type>::quiet_NaN(); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + return Sample(0); + } + } + } + + // Note that the cached samples of the left are sorted in ascending order, + // whereas the samples of the right tail are sorted in descending order + return *(boost::begin(tail(args)) + n - 1); + } + }; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_tail_quantile<> +// +namespace tag +{ + template<typename LeftRight> + struct weighted_tail_quantile + : depends_on<sum_of_weights, tail_weights<LeftRight> > + { + /// INTERNAL ONLY + typedef accumulators::impl::weighted_tail_quantile_impl<mpl::_1, mpl::_2, LeftRight> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_tail_quantile +// +namespace extract +{ + extractor<tag::quantile> const weighted_tail_quantile = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_tail_quantile) +} + +using extract::weighted_tail_quantile; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_tail_variate_means.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_variate_means.hpp new file mode 100644 index 0000000..da18189 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_tail_variate_means.hpp
@@ -0,0 +1,242 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_tail_variate_means.hpp +// +// Copyright 2006 Daniel Egloff, Olivier Gygi. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_TAIL_VARIATE_MEANS_HPP_DE_01_01_2006 + +#include <numeric> +#include <vector> +#include <limits> +#include <functional> +#include <sstream> +#include <stdexcept> +#include <boost/throw_exception.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/tail.hpp> +#include <boost/accumulators/statistics/tail_variate.hpp> +#include <boost/accumulators/statistics/tail_variate_means.hpp> +#include <boost/accumulators/statistics/weighted_tail_mean.hpp> +#include <boost/accumulators/statistics/parameters/quantile_probability.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost +{ + // for _BinaryOperatrion2 in std::inner_product below + // mutliplies two values and promotes the result to double + namespace numeric { namespace functional + { + /////////////////////////////////////////////////////////////////////////////// + // numeric::functional::multiply_and_promote_to_double + template<typename T, typename U> + struct multiply_and_promote_to_double + : multiplies<T, double const> + { + }; + }} +} + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /** + @brief Estimation of the absolute and relative weighted tail variate means (for both left and right tails) + + For all \f$j\f$-th variates associated to the + + \f[ + \lambda = \inf\left\{ l \left| \frac{1}{\bar{w}_n}\sum_{i=1}^{l} w_i \geq \alpha \right. \right\} + \f] + + smallest samples (left tail) or the weighted mean of the + + \f[ + n + 1 - \rho = n + 1 - \sup\left\{ r \left| \frac{1}{\bar{w}_n}\sum_{i=r}^{n} w_i \geq (1 - \alpha) \right. \right\} + \f] + + largest samples (right tail), the absolute weighted tail means \f$\widehat{ATM}_{n,\alpha}(X, j)\f$ + are computed and returned as an iterator range. Alternatively, the relative weighted tail means + \f$\widehat{RTM}_{n,\alpha}(X, j)\f$ are returned, which are the absolute weighted tail means + normalized with the weighted (non-coherent) sample tail mean \f$\widehat{NCTM}_{n,\alpha}(X)\f$. + + \f[ + \widehat{ATM}_{n,\alpha}^{\mathrm{right}}(X, j) = + \frac{1}{\sum_{i=\rho}^n w_i} + \sum_{i=\rho}^n w_i \xi_{j,i} + \f] + + \f[ + \widehat{ATM}_{n,\alpha}^{\mathrm{left}}(X, j) = + \frac{1}{\sum_{i=1}^{\lambda}} + \sum_{i=1}^{\lambda} w_i \xi_{j,i} + \f] + + \f[ + \widehat{RTM}_{n,\alpha}^{\mathrm{right}}(X, j) = + \frac{\sum_{i=\rho}^n w_i \xi_{j,i}} + {\sum_{i=\rho}^n w_i \widehat{NCTM}_{n,\alpha}^{\mathrm{right}}(X)} + \f] + + \f[ + \widehat{RTM}_{n,\alpha}^{\mathrm{left}}(X, j) = + \frac{\sum_{i=1}^{\lambda} w_i \xi_{j,i}} + {\sum_{i=1}^{\lambda} w_i \widehat{NCTM}_{n,\alpha}^{\mathrm{left}}(X)} + \f] + */ + + /////////////////////////////////////////////////////////////////////////////// + // weighted_tail_variate_means_impl + // by default: absolute weighted_tail_variate_means + template<typename Sample, typename Weight, typename Impl, typename LeftRight, typename VariateType> + struct weighted_tail_variate_means_impl + : accumulator_base + { + typedef typename numeric::functional::average<Weight, Weight>::result_type float_type; + typedef typename numeric::functional::average<typename numeric::functional::multiplies<VariateType, Weight>::result_type, Weight>::result_type array_type; + // for boost::result_of + typedef iterator_range<typename array_type::iterator> result_type; + + weighted_tail_variate_means_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + float_type threshold = sum_of_weights(args) + * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); + + std::size_t n = 0; + Weight sum = Weight(0); + + while (sum < threshold) + { + if (n < static_cast<std::size_t>(tail_weights(args).size())) + { + sum += *(tail_weights(args).begin() + n); + n++; + } + else + { + if (std::numeric_limits<float_type>::has_quiet_NaN) + { + std::fill( + this->tail_means_.begin() + , this->tail_means_.end() + , std::numeric_limits<float_type>::quiet_NaN() + ); + } + else + { + std::ostringstream msg; + msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; + boost::throw_exception(std::runtime_error(msg.str())); + } + } + } + + std::size_t num_variates = tail_variate(args).begin()->size(); + + this->tail_means_.clear(); + this->tail_means_.resize(num_variates, Sample(0)); + + this->tail_means_ = std::inner_product( + tail_variate(args).begin() + , tail_variate(args).begin() + n + , tail_weights(args).begin() + , this->tail_means_ + , numeric::functional::plus<array_type const, array_type const>() + , numeric::functional::multiply_and_promote_to_double<VariateType const, Weight const>() + ); + + float_type factor = sum * ( (is_same<Impl, relative>::value) ? non_coherent_weighted_tail_mean(args) : 1. ); + + std::transform( + this->tail_means_.begin() + , this->tail_means_.end() + , this->tail_means_.begin() + , std::bind2nd(numeric::functional::divides<typename array_type::value_type const, float_type const>(), factor) + ); + + return make_iterator_range(this->tail_means_); + } + + private: + + mutable array_type tail_means_; + + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::absolute_weighted_tail_variate_means +// tag::relative_weighted_tail_variate_means +// +namespace tag +{ + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_weighted_tail_variate_means + : depends_on<non_coherent_weighted_tail_mean<LeftRight>, tail_variate<VariateType, VariateTag, LeftRight>, tail_weights<LeftRight> > + { + typedef accumulators::impl::weighted_tail_variate_means_impl<mpl::_1, mpl::_2, absolute, LeftRight, VariateType> impl; + }; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_weighted_tail_variate_means + : depends_on<non_coherent_weighted_tail_mean<LeftRight>, tail_variate<VariateType, VariateTag, LeftRight>, tail_weights<LeftRight> > + { + typedef accumulators::impl::weighted_tail_variate_means_impl<mpl::_1, mpl::_2, relative, LeftRight, VariateType> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_tail_variate_means +// extract::relative_weighted_tail_variate_means +// +namespace extract +{ + extractor<tag::abstract_absolute_tail_variate_means> const weighted_tail_variate_means = {}; + extractor<tag::abstract_relative_tail_variate_means> const relative_weighted_tail_variate_means = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_tail_variate_means) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(relative_weighted_tail_variate_means) +} + +using extract::weighted_tail_variate_means; +using extract::relative_weighted_tail_variate_means; + +// weighted_tail_variate_means<LeftRight, VariateType, VariateTag>(absolute) -> absolute_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_feature<tag::weighted_tail_variate_means<LeftRight, VariateType, VariateTag>(absolute)> +{ + typedef tag::absolute_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +// weighted_tail_variate_means<LeftRight, VariateType, VariateTag>(relative) -> relative_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> +template<typename LeftRight, typename VariateType, typename VariateTag> +struct as_feature<tag::weighted_tail_variate_means<LeftRight, VariateType, VariateTag>(relative)> +{ + typedef tag::relative_weighted_tail_variate_means<LeftRight, VariateType, VariateTag> type; +}; + +}} // namespace boost::accumulators + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/weighted_variance.hpp b/boost_1_45_0/boost/accumulators/statistics/weighted_variance.hpp new file mode 100644 index 0000000..e91fdc1 --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/weighted_variance.hpp
@@ -0,0 +1,186 @@ +/////////////////////////////////////////////////////////////////////////////// +// weighted_variance.hpp +// +// Copyright 2005 Daniel Egloff, Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_VARIANCE_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_VARIANCE_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/variance.hpp> +#include <boost/accumulators/statistics/weighted_sum.hpp> +#include <boost/accumulators/statistics/weighted_mean.hpp> +#include <boost/accumulators/statistics/weighted_moment.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + //! Lazy calculation of variance of weighted samples. + /*! + The default implementation of the variance of weighted samples is based on the second moment + \f$\widehat{m}_n^{(2)}\f$ (weighted_moment<2>) and the mean\f$ \hat{\mu}_n\f$ (weighted_mean): + \f[ + \hat{\sigma}_n^2 = \widehat{m}_n^{(2)}-\hat{\mu}_n^2, + \f] + where \f$n\f$ is the number of samples. + */ + template<typename Sample, typename Weight, typename MeanFeature> + struct lazy_weighted_variance_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type; + + lazy_weighted_variance_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + extractor<MeanFeature> const some_mean = {}; + result_type tmp = some_mean(args); + return accumulators::weighted_moment<2>(args) - tmp * tmp; + } + }; + + //! Iterative calculation of variance of weighted samples. + /*! + Iterative calculation of variance of weighted samples: + \f[ + \hat{\sigma}_n^2 = + \frac{\bar{w}_n - w_n}{\bar{w}_n}\hat{\sigma}_{n - 1}^2 + + \frac{w_n}{\bar{w}_n - w_n}\left(X_n - \hat{\mu}_n\right)^2 + ,\quad n\ge2,\quad\hat{\sigma}_0^2 = 0. + \f] + where \f$\bar{w}_n\f$ is the sum of the \f$n\f$ weights \f$w_i\f$ and \f$\hat{\mu}_n\f$ + the estimate of the mean of the weighted smaples. Note that the sample variance is not defined for + \f$n <= 1\f$. + */ + template<typename Sample, typename Weight, typename MeanFeature, typename Tag> + struct weighted_variance_impl + : accumulator_base + { + typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample; + // for boost::result_of + typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type; + + template<typename Args> + weighted_variance_impl(Args const &args) + : weighted_variance(numeric::average(args[sample | Sample()], numeric::one<Weight>::value)) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + + if(cnt > 1) + { + extractor<MeanFeature> const some_mean = {}; + + result_type tmp = args[parameter::keyword<Tag>::get()] - some_mean(args); + + this->weighted_variance = + numeric::average(this->weighted_variance * (sum_of_weights(args) - args[weight]), sum_of_weights(args)) + + numeric::average(tmp * tmp * args[weight], sum_of_weights(args) - args[weight] ); + } + } + + result_type result(dont_care) const + { + return this->weighted_variance; + } + + private: + result_type weighted_variance; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::weighted_variance +// tag::immediate_weighted_variance +// +namespace tag +{ + struct lazy_weighted_variance + : depends_on<weighted_moment<2>, weighted_mean> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::lazy_weighted_variance_impl<mpl::_1, mpl::_2, weighted_mean> impl; + }; + + struct weighted_variance + : depends_on<count, immediate_weighted_mean> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::weighted_variance_impl<mpl::_1, mpl::_2, immediate_weighted_mean, sample> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::weighted_variance +// extract::immediate_weighted_variance +// +namespace extract +{ + extractor<tag::lazy_weighted_variance> const lazy_weighted_variance = {}; + extractor<tag::weighted_variance> const weighted_variance = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(lazy_weighted_variance) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_variance) +} + +using extract::lazy_weighted_variance; +using extract::weighted_variance; + +// weighted_variance(lazy) -> lazy_weighted_variance +template<> +struct as_feature<tag::weighted_variance(lazy)> +{ + typedef tag::lazy_weighted_variance type; +}; + +// weighted_variance(immediate) -> weighted_variance +template<> +struct as_feature<tag::weighted_variance(immediate)> +{ + typedef tag::weighted_variance type; +}; + +//////////////////////////////////////////////////////////////////////////// +//// droppable_accumulator<weighted_variance_impl> +//// need to specialize droppable lazy weighted_variance to cache the result at the +//// point the accumulator is dropped. +///// INTERNAL ONLY +///// +//template<typename Sample, typename Weight, typename MeanFeature> +//struct droppable_accumulator<impl::weighted_variance_impl<Sample, Weight, MeanFeature> > +// : droppable_accumulator_base< +// with_cached_result<impl::weighted_variance_impl<Sample, Weight, MeanFeature> > +// > +//{ +// template<typename Args> +// droppable_accumulator(Args const &args) +// : droppable_accumulator::base(args) +// { +// } +//}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics/with_error.hpp b/boost_1_45_0/boost/accumulators/statistics/with_error.hpp new file mode 100644 index 0000000..adafc8e --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics/with_error.hpp
@@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////////////////////// +// with_error.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_WITH_ERROR_HPP_EAN_01_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_WITH_ERROR_HPP_EAN_01_11_2005 + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/error_of.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + template<typename Feature> + struct error_of_tag + { + typedef tag::error_of<Feature> type; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// with_error +// +template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)> +struct with_error + : mpl::transform_view< + mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> + , detail::error_of_tag<mpl::_1> + > +{ +}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/accumulators/statistics_fwd.hpp b/boost_1_45_0/boost/accumulators/statistics_fwd.hpp new file mode 100644 index 0000000..196814b --- /dev/null +++ b/boost_1_45_0/boost/accumulators/statistics_fwd.hpp
@@ -0,0 +1,419 @@ +/////////////////////////////////////////////////////////////////////////////// +// statistics_fwd.hpp +// +// Copyright 2005 Eric Niebler. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ACCUMULATORS_STATISTICS_STATISTICS_FWD_HPP_EAN_23_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_STATISTICS_FWD_HPP_EAN_23_11_2005 + +#include <boost/mpl/apply_fwd.hpp> // for mpl::na +#include <boost/mpl/print.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// base struct and base extractor for quantiles +namespace tag +{ + struct quantile + : depends_on<> + { + typedef mpl::print<class ____MISSING_SPECIFIC_QUANTILE_FEATURE_IN_ACCUMULATOR_SET____ > impl; + }; +} +namespace extract +{ + extractor<tag::quantile> const quantile = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(quantile) +} +using extract::quantile; + +/////////////////////////////////////////////////////////////////////////////// +// base struct and base extractor for *coherent* tail means +namespace tag +{ + struct tail_mean + : depends_on<> + { + typedef mpl::print<class ____MISSING_SPECIFIC_TAIL_MEAN_FEATURE_IN_ACCUMULATOR_SET____ > impl; + }; +} +namespace extract +{ + extractor<tag::tail_mean> const tail_mean = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_mean) +} +using extract::tail_mean; + +namespace tag +{ + /////////////////////////////////////////////////////////////////////////////// + // Variates tags + struct weights; + struct covariate1; + struct covariate2; + + /////////////////////////////////////////////////////////////////////////////// + // Statistic tags + struct count; + template<typename VariateType, typename VariateTag> + struct covariance; + struct density; + template<typename Feature> + struct error_of; + struct extended_p_square; + struct extended_p_square_quantile; + struct extended_p_square_quantile_quadratic; + struct kurtosis; + struct max; + struct mean; + struct immediate_mean; + struct mean_of_weights; + struct immediate_mean_of_weights; + template<typename VariateType, typename VariateTag> + struct mean_of_variates; + template<typename VariateType, typename VariateTag> + struct immediate_mean_of_variates; + struct median; + struct with_density_median; + struct with_p_square_cumulative_distribution_median; + struct min; + template<int N> + struct moment; + template<typename LeftRight> + struct peaks_over_threshold; + template<typename LeftRight> + struct peaks_over_threshold_prob; + template<typename LeftRight> + struct pot_tail_mean; + template<typename LeftRight> + struct pot_tail_mean_prob; + template<typename LeftRight> + struct pot_quantile; + template<typename LeftRight> + struct pot_quantile_prob; + struct p_square_cumulative_distribution; + struct p_square_quantile; + struct p_square_quantile_for_median; + struct skewness; + struct sum; + struct sum_of_weights; + template<typename VariateType, typename VariateTag> + struct sum_of_variates; + template<typename LeftRight> + struct tail; + template<typename LeftRight> + struct coherent_tail_mean; + template<typename LeftRight> + struct non_coherent_tail_mean; + template<typename LeftRight> + struct tail_quantile; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate; + template<typename LeftRight> + struct tail_weights; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct right_tail_variate; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct left_tail_variate; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_tail_variate_means; + struct lazy_variance; + struct variance; + template<typename VariateType, typename VariateTag> + struct weighted_covariance; + struct weighted_density; + struct weighted_kurtosis; + struct weighted_mean; + struct immediate_weighted_mean; + template<typename VariateType, typename VariateTag> + struct weighted_mean_of_variates; + template<typename VariateType, typename VariateTag> + struct immediate_weighted_mean_of_variates; + struct weighted_median; + struct with_density_weighted_median; + struct with_p_square_cumulative_distribution_weighted_median; + struct weighted_extended_p_square; + struct weighted_extended_p_square_quantile; + struct weighted_extended_p_square_quantile_quadratic; + template<int N> + struct weighted_moment; + template<typename LeftRight> + struct weighted_peaks_over_threshold; + template<typename LeftRight> + struct weighted_peaks_over_threshold_prob; + template<typename LeftRight> + struct weighted_pot_quantile; + template<typename LeftRight> + struct weighted_pot_quantile_prob; + template<typename LeftRight> + struct weighted_pot_tail_mean; + template<typename LeftRight> + struct weighted_pot_tail_mean_prob; + struct weighted_p_square_cumulative_distribution; + struct weighted_p_square_quantile; + struct weighted_p_square_quantile_for_median; + struct weighted_skewness; + template<typename LeftRight> + struct weighted_tail_quantile; + template<typename LeftRight> + struct non_coherent_weighted_tail_mean; + template<typename LeftRight> + struct weighted_tail_quantile; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct weighted_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_weighted_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_weighted_tail_variate_means; + struct lazy_weighted_variance; + struct weighted_variance; + struct weighted_sum; + template<typename VariateType, typename VariateTag> + struct weighted_sum_of_variates; + struct rolling_window_plus1; + struct rolling_window; + struct rolling_sum; + struct rolling_count; + struct rolling_mean; +} // namespace tag + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // Statistics impls + struct count_impl; + + template<typename Sample, typename VariateType, typename VariateTag> + struct covariance_impl; + + template<typename Sample> + struct density_impl; + + template<typename Sample, typename Feature> + struct error_of_impl; + + template<typename Sample, typename Variance> + struct error_of_mean_impl; + + template<typename Sample> + struct extended_p_square_impl; + + template<typename Sample, typename Impl1, typename Impl2> + struct extended_p_square_quantile_impl; + + template<typename Sample> + struct kurtosis_impl; + + template<typename Sample> + struct max_impl; + + template<typename Sample> + struct median_impl; + + template<typename Sample> + struct with_density_median_impl; + + template<typename Sample> + struct with_p_square_cumulative_distribution_median_impl; + + template<typename Sample> + struct min_impl; + + template<typename Sample, typename SumFeature = tag::sum> + struct mean_impl; + + template<typename Sample, typename Tag = tag::sample> + struct immediate_mean_impl; + + template<typename N, typename Sample> + struct moment_impl; + + template<typename Sample, typename LeftRight> + struct peaks_over_threshold_prob_impl; + + template<typename Sample, typename Impl, typename LeftRight> + struct pot_quantile_impl; + + template<typename Sample, typename Impl, typename LeftRight> + struct pot_tail_mean_impl; + + template<typename Sample> + struct p_square_cumulative_distribution_impl; + + template<typename Sample, typename Impl> + struct p_square_quantile_impl; + + template<typename Sample> + struct skewness_impl; + + template<typename Sample, typename Tag = tag::sample> + struct sum_impl; + + template<typename Sample, typename LeftRight> + struct tail_impl; + + template<typename Sample, typename LeftRight> + struct coherent_tail_mean_impl; + + template<typename Sample, typename LeftRight> + struct non_coherent_tail_mean_impl; + + template<typename Sample, typename LeftRight> + struct tail_quantile_impl; + + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate_impl; + + template<typename Sample, typename Impl, typename LeftRight, typename VariateTag> + struct tail_variate_means_impl; + + template<typename Sample, typename MeanFeature> + struct lazy_variance_impl; + + template<typename Sample, typename MeanFeature, typename Tag> + struct variance_impl; + + template<typename Sample, typename Weight, typename VariateType, typename VariateTag> + struct weighted_covariance_impl; + + template<typename Sample, typename Weight> + struct weighted_density_impl; + + template<typename Sample, typename Weight> + struct weighted_kurtosis_impl; + + template<typename Sample> + struct weighted_median_impl; + + template<typename Sample> + struct with_density_weighted_median_impl; + + template<typename Sample, typename Weight> + struct with_p_square_cumulative_distribution_weighted_median_impl; + + template<typename Sample, typename Weight, typename Tag> + struct weighted_mean_impl; + + template<typename Sample, typename Weight, typename Tag> + struct immediate_weighted_mean_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_prob_impl; + + template<typename Sample, typename Weight> + struct with_p_square_cumulative_distribution_weighted_median_impl; + + template<typename Sample, typename Weight> + struct weighted_extended_p_square_impl; + + template<typename N, typename Sample, typename Weight> + struct weighted_moment_impl; + + template<typename Sample, typename Weight> + struct weighted_p_square_cumulative_distribution_impl; + + template<typename Sample, typename Weight, typename Impl> + struct weighted_p_square_quantile_impl; + + template<typename Sample, typename Weight> + struct weighted_skewness_impl; + + template<typename Sample, typename Weight, typename Tag> + struct weighted_sum_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct non_coherent_weighted_tail_mean_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_tail_quantile_impl; + + template<typename Sample, typename Weight, typename Impl, typename LeftRight, typename VariateType> + struct weighted_tail_variate_means_impl; + + template<typename Sample, typename Weight, typename MeanFeature> + struct lazy_weighted_variance_impl; + + template<typename Sample, typename Weight, typename MeanFeature, typename Tag> + struct weighted_variance_impl; + + template<typename Sample> + struct rolling_window_plus1_impl; + + template<typename Sample> + struct rolling_window_impl; + + template<typename Sample> + struct rolling_sum_impl; + + template<typename Sample> + struct rolling_count_impl; + + template<typename Sample> + struct rolling_mean_impl; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// stats +// A more descriptive name for an MPL sequence of statistics. +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct stats; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct with_error; + +// modifiers for the mean and variance stats +struct lazy {}; +struct immediate {}; + +// modifiers for the variance stat +// struct fast {}; +// struct accurate {}; + +// modifiers for order +struct right {}; +struct left {}; +// typedef right default_order_tag_type; + +// modifiers for the tail_variate_means stat +struct absolute {}; +struct relative {}; + +// modifiers for median and weighted_median stats +struct with_density {}; +struct with_p_square_cumulative_distribution {}; +struct with_p_square_quantile {}; + +// modifiers for peaks_over_threshold stat +struct with_threshold_value {}; +struct with_threshold_probability {}; + +// modifiers for extended_p_square_quantile and weighted_extended_p_square_quantile stats +struct weighted {}; +struct unweighted {}; +struct linear {}; +struct quadratic {}; + +// modifiers for p_square_quantile +struct regular {}; +struct for_median {}; + +}} // namespace boost::accumulators + +#endif
diff --git a/boost_1_45_0/boost/algorithm/minmax.hpp b/boost_1_45_0/boost/algorithm/minmax.hpp new file mode 100644 index 0000000..053a7d6 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/minmax.hpp
@@ -0,0 +1,47 @@ +// (C) Copyright Herve Bronnimann 2004. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 1 July 2004 + Split the code into two headers to lessen dependence on + Boost.tuple. (Herve) + 26 June 2004 + Added the code for the boost minmax library. (Herve) +*/ + +#ifndef BOOST_ALGORITHM_MINMAX_HPP +#define BOOST_ALGORITHM_MINMAX_HPP + +/* PROPOSED STANDARD EXTENSIONS: + * + * minmax(a, b) + * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b); + * + * minmax(a, b, comp) + * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b); + * + */ + +#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref +#include <boost/ref.hpp> + +namespace boost { + + template <typename T> + tuple< T const&, T const& > + minmax(T const& a, T const& b) { + return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); + } + + template <typename T, class BinaryPredicate> + tuple< T const&, T const& > + minmax(T const& a, T const& b, BinaryPredicate comp) { + return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); + } + +} // namespace boost + +#endif // BOOST_ALGORITHM_MINMAX_HPP
diff --git a/boost_1_45_0/boost/algorithm/minmax_element.hpp b/boost_1_45_0/boost/algorithm/minmax_element.hpp new file mode 100644 index 0000000..0d2efd8 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/minmax_element.hpp
@@ -0,0 +1,551 @@ +// (C) Copyright Herve Bronnimann 2004. +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 1 July 2004 + Split the code into two headers to lessen dependence on + Boost.tuple. (Herve) + 26 June 2004 + Added the code for the boost minmax library. (Herve) +*/ + +#ifndef BOOST_ALGORITHM_MINMAX_ELEMENT_HPP +#define BOOST_ALGORITHM_MINMAX_ELEMENT_HPP + +/* PROPOSED STANDARD EXTENSIONS: + * + * minmax_element(first, last) + * Effect: std::make_pair( std::min_element(first, last), + * std::max_element(first, last) ); + * + * minmax_element(first, last, comp) + * Effect: std::make_pair( std::min_element(first, last, comp), + * std::max_element(first, last, comp) ); + */ + +#include <utility> // for std::pair and std::make_pair + +namespace boost { + + namespace detail { // for obtaining a uniform version of minmax_element + // that compiles with VC++ 6.0 -- avoid the iterator_traits by + // having comparison object over iterator, not over dereferenced value + + template <typename Iterator> + struct less_over_iter { + bool operator()(Iterator const& it1, + Iterator const& it2) const { return *it1 < *it2; } + }; + + template <typename Iterator, class BinaryPredicate> + struct binary_pred_over_iter { + explicit binary_pred_over_iter(BinaryPredicate const& p ) : m_p( p ) {} + bool operator()(Iterator const& it1, + Iterator const& it2) const { return m_p(*it1, *it2); } + private: + BinaryPredicate m_p; + }; + + // common base for the two minmax_element overloads + + template <typename ForwardIter, class Compare > + std::pair<ForwardIter,ForwardIter> + basic_minmax_element(ForwardIter first, ForwardIter last, Compare comp) + { + if (first == last) + return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + // if only one element + ForwardIter second = first; ++second; + if (second == last) + return std::make_pair(min_result, max_result); + + // treat first pair separately (only one comparison for first two elements) + ForwardIter potential_min_result = last; + if (comp(first, second)) + max_result = second; + else { + min_result = second; + potential_min_result = first; + } + + // then each element by pairs, with at most 3 comparisons per pair + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (comp(first, min_result)) { + min_result = first; + potential_min_result = last; + } + if (comp(max_result, second)) + max_result = second; + } else { + if (comp(second, min_result)) { + min_result = second; + potential_min_result = first; + } + if (comp(max_result, first)) + max_result = first; + } + first = ++second; + if (first != last) ++second; + } + + // if odd number of elements, treat last element + if (first != last) { // odd number of elements + if (comp(first, min_result)) + min_result = first, potential_min_result = last; + else if (comp(max_result, first)) + max_result = first; + } + + // resolve min_result being incorrect with one extra comparison + // (in which case potential_min_result is necessarily the correct result) + if (potential_min_result != last + && !comp(min_result, potential_min_result)) + min_result = potential_min_result; + + return std::make_pair(min_result,max_result); + } + + } // namespace detail + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + minmax_element(ForwardIter first, ForwardIter last) + { + return detail::basic_minmax_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + minmax_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_minmax_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + +} + +/* PROPOSED BOOST EXTENSIONS + * In the description below, [rfirst,rlast) denotes the reversed range + * of [first,last). Even though the iterator type of first and last may + * be only a Forward Iterator, it is possible to explain the semantics + * by assuming that it is a Bidirectional Iterator. In the sequel, + * reverse(ForwardIterator&) returns the reverse_iterator adaptor. + * This is not how the functions would be implemented! + * + * first_min_element(first, last) + * Effect: std::min_element(first, last); + * + * first_min_element(first, last, comp) + * Effect: std::min_element(first, last, comp); + * + * last_min_element(first, last) + * Effect: reverse( std::min_element(reverse(last), reverse(first)) ); + * + * last_min_element(first, last, comp) + * Effect: reverse( std::min_element(reverse(last), reverse(first), comp) ); + * + * first_max_element(first, last) + * Effect: std::max_element(first, last); + * + * first_max_element(first, last, comp) + * Effect: max_element(first, last); + * + * last_max_element(first, last) + * Effect: reverse( std::max_element(reverse(last), reverse(first)) ); + * + * last_max_element(first, last, comp) + * Effect: reverse( std::max_element(reverse(last), reverse(first), comp) ); + * + * first_min_first_max_element(first, last) + * Effect: std::make_pair( first_min_element(first, last), + * first_max_element(first, last) ); + * + * first_min_first_max_element(first, last, comp) + * Effect: std::make_pair( first_min_element(first, last, comp), + * first_max_element(first, last, comp) ); + * + * first_min_last_max_element(first, last) + * Effect: std::make_pair( first_min_element(first, last), + * last_max_element(first, last) ); + * + * first_min_last_max_element(first, last, comp) + * Effect: std::make_pair( first_min_element(first, last, comp), + * last_max_element(first, last, comp) ); + * + * last_min_first_max_element(first, last) + * Effect: std::make_pair( last_min_element(first, last), + * first_max_element(first, last) ); + * + * last_min_first_max_element(first, last, comp) + * Effect: std::make_pair( last_min_element(first, last, comp), + * first_max_element(first, last, comp) ); + * + * last_min_last_max_element(first, last) + * Effect: std::make_pair( last_min_element(first, last), + * last_max_element(first, last) ); + * + * last_min_last_max_element(first, last, comp) + * Effect: std::make_pair( last_min_element(first, last, comp), + * last_max_element(first, last, comp) ); + */ + +namespace boost { + + // Min_element and max_element variants + + namespace detail { // common base for the overloads + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_first_min_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter min_result = first; + while (++first != last) + if (comp(first, min_result)) + min_result = first; + return min_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_last_min_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter min_result = first; + while (++first != last) + if (!comp(min_result, first)) + min_result = first; + return min_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter max_result = first; + while (++first != last) + if (comp(max_result, first)) + max_result = first; + return max_result; + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + basic_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return last; + ForwardIter max_result = first; + while (++first != last) + if (!comp(first, max_result)) + max_result = first; + return max_result; + } + + } // namespace detail + + template <typename ForwardIter> + ForwardIter + first_min_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_min_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + first_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_first_min_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + last_min_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + last_min_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_last_min_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + first_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + first_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_first_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + ForwardIter + last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + ForwardIter + last_max_element(ForwardIter first, ForwardIter last, BinaryPredicate comp) + { + return detail::basic_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + + // Minmax_element variants -- comments removed + + namespace detail { + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_first_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) + return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = ++first; + if (second == last) + return std::make_pair(min_result, max_result); + + if (comp(second, min_result)) + min_result = second; + else + max_result = second; + + first = ++second; if (first != last) ++second; + while (second != last) { + if (!comp(second, first)) { + if (comp(first, min_result)) + min_result = first; + if (!comp(second, max_result)) + max_result = second; + } else { + if (comp(second, min_result)) + min_result = second; + if (!comp(first, max_result)) + max_result = first; + } + first = ++second; if (first != last) ++second; + } + + if (first != last) { + if (comp(first, min_result)) + min_result = first; + else if (!comp(first, max_result)) + max_result = first; + } + + return std::make_pair(min_result, max_result); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_last_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = ++first; + if (second == last) + return std::make_pair(min_result, max_result); + + if (comp(max_result, second)) + max_result = second; + else + min_result = second; + + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (!comp(min_result, first)) + min_result = first; + if (comp(max_result, second)) + max_result = second; + } else { + if (!comp(min_result, second)) + min_result = second; + if (comp(max_result, first)) + max_result = first; + } + first = ++second; if (first != last) ++second; + } + + if (first != last) { + if (!comp(min_result, first)) + min_result = first; + else if (comp(max_result, first)) + max_result = first; + } + + return std::make_pair(min_result, max_result); + } + + template <typename ForwardIter, class BinaryPredicate> + std::pair<ForwardIter,ForwardIter> + basic_last_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + if (first == last) return std::make_pair(last,last); + + ForwardIter min_result = first; + ForwardIter max_result = first; + + ForwardIter second = first; ++second; + if (second == last) + return std::make_pair(min_result,max_result); + + ForwardIter potential_max_result = last; + if (comp(first, second)) + max_result = second; + else { + min_result = second; + potential_max_result = second; + } + + first = ++second; if (first != last) ++second; + while (second != last) { + if (comp(first, second)) { + if (!comp(min_result, first)) + min_result = first; + if (!comp(second, max_result)) { + max_result = second; + potential_max_result = last; + } + } else { + if (!comp(min_result, second)) + min_result = second; + if (!comp(first, max_result)) { + max_result = first; + potential_max_result = second; + } + } + first = ++second; + if (first != last) ++second; + } + + if (first != last) { + if (!comp(min_result, first)) + min_result = first; + if (!comp(first, max_result)) { + max_result = first; + potential_max_result = last; + } + } + + if (potential_max_result != last + && !comp(potential_max_result, max_result)) + max_result = potential_max_result; + + return std::make_pair(min_result,max_result); + } + + } // namespace detail + + template <typename ForwardIter> + inline std::pair<ForwardIter,ForwardIter> + first_min_first_max_element(ForwardIter first, ForwardIter last) + { + return minmax_element(first, last); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + first_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return minmax_element(first, last, comp); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + first_min_last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_first_min_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + first_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_first_min_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + last_min_first_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_first_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + last_min_first_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_last_min_first_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + + template <typename ForwardIter> + std::pair<ForwardIter,ForwardIter> + last_min_last_max_element(ForwardIter first, ForwardIter last) + { + return detail::basic_last_min_last_max_element(first, last, + detail::less_over_iter<ForwardIter>() ); + } + + template <typename ForwardIter, class BinaryPredicate> + inline std::pair<ForwardIter,ForwardIter> + last_min_last_max_element(ForwardIter first, ForwardIter last, + BinaryPredicate comp) + { + return detail::basic_last_min_last_max_element(first, last, + detail::binary_pred_over_iter<ForwardIter,BinaryPredicate>(comp) ); + } + +} // namespace boost + +#endif // BOOST_ALGORITHM_MINMAX_ELEMENT_HPP
diff --git a/boost_1_45_0/boost/algorithm/string.hpp b/boost_1_45_0/boost/algorithm/string.hpp new file mode 100644 index 0000000..0771517 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string.hpp
@@ -0,0 +1,31 @@ +// Boost string_algo library string_algo.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2004. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_ALGO_HPP +#define BOOST_STRING_ALGO_HPP + +/*! \file + Cumulative include for string_algo library +*/ + +#include <boost/algorithm/string/std_containers_traits.hpp> +#include <boost/algorithm/string/trim.hpp> +#include <boost/algorithm/string/case_conv.hpp> +#include <boost/algorithm/string/predicate.hpp> +#include <boost/algorithm/string/find.hpp> +#include <boost/algorithm/string/split.hpp> +#include <boost/algorithm/string/join.hpp> +#include <boost/algorithm/string/replace.hpp> +#include <boost/algorithm/string/erase.hpp> +#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string/find_iterator.hpp> + + +#endif // BOOST_STRING_ALGO_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/case_conv.hpp b/boost_1_45_0/boost/algorithm/string/case_conv.hpp new file mode 100644 index 0000000..683340b --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/case_conv.hpp
@@ -0,0 +1,176 @@ +// Boost string_algo library case_conv.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CASE_CONV_HPP +#define BOOST_STRING_CASE_CONV_HPP + +#include <boost/algorithm/string/config.hpp> +#include <algorithm> +#include <locale> +#include <boost/iterator/transform_iterator.hpp> + +#include <boost/range/as_literal.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/value_type.hpp> + +#include <boost/algorithm/string/detail/case_conv.hpp> + +/*! \file + Defines sequence case-conversion algorithms. + Algorithms convert each element in the input sequence to the + desired case using provided locales. +*/ + +namespace boost { + namespace algorithm { + +// to_lower -----------------------------------------------// + + //! Convert to lower case + /*! + Each element of the input sequence is converted to lower + case. The result is a copy of the input converted to lower case. + It is returned as a sequence or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input range + \param Loc A locale used for conversion + \return + An output iterator pointing just after the last inserted character or + a copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + + */ + template<typename OutputIteratorT, typename RangeT> + inline OutputIteratorT + to_lower_copy( + OutputIteratorT Output, + const RangeT& Input, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::detail::transform_range_copy( + Output, + ::boost::as_literal(Input), + ::boost::algorithm::detail::to_lowerF< + typename range_value<RangeT>::type >(Loc)); + } + + //! Convert to lower case + /*! + \overload + */ + template<typename SequenceT> + inline SequenceT to_lower_copy( + const SequenceT& Input, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::detail::transform_range_copy<SequenceT>( + Input, + ::boost::algorithm::detail::to_lowerF< + typename range_value<SequenceT>::type >(Loc)); + } + + //! Convert to lower case + /*! + Each element of the input sequence is converted to lower + case. The input sequence is modified in-place. + + \param Input A range + \param Loc a locale used for conversion + */ + template<typename WritableRangeT> + inline void to_lower( + WritableRangeT& Input, + const std::locale& Loc=std::locale()) + { + ::boost::algorithm::detail::transform_range( + ::boost::as_literal(Input), + ::boost::algorithm::detail::to_lowerF< + typename range_value<WritableRangeT>::type >(Loc)); + } + +// to_upper -----------------------------------------------// + + //! Convert to upper case + /*! + Each element of the input sequence is converted to upper + case. The result is a copy of the input converted to upper case. + It is returned as a sequence or copied to the output iterator + + \param Output An output iterator to which the result will be copied + \param Input An input range + \param Loc A locale used for conversion + \return + An output iterator pointing just after the last inserted character or + a copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template<typename OutputIteratorT, typename RangeT> + inline OutputIteratorT + to_upper_copy( + OutputIteratorT Output, + const RangeT& Input, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::detail::transform_range_copy( + Output, + ::boost::as_literal(Input), + ::boost::algorithm::detail::to_upperF< + typename range_value<RangeT>::type >(Loc)); + } + + //! Convert to upper case + /*! + \overload + */ + template<typename SequenceT> + inline SequenceT to_upper_copy( + const SequenceT& Input, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::detail::transform_range_copy<SequenceT>( + Input, + ::boost::algorithm::detail::to_upperF< + typename range_value<SequenceT>::type >(Loc)); + } + + //! Convert to upper case + /*! + Each element of the input sequence is converted to upper + case. The input sequence is modified in-place. + + \param Input An input range + \param Loc a locale used for conversion + */ + template<typename WritableRangeT> + inline void to_upper( + WritableRangeT& Input, + const std::locale& Loc=std::locale()) + { + ::boost::algorithm::detail::transform_range( + ::boost::as_literal(Input), + ::boost::algorithm::detail::to_upperF< + typename range_value<WritableRangeT>::type >(Loc)); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::to_lower; + using algorithm::to_lower_copy; + using algorithm::to_upper; + using algorithm::to_upper_copy; + +} // namespace boost + +#endif // BOOST_STRING_CASE_CONV_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/classification.hpp b/boost_1_45_0/boost/algorithm/string/classification.hpp new file mode 100644 index 0000000..ca43602 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/classification.hpp
@@ -0,0 +1,312 @@ +// Boost string_algo library classification.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CLASSIFICATION_HPP +#define BOOST_STRING_CLASSIFICATION_HPP + +#include <algorithm> +#include <locale> +#include <boost/range/value_type.hpp> +#include <boost/range/as_literal.hpp> +#include <boost/algorithm/string/detail/classification.hpp> +#include <boost/algorithm/string/predicate_facade.hpp> + + +/*! \file + Classification predicates are included in the library to give + some more convenience when using algorithms like \c trim() and \c all(). + They wrap functionality of STL classification functions ( e.g. \c std::isspace() ) + into generic functors. +*/ + +namespace boost { + namespace algorithm { + +// classification functor generator -------------------------------------// + + //! is_classified predicate + /*! + Construct the \c is_classified predicate. This predicate holds if the input is + of specified \c std::ctype category. + + \param Type A \c std::ctype category + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_classified(std::ctype_base::mask Type, const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(Type, Loc); + } + + //! is_space predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::space category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_space(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::space, Loc); + } + + //! is_alnum predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::alnum category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_alnum(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::alnum, Loc); + } + + //! is_alpha predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::alpha category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_alpha(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::alpha, Loc); + } + + //! is_cntrl predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::cntrl category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_cntrl(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::cntrl, Loc); + } + + //! is_digit predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::digit category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_digit(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::digit, Loc); + } + + //! is_graph predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::graph category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_graph(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::graph, Loc); + } + + //! is_lower predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::lower category. + + \param Loc A locale used for classification + \return An instance of \c is_classified predicate + */ + inline detail::is_classifiedF + is_lower(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::lower, Loc); + } + + //! is_print predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::print category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_print(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::print, Loc); + } + + //! is_punct predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::punct category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_punct(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::punct, Loc); + } + + //! is_upper predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::upper category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_upper(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::upper, Loc); + } + + //! is_xdigit predicate + /*! + Construct the \c is_classified predicate for the \c ctype_base::xdigit category. + + \param Loc A locale used for classification + \return An instance of the \c is_classified predicate + */ + inline detail::is_classifiedF + is_xdigit(const std::locale& Loc=std::locale()) + { + return detail::is_classifiedF(std::ctype_base::xdigit, Loc); + } + + //! is_any_of predicate + /*! + Construct the \c is_any_of predicate. The predicate holds if the input + is included in the specified set of characters. + + \param Set A set of characters to be recognized + \return An instance of the \c is_any_of predicate + */ + template<typename RangeT> + inline detail::is_any_ofF< + BOOST_STRING_TYPENAME range_value<RangeT>::type> + is_any_of( const RangeT& Set ) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_set(boost::as_literal(Set)); + return detail::is_any_ofF<BOOST_STRING_TYPENAME range_value<RangeT>::type>(lit_set); + } + + //! is_from_range predicate + /*! + Construct the \c is_from_range predicate. The predicate holds if the input + is included in the specified range. (i.e. From <= Ch <= To ) + + \param From The start of the range + \param To The end of the range + \return An instance of the \c is_from_range predicate + */ + template<typename CharT> + inline detail::is_from_rangeF<CharT> is_from_range(CharT From, CharT To) + { + return detail::is_from_rangeF<CharT>(From,To); + } + + // predicate combinators ---------------------------------------------------// + + //! predicate 'and' composition predicate + /*! + Construct the \c class_and predicate. This predicate can be used + to logically combine two classification predicates. \c class_and holds, + if both predicates return true. + + \param Pred1 The first predicate + \param Pred2 The second predicate + \return An instance of the \c class_and predicate + */ + template<typename Pred1T, typename Pred2T> + inline detail::pred_andF<Pred1T, Pred2T> + operator&&( + const predicate_facade<Pred1T>& Pred1, + const predicate_facade<Pred2T>& Pred2 ) + { + // Doing the static_cast with the pointer instead of the reference + // is a workaround for some compilers which have problems with + // static_cast's of template references, i.e. CW8. /grafik/ + return detail::pred_andF<Pred1T,Pred2T>( + *static_cast<const Pred1T*>(&Pred1), + *static_cast<const Pred2T*>(&Pred2) ); + } + + //! predicate 'or' composition predicate + /*! + Construct the \c class_or predicate. This predicate can be used + to logically combine two classification predicates. \c class_or holds, + if one of the predicates return true. + + \param Pred1 The first predicate + \param Pred2 The second predicate + \return An instance of the \c class_or predicate + */ + template<typename Pred1T, typename Pred2T> + inline detail::pred_orF<Pred1T, Pred2T> + operator||( + const predicate_facade<Pred1T>& Pred1, + const predicate_facade<Pred2T>& Pred2 ) + { + // Doing the static_cast with the pointer instead of the reference + // is a workaround for some compilers which have problems with + // static_cast's of template references, i.e. CW8. /grafik/ + return detail::pred_orF<Pred1T,Pred2T>( + *static_cast<const Pred1T*>(&Pred1), + *static_cast<const Pred2T*>(&Pred2)); + } + + //! predicate negation operator + /*! + Construct the \c class_not predicate. This predicate represents a negation. + \c class_or holds if of the predicates return false. + + \param Pred The predicate to be negated + \return An instance of the \c class_not predicate + */ + template<typename PredT> + inline detail::pred_notF<PredT> + operator!( const predicate_facade<PredT>& Pred ) + { + // Doing the static_cast with the pointer instead of the reference + // is a workaround for some compilers which have problems with + // static_cast's of template references, i.e. CW8. /grafik/ + return detail::pred_notF<PredT>(*static_cast<const PredT*>(&Pred)); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::is_classified; + using algorithm::is_space; + using algorithm::is_alnum; + using algorithm::is_alpha; + using algorithm::is_cntrl; + using algorithm::is_digit; + using algorithm::is_graph; + using algorithm::is_lower; + using algorithm::is_upper; + using algorithm::is_print; + using algorithm::is_punct; + using algorithm::is_xdigit; + using algorithm::is_any_of; + using algorithm::is_from_range; + +} // namespace boost + +#endif // BOOST_STRING_PREDICATE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/compare.hpp b/boost_1_45_0/boost/algorithm/string/compare.hpp new file mode 100644 index 0000000..734303a --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/compare.hpp
@@ -0,0 +1,199 @@ +// Boost string_algo library compare.hpp header file -------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_COMPARE_HPP +#define BOOST_STRING_COMPARE_HPP + +#include <boost/algorithm/string/config.hpp> +#include <locale> + +/*! \file + Defines element comparison predicates. Many algorithms in this library can + take an additional argument with a predicate used to compare elements. + This makes it possible, for instance, to have case insensitive versions + of the algorithms. +*/ + +namespace boost { + namespace algorithm { + + // is_equal functor -----------------------------------------------// + + //! is_equal functor + /*! + Standard STL equal_to only handle comparison between arguments + of the same type. This is a less restrictive version which wraps operator ==. + */ + struct is_equal + { + //! Function operator + /*! + Compare two operands for equality + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + return Arg1==Arg2; + } + }; + + //! case insensitive version of is_equal + /*! + Case insensitive comparison predicate. Comparison is done using + specified locales. + */ + struct is_iequal + { + //! Constructor + /*! + \param Loc locales used for comparison + */ + is_iequal( const std::locale& Loc=std::locale() ) : + m_Loc( Loc ) {} + + //! Function operator + /*! + Compare two operands. Case is ignored. + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) + return std::toupper(Arg1)==std::toupper(Arg2); + #else + return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc); + #endif + } + + private: + std::locale m_Loc; + }; + + // is_less functor -----------------------------------------------// + + //! is_less functor + /*! + Convenient version of standard std::less. Operation is templated, therefore it is + not required to specify the exact types upon the construction + */ + struct is_less + { + //! Functor operation + /*! + Compare two operands using > operator + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + return Arg1<Arg2; + } + }; + + + //! case insensitive version of is_less + /*! + Case insensitive comparison predicate. Comparison is done using + specified locales. + */ + struct is_iless + { + //! Constructor + /*! + \param Loc locales used for comparison + */ + is_iless( const std::locale& Loc=std::locale() ) : + m_Loc( Loc ) {} + + //! Function operator + /*! + Compare two operands. Case is ignored. + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) + return std::toupper(Arg1)<std::toupper(Arg2); + #else + return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc); + #endif + } + + private: + std::locale m_Loc; + }; + + // is_not_greater functor -----------------------------------------------// + + //! is_not_greater functor + /*! + Convenient version of standard std::not_greater_to. Operation is templated, therefore it is + not required to specify the exact types upon the construction + */ + struct is_not_greater + { + //! Functor operation + /*! + Compare two operands using > operator + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + return Arg1<=Arg2; + } + }; + + + //! case insensitive version of is_not_greater + /*! + Case insensitive comparison predicate. Comparison is done using + specified locales. + */ + struct is_not_igreater + { + //! Constructor + /*! + \param Loc locales used for comparison + */ + is_not_igreater( const std::locale& Loc=std::locale() ) : + m_Loc( Loc ) {} + + //! Function operator + /*! + Compare two operands. Case is ignored. + */ + template< typename T1, typename T2 > + bool operator()( const T1& Arg1, const T2& Arg2 ) const + { + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) + return std::toupper(Arg1)<=std::toupper(Arg2); + #else + return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc); + #endif + } + + private: + std::locale m_Loc; + }; + + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::is_equal; + using algorithm::is_iequal; + using algorithm::is_less; + using algorithm::is_iless; + using algorithm::is_not_greater; + using algorithm::is_not_igreater; + +} // namespace boost + + +#endif // BOOST_STRING_COMPARE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/concept.hpp b/boost_1_45_0/boost/algorithm/string/concept.hpp new file mode 100644 index 0000000..9876e98 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/concept.hpp
@@ -0,0 +1,83 @@ +// Boost string_algo library concept.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CONCEPT_HPP +#define BOOST_STRING_CONCEPT_HPP + +#include <boost/concept_check.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +/*! \file + Defines concepts used in string_algo library +*/ + +namespace boost { + namespace algorithm { + + //! Finder concept + /*! + Defines the Finder concept. Finder is a functor which selects + an arbitrary part of a string. Search is performed on + the range specified by starting and ending iterators. + + Result of the find operation must be convertible to iterator_range. + */ + template<typename FinderT, typename IteratorT> + struct FinderConcept + { + private: + typedef iterator_range<IteratorT> range; + public: + void constraints() + { + // Operation + r=(*pF)(i,i); + } + private: + range r; + IteratorT i; + FinderT* pF; + }; // Finder_concept + + + //! Formatter concept + /*! + Defines the Formatter concept. Formatter is a functor, which + takes a result from a finder operation and transforms it + in a specific way. + + Result must be a container supported by container_traits, + or a reference to it. + */ + template<typename FormatterT, typename FinderT, typename IteratorT> + struct FormatterConcept + { + public: + void constraints() + { + // Operation + ::boost::begin((*pFo)( (*pF)(i,i) )); + ::boost::end((*pFo)( (*pF)(i,i) )); + } + private: + IteratorT i; + FinderT* pF; + FormatterT *pFo; + }; // FormatterConcept; + + } // namespace algorithm +} // namespace boost + + + + +#endif // BOOST_STRING_CONCEPT_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/config.hpp b/boost_1_45_0/boost/algorithm/string/config.hpp new file mode 100644 index 0000000..559750a --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/config.hpp
@@ -0,0 +1,28 @@ +// Boost string_algo library config.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CONFIG_HPP +#define BOOST_STRING_CONFIG_HPP + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> + +#ifdef BOOST_STRING_DEDUCED_TYPENAME +# error "macro already defined!" +#endif + +#define BOOST_STRING_TYPENAME BOOST_DEDUCED_TYPENAME + +// Metrowerks workaround +#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x +#pragma parse_func_templ off +#endif + +#endif // BOOST_STRING_CONFIG_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/constants.hpp b/boost_1_45_0/boost/algorithm/string/constants.hpp new file mode 100644 index 0000000..6ed70ef --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/constants.hpp
@@ -0,0 +1,36 @@ +// Boost string_algo library constants.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CONSTANTS_HPP +#define BOOST_STRING_CONSTANTS_HPP + +namespace boost { + namespace algorithm { + + //! Token compression mode + /*! + Specifies token compression mode for the token_finder. + */ + enum token_compress_mode_type + { + token_compress_on, //!< Compress adjacent tokens + token_compress_off //!< Do not compress adjacent tokens + }; + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::token_compress_on; + using algorithm::token_compress_off; + +} // namespace boost + +#endif // BOOST_STRING_CONSTANTS_HPP +
diff --git a/boost_1_45_0/boost/algorithm/string/detail/case_conv.hpp b/boost_1_45_0/boost/algorithm/string/detail/case_conv.hpp new file mode 100644 index 0000000..5b0064f --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/case_conv.hpp
@@ -0,0 +1,121 @@ +// Boost string_algo library string_funct.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP +#define BOOST_STRING_CASE_CONV_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <locale> +#include <functional> + +namespace boost { + namespace algorithm { + namespace detail { + +// case conversion functors -----------------------------------------------// + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +#pragma warning(push) +#pragma warning(disable:4512) //assignment operator could not be generated +#endif + + // a tolower functor + template<typename CharT> + struct to_lowerF : public std::unary_function<CharT, CharT> + { + // Constructor + to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {} + + // Operation + CharT operator ()( CharT Ch ) const + { + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) + return std::tolower( Ch); + #else + return std::tolower<CharT>( Ch, *m_Loc ); + #endif + } + private: + const std::locale* m_Loc; + }; + + // a toupper functor + template<typename CharT> + struct to_upperF : public std::unary_function<CharT, CharT> + { + // Constructor + to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {} + + // Operation + CharT operator ()( CharT Ch ) const + { + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) + return std::toupper( Ch); + #else + return std::toupper<CharT>( Ch, *m_Loc ); + #endif + } + private: + const std::locale* m_Loc; + }; + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +#pragma warning(pop) +#endif + +// algorithm implementation ------------------------------------------------------------------------- + + // Transform a range + template<typename OutputIteratorT, typename RangeT, typename FunctorT> + OutputIteratorT transform_range_copy( + OutputIteratorT Output, + const RangeT& Input, + FunctorT Functor) + { + return std::transform( + ::boost::begin(Input), + ::boost::end(Input), + Output, + Functor); + } + + // Transform a range (in-place) + template<typename RangeT, typename FunctorT> + void transform_range( + const RangeT& Input, + FunctorT Functor) + { + std::transform( + ::boost::begin(Input), + ::boost::end(Input), + ::boost::begin(Input), + Functor); + } + + template<typename SequenceT, typename RangeT, typename FunctorT> + inline SequenceT transform_range_copy( + const RangeT& Input, + FunctorT Functor) + { + return SequenceT( + ::boost::make_transform_iterator( + ::boost::begin(Input), + Functor), + ::boost::make_transform_iterator( + ::boost::end(Input), + Functor)); + } + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_CASE_CONV_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/classification.hpp b/boost_1_45_0/boost/algorithm/string/detail/classification.hpp new file mode 100644 index 0000000..fb43955 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/classification.hpp
@@ -0,0 +1,353 @@ +// Boost string_algo library classification.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP +#define BOOST_STRING_CLASSIFICATION_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <algorithm> +#include <functional> +#include <locale> + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/algorithm/string/predicate_facade.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// classification functors -----------------------------------------------// + + // is_classified functor + struct is_classifiedF : + public predicate_facade<is_classifiedF> + { + // Boost.ResultOf support + typedef bool result_type; + + // Constructor from a locale + is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) : + m_Type(Type), m_Locale(Loc) {} + // Operation + template<typename CharT> + bool operator()( CharT Ch ) const + { + return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch ); + } + + #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x582) && !defined(_USE_OLD_RW_STL) + template<> + bool operator()( char const Ch ) const + { + return std::use_facet< std::ctype<char> >(m_Locale).is( m_Type, Ch ); + } + #endif + + private: + std::ctype_base::mask m_Type; + std::locale m_Locale; + }; + + + // is_any_of functor + /* + returns true if the value is from the specified set + */ + template<typename CharT> + struct is_any_ofF : + public predicate_facade<is_any_ofF<CharT> > + { + private: + // set cannot operate on const value-type + typedef typename ::boost::remove_const<CharT>::type set_value_type; + + public: + // Boost.ResultOf support + typedef bool result_type; + + // Constructor + template<typename RangeT> + is_any_ofF( const RangeT& Range ) : m_Size(0) + { + // Prepare storage + m_Storage.m_dynSet=0; + + std::size_t Size=::boost::distance(Range); + m_Size=Size; + set_value_type* Storage=0; + + if(use_fixed_storage(m_Size)) + { + // Use fixed storage + Storage=&m_Storage.m_fixSet[0]; + } + else + { + // Use dynamic storage + m_Storage.m_dynSet=new set_value_type[m_Size]; + Storage=m_Storage.m_dynSet; + } + + // Use fixed storage + ::std::copy(::boost::begin(Range), ::boost::end(Range), Storage); + ::std::sort(Storage, Storage+m_Size); + } + + // Copy constructor + is_any_ofF(const is_any_ofF& Other) : m_Size(Other.m_Size) + { + // Prepare storage + m_Storage.m_dynSet=0; + const set_value_type* SrcStorage=0; + set_value_type* DestStorage=0; + + if(use_fixed_storage(m_Size)) + { + // Use fixed storage + DestStorage=&m_Storage.m_fixSet[0]; + SrcStorage=&Other.m_Storage.m_fixSet[0]; + } + else + { + // Use dynamic storage + m_Storage.m_dynSet=new set_value_type[m_Size]; + DestStorage=m_Storage.m_dynSet; + SrcStorage=Other.m_Storage.m_dynSet; + } + + // Use fixed storage + ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + } + + // Destructor + ~is_any_ofF() + { + if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) + { + delete [] m_Storage.m_dynSet; + } + } + + // Assignment + is_any_ofF& operator=(const is_any_ofF& Other) + { + // Handle self assignment + if(this==&Other) return *this; + + // Prepare storage + const set_value_type* SrcStorage; + set_value_type* DestStorage; + + if(use_fixed_storage(Other.m_Size)) + { + // Use fixed storage + DestStorage=&m_Storage.m_fixSet[0]; + SrcStorage=&Other.m_Storage.m_fixSet[0]; + + // Delete old storage if was present + if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0) + { + delete [] m_Storage.m_dynSet; + } + + // Set new size + m_Size=Other.m_Size; + } + else + { + // Other uses dynamic storage + SrcStorage=Other.m_Storage.m_dynSet; + + // Check what kind of storage are we using right now + if(use_fixed_storage(m_Size)) + { + // Using fixed storage, allocate new + set_value_type* pTemp=new set_value_type[Other.m_Size]; + DestStorage=pTemp; + m_Storage.m_dynSet=pTemp; + m_Size=Other.m_Size; + } + else + { + // Using dynamic storage, check if can reuse + if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size<Other.m_Size*2) + { + // Reuse the current storage + DestStorage=m_Storage.m_dynSet; + m_Size=Other.m_Size; + } + else + { + // Allocate the new one + set_value_type* pTemp=new set_value_type[Other.m_Size]; + DestStorage=pTemp; + + // Delete old storage if necessary + if(m_Storage.m_dynSet!=0) + { + delete [] m_Storage.m_dynSet; + } + // Store the new storage + m_Storage.m_dynSet=pTemp; + // Set new size + m_Size=Other.m_Size; + } + } + } + + // Copy the data + ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + + return *this; + } + + // Operation + template<typename Char2T> + bool operator()( Char2T Ch ) const + { + const set_value_type* Storage= + (use_fixed_storage(m_Size)) + ? &m_Storage.m_fixSet[0] + : m_Storage.m_dynSet; + + return ::std::binary_search(Storage, Storage+m_Size, Ch); + } + private: + // check if the size is eligible for fixed storage + static bool use_fixed_storage(std::size_t size) + { + return size<=sizeof(set_value_type*)*2; + } + + + private: + // storage + // The actual used storage is selected on the type + union + { + set_value_type* m_dynSet; + set_value_type m_fixSet[sizeof(set_value_type*)*2]; + } + m_Storage; + + // storage size + ::std::size_t m_Size; + }; + + // is_from_range functor + /* + returns true if the value is from the specified range. + (i.e. x>=From && x>=To) + */ + template<typename CharT> + struct is_from_rangeF : + public predicate_facade< is_from_rangeF<CharT> > + { + // Boost.ResultOf support + typedef bool result_type; + + // Constructor + is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {} + + // Operation + template<typename Char2T> + bool operator()( Char2T Ch ) const + { + return ( m_From <= Ch ) && ( Ch <= m_To ); + } + + private: + CharT m_From; + CharT m_To; + }; + + // class_and composition predicate + template<typename Pred1T, typename Pred2T> + struct pred_andF : + public predicate_facade< pred_andF<Pred1T,Pred2T> > + { + public: + + // Boost.ResultOf support + typedef bool result_type; + + // Constructor + pred_andF( Pred1T Pred1, Pred2T Pred2 ) : + m_Pred1(Pred1), m_Pred2(Pred2) {} + + // Operation + template<typename CharT> + bool operator()( CharT Ch ) const + { + return m_Pred1(Ch) && m_Pred2(Ch); + } + + private: + Pred1T m_Pred1; + Pred2T m_Pred2; + }; + + // class_or composition predicate + template<typename Pred1T, typename Pred2T> + struct pred_orF : + public predicate_facade< pred_orF<Pred1T,Pred2T> > + { + public: + // Boost.ResultOf support + typedef bool result_type; + + // Constructor + pred_orF( Pred1T Pred1, Pred2T Pred2 ) : + m_Pred1(Pred1), m_Pred2(Pred2) {} + + // Operation + template<typename CharT> + bool operator()( CharT Ch ) const + { + return m_Pred1(Ch) || m_Pred2(Ch); + } + + private: + Pred1T m_Pred1; + Pred2T m_Pred2; + }; + + // class_not composition predicate + template< typename PredT > + struct pred_notF : + public predicate_facade< pred_notF<PredT> > + { + public: + // Boost.ResultOf support + typedef bool result_type; + + // Constructor + pred_notF( PredT Pred ) : m_Pred(Pred) {} + + // Operation + template<typename CharT> + bool operator()( CharT Ch ) const + { + return !m_Pred(Ch); + } + + private: + PredT m_Pred; + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/find_format.hpp b/boost_1_45_0/boost/algorithm/string/detail/find_format.hpp new file mode 100644 index 0000000..7f5f780 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/find_format.hpp
@@ -0,0 +1,204 @@ +// Boost string_algo library find_format.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_FORMAT_DETAIL_HPP +#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/range/const_iterator.hpp> +#include <boost/range/iterator.hpp> +#include <boost/algorithm/string/detail/find_format_store.hpp> +#include <boost/algorithm/string/detail/replace_storage.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// find_format_copy (iterator variant) implementation -------------------------------// + + template< + typename OutputIteratorT, + typename InputT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline OutputIteratorT find_format_copy_impl2( + OutputIteratorT Output, + const InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult, + const FormatResultT& FormatResult ) + { + typedef find_format_store< + BOOST_STRING_TYPENAME + range_const_iterator<InputT>::type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + if ( !M ) + { + // Match not found - return original sequence + Output = std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); + return Output; + } + + // Copy the beginning of the sequence + Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output ); + // Format find result + // Copy formated result + Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output ); + // Copy the rest of the sequence + Output = std::copy( M.end(), ::boost::end(Input), Output ); + + return Output; + } + + template< + typename OutputIteratorT, + typename InputT, + typename FormatterT, + typename FindResultT > + inline OutputIteratorT find_format_copy_impl( + OutputIteratorT Output, + const InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult ) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + return ::boost::algorithm::detail::find_format_copy_impl2( + Output, + Input, + Formatter, + FindResult, + Formatter(FindResult) ); + } else { + return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); + } + } + + +// find_format_copy implementation --------------------------------------------------// + + template< + typename InputT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline InputT find_format_copy_impl2( + const InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult, + const FormatResultT& FormatResult) + { + typedef find_format_store< + BOOST_STRING_TYPENAME + range_const_iterator<InputT>::type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + if ( !M ) + { + // Match not found - return original sequence + return InputT( Input ); + } + + InputT Output; + // Copy the beginning of the sequence + insert( Output, ::boost::end(Output), ::boost::begin(Input), M.begin() ); + // Copy formated result + insert( Output, ::boost::end(Output), M.format_result() ); + // Copy the rest of the sequence + insert( Output, ::boost::end(Output), M.end(), ::boost::end(Input) ); + + return Output; + } + + template< + typename InputT, + typename FormatterT, + typename FindResultT > + inline InputT find_format_copy_impl( + const InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + return ::boost::algorithm::detail::find_format_copy_impl2( + Input, + Formatter, + FindResult, + Formatter(FindResult) ); + } else { + return Input; + } + } + + // replace implementation ----------------------------------------------------// + + template< + typename InputT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline void find_format_impl2( + InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult, + const FormatResultT& FormatResult) + { + typedef find_format_store< + BOOST_STRING_TYPENAME + range_iterator<InputT>::type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + if ( !M ) + { + // Search not found - return original sequence + return; + } + + // Replace match + ::boost::algorithm::detail::replace( Input, M.begin(), M.end(), M.format_result() ); + } + + template< + typename InputT, + typename FormatterT, + typename FindResultT > + inline void find_format_impl( + InputT& Input, + FormatterT Formatter, + const FindResultT& FindResult) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + ::boost::algorithm::detail::find_format_impl2( + Input, + Formatter, + FindResult, + Formatter(FindResult) ); + } + } + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FIND_FORMAT_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/find_format_all.hpp b/boost_1_45_0/boost/algorithm/string/detail/find_format_all.hpp new file mode 100644 index 0000000..0f184a3 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/find_format_all.hpp
@@ -0,0 +1,273 @@ +// Boost string_algo library find_format_all.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP +#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/range/const_iterator.hpp> +#include <boost/range/value_type.hpp> +#include <boost/algorithm/string/detail/find_format_store.hpp> +#include <boost/algorithm/string/detail/replace_storage.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// find_format_all_copy (iterator variant) implementation ---------------------------// + + template< + typename OutputIteratorT, + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline OutputIteratorT find_format_all_copy_impl2( + OutputIteratorT Output, + const InputT& Input, + FinderT Finder, + FormatterT Formatter, + const FindResultT& FindResult, + const FormatResultT& FormatResult ) + { + typedef BOOST_STRING_TYPENAME + range_const_iterator<InputT>::type input_iterator_type; + + typedef find_format_store< + input_iterator_type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + // Initialize last match + input_iterator_type LastMatch=::boost::begin(Input); + + // Iterate through all matches + while( M ) + { + // Copy the beginning of the sequence + Output = std::copy( LastMatch, M.begin(), Output ); + // Copy formated result + Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output ); + + // Proceed to the next match + LastMatch=M.end(); + M=Finder( LastMatch, ::boost::end(Input) ); + } + + // Copy the rest of the sequence + Output = std::copy( LastMatch, ::boost::end(Input), Output ); + + return Output; + } + + template< + typename OutputIteratorT, + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT > + inline OutputIteratorT find_format_all_copy_impl( + OutputIteratorT Output, + const InputT& Input, + FinderT Finder, + FormatterT Formatter, + const FindResultT& FindResult ) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + return ::boost::algorithm::detail::find_format_all_copy_impl2( + Output, + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); + } else { + return std::copy( ::boost::begin(Input), ::boost::end(Input), Output ); + } + } + + // find_format_all_copy implementation ----------------------------------------------// + + template< + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline InputT find_format_all_copy_impl2( + const InputT& Input, + FinderT Finder, + FormatterT Formatter, + const FindResultT& FindResult, + const FormatResultT& FormatResult) + { + typedef BOOST_STRING_TYPENAME + range_const_iterator<InputT>::type input_iterator_type; + + typedef find_format_store< + input_iterator_type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + // Initialize last match + input_iterator_type LastMatch=::boost::begin(Input); + + // Output temporary + InputT Output; + + // Iterate through all matches + while( M ) + { + // Copy the beginning of the sequence + insert( Output, ::boost::end(Output), LastMatch, M.begin() ); + // Copy formated result + insert( Output, ::boost::end(Output), M.format_result() ); + + // Proceed to the next match + LastMatch=M.end(); + M=Finder( LastMatch, ::boost::end(Input) ); + } + + // Copy the rest of the sequence + ::boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, ::boost::end(Input) ); + + return Output; + } + + template< + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT > + inline InputT find_format_all_copy_impl( + const InputT& Input, + FinderT Finder, + FormatterT Formatter, + const FindResultT& FindResult) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + return ::boost::algorithm::detail::find_format_all_copy_impl2( + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); + } else { + return Input; + } + } + + // find_format_all implementation ------------------------------------------------// + + template< + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT, + typename FormatResultT > + inline void find_format_all_impl2( + InputT& Input, + FinderT Finder, + FormatterT Formatter, + FindResultT FindResult, + FormatResultT FormatResult) + { + typedef BOOST_STRING_TYPENAME + range_iterator<InputT>::type input_iterator_type; + typedef find_format_store< + input_iterator_type, + FormatterT, + FormatResultT > store_type; + + // Create store for the find result + store_type M( FindResult, FormatResult, Formatter ); + + // Instantiate replacement storage + std::deque< + BOOST_STRING_TYPENAME range_value<InputT>::type> Storage; + + // Initialize replacement iterators + input_iterator_type InsertIt=::boost::begin(Input); + input_iterator_type SearchIt=::boost::begin(Input); + + while( M ) + { + // process the segment + InsertIt=process_segment( + Storage, + Input, + InsertIt, + SearchIt, + M.begin() ); + + // Adjust search iterator + SearchIt=M.end(); + + // Copy formated replace to the storage + ::boost::algorithm::detail::copy_to_storage( Storage, M.format_result() ); + + // Find range for a next match + M=Finder( SearchIt, ::boost::end(Input) ); + } + + // process the last segment + InsertIt=::boost::algorithm::detail::process_segment( + Storage, + Input, + InsertIt, + SearchIt, + ::boost::end(Input) ); + + if ( Storage.empty() ) + { + // Truncate input + ::boost::algorithm::detail::erase( Input, InsertIt, ::boost::end(Input) ); + } + else + { + // Copy remaining data to the end of input + ::boost::algorithm::detail::insert( Input, ::boost::end(Input), Storage.begin(), Storage.end() ); + } + } + + template< + typename InputT, + typename FinderT, + typename FormatterT, + typename FindResultT > + inline void find_format_all_impl( + InputT& Input, + FinderT Finder, + FormatterT Formatter, + FindResultT FindResult) + { + if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) { + ::boost::algorithm::detail::find_format_all_impl2( + Input, + Finder, + Formatter, + FindResult, + Formatter(FindResult) ); + } + } + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/find_format_store.hpp b/boost_1_45_0/boost/algorithm/string/detail/find_format_store.hpp new file mode 100644 index 0000000..4872c5a --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/find_format_store.hpp
@@ -0,0 +1,89 @@ +// Boost string_algo library find_format_store.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP +#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/range/iterator_range.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// temporary format and find result storage --------------------------------// + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +#pragma warning(push) +#pragma warning(disable:4512) //assignment operator could not be generated +#endif + template< + typename ForwardIteratorT, + typename FormatterT, + typename FormatResultT > + class find_format_store : + public iterator_range<ForwardIteratorT> + { + public: + // typedefs + typedef iterator_range<ForwardIteratorT> base_type; + typedef FormatterT formatter_type; + typedef FormatResultT format_result_type; + + public: + // Construction + find_format_store( + const base_type& FindResult, + const format_result_type& FormatResult, + const formatter_type& Formatter ) : + base_type(FindResult), + m_FormatResult(FormatResult), + m_Formatter(Formatter) {} + + // Assignment + template< typename FindResultT > + find_format_store& operator=( FindResultT FindResult ) + { + iterator_range<ForwardIteratorT>::operator=(FindResult); + if( !this->empty() ) { + m_FormatResult=m_Formatter(FindResult); + } + + return *this; + } + + // Retrieve format result + const format_result_type& format_result() + { + return m_FormatResult; + } + + private: + format_result_type m_FormatResult; + const formatter_type& m_Formatter; + }; + + template<typename InputT, typename FindResultT> + bool check_find_result(InputT&, FindResultT& FindResult) + { + typedef BOOST_STRING_TYPENAME + range_const_iterator<InputT>::type input_iterator_type; + iterator_range<input_iterator_type> ResultRange(FindResult); + return !ResultRange.empty(); + } + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +#pragma warning(pop) +#endif + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/find_iterator.hpp b/boost_1_45_0/boost/algorithm/string/detail/find_iterator.hpp new file mode 100644 index 0000000..c76993a --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/find_iterator.hpp
@@ -0,0 +1,87 @@ +// Boost string_algo library find_iterator.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP +#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/iterator/iterator_facade.hpp> +#include <boost/iterator/iterator_categories.hpp> +#include <boost/function.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// find_iterator base -----------------------------------------------// + + // Find iterator base + template<typename IteratorT> + class find_iterator_base + { + protected: + // typedefs + typedef IteratorT input_iterator_type; + typedef iterator_range<IteratorT> match_type; + typedef function2< + match_type, + input_iterator_type, + input_iterator_type> finder_type; + + protected: + // Protected construction/destruction + + // Default constructor + find_iterator_base() {}; + // Copy construction + find_iterator_base( const find_iterator_base& Other ) : + m_Finder(Other.m_Finder) {} + + // Constructor + template<typename FinderT> + find_iterator_base( FinderT Finder, int ) : + m_Finder(Finder) {} + + // Destructor + ~find_iterator_base() {} + + // Find operation + match_type do_find( + input_iterator_type Begin, + input_iterator_type End ) const + { + if (!m_Finder.empty()) + { + return m_Finder(Begin,End); + } + else + { + return match_type(End,End); + } + } + + // Check + bool is_null() const + { + return m_Finder.empty(); + } + + private: + // Finder + finder_type m_Finder; + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/finder.hpp b/boost_1_45_0/boost/algorithm/string/detail/finder.hpp new file mode 100644 index 0000000..5fd67fa --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/finder.hpp
@@ -0,0 +1,641 @@ +// Boost string_algo library finder.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FINDER_DETAIL_HPP +#define BOOST_STRING_FINDER_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/algorithm/string/constants.hpp> +#include <boost/detail/iterator.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/empty.hpp> +#include <boost/range/as_literal.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + + +// find first functor -----------------------------------------------// + + // find a subsequence in the sequence ( functor ) + /* + Returns a pair <begin,end> marking the subsequence in the sequence. + If the find fails, functor returns <End,End> + */ + template<typename SearchIteratorT,typename PredicateT> + struct first_finderF + { + typedef SearchIteratorT search_iterator_type; + + // Construction + template< typename SearchT > + first_finderF( const SearchT& Search, PredicateT Comp ) : + m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} + first_finderF( + search_iterator_type SearchBegin, + search_iterator_type SearchEnd, + PredicateT Comp ) : + m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + typedef iterator_range<ForwardIteratorT> result_type; + typedef ForwardIteratorT input_iterator_type; + + // Outer loop + for(input_iterator_type OuterIt=Begin; + OuterIt!=End; + ++OuterIt) + { + // Sanity check + if( boost::empty(m_Search) ) + return result_type( End, End ); + + input_iterator_type InnerIt=OuterIt; + search_iterator_type SubstrIt=m_Search.begin(); + for(; + InnerIt!=End && SubstrIt!=m_Search.end(); + ++InnerIt,++SubstrIt) + { + if( !( m_Comp(*InnerIt,*SubstrIt) ) ) + break; + } + + // Substring matching succeeded + if ( SubstrIt==m_Search.end() ) + return result_type( OuterIt, InnerIt ); + } + + return result_type( End, End ); + } + + private: + iterator_range<search_iterator_type> m_Search; + PredicateT m_Comp; + }; + +// find last functor -----------------------------------------------// + + // find the last match a subseqeunce in the sequence ( functor ) + /* + Returns a pair <begin,end> marking the subsequence in the sequence. + If the find fails, returns <End,End> + */ + template<typename SearchIteratorT, typename PredicateT> + struct last_finderF + { + typedef SearchIteratorT search_iterator_type; + typedef first_finderF< + search_iterator_type, + PredicateT> first_finder_type; + + // Construction + template< typename SearchT > + last_finderF( const SearchT& Search, PredicateT Comp ) : + m_Search(::boost::begin(Search), ::boost::end(Search)), m_Comp(Comp) {} + last_finderF( + search_iterator_type SearchBegin, + search_iterator_type SearchEnd, + PredicateT Comp ) : + m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + typedef iterator_range<ForwardIteratorT> result_type; + + if( boost::empty(m_Search) ) + return result_type( End, End ); + + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits<ForwardIteratorT>::iterator_category category; + + return findit( Begin, End, category() ); + } + + private: + // forward iterator + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + findit( + ForwardIteratorT Begin, + ForwardIteratorT End, + std::forward_iterator_tag ) const + { + typedef iterator_range<ForwardIteratorT> result_type; + + first_finder_type first_finder( + m_Search.begin(), m_Search.end(), m_Comp ); + + result_type M=first_finder( Begin, End ); + result_type Last=M; + + while( M ) + { + Last=M; + M=first_finder( ::boost::end(M), End ); + } + + return Last; + } + + // bidirectional iterator + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + findit( + ForwardIteratorT Begin, + ForwardIteratorT End, + std::bidirectional_iterator_tag ) const + { + typedef iterator_range<ForwardIteratorT> result_type; + typedef ForwardIteratorT input_iterator_type; + + // Outer loop + for(input_iterator_type OuterIt=End; + OuterIt!=Begin; ) + { + input_iterator_type OuterIt2=--OuterIt; + + input_iterator_type InnerIt=OuterIt2; + search_iterator_type SubstrIt=m_Search.begin(); + for(; + InnerIt!=End && SubstrIt!=m_Search.end(); + ++InnerIt,++SubstrIt) + { + if( !( m_Comp(*InnerIt,*SubstrIt) ) ) + break; + } + + // Substring matching succeeded + if( SubstrIt==m_Search.end() ) + return result_type( OuterIt2, InnerIt ); + } + + return result_type( End, End ); + } + + private: + iterator_range<search_iterator_type> m_Search; + PredicateT m_Comp; + }; + +// find n-th functor -----------------------------------------------// + + // find the n-th match of a subsequence in the sequence ( functor ) + /* + Returns a pair <begin,end> marking the subsequence in the sequence. + If the find fails, returns <End,End> + */ + template<typename SearchIteratorT, typename PredicateT> + struct nth_finderF + { + typedef SearchIteratorT search_iterator_type; + typedef first_finderF< + search_iterator_type, + PredicateT> first_finder_type; + typedef last_finderF< + search_iterator_type, + PredicateT> last_finder_type; + + // Construction + template< typename SearchT > + nth_finderF( + const SearchT& Search, + int Nth, + PredicateT Comp) : + m_Search(::boost::begin(Search), ::boost::end(Search)), + m_Nth(Nth), + m_Comp(Comp) {} + nth_finderF( + search_iterator_type SearchBegin, + search_iterator_type SearchEnd, + int Nth, + PredicateT Comp) : + m_Search(SearchBegin, SearchEnd), + m_Nth(Nth), + m_Comp(Comp) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + if(m_Nth>=0) + { + return find_forward(Begin, End, m_Nth); + } + else + { + return find_backward(Begin, End, -m_Nth); + } + + } + + private: + // Implementation helpers + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_forward( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N) const + { + typedef iterator_range<ForwardIteratorT> result_type; + + // Sanity check + if( boost::empty(m_Search) ) + return result_type( End, End ); + + // Instantiate find functor + first_finder_type first_finder( + m_Search.begin(), m_Search.end(), m_Comp ); + + result_type M( Begin, Begin ); + + for( unsigned int n=0; n<=N; ++n ) + { + // find next match + M=first_finder( ::boost::end(M), End ); + + if ( !M ) + { + // Subsequence not found, return + return M; + } + } + + return M; + } + + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_backward( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N) const + { + typedef iterator_range<ForwardIteratorT> result_type; + + // Sanity check + if( boost::empty(m_Search) ) + return result_type( End, End ); + + // Instantiate find functor + last_finder_type last_finder( + m_Search.begin(), m_Search.end(), m_Comp ); + + result_type M( End, End ); + + for( unsigned int n=1; n<=N; ++n ) + { + // find next match + M=last_finder( Begin, ::boost::begin(M) ); + + if ( !M ) + { + // Subsequence not found, return + return M; + } + } + + return M; + } + + + private: + iterator_range<search_iterator_type> m_Search; + int m_Nth; + PredicateT m_Comp; + }; + +// find head/tail implementation helpers ---------------------------// + + template<typename ForwardIteratorT> + iterator_range<ForwardIteratorT> + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::forward_iterator_tag ) + { + typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + input_iterator_type It=Begin; + for( + unsigned int Index=0; + Index<N && It!=End; ++Index,++It ) {}; + + return result_type( Begin, It ); + } + + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::random_access_iterator_tag ) + { + typedef iterator_range<ForwardIteratorT> result_type; + + if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) + return result_type( Begin, End ); + + return result_type(Begin,Begin+N); + } + + // Find head implementation + template<typename ForwardIteratorT> + iterator_range<ForwardIteratorT> + find_head_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N ) + { + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits<ForwardIteratorT>::iterator_category category; + + return ::boost::algorithm::detail::find_head_impl( Begin, End, N, category() ); + } + + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_tail_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::forward_iterator_tag ) + { + typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + unsigned int Index=0; + input_iterator_type It=Begin; + input_iterator_type It2=Begin; + + // Advance It2 by N increments + for( Index=0; Index<N && It2!=End; ++Index,++It2 ) {}; + + // Advance It, It2 to the end + for(; It2!=End; ++It,++It2 ) {}; + + return result_type( It, It2 ); + } + + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_tail_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::bidirectional_iterator_tag ) + { + typedef ForwardIteratorT input_iterator_type; + typedef iterator_range<ForwardIteratorT> result_type; + + input_iterator_type It=End; + for( + unsigned int Index=0; + Index<N && It!=Begin; ++Index,--It ) {}; + + return result_type( It, End ); + } + + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_tail_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N, + std::random_access_iterator_tag ) + { + typedef iterator_range<ForwardIteratorT> result_type; + + if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) ) + return result_type( Begin, End ); + + return result_type( End-N, End ); + } + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + find_tail_impl( + ForwardIteratorT Begin, + ForwardIteratorT End, + unsigned int N ) + { + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits<ForwardIteratorT>::iterator_category category; + + return ::boost::algorithm::detail::find_tail_impl( Begin, End, N, category() ); + } + + + +// find head functor -----------------------------------------------// + + + // find a head in the sequence ( functor ) + /* + This functor find a head of the specified range. For + a specified N, the head is a subsequence of N starting + elements of the range. + */ + struct head_finderF + { + // Construction + head_finderF( int N ) : m_N(N) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + if(m_N>=0) + { + return ::boost::algorithm::detail::find_head_impl( Begin, End, m_N ); + } + else + { + iterator_range<ForwardIteratorT> Res= + ::boost::algorithm::detail::find_tail_impl( Begin, End, -m_N ); + + return ::boost::make_iterator_range(Begin, Res.begin()); + } + } + + private: + int m_N; + }; + +// find tail functor -----------------------------------------------// + + + // find a tail in the sequence ( functor ) + /* + This functor find a tail of the specified range. For + a specified N, the head is a subsequence of N starting + elements of the range. + */ + struct tail_finderF + { + // Construction + tail_finderF( int N ) : m_N(N) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + if(m_N>=0) + { + return ::boost::algorithm::detail::find_tail_impl( Begin, End, m_N ); + } + else + { + iterator_range<ForwardIteratorT> Res= + ::boost::algorithm::detail::find_head_impl( Begin, End, -m_N ); + + return ::boost::make_iterator_range(Res.end(), End); + } + } + + private: + int m_N; + }; + +// find token functor -----------------------------------------------// + + // find a token in a sequence ( functor ) + /* + This find functor finds a token specified be a predicate + in a sequence. It is equivalent of std::find algorithm, + with an exception that it return range instead of a single + iterator. + + If bCompress is set to true, adjacent matching tokens are + concatenated into one match. + */ + template< typename PredicateT > + struct token_finderF + { + // Construction + token_finderF( + PredicateT Pred, + token_compress_mode_type eCompress=token_compress_off ) : + m_Pred(Pred), m_eCompress(eCompress) {} + + // Operation + template< typename ForwardIteratorT > + iterator_range<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + typedef iterator_range<ForwardIteratorT> result_type; + + ForwardIteratorT It=std::find_if( Begin, End, m_Pred ); + + if( It==End ) + { + return result_type( End, End ); + } + else + { + ForwardIteratorT It2=It; + + if( m_eCompress==token_compress_on ) + { + // Find first non-matching character + while( It2!=End && m_Pred(*It2) ) ++It2; + } + else + { + // Advance by one position + ++It2; + } + + return result_type( It, It2 ); + } + } + + private: + PredicateT m_Pred; + token_compress_mode_type m_eCompress; + }; + +// find range functor -----------------------------------------------// + + // find a range in the sequence ( functor ) + /* + This functor actually does not perform any find operation. + It always returns given iterator range as a result. + */ + template<typename ForwardIterator1T> + struct range_finderF + { + typedef ForwardIterator1T input_iterator_type; + typedef iterator_range<input_iterator_type> result_type; + + // Construction + range_finderF( + input_iterator_type Begin, + input_iterator_type End ) : m_Range(Begin, End) {} + + range_finderF(const iterator_range<input_iterator_type>& Range) : + m_Range(Range) {} + + // Operation + template< typename ForwardIterator2T > + iterator_range<ForwardIterator2T> + operator()( + ForwardIterator2T, + ForwardIterator2T ) const + { +#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) + return iterator_range<const ForwardIterator2T>(this->m_Range); +#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end()); +#else + return m_Range; +#endif + } + + private: + iterator_range<input_iterator_type> m_Range; + }; + + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FINDER_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/finder_regex.hpp b/boost_1_45_0/boost/algorithm/string/detail/finder_regex.hpp new file mode 100644 index 0000000..673d93a --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/finder_regex.hpp
@@ -0,0 +1,122 @@ +// Boost string_algo library find_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FINDER_REGEX_DETAIL_HPP +#define BOOST_STRING_FINDER_REGEX_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// regex find functor -----------------------------------------------// + + // regex search result + template<typename IteratorT> + struct regex_search_result : + public iterator_range<IteratorT> + { + typedef regex_search_result<IteratorT> type; + typedef iterator_range<IteratorT> base_type; + typedef BOOST_STRING_TYPENAME base_type::value_type value_type; + typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type; + typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator; + typedef BOOST_STRING_TYPENAME base_type::iterator iterator; + typedef boost::match_results<iterator> match_results_type; + + // Construction + + // Construction from the match result + regex_search_result( const match_results_type& MatchResults ) : + base_type( MatchResults[0].first, MatchResults[0].second ), + m_MatchResults( MatchResults ) {} + + // Construction of empty match. End iterator has to be specified + regex_search_result( IteratorT End ) : + base_type( End, End ) {} + + regex_search_result( const regex_search_result& Other ) : + base_type( Other.begin(), Other.end() ), + m_MatchResults( Other.m_MatchResults ) {} + + // Assignment + regex_search_result& operator=( const regex_search_result& Other ) + { + base_type::operator=( Other ); + m_MatchResults=Other.m_MatchResults; + return *this; + } + + // Match result retrival + const match_results_type& match_results() const + { + return m_MatchResults; + } + + private: + // Saved matchresult + match_results_type m_MatchResults; + }; + + // find_regex + /* + Regex based search functor + */ + template<typename RegExT> + struct find_regexF + { + typedef RegExT regex_type; + typedef const RegExT& regex_reference_type; + + // Construction + find_regexF( regex_reference_type Rx, match_flag_type MatchFlags = match_default ) : + m_Rx(Rx), m_MatchFlags(MatchFlags) {} + + // Operation + template< typename ForwardIteratorT > + regex_search_result<ForwardIteratorT> + operator()( + ForwardIteratorT Begin, + ForwardIteratorT End ) const + { + typedef ForwardIteratorT input_iterator_type; + typedef regex_search_result<ForwardIteratorT> result_type; + + // instantiate match result + match_results<input_iterator_type> result; + // search for a match + if ( ::boost::regex_search( Begin, End, result, m_Rx, m_MatchFlags ) ) + { + // construct a result + return result_type( result ); + } + else + { + // empty result + return result_type( End ); + } + } + + private: + regex_reference_type m_Rx; // Regexp + match_flag_type m_MatchFlags; // match flags + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FIND_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/formatter.hpp b/boost_1_45_0/boost/algorithm/string/detail/formatter.hpp new file mode 100644 index 0000000..bd6a780 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/formatter.hpp
@@ -0,0 +1,94 @@ +// Boost string_algo library formatter.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FORMATTER_DETAIL_HPP +#define BOOST_STRING_FORMATTER_DETAIL_HPP + + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/const_iterator.hpp> + +#include <boost/algorithm/string/detail/util.hpp> + +// generic replace functors -----------------------------------------------// + +namespace boost { + namespace algorithm { + namespace detail { + +// const format functor ----------------------------------------------------// + + // constant format functor + template<typename RangeT> + struct const_formatF + { + private: + typedef BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type format_iterator; + typedef iterator_range<format_iterator> result_type; + + public: + // Construction + const_formatF(const RangeT& Format) : + m_Format(::boost::begin(Format), ::boost::end(Format)) {} + + // Operation +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + template<typename Range2T> + result_type& operator()(const Range2T&) + { + return m_Format; + } +#endif + + template<typename Range2T> + const result_type& operator()(const Range2T&) const + { + return m_Format; + } + + private: + result_type m_Format; + }; + +// identity format functor ----------------------------------------------------// + + // identity format functor + template<typename RangeT> + struct identity_formatF + { + // Operation + template< typename Range2T > + const RangeT& operator()(const Range2T& Replace) const + { + return RangeT(::boost::begin(Replace), ::boost::end(Replace)); + } + }; + +// empty format functor ( used by erase ) ------------------------------------// + + // empty format functor + template< typename CharT > + struct empty_formatF + { + template< typename ReplaceT > + empty_container<CharT> operator()(const ReplaceT&) const + { + return empty_container<CharT>(); + } + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/formatter_regex.hpp b/boost_1_45_0/boost/algorithm/string/detail/formatter_regex.hpp new file mode 100644 index 0000000..5f26407 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/formatter_regex.hpp
@@ -0,0 +1,61 @@ +// Boost string_algo library formatter_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP +#define BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <string> +#include <boost/regex.hpp> +#include <boost/algorithm/string/detail/finder_regex.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// regex format functor -----------------------------------------// + + // regex format functor + template<typename StringT> + struct regex_formatF + { + private: + typedef StringT result_type; + typedef BOOST_STRING_TYPENAME StringT::value_type char_type; + + public: + // Construction + regex_formatF( const StringT& Fmt, match_flag_type Flags=format_default ) : + m_Fmt(Fmt), m_Flags( Flags ) {} + + template<typename InputIteratorT> + result_type operator()( + const regex_search_result<InputIteratorT>& Replace ) const + { + if ( Replace.empty() ) + { + return result_type(); + } + else + { + return Replace.match_results().format( m_Fmt, m_Flags ); + } + } + private: + const StringT& m_Fmt; + match_flag_type m_Flags; + }; + + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/predicate.hpp b/boost_1_45_0/boost/algorithm/string/detail/predicate.hpp new file mode 100644 index 0000000..5acf3cc --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/predicate.hpp
@@ -0,0 +1,77 @@ +// Boost string_algo library predicate.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP +#define BOOST_STRING_PREDICATE_DETAIL_HPP + +#include <iterator> +#include <boost/algorithm/string/find.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// ends_with predicate implementation ----------------------------------// + + template< + typename ForwardIterator1T, + typename ForwardIterator2T, + typename PredicateT> + inline bool ends_with_iter_select( + ForwardIterator1T Begin, + ForwardIterator1T End, + ForwardIterator2T SubBegin, + ForwardIterator2T SubEnd, + PredicateT Comp, + std::bidirectional_iterator_tag) + { + ForwardIterator1T it=End; + ForwardIterator2T pit=SubEnd; + for(;it!=Begin && pit!=SubBegin;) + { + if( !(Comp(*(--it),*(--pit))) ) + return false; + } + + return pit==SubBegin; + } + + template< + typename ForwardIterator1T, + typename ForwardIterator2T, + typename PredicateT> + inline bool ends_with_iter_select( + ForwardIterator1T Begin, + ForwardIterator1T End, + ForwardIterator2T SubBegin, + ForwardIterator2T SubEnd, + PredicateT Comp, + std::forward_iterator_tag) + { + if ( SubBegin==SubEnd ) + { + // empty subsequence check + return true; + } + + iterator_range<ForwardIterator1T> Result + =last_finder( + ::boost::make_iterator_range(SubBegin, SubEnd), + Comp)(Begin, End); + + return !Result.empty() && Result.end()==End; + } + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_PREDICATE_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/replace_storage.hpp b/boost_1_45_0/boost/algorithm/string/detail/replace_storage.hpp new file mode 100644 index 0000000..db35e4c --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/replace_storage.hpp
@@ -0,0 +1,159 @@ +// Boost string_algo library replace_storage.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP +#define BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <algorithm> +#include <boost/mpl/bool.hpp> +#include <boost/algorithm/string/sequence_traits.hpp> +#include <boost/algorithm/string/detail/sequence.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// storage handling routines -----------------------------------------------// + + template< typename StorageT, typename OutputIteratorT > + inline OutputIteratorT move_from_storage( + StorageT& Storage, + OutputIteratorT DestBegin, + OutputIteratorT DestEnd ) + { + OutputIteratorT OutputIt=DestBegin; + + while( !Storage.empty() && OutputIt!=DestEnd ) + { + *OutputIt=Storage.front(); + Storage.pop_front(); + ++OutputIt; + } + + return OutputIt; + } + + template< typename StorageT, typename WhatT > + inline void copy_to_storage( + StorageT& Storage, + const WhatT& What ) + { + Storage.insert( Storage.end(), ::boost::begin(What), ::boost::end(What) ); + } + + +// process segment routine -----------------------------------------------// + + template< bool HasStableIterators > + struct process_segment_helper + { + // Optimized version of process_segment for generic sequence + template< + typename StorageT, + typename InputT, + typename ForwardIteratorT > + ForwardIteratorT operator()( + StorageT& Storage, + InputT& /*Input*/, + ForwardIteratorT InsertIt, + ForwardIteratorT SegmentBegin, + ForwardIteratorT SegmentEnd ) + { + // Copy data from the storage until the beginning of the segment + ForwardIteratorT It=::boost::algorithm::detail::move_from_storage( Storage, InsertIt, SegmentBegin ); + + // 3 cases are possible : + // a) Storage is empty, It==SegmentBegin + // b) Storage is empty, It!=SegmentBegin + // c) Storage is not empty + + if( Storage.empty() ) + { + if( It==SegmentBegin ) + { + // Case a) everything is grand, just return end of segment + return SegmentEnd; + } + else + { + // Case b) move the segment backwards + return std::copy( SegmentBegin, SegmentEnd, It ); + } + } + else + { + // Case c) -> shift the segment to the left and keep the overlap in the storage + while( It!=SegmentEnd ) + { + // Store value into storage + Storage.push_back( *It ); + // Get the top from the storage and put it here + *It=Storage.front(); + Storage.pop_front(); + + // Advance + ++It; + } + + return It; + } + } + }; + + template<> + struct process_segment_helper< true > + { + // Optimized version of process_segment for list-like sequence + template< + typename StorageT, + typename InputT, + typename ForwardIteratorT > + ForwardIteratorT operator()( + StorageT& Storage, + InputT& Input, + ForwardIteratorT InsertIt, + ForwardIteratorT SegmentBegin, + ForwardIteratorT SegmentEnd ) + + { + // Call replace to do the job + ::boost::algorithm::detail::replace( Input, InsertIt, SegmentBegin, Storage ); + // Empty the storage + Storage.clear(); + // Iterators were not changed, simply return the end of segment + return SegmentEnd; + } + }; + + // Process one segment in the replace_all algorithm + template< + typename StorageT, + typename InputT, + typename ForwardIteratorT > + inline ForwardIteratorT process_segment( + StorageT& Storage, + InputT& Input, + ForwardIteratorT InsertIt, + ForwardIteratorT SegmentBegin, + ForwardIteratorT SegmentEnd ) + { + return + process_segment_helper< + has_stable_iterators<InputT>::value>()( + Storage, Input, InsertIt, SegmentBegin, SegmentEnd ); + } + + + } // namespace detail + } // namespace algorithm +} // namespace boost + +#endif // BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/sequence.hpp b/boost_1_45_0/boost/algorithm/string/detail/sequence.hpp new file mode 100644 index 0000000..dc47409 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/sequence.hpp
@@ -0,0 +1,200 @@ +// Boost string_algo library sequence.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_DETAIL_SEQUENCE_HPP +#define BOOST_STRING_DETAIL_SEQUENCE_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/logical.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> + +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// insert helpers -------------------------------------------------// + + template< typename InputT, typename ForwardIteratorT > + inline void insert( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator At, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + Input.insert( At, Begin, End ); + } + + template< typename InputT, typename InsertT > + inline void insert( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator At, + const InsertT& Insert ) + { + ::boost::algorithm::detail::insert( Input, At, ::boost::begin(Insert), ::boost::end(Insert) ); + } + +// erase helper ---------------------------------------------------// + + // Erase a range in the sequence + /* + Returns the iterator pointing just after the erase subrange + */ + template< typename InputT > + inline typename InputT::iterator erase( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To ) + { + return Input.erase( From, To ); + } + +// replace helper implementation ----------------------------------// + + // Optimized version of replace for generic sequence containers + // Assumption: insert and erase are expensive + template< bool HasConstTimeOperations > + struct replace_const_time_helper + { + template< typename InputT, typename ForwardIteratorT > + void operator()( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + // Copy data to the container ( as much as possible ) + ForwardIteratorT InsertIt=Begin; + BOOST_STRING_TYPENAME InputT::iterator InputIt=From; + for(; InsertIt!=End && InputIt!=To; InsertIt++, InputIt++ ) + { + *InputIt=*InsertIt; + } + + if ( InsertIt!=End ) + { + // Replace sequence is longer, insert it + Input.insert( InputIt, InsertIt, End ); + } + else + { + if ( InputIt!=To ) + { + // Replace sequence is shorter, erase the rest + Input.erase( InputIt, To ); + } + } + } + }; + + template<> + struct replace_const_time_helper< true > + { + // Const-time erase and insert methods -> use them + template< typename InputT, typename ForwardIteratorT > + void operator()( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To ); + if ( Begin!=End ) + { + if(!Input.empty()) + { + Input.insert( At, Begin, End ); + } + else + { + Input.insert( Input.begin(), Begin, End ); + } + } + } + }; + + // No native replace method + template< bool HasNative > + struct replace_native_helper + { + template< typename InputT, typename ForwardIteratorT > + void operator()( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + replace_const_time_helper< + boost::mpl::and_< + has_const_time_insert<InputT>, + has_const_time_erase<InputT> >::value >()( + Input, From, To, Begin, End ); + } + }; + + // Container has native replace method + template<> + struct replace_native_helper< true > + { + template< typename InputT, typename ForwardIteratorT > + void operator()( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + Input.replace( From, To, Begin, End ); + } + }; + +// replace helper -------------------------------------------------// + + template< typename InputT, typename ForwardIteratorT > + inline void replace( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + replace_native_helper< has_native_replace<InputT>::value >()( + Input, From, To, Begin, End ); + } + + template< typename InputT, typename InsertT > + inline void replace( + InputT& Input, + BOOST_STRING_TYPENAME InputT::iterator From, + BOOST_STRING_TYPENAME InputT::iterator To, + const InsertT& Insert ) + { + if(From!=To) + { + ::boost::algorithm::detail::replace( Input, From, To, ::boost::begin(Insert), ::boost::end(Insert) ); + } + else + { + ::boost::algorithm::detail::insert( Input, From, ::boost::begin(Insert), ::boost::end(Insert) ); + } + } + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_DETAIL_SEQUENCE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/trim.hpp b/boost_1_45_0/boost/algorithm/string/detail/trim.hpp new file mode 100644 index 0000000..1233e49 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/trim.hpp
@@ -0,0 +1,95 @@ +// Boost string_algo library trim.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_TRIM_DETAIL_HPP +#define BOOST_STRING_TRIM_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/detail/iterator.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// trim iterator helper -----------------------------------------------// + + template< typename ForwardIteratorT, typename PredicateT > + inline ForwardIteratorT trim_end_iter_select( + ForwardIteratorT InBegin, + ForwardIteratorT InEnd, + PredicateT IsSpace, + std::forward_iterator_tag ) + { + ForwardIteratorT TrimIt=InBegin; + + for( ForwardIteratorT It=InBegin; It!=InEnd; ++It ) + { + if ( !IsSpace(*It) ) + { + TrimIt=It; + ++TrimIt; + } + } + + return TrimIt; + } + + template< typename ForwardIteratorT, typename PredicateT > + inline ForwardIteratorT trim_end_iter_select( + ForwardIteratorT InBegin, + ForwardIteratorT InEnd, + PredicateT IsSpace, + std::bidirectional_iterator_tag ) + { + for( ForwardIteratorT It=InEnd; It!=InBegin; ) + { + if ( !IsSpace(*(--It)) ) + return ++It; + } + + return InBegin; + } + // Search for first non matching character from the beginning of the sequence + template< typename ForwardIteratorT, typename PredicateT > + inline ForwardIteratorT trim_begin( + ForwardIteratorT InBegin, + ForwardIteratorT InEnd, + PredicateT IsSpace ) + { + ForwardIteratorT It=InBegin; + for(; It!=InEnd; ++It ) + { + if (!IsSpace(*It)) + return It; + } + + return It; + } + + // Search for first non matching character from the end of the sequence + template< typename ForwardIteratorT, typename PredicateT > + inline ForwardIteratorT trim_end( + ForwardIteratorT InBegin, + ForwardIteratorT InEnd, + PredicateT IsSpace ) + { + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits<ForwardIteratorT>::iterator_category category; + + return ::boost::algorithm::detail::trim_end_iter_select( InBegin, InEnd, IsSpace, category() ); + } + + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_TRIM_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/detail/util.hpp b/boost_1_45_0/boost/algorithm/string/detail/util.hpp new file mode 100644 index 0000000..7e8471f --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/detail/util.hpp
@@ -0,0 +1,106 @@ +// Boost string_algo library util.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_UTIL_DETAIL_HPP +#define BOOST_STRING_UTIL_DETAIL_HPP + +#include <boost/algorithm/string/config.hpp> +#include <functional> +#include <boost/range/iterator_range.hpp> + +namespace boost { + namespace algorithm { + namespace detail { + +// empty container -----------------------------------------------// + + // empty_container + /* + This class represents always empty container, + containing elements of type CharT. + + It is supposed to be used in a const version only + */ + template< typename CharT > + struct empty_container + { + typedef empty_container<CharT> type; + typedef CharT value_type; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type& reference; + typedef const value_type& const_reference; + typedef const value_type* iterator; + typedef const value_type* const_iterator; + + + // Operations + const_iterator begin() const + { + return reinterpret_cast<const_iterator>(0); + } + + const_iterator end() const + { + return reinterpret_cast<const_iterator>(0); + } + + bool empty() const + { + return false; + } + + size_type size() const + { + return 0; + } + }; + +// bounded copy algorithm -----------------------------------------------// + + // Bounded version of the std::copy algorithm + template<typename InputIteratorT, typename OutputIteratorT> + inline OutputIteratorT bounded_copy( + InputIteratorT First, + InputIteratorT Last, + OutputIteratorT DestFirst, + OutputIteratorT DestLast ) + { + InputIteratorT InputIt=First; + OutputIteratorT OutputIt=DestFirst; + for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ ) + { + *OutputIt=*InputIt; + } + + return OutputIt; + } + +// iterator range utilities -----------------------------------------// + + // copy range functor + template< + typename SeqT, + typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator > + struct copy_iterator_rangeF : + public std::unary_function< iterator_range<IteratorT>, SeqT > + { + SeqT operator()( const iterator_range<IteratorT>& Range ) const + { + return copy_range<SeqT>(Range); + } + }; + + } // namespace detail + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_UTIL_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/erase.hpp b/boost_1_45_0/boost/algorithm/string/erase.hpp new file mode 100644 index 0000000..e738b86 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/erase.hpp
@@ -0,0 +1,844 @@ +// Boost string_algo library erase.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_ERASE_HPP +#define BOOST_STRING_ERASE_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/const_iterator.hpp> + +#include <boost/algorithm/string/find_format.hpp> +#include <boost/algorithm/string/finder.hpp> +#include <boost/algorithm/string/formatter.hpp> + +/*! \file + Defines various erase algorithms. Each algorithm removes + part(s) of the input according to a searching criteria. +*/ + +namespace boost { + namespace algorithm { + +// erase_range -------------------------------------------------------// + + //! Erase range algorithm + /*! + Remove the given range from the input. The result is a modified copy of + the input. It is returned as a sequence or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input sequence + \param SearchRange A range in the input to be removed + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template<typename OutputIteratorT, typename RangeT> + inline OutputIteratorT erase_range_copy( + OutputIteratorT Output, + const RangeT& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type>& SearchRange ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase range algorithm + /*! + \overload + */ + template<typename SequenceT> + inline SequenceT erase_range_copy( + const SequenceT& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_const_iterator<SequenceT>::type>& SearchRange ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase range algorithm + /*! + Remove the given range from the input. + The input sequence is modified in-place. + + \param Input An input sequence + \param SearchRange A range in the input to be removed + */ + template<typename SequenceT> + inline void erase_range( + SequenceT& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_iterator<SequenceT>::type>& SearchRange ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_first --------------------------------------------------------// + + //! Erase first algorithm + /*! + Remove the first occurrence of the substring from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT erase_first_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase first algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT erase_first_copy( + const SequenceT& Input, + const RangeT& Search ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase first algorithm + /*! + Remove the first occurrence of the substring from the input. + The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for. + */ + template<typename SequenceT, typename RangeT> + inline void erase_first( + SequenceT& Input, + const RangeT& Search ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_first ( case insensitive ) ------------------------------------// + + //! Erase first algorithm ( case insensitive ) + /*! + Remove the first occurrence of the substring from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT ierase_first_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase first algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT ierase_first_copy( + const SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase first algorithm ( case insensitive ) + /*! + Remove the first occurrence of the substring from the input. + The input sequence is modified in-place. Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename RangeT> + inline void ierase_first( + SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_last --------------------------------------------------------// + + //! Erase last algorithm + /*! + Remove the last occurrence of the substring from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for. + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT erase_last_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase last algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT erase_last_copy( + const SequenceT& Input, + const RangeT& Search ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase last algorithm + /*! + Remove the last occurrence of the substring from the input. + The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for + */ + template<typename SequenceT, typename RangeT> + inline void erase_last( + SequenceT& Input, + const RangeT& Search ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_last ( case insensitive ) ------------------------------------// + + //! Erase last algorithm ( case insensitive ) + /*! + Remove the last occurrence of the substring from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT ierase_last_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase last algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT ierase_last_copy( + const SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase last algorithm ( case insensitive ) + /*! + Remove the last occurrence of the substring from the input. + The input sequence is modified in-place. Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename RangeT> + inline void ierase_last( + SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_nth --------------------------------------------------------------------// + + //! Erase nth algorithm + /*! + Remove the Nth occurrence of the substring in the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT erase_nth_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + int Nth ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase nth algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT erase_nth_copy( + const SequenceT& Input, + const RangeT& Search, + int Nth ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase nth algorithm + /*! + Remove the Nth occurrence of the substring in the input. + The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for. + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + */ + template<typename SequenceT, typename RangeT> + inline void erase_nth( + SequenceT& Input, + const RangeT& Search, + int Nth ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_nth ( case insensitive ) ---------------------------------------------// + + //! Erase nth algorithm ( case insensitive ) + /*! + Remove the Nth occurrence of the substring in the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for. + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT ierase_nth_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + int Nth, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase nth algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT ierase_nth_copy( + const SequenceT& Input, + const RangeT& Search, + int Nth, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), + empty_formatter(Input) ); + } + + //! Erase nth algorithm + /*! + Remove the Nth occurrence of the substring in the input. + The input sequence is modified in-place. Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for. + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename RangeT> + inline void ierase_nth( + SequenceT& Input, + const RangeT& Search, + int Nth, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + +// erase_all --------------------------------------------------------// + + //! Erase all algorithm + /*! + Remove all the occurrences of the string from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + + \param Output An output iterator to which the result will be copied + \param Input An input sequence + \param Search A substring to be searched for. + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT erase_all_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase all algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT erase_all_copy( + const SequenceT& Input, + const RangeT& Search ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase all algorithm + /*! + Remove all the occurrences of the string from the input. + The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for. + */ + template<typename SequenceT, typename RangeT> + inline void erase_all( + SequenceT& Input, + const RangeT& Search ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_all ( case insensitive ) ------------------------------------// + + //! Erase all algorithm ( case insensitive ) + /*! + Remove all the occurrences of the string from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT ierase_all_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase all algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT ierase_all_copy( + const SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + + //! Erase all algorithm ( case insensitive ) + /*! + Remove all the occurrences of the string from the input. + The input sequence is modified in-place. Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for. + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename RangeT> + inline void ierase_all( + SequenceT& Input, + const RangeT& Search, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::empty_formatter(Input) ); + } + +// erase_head --------------------------------------------------------------------// + + //! Erase head algorithm + /*! + Remove the head from the input. The head is a prefix of a sequence of given size. + If the sequence is shorter then required, the whole string is + considered to be the head. The result is a modified copy of the input. + It is returned as a sequence or copied to the output iterator. + + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param N Length of the head. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT> + inline OutputIteratorT erase_head_copy( + OutputIteratorT Output, + const RangeT& Input, + int N ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase head algorithm + /*! + \overload + */ + template<typename SequenceT> + inline SequenceT erase_head_copy( + const SequenceT& Input, + int N ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase head algorithm + /*! + Remove the head from the input. The head is a prefix of a sequence of given size. + If the sequence is shorter then required, the whole string is + considered to be the head. The input sequence is modified in-place. + + \param Input An input string + \param N Length of the head + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + */ + template<typename SequenceT> + inline void erase_head( + SequenceT& Input, + int N ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + +// erase_tail --------------------------------------------------------------------// + + //! Erase tail algorithm + /*! + Remove the tail from the input. The tail is a suffix of a sequence of given size. + If the sequence is shorter then required, the whole string is + considered to be the tail. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param N Length of the tail. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT> + inline OutputIteratorT erase_tail_copy( + OutputIteratorT Output, + const RangeT& Input, + int N ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase tail algorithm + /*! + \overload + */ + template<typename SequenceT> + inline SequenceT erase_tail_copy( + const SequenceT& Input, + int N ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase tail algorithm + /*! + Remove the tail from the input. The tail is a suffix of a sequence of given size. + If the sequence is shorter then required, the whole string is + considered to be the tail. The input sequence is modified in-place. + + \param Input An input string + \param N Length of the tail + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + */ + template<typename SequenceT> + inline void erase_tail( + SequenceT& Input, + int N ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::empty_formatter( Input ) ); + } + + } // namespace algorithm + + // pull names into the boost namespace + using algorithm::erase_range_copy; + using algorithm::erase_range; + using algorithm::erase_first_copy; + using algorithm::erase_first; + using algorithm::ierase_first_copy; + using algorithm::ierase_first; + using algorithm::erase_last_copy; + using algorithm::erase_last; + using algorithm::ierase_last_copy; + using algorithm::ierase_last; + using algorithm::erase_nth_copy; + using algorithm::erase_nth; + using algorithm::ierase_nth_copy; + using algorithm::ierase_nth; + using algorithm::erase_all_copy; + using algorithm::erase_all; + using algorithm::ierase_all_copy; + using algorithm::ierase_all; + using algorithm::erase_head_copy; + using algorithm::erase_head; + using algorithm::erase_tail_copy; + using algorithm::erase_tail; + +} // namespace boost + + +#endif // BOOST_ERASE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/find.hpp b/boost_1_45_0/boost/algorithm/string/find.hpp new file mode 100644 index 0000000..304646d --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/find.hpp
@@ -0,0 +1,334 @@ +// Boost string_algo library find.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_HPP +#define BOOST_STRING_FIND_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/finder.hpp> +#include <boost/algorithm/string/compare.hpp> +#include <boost/algorithm/string/constants.hpp> + +/*! \file + Defines a set of find algorithms. The algorithms are searching + for a substring of the input. The result is given as an \c iterator_range + delimiting the substring. +*/ + +namespace boost { + namespace algorithm { + +// Generic find -----------------------------------------------// + + //! Generic find algorithm + /*! + Search the input using the given finder. + + \param Input A string which will be searched. + \param Finder Finder object used for searching. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + */ + template<typename RangeT, typename FinderT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + find( + RangeT& Input, + const FinderT& Finder) + { + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + return Finder(::boost::begin(lit_input),::boost::end(lit_input)); + } + +// find_first -----------------------------------------------// + + //! Find first algorithm + /*! + Search for the first occurrence of the substring in the input. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + find_first( + Range1T& Input, + const Range2T& Search) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search)); + } + + //! Find first algorithm ( case insensitive ) + /*! + Search for the first occurence of the substring in the input. + Searching is case insensitive. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \param Loc A locale used for case insensitive comparison + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + ifind_first( + Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search,is_iequal(Loc))); + } + +// find_last -----------------------------------------------// + + //! Find last algorithm + /*! + Search for the last occurrence of the substring in the input. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + find_last( + Range1T& Input, + const Range2T& Search) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search)); + } + + //! Find last algorithm ( case insensitive ) + /*! + Search for the last match a string in the input. + Searching is case insensitive. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \param Loc A locale used for case insensitive comparison + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + ifind_last( + Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search, is_iequal(Loc))); + } + +// find_nth ----------------------------------------------------------------------// + + //! Find n-th algorithm + /*! + Search for the n-th (zero-indexed) occurrence of the substring in the + input. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \param Nth An index (zero-indexed) of the match to be found. + For negative N, the matches are counted from the end of string. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + find_nth( + Range1T& Input, + const Range2T& Search, + int Nth) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth)); + } + + //! Find n-th algorithm ( case insensitive ). + /*! + Search for the n-th (zero-indexed) occurrence of the substring in the + input. Searching is case insensitive. + + \param Input A string which will be searched. + \param Search A substring to be searched for. + \param Nth An index (zero-indexed) of the match to be found. + For negative N, the matches are counted from the end of string. + \param Loc A locale used for case insensitive comparison + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<Range1T>::type> + ifind_nth( + Range1T& Input, + const Range2T& Search, + int Nth, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth,is_iequal(Loc))); + } + +// find_head ----------------------------------------------------------------------// + + //! Find head algorithm + /*! + Get the head of the input. Head is a prefix of the string of the + given size. If the input is shorter then required, whole input if considered + to be the head. + + \param Input An input string + \param N Length of the head + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c Range1T::iterator or + \c Range1T::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename RangeT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + find_head( + RangeT& Input, + int N) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::head_finder(N)); + } + +// find_tail ----------------------------------------------------------------------// + + //! Find tail algorithm + /*! + Get the tail of the input. Tail is a suffix of the string of the + given size. If the input is shorter then required, whole input if considered + to be the tail. + + \param Input An input string + \param N Length of the tail. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + + + \note This function provides the strong exception-safety guarantee + */ + template<typename RangeT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + find_tail( + RangeT& Input, + int N) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::tail_finder(N)); + } + +// find_token --------------------------------------------------------------------// + + //! Find token algorithm + /*! + Look for a given token in the string. Token is a character that matches the + given predicate. + If the "token compress mode" is enabled, adjacent tokens are considered to be one match. + + \param Input A input string. + \param Pred An unary predicate to identify a token + \param eCompress Enable/Disable compressing of adjacent tokens + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template<typename RangeT, typename PredicateT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + find_token( + RangeT& Input, + PredicateT Pred, + token_compress_mode_type eCompress=token_compress_off) + { + return ::boost::algorithm::find(Input, ::boost::algorithm::token_finder(Pred, eCompress)); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::find; + using algorithm::find_first; + using algorithm::ifind_first; + using algorithm::find_last; + using algorithm::ifind_last; + using algorithm::find_nth; + using algorithm::ifind_nth; + using algorithm::find_head; + using algorithm::find_tail; + using algorithm::find_token; + +} // namespace boost + + +#endif // BOOST_STRING_FIND_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/find_format.hpp b/boost_1_45_0/boost/algorithm/string/find_format.hpp new file mode 100644 index 0000000..ef03739 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/find_format.hpp
@@ -0,0 +1,287 @@ +// Boost string_algo library find_format.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_FORMAT_HPP +#define BOOST_STRING_FIND_FORMAT_HPP + +#include <deque> +#include <boost/detail/iterator.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/const_iterator.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/concept.hpp> +#include <boost/algorithm/string/detail/find_format.hpp> +#include <boost/algorithm/string/detail/find_format_all.hpp> + +/*! \file + Defines generic replace algorithms. Each algorithm replaces + part(s) of the input. The part to be replaced is looked up using a Finder object. + Result of finding is then used by a Formatter object to generate the replacement. +*/ + +namespace boost { + namespace algorithm { + +// generic replace -----------------------------------------------------------------// + + //! Generic replace algorithm + /*! + Use the Finder to search for a substring. Use the Formatter to format + this substring and replace it in the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input sequence + \param Finder A Finder object used to search for a match to be replaced + \param Formatter A Formatter object used to format a match + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename FinderT, + typename FormatterT> + inline OutputIteratorT find_format_copy( + OutputIteratorT Output, + const RangeT& Input, + FinderT Finder, + FormatterT Formatter ) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> + )); + + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + return detail::find_format_copy_impl( + Output, + lit_input, + Formatter, + Finder( ::boost::begin(lit_input), ::boost::end(lit_input) ) ); + } + + //! Generic replace algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename FinderT, + typename FormatterT> + inline SequenceT find_format_copy( + const SequenceT& Input, + FinderT Finder, + FormatterT Formatter ) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + + return detail::find_format_copy_impl( + Input, + Formatter, + Finder(::boost::begin(Input), ::boost::end(Input))); + } + + //! Generic replace algorithm + /*! + Use the Finder to search for a substring. Use the Formatter to format + this substring and replace it in the input. The input is modified in-place. + + \param Input An input sequence + \param Finder A Finder object used to search for a match to be replaced + \param Formatter A Formatter object used to format a match + */ + template< + typename SequenceT, + typename FinderT, + typename FormatterT> + inline void find_format( + SequenceT& Input, + FinderT Finder, + FormatterT Formatter) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + + detail::find_format_impl( + Input, + Formatter, + Finder(::boost::begin(Input), ::boost::end(Input))); + } + + +// find_format_all generic ----------------------------------------------------------------// + + //! Generic replace all algorithm + /*! + Use the Finder to search for a substring. Use the Formatter to format + this substring and replace it in the input. Repeat this for all matching + substrings. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input sequence + \param Finder A Finder object used to search for a match to be replaced + \param Formatter A Formatter object used to format a match + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename FinderT, + typename FormatterT> + inline OutputIteratorT find_format_all_copy( + OutputIteratorT Output, + const RangeT& Input, + FinderT Finder, + FormatterT Formatter) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> + )); + + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + return detail::find_format_all_copy_impl( + Output, + lit_input, + Finder, + Formatter, + Finder(::boost::begin(lit_input), ::boost::end(lit_input))); + } + + //! Generic replace all algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename FinderT, + typename FormatterT > + inline SequenceT find_format_all_copy( + const SequenceT& Input, + FinderT Finder, + FormatterT Formatter ) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + + return detail::find_format_all_copy_impl( + Input, + Finder, + Formatter, + Finder( ::boost::begin(Input), ::boost::end(Input) ) ); + } + + //! Generic replace all algorithm + /*! + Use the Finder to search for a substring. Use the Formatter to format + this substring and replace it in the input. Repeat this for all matching + substrings.The input is modified in-place. + + \param Input An input sequence + \param Finder A Finder object used to search for a match to be replaced + \param Formatter A Formatter object used to format a match + */ + template< + typename SequenceT, + typename FinderT, + typename FormatterT > + inline void find_format_all( + SequenceT& Input, + FinderT Finder, + FormatterT Formatter ) + { + // Concept check + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + BOOST_CONCEPT_ASSERT(( + FormatterConcept< + FormatterT, + FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type> + )); + + detail::find_format_all_impl( + Input, + Finder, + Formatter, + Finder(::boost::begin(Input), ::boost::end(Input))); + + } + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::find_format_copy; + using algorithm::find_format; + using algorithm::find_format_all_copy; + using algorithm::find_format_all; + +} // namespace boost + + +#endif // BOOST_STRING_FIND_FORMAT_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/find_iterator.hpp b/boost_1_45_0/boost/algorithm/string/find_iterator.hpp new file mode 100644 index 0000000..72696c7 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/find_iterator.hpp
@@ -0,0 +1,375 @@ +// Boost string_algo library find_iterator.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2004. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FIND_ITERATOR_HPP +#define BOOST_STRING_FIND_ITERATOR_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/iterator/iterator_facade.hpp> +#include <boost/iterator/iterator_categories.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/detail/find_iterator.hpp> + +/*! \file + Defines find iterator classes. Find iterator repeatedly applies a Finder + to the specified input string to search for matches. Dereferencing + the iterator yields the current match or a range between the last and the current + match depending on the iterator used. +*/ + +namespace boost { + namespace algorithm { + +// find_iterator -----------------------------------------------// + + //! find_iterator + /*! + Find iterator encapsulates a Finder and allows + for incremental searching in a string. + Each increment moves the iterator to the next match. + + Find iterator is a readable forward traversal iterator. + + Dereferencing the iterator yields an iterator_range delimiting + the current match. + */ + template<typename IteratorT> + class find_iterator : + public iterator_facade< + find_iterator<IteratorT>, + const iterator_range<IteratorT>, + forward_traversal_tag >, + private detail::find_iterator_base<IteratorT> + { + private: + // facade support + friend class ::boost::iterator_core_access; + + private: + // typedefs + + typedef detail::find_iterator_base<IteratorT> base_type; + typedef BOOST_STRING_TYPENAME + base_type::input_iterator_type input_iterator_type; + typedef BOOST_STRING_TYPENAME + base_type::match_type match_type; + + public: + //! Default constructor + /*! + Construct null iterator. All null iterators are equal. + + \post eof()==true + */ + find_iterator() {} + + //! Copy constructor + /*! + Construct a copy of the find_iterator + */ + find_iterator( const find_iterator& Other ) : + base_type(Other), + m_Match(Other.m_Match), + m_End(Other.m_End) {} + + //! Constructor + /*! + Construct new find_iterator for a given finder + and a range. + */ + template<typename FinderT> + find_iterator( + IteratorT Begin, + IteratorT End, + FinderT Finder ) : + detail::find_iterator_base<IteratorT>(Finder,0), + m_Match(Begin,Begin), + m_End(End) + { + increment(); + } + + //! Constructor + /*! + Construct new find_iterator for a given finder + and a range. + */ + template<typename FinderT, typename RangeT> + find_iterator( + RangeT& Col, + FinderT Finder ) : + detail::find_iterator_base<IteratorT>(Finder,0) + { + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(::boost::as_literal(Col)); + m_Match=::boost::make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); + m_End=::boost::end(lit_col); + + increment(); + } + + private: + // iterator operations + + // dereference + const match_type& dereference() const + { + return m_Match; + } + + // increment + void increment() + { + m_Match=this->do_find(m_Match.end(),m_End); + } + + // comparison + bool equal( const find_iterator& Other ) const + { + bool bEof=eof(); + bool bOtherEof=Other.eof(); + + return bEof || bOtherEof ? bEof==bOtherEof : + ( + m_Match==Other.m_Match && + m_End==Other.m_End + ); + } + + public: + // operations + + //! Eof check + /*! + Check the eof condition. Eof condition means that + there is nothing more to be searched i.e. find_iterator + is after the last match. + */ + bool eof() const + { + return + this->is_null() || + ( + m_Match.begin() == m_End && + m_Match.end() == m_End + ); + } + + private: + // Attributes + match_type m_Match; + input_iterator_type m_End; + }; + + //! find iterator construction helper + /*! + * Construct a find iterator to iterate through the specified string + */ + template<typename RangeT, typename FinderT> + inline find_iterator< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + make_find_iterator( + RangeT& Collection, + FinderT Finder) + { + return find_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>( + Collection, Finder); + } + +// split iterator -----------------------------------------------// + + //! split_iterator + /*! + Split iterator encapsulates a Finder and allows + for incremental searching in a string. + Unlike the find iterator, split iterator iterates + through gaps between matches. + + Find iterator is a readable forward traversal iterator. + + Dereferencing the iterator yields an iterator_range delimiting + the current match. + */ + template<typename IteratorT> + class split_iterator : + public iterator_facade< + split_iterator<IteratorT>, + const iterator_range<IteratorT>, + forward_traversal_tag >, + private detail::find_iterator_base<IteratorT> + { + private: + // facade support + friend class ::boost::iterator_core_access; + + private: + // typedefs + + typedef detail::find_iterator_base<IteratorT> base_type; + typedef BOOST_STRING_TYPENAME + base_type::input_iterator_type input_iterator_type; + typedef BOOST_STRING_TYPENAME + base_type::match_type match_type; + + public: + //! Default constructor + /*! + Construct null iterator. All null iterators are equal. + + \post eof()==true + */ + split_iterator() {} + //! Copy constructor + /*! + Construct a copy of the split_iterator + */ + split_iterator( const split_iterator& Other ) : + base_type(Other), + m_Match(Other.m_Match), + m_Next(Other.m_Next), + m_End(Other.m_End), + m_bEof(Other.m_bEof) + {} + + //! Constructor + /*! + Construct new split_iterator for a given finder + and a range. + */ + template<typename FinderT> + split_iterator( + IteratorT Begin, + IteratorT End, + FinderT Finder ) : + detail::find_iterator_base<IteratorT>(Finder,0), + m_Match(Begin,Begin), + m_Next(Begin), + m_End(End), + m_bEof(false) + { + increment(); + } + //! Constructor + /*! + Construct new split_iterator for a given finder + and a collection. + */ + template<typename FinderT, typename RangeT> + split_iterator( + RangeT& Col, + FinderT Finder ) : + detail::find_iterator_base<IteratorT>(Finder,0), + m_bEof(false) + { + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(::boost::as_literal(Col)); + m_Match=make_iterator_range(::boost::begin(lit_col), ::boost::begin(lit_col)); + m_Next=::boost::begin(lit_col); + m_End=::boost::end(lit_col); + + increment(); + } + + + private: + // iterator operations + + // dereference + const match_type& dereference() const + { + return m_Match; + } + + // increment + void increment() + { + match_type FindMatch=this->do_find( m_Next, m_End ); + + if(FindMatch.begin()==m_End && FindMatch.end()==m_End) + { + if(m_Match.end()==m_End) + { + // Mark iterator as eof + m_bEof=true; + } + } + + m_Match=match_type( m_Next, FindMatch.begin() ); + m_Next=FindMatch.end(); + } + + // comparison + bool equal( const split_iterator& Other ) const + { + bool bEof=eof(); + bool bOtherEof=Other.eof(); + + return bEof || bOtherEof ? bEof==bOtherEof : + ( + m_Match==Other.m_Match && + m_Next==Other.m_Next && + m_End==Other.m_End + ); + } + + public: + // operations + + //! Eof check + /*! + Check the eof condition. Eof condition means that + there is nothing more to be searched i.e. find_iterator + is after the last match. + */ + bool eof() const + { + return this->is_null() || m_bEof; + } + + private: + // Attributes + match_type m_Match; + input_iterator_type m_Next; + input_iterator_type m_End; + bool m_bEof; + }; + + //! split iterator construction helper + /*! + * Construct a split iterator to iterate through the specified collection + */ + template<typename RangeT, typename FinderT> + inline split_iterator< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + make_split_iterator( + RangeT& Collection, + FinderT Finder) + { + return split_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>( + Collection, Finder); + } + + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::find_iterator; + using algorithm::make_find_iterator; + using algorithm::split_iterator; + using algorithm::make_split_iterator; + +} // namespace boost + + +#endif // BOOST_STRING_FIND_ITERATOR_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/finder.hpp b/boost_1_45_0/boost/algorithm/string/finder.hpp new file mode 100644 index 0000000..4c7ac38 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/finder.hpp
@@ -0,0 +1,270 @@ +// Boost string_algo library finder.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FINDER_HPP +#define BOOST_STRING_FINDER_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/const_iterator.hpp> + +#include <boost/algorithm/string/constants.hpp> +#include <boost/algorithm/string/detail/finder.hpp> +#include <boost/algorithm/string/compare.hpp> + +/*! \file + Defines Finder generators. Finder object is a functor which is able to + find a substring matching a specific criteria in the input. + Finders are used as a pluggable components for replace, find + and split facilities. This header contains generator functions + for finders provided in this library. +*/ + +namespace boost { + namespace algorithm { + +// Finder generators ------------------------------------------// + + //! "First" finder + /*! + Construct the \c first_finder. The finder searches for the first + occurrence of the string in a given input. + The result is given as an \c iterator_range delimiting the match. + + \param Search A substring to be searched for. + \param Comp An element comparison predicate + \return An instance of the \c first_finder object + */ + template<typename RangeT> + inline detail::first_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + is_equal> + first_finder( const RangeT& Search ) + { + return + detail::first_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + is_equal>( ::boost::as_literal(Search), is_equal() ) ; + } + + //! "First" finder + /*! + \overload + */ + template<typename RangeT,typename PredicateT> + inline detail::first_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + PredicateT> + first_finder( + const RangeT& Search, PredicateT Comp ) + { + return + detail::first_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + PredicateT>( ::boost::as_literal(Search), Comp ); + } + + //! "Last" finder + /*! + Construct the \c last_finder. The finder searches for the last + occurrence of the string in a given input. + The result is given as an \c iterator_range delimiting the match. + + \param Search A substring to be searched for. + \param Comp An element comparison predicate + \return An instance of the \c last_finder object + */ + template<typename RangeT> + inline detail::last_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + is_equal> + last_finder( const RangeT& Search ) + { + return + detail::last_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + is_equal>( ::boost::as_literal(Search), is_equal() ); + } + //! "Last" finder + /*! + \overload + */ + template<typename RangeT, typename PredicateT> + inline detail::last_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + PredicateT> + last_finder( const RangeT& Search, PredicateT Comp ) + { + return + detail::last_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + PredicateT>( ::boost::as_literal(Search), Comp ) ; + } + + //! "Nth" finder + /*! + Construct the \c nth_finder. The finder searches for the n-th (zero-indexed) + occurrence of the string in a given input. + The result is given as an \c iterator_range delimiting the match. + + \param Search A substring to be searched for. + \param Nth An index of the match to be find + \param Comp An element comparison predicate + \return An instance of the \c nth_finder object + */ + template<typename RangeT> + inline detail::nth_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + is_equal> + nth_finder( + const RangeT& Search, + int Nth) + { + return + detail::nth_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + is_equal>( ::boost::as_literal(Search), Nth, is_equal() ) ; + } + //! "Nth" finder + /*! + \overload + */ + template<typename RangeT, typename PredicateT> + inline detail::nth_finderF< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type, + PredicateT> + nth_finder( + const RangeT& Search, + int Nth, + PredicateT Comp ) + { + return + detail::nth_finderF< + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type, + PredicateT>( ::boost::as_literal(Search), Nth, Comp ); + } + + //! "Head" finder + /*! + Construct the \c head_finder. The finder returns a head of a given + input. The head is a prefix of a string up to n elements in + size. If an input has less then n elements, whole input is + considered a head. + The result is given as an \c iterator_range delimiting the match. + + \param N The size of the head + \return An instance of the \c head_finder object + */ + inline detail::head_finderF + head_finder( int N ) + { + return detail::head_finderF(N); + } + + //! "Tail" finder + /*! + Construct the \c tail_finder. The finder returns a tail of a given + input. The tail is a suffix of a string up to n elements in + size. If an input has less then n elements, whole input is + considered a head. + The result is given as an \c iterator_range delimiting the match. + + \param N The size of the head + \return An instance of the \c tail_finder object + */ + inline detail::tail_finderF + tail_finder( int N ) + { + return detail::tail_finderF(N); + } + + //! "Token" finder + /*! + Construct the \c token_finder. The finder searches for a token + specified by a predicate. It is similar to std::find_if + algorithm, with an exception that it return a range of + instead of a single iterator. + + If "compress token mode" is enabled, adjacent matching tokens are + concatenated into one match. Thus the finder can be used to + search for continuous segments of characters satisfying the + given predicate. + + The result is given as an \c iterator_range delimiting the match. + + \param Pred An element selection predicate + \param eCompress Compress flag + \return An instance of the \c token_finder object + */ + template< typename PredicateT > + inline detail::token_finderF<PredicateT> + token_finder( + PredicateT Pred, + token_compress_mode_type eCompress=token_compress_off ) + { + return detail::token_finderF<PredicateT>( Pred, eCompress ); + } + + //! "Range" finder + /*! + Construct the \c range_finder. The finder does not perform + any operation. It simply returns the given range for + any input. + + \param Begin Beginning of the range + \param End End of the range + \param Range The range. + \return An instance of the \c range_finger object + */ + template< typename ForwardIteratorT > + inline detail::range_finderF<ForwardIteratorT> + range_finder( + ForwardIteratorT Begin, + ForwardIteratorT End ) + { + return detail::range_finderF<ForwardIteratorT>( Begin, End ); + } + + //! "Range" finder + /*! + \overload + */ + template< typename ForwardIteratorT > + inline detail::range_finderF<ForwardIteratorT> + range_finder( iterator_range<ForwardIteratorT> Range ) + { + return detail::range_finderF<ForwardIteratorT>( Range ); + } + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::first_finder; + using algorithm::last_finder; + using algorithm::nth_finder; + using algorithm::head_finder; + using algorithm::tail_finder; + using algorithm::token_finder; + using algorithm::range_finder; + +} // namespace boost + + +#endif // BOOST_STRING_FINDER_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/formatter.hpp b/boost_1_45_0/boost/algorithm/string/formatter.hpp new file mode 100644 index 0000000..50006df --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/formatter.hpp
@@ -0,0 +1,103 @@ +// Boost string_algo library formatter.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_FORMATTER_HPP +#define BOOST_STRING_FORMATTER_HPP + +#include <boost/detail/iterator.hpp> +#include <boost/range/value_type.hpp> +#include <boost/range/iterator_range.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/detail/formatter.hpp> + +/*! \file + Defines Formatter generators. Formatter is a functor which formats + a string according to given parameters. A Formatter works + in conjunction with a Finder. A Finder can provide additional information + for a specific Formatter. An example of such a cooperation is regex_finder + and regex_formatter. + + Formatters are used as pluggable components for replace facilities. + This header contains generator functions for the Formatters provided in this library. +*/ + +namespace boost { + namespace algorithm { + +// generic formatters ---------------------------------------------------------------// + + //! Constant formatter + /*! + Construct the \c const_formatter. Const formatter always returns + the same value, regardless of the parameter. + + \param Format A predefined value used as a result for formating + \return An instance of the \c const_formatter object. + */ + template<typename RangeT> + inline detail::const_formatF< + iterator_range< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> > + const_formatter(const RangeT& Format) + { + return detail::const_formatF< + iterator_range< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(::boost::as_literal(Format)); + } + + //! Identity formatter + /*! + Construct the \c identity_formatter. Identity formatter always returns + the parameter. + + \return An instance of the \c identity_formatter object. + */ + template<typename RangeT> + inline detail::identity_formatF< + iterator_range< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> > + identity_formatter() + { + return detail::identity_formatF< + iterator_range< + BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(); + } + + //! Empty formatter + /*! + Construct the \c empty_formatter. Empty formatter always returns an empty + sequence. + + \param Input container used to select a correct value_type for the + resulting empty_container<>. + \return An instance of the \c empty_formatter object. + */ + template<typename RangeT> + inline detail::empty_formatF< + BOOST_STRING_TYPENAME range_value<RangeT>::type> + empty_formatter(const RangeT&) + { + return detail::empty_formatF< + BOOST_STRING_TYPENAME range_value<RangeT>::type>(); + } + + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::const_formatter; + using algorithm::identity_formatter; + using algorithm::empty_formatter; + +} // namespace boost + + +#endif // BOOST_FORMATTER_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/iter_find.hpp b/boost_1_45_0/boost/algorithm/string/iter_find.hpp new file mode 100644 index 0000000..9e0245f --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/iter_find.hpp
@@ -0,0 +1,193 @@ +// Boost string_algo library iter_find.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_ITER_FIND_HPP +#define BOOST_STRING_ITER_FIND_HPP + +#include <boost/algorithm/string/config.hpp> +#include <algorithm> +#include <iterator> +#include <boost/iterator/transform_iterator.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/value_type.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/concept.hpp> +#include <boost/algorithm/string/find_iterator.hpp> +#include <boost/algorithm/string/detail/util.hpp> + +/*! \file + Defines generic split algorithms. Split algorithms can be + used to divide a sequence into several part according + to a given criteria. Result is given as a 'container + of containers' where elements are copies or references + to extracted parts. + + There are two algorithms provided. One iterates over matching + substrings, the other one over the gaps between these matches. +*/ + +namespace boost { + namespace algorithm { + +// iterate find ---------------------------------------------------// + + //! Iter find algorithm + /*! + This algorithm executes a given finder in iteration on the input, + until the end of input is reached, or no match is found. + Iteration is done using built-in find_iterator, so the real + searching is performed only when needed. + In each iteration new match is found and added to the result. + + \param Result A 'container container' to contain the result of search. + Both outer and inner container must have constructor taking a pair + of iterators as an argument. + Typical type of the result is + \c std::vector<boost::iterator_range<iterator>> + (each element of such a vector will container a range delimiting + a match). + \param Input A container which will be searched. + \param Finder A Finder object used for searching + \return A reference the result + + \note Prior content of the result will be overwritten. + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename FinderT > + inline SequenceSequenceT& + iter_find( + SequenceSequenceT& Result, + RangeT& Input, + FinderT Finder ) + { + BOOST_CONCEPT_ASSERT(( + FinderConcept< + FinderT, + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + )); + + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + typedef BOOST_STRING_TYPENAME + range_iterator<RangeT>::type input_iterator_type; + typedef find_iterator<input_iterator_type> find_iterator_type; + typedef detail::copy_iterator_rangeF< + BOOST_STRING_TYPENAME + range_value<SequenceSequenceT>::type, + input_iterator_type> copy_range_type; + + input_iterator_type InputEnd=::boost::end(lit_input); + + typedef transform_iterator<copy_range_type, find_iterator_type> + transform_iter_type; + + transform_iter_type itBegin= + ::boost::make_transform_iterator( + find_iterator_type( ::boost::begin(lit_input), InputEnd, Finder ), + copy_range_type()); + + transform_iter_type itEnd= + ::boost::make_transform_iterator( + find_iterator_type(), + copy_range_type()); + + SequenceSequenceT Tmp(itBegin, itEnd); + + Result.swap(Tmp); + return Result; + } + +// iterate split ---------------------------------------------------// + + //! Split find algorithm + /*! + This algorithm executes a given finder in iteration on the input, + until the end of input is reached, or no match is found. + Iteration is done using built-in find_iterator, so the real + searching is performed only when needed. + Each match is used as a separator of segments. These segments are then + returned in the result. + + \param Result A 'container container' to container the result of search. + Both outer and inner container must have constructor taking a pair + of iterators as an argument. + Typical type of the result is + \c std::vector<boost::iterator_range<iterator>> + (each element of such a vector will container a range delimiting + a match). + \param Input A container which will be searched. + \param Finder A finder object used for searching + \return A reference the result + + \note Prior content of the result will be overwritten. + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename FinderT > + inline SequenceSequenceT& + iter_split( + SequenceSequenceT& Result, + RangeT& Input, + FinderT Finder ) + { + BOOST_CONCEPT_ASSERT(( + FinderConcept<FinderT, + BOOST_STRING_TYPENAME range_iterator<RangeT>::type> + )); + + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + typedef BOOST_STRING_TYPENAME + range_iterator<RangeT>::type input_iterator_type; + typedef split_iterator<input_iterator_type> find_iterator_type; + typedef detail::copy_iterator_rangeF< + BOOST_STRING_TYPENAME + range_value<SequenceSequenceT>::type, + input_iterator_type> copy_range_type; + + input_iterator_type InputEnd=::boost::end(lit_input); + + typedef transform_iterator<copy_range_type, find_iterator_type> + transform_iter_type; + + transform_iter_type itBegin= + ::boost::make_transform_iterator( + find_iterator_type( ::boost::begin(lit_input), InputEnd, Finder ), + copy_range_type() ); + + transform_iter_type itEnd= + ::boost::make_transform_iterator( + find_iterator_type(), + copy_range_type() ); + + SequenceSequenceT Tmp(itBegin, itEnd); + + Result.swap(Tmp); + return Result; + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::iter_find; + using algorithm::iter_split; + +} // namespace boost + + +#endif // BOOST_STRING_ITER_FIND_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/join.hpp b/boost_1_45_0/boost/algorithm/string/join.hpp new file mode 100644 index 0000000..b871eb4 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/join.hpp
@@ -0,0 +1,145 @@ +// Boost string_algo library join.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_JOIN_HPP +#define BOOST_STRING_JOIN_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/algorithm/string/detail/sequence.hpp> +#include <boost/range/value_type.hpp> +#include <boost/range/as_literal.hpp> + +/*! \file + Defines join algorithm. + + Join algorithm is a counterpart to split algorithms. + It joins strings from a 'list' by adding user defined separator. + Additionally there is a version that allows simple filtering + by providing a predicate. +*/ + +namespace boost { + namespace algorithm { + +// join --------------------------------------------------------------// + + //! Join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< typename SequenceSequenceT, typename Range1T> + inline typename range_value<SequenceSequenceT>::type + join( + const SequenceSequenceT& Input, + const Range1T& Separator) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + // Append first element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + + return Result; + } + +// join_if ----------------------------------------------------------// + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + satisfy the predicate will be added to the result. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Pred A segment selection predicate + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< typename SequenceSequenceT, typename Range1T, typename PredicateT> + inline typename range_value<SequenceSequenceT>::type + join_if( + const SequenceSequenceT& Input, + const Range1T& Separator, + PredicateT Pred) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + // Roll to the first element that will be added + while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin; + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(Pred(*itBegin)) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + } + + return Result; + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::join; + using algorithm::join_if; + +} // namespace boost + + +#endif // BOOST_STRING_JOIN_HPP +
diff --git a/boost_1_45_0/boost/algorithm/string/predicate.hpp b/boost_1_45_0/boost/algorithm/string/predicate.hpp new file mode 100644 index 0000000..6642f42 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/predicate.hpp
@@ -0,0 +1,475 @@ +// Boost string_algo library predicate.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_PREDICATE_HPP +#define BOOST_STRING_PREDICATE_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/const_iterator.hpp> +#include <boost/range/as_literal.hpp> +#include <boost/range/iterator_range.hpp> + +#include <boost/algorithm/string/compare.hpp> +#include <boost/algorithm/string/find.hpp> +#include <boost/algorithm/string/detail/predicate.hpp> + +/*! \file boost/algorithm/string/predicate.hpp + Defines string-related predicates. + The predicates determine whether a substring is contained in the input string + under various conditions: a string starts with the substring, ends with the + substring, simply contains the substring or if both strings are equal. + Additionaly the algorithm \c all() checks all elements of a container to satisfy a + condition. + + All predicates provide the strong exception guarantee. +*/ + +namespace boost { + namespace algorithm { + +// starts_with predicate -----------------------------------------------// + + //! 'Starts with' predicate + /*! + This predicate holds when the test string is a prefix of the Input. + In other words, if the input starts with the test. + When the optional predicate is specified, it is used for character-wise + comparison. + + \param Input An input sequence + \param Test A test sequence + \param Comp An element comparison predicate + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T, typename PredicateT> + inline bool starts_with( + const Range1T& Input, + const Range2T& Test, + PredicateT Comp) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); + + typedef BOOST_STRING_TYPENAME + range_const_iterator<Range1T>::type Iterator1T; + typedef BOOST_STRING_TYPENAME + range_const_iterator<Range2T>::type Iterator2T; + + Iterator1T InputEnd=::boost::end(lit_input); + Iterator2T TestEnd=::boost::end(lit_test); + + Iterator1T it=::boost::begin(lit_input); + Iterator2T pit=::boost::begin(lit_test); + for(; + it!=InputEnd && pit!=TestEnd; + ++it,++pit) + { + if( !(Comp(*it,*pit)) ) + return false; + } + + return pit==TestEnd; + } + + //! 'Starts with' predicate + /*! + \overload + */ + template<typename Range1T, typename Range2T> + inline bool starts_with( + const Range1T& Input, + const Range2T& Test) + { + return ::boost::algorithm::starts_with(Input, Test, is_equal()); + } + + //! 'Starts with' predicate ( case insensitive ) + /*! + This predicate holds when the test string is a prefix of the Input. + In other words, if the input starts with the test. + Elements are compared case insensitively. + + \param Input An input sequence + \param Test A test sequence + \param Loc A locale used for case insensitive comparison + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline bool istarts_with( + const Range1T& Input, + const Range2T& Test, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::starts_with(Input, Test, is_iequal(Loc)); + } + + +// ends_with predicate -----------------------------------------------// + + //! 'Ends with' predicate + /*! + This predicate holds when the test string is a suffix of the Input. + In other words, if the input ends with the test. + When the optional predicate is specified, it is used for character-wise + comparison. + + + \param Input An input sequence + \param Test A test sequence + \param Comp An element comparison predicate + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T, typename PredicateT> + inline bool ends_with( + const Range1T& Input, + const Range2T& Test, + PredicateT Comp) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); + + typedef BOOST_STRING_TYPENAME + range_const_iterator<Range1T>::type Iterator1T; + typedef BOOST_STRING_TYPENAME boost::detail:: + iterator_traits<Iterator1T>::iterator_category category; + + return detail:: + ends_with_iter_select( + ::boost::begin(lit_input), + ::boost::end(lit_input), + ::boost::begin(lit_test), + ::boost::end(lit_test), + Comp, + category()); + } + + + //! 'Ends with' predicate + /*! + \overload + */ + template<typename Range1T, typename Range2T> + inline bool ends_with( + const Range1T& Input, + const Range2T& Test) + { + return ::boost::algorithm::ends_with(Input, Test, is_equal()); + } + + //! 'Ends with' predicate ( case insensitive ) + /*! + This predicate holds when the test container is a suffix of the Input. + In other words, if the input ends with the test. + Elements are compared case insensitively. + + \param Input An input sequence + \param Test A test sequence + \param Loc A locale used for case insensitive comparison + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline bool iends_with( + const Range1T& Input, + const Range2T& Test, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::ends_with(Input, Test, is_iequal(Loc)); + } + +// contains predicate -----------------------------------------------// + + //! 'Contains' predicate + /*! + This predicate holds when the test container is contained in the Input. + When the optional predicate is specified, it is used for character-wise + comparison. + + \param Input An input sequence + \param Test A test sequence + \param Comp An element comparison predicate + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T, typename PredicateT> + inline bool contains( + const Range1T& Input, + const Range2T& Test, + PredicateT Comp) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); + + if (::boost::empty(lit_test)) + { + // Empty range is contained always + return true; + } + + // Use the temporary variable to make VACPP happy + bool bResult=(::boost::algorithm::first_finder(lit_test,Comp)(::boost::begin(lit_input), ::boost::end(lit_input))); + return bResult; + } + + //! 'Contains' predicate + /*! + \overload + */ + template<typename Range1T, typename Range2T> + inline bool contains( + const Range1T& Input, + const Range2T& Test) + { + return ::boost::algorithm::contains(Input, Test, is_equal()); + } + + //! 'Contains' predicate ( case insensitive ) + /*! + This predicate holds when the test container is contained in the Input. + Elements are compared case insensitively. + + \param Input An input sequence + \param Test A test sequence + \param Loc A locale used for case insensitive comparison + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline bool icontains( + const Range1T& Input, + const Range2T& Test, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::contains(Input, Test, is_iequal(Loc)); + } + +// equals predicate -----------------------------------------------// + + //! 'Equals' predicate + /*! + This predicate holds when the test container is equal to the + input container i.e. all elements in both containers are same. + When the optional predicate is specified, it is used for character-wise + comparison. + + \param Input An input sequence + \param Test A test sequence + \param Comp An element comparison predicate + \return The result of the test + + \note This is a two-way version of \c std::equal algorithm + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T, typename PredicateT> + inline bool equals( + const Range1T& Input, + const Range2T& Test, + PredicateT Comp) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input)); + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test)); + + typedef BOOST_STRING_TYPENAME + range_const_iterator<Range1T>::type Iterator1T; + typedef BOOST_STRING_TYPENAME + range_const_iterator<Range2T>::type Iterator2T; + + Iterator1T InputEnd=::boost::end(lit_input); + Iterator2T TestEnd=::boost::end(lit_test); + + Iterator1T it=::boost::begin(lit_input); + Iterator2T pit=::boost::begin(lit_test); + for(; + it!=InputEnd && pit!=TestEnd; + ++it,++pit) + { + if( !(Comp(*it,*pit)) ) + return false; + } + + return (pit==TestEnd) && (it==InputEnd); + } + + //! 'Equals' predicate + /*! + \overload + */ + template<typename Range1T, typename Range2T> + inline bool equals( + const Range1T& Input, + const Range2T& Test) + { + return ::boost::algorithm::equals(Input, Test, is_equal()); + } + + //! 'Equals' predicate ( case insensitive ) + /*! + This predicate holds when the test container is equal to the + input container i.e. all elements in both containers are same. + Elements are compared case insensitively. + + \param Input An input sequence + \param Test A test sequence + \param Loc A locale used for case insensitive comparison + \return The result of the test + + \note This is a two-way version of \c std::equal algorithm + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline bool iequals( + const Range1T& Input, + const Range2T& Test, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::equals(Input, Test, is_iequal(Loc)); + } + +// lexicographical_compare predicate -----------------------------// + + //! Lexicographical compare predicate + /*! + This predicate is an overload of std::lexicographical_compare + for range arguments + + It check whether the first argument is lexicographically less + then the second one. + + If the optional predicate is specified, it is used for character-wise + comparison + + \param Arg1 First argument + \param Arg2 Second argument + \param Pred Comparison predicate + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T, typename PredicateT> + inline bool lexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2, + PredicateT Pred) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(::boost::as_literal(Arg1)); + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(::boost::as_literal(Arg2)); + + return std::lexicographical_compare( + ::boost::begin(lit_arg1), + ::boost::end(lit_arg1), + ::boost::begin(lit_arg2), + ::boost::end(lit_arg2), + Pred); + } + + //! Lexicographical compare predicate + /*! + \overload + */ + template<typename Range1T, typename Range2T> + inline bool lexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2) + { + return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_less()); + } + + //! Lexicographical compare predicate (case-insensitive) + /*! + This predicate is an overload of std::lexicographical_compare + for range arguments. + It check whether the first argument is lexicographically less + then the second one. + Elements are compared case insensitively + + + \param Arg1 First argument + \param Arg2 Second argument + \param Loc A locale used for case insensitive comparison + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename Range1T, typename Range2T> + inline bool ilexicographical_compare( + const Range1T& Arg1, + const Range2T& Arg2, + const std::locale& Loc=std::locale()) + { + return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_iless(Loc)); + } + + +// all predicate -----------------------------------------------// + + //! 'All' predicate + /*! + This predicate holds it all its elements satisfy a given + condition, represented by the predicate. + + \param Input An input sequence + \param Pred A predicate + \return The result of the test + + \note This function provides the strong exception-safety guarantee + */ + template<typename RangeT, typename PredicateT> + inline bool all( + const RangeT& Input, + PredicateT Pred) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + typedef BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type Iterator1T; + + Iterator1T InputEnd=::boost::end(lit_input); + for( Iterator1T It=::boost::begin(lit_input); It!=InputEnd; ++It) + { + if (!Pred(*It)) + return false; + } + + return true; + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::starts_with; + using algorithm::istarts_with; + using algorithm::ends_with; + using algorithm::iends_with; + using algorithm::contains; + using algorithm::icontains; + using algorithm::equals; + using algorithm::iequals; + using algorithm::all; + using algorithm::lexicographical_compare; + using algorithm::ilexicographical_compare; + +} // namespace boost + + +#endif // BOOST_STRING_PREDICATE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/predicate_facade.hpp b/boost_1_45_0/boost/algorithm/string/predicate_facade.hpp new file mode 100644 index 0000000..c8319f7 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/predicate_facade.hpp
@@ -0,0 +1,42 @@ +// Boost string_algo library predicate_facade.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_PREDICATE_FACADE_HPP +#define BOOST_STRING_PREDICATE_FACADE_HPP + +#include <boost/algorithm/string/config.hpp> + +/* + \file boost/algorith/string/predicate_facade.hpp + This file containes predicate_facade definition. This template class is used + to identify classification predicates, so they can be combined using + composition operators. +*/ + +namespace boost { + namespace algorithm { + +// predicate facade ------------------------------------------------------// + + //! Predicate facade + /*! + This class allows to recognize classification + predicates, so that they can be combined using + composition operators. + Every classification predicate must be derived from this class. + */ + template<typename Derived> + struct predicate_facade {}; + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/regex.hpp b/boost_1_45_0/boost/algorithm/string/regex.hpp new file mode 100644 index 0000000..0a4c38b --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/regex.hpp
@@ -0,0 +1,646 @@ +// Boost string_algo library regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REGEX_HPP +#define BOOST_STRING_REGEX_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/as_literal.hpp> + +#include <boost/algorithm/string/find_format.hpp> +#include <boost/algorithm/string/regex_find_format.hpp> +#include <boost/algorithm/string/formatter.hpp> +#include <boost/algorithm/string/iter_find.hpp> + +/*! \file + Defines regex variants of the algorithms. +*/ + +namespace boost { + namespace algorithm { + +// find_regex -----------------------------------------------// + + //! Find regex algorithm + /*! + Search for a substring matching the given regex in the input. + + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return + An \c iterator_range delimiting the match. + Returned iterator is either \c RangeT::iterator or + \c RangeT::const_iterator, depending on the constness of + the input parameter. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename RangeT, + typename CharT, + typename RegexTraitsT> + inline iterator_range< + BOOST_STRING_TYPENAME range_iterator<RangeT>::type > + find_regex( + RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input)); + + return ::boost::algorithm::regex_finder(Rx,Flags)( + ::boost::begin(lit_input), ::boost::end(lit_input) ); + } + +// replace_regex --------------------------------------------------------------------// + + //! Replace regex algorithm + /*! + Search for a substring matching given regex and format it with + the specified format. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline OutputIteratorT replace_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline SequenceT replace_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace regex algorithm + /*! + Search for a substring matching given regex and format it with + the specified format. The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline void replace_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + +// replace_all_regex --------------------------------------------------------------------// + + //! Replace all regex algorithm + /*! + Format all substrings, matching given regex, with the specified format. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline OutputIteratorT replace_all_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace all regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline SequenceT replace_all_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + + //! Replace all regex algorithm + /*! + Format all substrings, matching given regex, with the specified format. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Format Regex format definition + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT, + typename FormatStringTraitsT, typename FormatStringAllocatorT > + inline void replace_all_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + const std::basic_string<CharT, FormatStringTraitsT, FormatStringAllocatorT>& Format, + match_flag_type Flags=match_default | format_default ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::regex_formatter( Format, Flags ) ); + } + +// erase_regex --------------------------------------------------------------------// + + //! Erase regex algorithm + /*! + Remove a substring matching given regex from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline OutputIteratorT erase_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline SequenceT erase_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase regex algorithm + /*! + Remove a substring matching given regex from the input. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline void erase_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + +// erase_all_regex --------------------------------------------------------------------// + + //! Erase all regex algorithm + /*! + Erase all substrings, matching given regex, from the input. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline OutputIteratorT erase_all_regex_copy( + OutputIteratorT Output, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase all regex algorithm + /*! + \overload + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT > + inline SequenceT erase_all_regex_copy( + const SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + + //! Erase all regex algorithm + /*! + Erase all substrings, matching given regex, from the input. + The input string is modified in-place. + + \param Input An input string + \param Rx A regular expression + \param Flags Regex options + */ + template< + typename SequenceT, + typename CharT, + typename RegexTraitsT> + inline void erase_all_regex( + SequenceT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::regex_finder( Rx, Flags ), + ::boost::algorithm::empty_formatter( Input ) ); + } + +// find_all_regex ------------------------------------------------------------------// + + //! Find all regex algorithm + /*! + This algorithm finds all substrings matching the give regex + in the input. + + Each part is copied and added as a new element to the output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings. + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return A reference to the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline SequenceSequenceT& find_all_regex( + SequenceSequenceT& Result, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::iter_find( + Result, + Input, + ::boost::algorithm::regex_finder(Rx,Flags) ); + } + +// split_regex ------------------------------------------------------------------// + + //! Split regex algorithm + /*! + Tokenize expression. This function is equivalent to C strtok. Input + sequence is split into tokens, separated by separators. Separator + is an every match of the given regex. + Each part is copied and added as a new element to the output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings. + \param Input A container which will be searched. + \param Rx A regular expression + \param Flags Regex options + \return A reference to the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename RangeT, + typename CharT, + typename RegexTraitsT > + inline SequenceSequenceT& split_regex( + SequenceSequenceT& Result, + const RangeT& Input, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + return ::boost::algorithm::iter_split( + Result, + Input, + ::boost::algorithm::regex_finder(Rx,Flags) ); + } + +// join_if ------------------------------------------------------------------// + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + match the given regular expression will be added to the result + + This is a specialization of join_if algorithm. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Rx A regular expression + \param Flags Regex options + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename Range1T, + typename CharT, + typename RegexTraitsT > + inline typename range_value<SequenceSequenceT>::type + join_if( + const SequenceSequenceT& Input, + const Range1T& Separator, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + + // Roll to the first element that will be added + while( + itBegin!=itEnd && + !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; + + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + } + + return Result; + } + +#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + //! Conditional join algorithm + /*! + This algorithm joins all strings in a 'list' into one long string. + Segments are concatenated by given separator. Only segments that + match the given regular expression will be added to the result + + This is a specialization of join_if algorithm. + + \param Input A container that holds the input strings. It must be a container-of-containers. + \param Separator A string that will separate the joined segments. + \param Rx A regular expression + \param Flags Regex options + \return Concatenated string. + + \note This function provides the strong exception-safety guarantee + */ + template< + typename SequenceSequenceT, + typename Range1T, + typename CharT, + typename RegexTraitsT > + inline typename range_value<SequenceSequenceT>::type + join_if_regex( + const SequenceSequenceT& Input, + const Range1T& Separator, + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type Flags=match_default ) + { + // Define working types + typedef typename range_value<SequenceSequenceT>::type ResultT; + typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT; + + // Parse input + InputIteratorT itBegin=::boost::begin(Input); + InputIteratorT itEnd=::boost::end(Input); + + // Construct container to hold the result + ResultT Result; + + + // Roll to the first element that will be added + while( + itBegin!=itEnd && + !::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) ++itBegin; + + // Add this element + if(itBegin!=itEnd) + { + detail::insert(Result, ::boost::end(Result), *itBegin); + ++itBegin; + } + + for(;itBegin!=itEnd; ++itBegin) + { + if(::boost::regex_match(::boost::begin(*itBegin), ::boost::end(*itBegin), Rx, Flags)) + { + // Add separator + detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator)); + // Add element + detail::insert(Result, ::boost::end(Result), *itBegin); + } + } + + return Result; + } + + +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + } // namespace algorithm + + // pull names into the boost namespace + using algorithm::find_regex; + using algorithm::replace_regex; + using algorithm::replace_regex_copy; + using algorithm::replace_all_regex; + using algorithm::replace_all_regex_copy; + using algorithm::erase_regex; + using algorithm::erase_regex_copy; + using algorithm::erase_all_regex; + using algorithm::erase_all_regex_copy; + using algorithm::find_all_regex; + using algorithm::split_regex; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + using algorithm::join_if; +#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + using algorithm::join_if_regex; +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +} // namespace boost + + +#endif // BOOST_STRING_REGEX_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/regex_find_format.hpp b/boost_1_45_0/boost/algorithm/string/regex_find_format.hpp new file mode 100644 index 0000000..f698004 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/regex_find_format.hpp
@@ -0,0 +1,90 @@ +// Boost string_algo library regex_find_format.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REGEX_FIND_FORMAT_HPP +#define BOOST_STRING_REGEX_FIND_FORMAT_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/regex.hpp> +#include <boost/algorithm/string/detail/finder_regex.hpp> +#include <boost/algorithm/string/detail/formatter_regex.hpp> + +/*! \file + Defines the \c regex_finder and \c regex_formatter generators. These two functors + are designed to work together. \c regex_formatter uses additional information + about a match contained in the regex_finder search result. +*/ + +namespace boost { + namespace algorithm { + +// regex_finder -----------------------------------------------// + + //! "Regex" finder + /*! + Construct the \c regex_finder. Finder uses the regex engine to search + for a match. + Result is given in \c regex_search_result. This is an extension + of the iterator_range. In addition it containes match results + from the \c regex_search algorithm. + + \param Rx A regular expression + \param MatchFlags Regex search options + \return An instance of the \c regex_finder object + */ + template< + typename CharT, + typename RegexTraitsT> + inline detail::find_regexF< basic_regex<CharT, RegexTraitsT> > + regex_finder( + const basic_regex<CharT, RegexTraitsT>& Rx, + match_flag_type MatchFlags=match_default ) + { + return detail:: + find_regexF< + basic_regex<CharT, RegexTraitsT> >( Rx, MatchFlags ); + } + +// regex_formater ---------------------------------------------// + + //! Regex formatter + /*! + Construct the \c regex_formatter. Regex formatter uses the regex engine to + format a match found by the \c regex_finder. + This formatted it designed to closely cooperate with \c regex_finder. + + \param Format Regex format definition + \param Flags Format flags + \return An instance of the \c regex_formatter functor + */ + template< + typename CharT, + typename TraitsT, typename AllocT > + inline detail::regex_formatF< std::basic_string< CharT, TraitsT, AllocT > > + regex_formatter( + const std::basic_string<CharT, TraitsT, AllocT>& Format, + match_flag_type Flags=format_default ) + { + return + detail::regex_formatF< std::basic_string<CharT, TraitsT, AllocT> >( + Format, + Flags ); + } + + } // namespace algorithm + + // pull the names to the boost namespace + using algorithm::regex_finder; + using algorithm::regex_formatter; + +} // namespace boost + + +#endif // BOOST_STRING_REGEX_FIND_FORMAT_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/replace.hpp b/boost_1_45_0/boost/algorithm/string/replace.hpp new file mode 100644 index 0000000..f2d201f --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/replace.hpp
@@ -0,0 +1,928 @@ +// Boost string_algo library replace.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_REPLACE_HPP +#define BOOST_STRING_REPLACE_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/range/iterator_range.hpp> +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/iterator.hpp> +#include <boost/range/const_iterator.hpp> + +#include <boost/algorithm/string/find_format.hpp> +#include <boost/algorithm/string/finder.hpp> +#include <boost/algorithm/string/formatter.hpp> +#include <boost/algorithm/string/compare.hpp> + +/*! \file + Defines various replace algorithms. Each algorithm replaces + part(s) of the input according to set of searching and replace criteria. +*/ + +namespace boost { + namespace algorithm { + +// replace_range --------------------------------------------------------------------// + + //! Replace range algorithm + /*! + Replace the given range in the input string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param SearchRange A range in the input to be substituted + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT replace_range_copy( + OutputIteratorT Output, + const Range1T& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_const_iterator<Range1T>::type>& SearchRange, + const Range2T& Format) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::const_formatter(Format)); + } + + //! Replace range algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT replace_range_copy( + const SequenceT& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_const_iterator<SequenceT>::type>& SearchRange, + const RangeT& Format) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::const_formatter(Format)); + } + + //! Replace range algorithm + /*! + Replace the given range in the input string. + The input sequence is modified in-place. + + \param Input An input string + \param SearchRange A range in the input to be substituted + \param Format A substitute string + */ + template<typename SequenceT, typename RangeT> + inline void replace_range( + SequenceT& Input, + const iterator_range< + BOOST_STRING_TYPENAME + range_iterator<SequenceT>::type>& SearchRange, + const RangeT& Format) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::range_finder(SearchRange), + ::boost::algorithm::const_formatter(Format)); + } + +// replace_first --------------------------------------------------------------------// + + //! Replace first algorithm + /*! + Replace the first match of the search substring in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT replace_first_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace first algorithm + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT replace_first_copy( + const SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace first algorithm + /*! + replace the first match of the search substring in the input + with the format string. The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void replace_first( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_first ( case insensitive ) ---------------------------------------------// + + //! Replace first algorithm ( case insensitive ) + /*! + Replace the first match of the search substring in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT ireplace_first_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace first algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename Range2T, typename Range1T> + inline SequenceT ireplace_first_copy( + const SequenceT& Input, + const Range2T& Search, + const Range1T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace first algorithm ( case insensitive ) + /*! + Replace the first match of the search substring in the input + with the format string. Input sequence is modified in-place. + Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void ireplace_first( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_last --------------------------------------------------------------------// + + //! Replace last algorithm + /*! + Replace the last match of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT replace_last_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace last algorithm + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT replace_last_copy( + const SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace last algorithm + /*! + Replace the last match of the search string in the input + with the format string. Input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void replace_last( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::last_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_last ( case insensitive ) -----------------------------------------------// + + //! Replace last algorithm ( case insensitive ) + /*! + Replace the last match of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT ireplace_last_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace last algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT ireplace_last_copy( + const SequenceT& Input, + const Range1T& Search, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace last algorithm ( case insensitive ) + /*! + Replace the last match of the search string in the input + with the format string.The input sequence is modified in-place. + Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + \return A reference to the modified input + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void ireplace_last( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::last_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_nth --------------------------------------------------------------------// + + //! Replace nth algorithm + /*! + Replace an Nth (zero-indexed) match of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT replace_nth_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + int Nth, + const Range3T& Format ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace nth algorithm + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT replace_nth_copy( + const SequenceT& Input, + const Range1T& Search, + int Nth, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace nth algorithm + /*! + Replace an Nth (zero-indexed) match of the search string in the input + with the format string. Input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Format A substitute string + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void replace_nth( + SequenceT& Input, + const Range1T& Search, + int Nth, + const Range2T& Format ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::nth_finder(Search, Nth), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_nth ( case insensitive ) -----------------------------------------------// + + //! Replace nth algorithm ( case insensitive ) + /*! + Replace an Nth (zero-indexed) match of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT ireplace_nth_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + int Nth, + const Range3T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace nth algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT ireplace_nth_copy( + const SequenceT& Input, + const Range1T& Search, + int Nth, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace nth algorithm ( case insensitive ) + /*! + Replace an Nth (zero-indexed) match of the search string in the input + with the format string. Input sequence is modified in-place. + Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Nth An index of the match to be replaced. The index is 0-based. + For negative N, matches are counted from the end of string. + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void ireplace_nth( + SequenceT& Input, + const Range1T& Search, + int Nth, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_all --------------------------------------------------------------------// + + //! Replace all algorithm + /*! + Replace all occurrences of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT replace_all_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace all algorithm + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT replace_all_copy( + const SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace all algorithm + /*! + Replace all occurrences of the search string in the input + with the format string. The input sequence is modified in-place. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \return A reference to the modified input + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void replace_all( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::first_finder(Search), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_all ( case insensitive ) -----------------------------------------------// + + //! Replace all algorithm ( case insensitive ) + /*! + Replace all occurrences of the search string in the input + with the format string. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + Searching is case insensitive. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T, + typename Range3T> + inline OutputIteratorT ireplace_all_copy( + OutputIteratorT Output, + const Range1T& Input, + const Range2T& Search, + const Range3T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_all_copy( + Output, + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace all algorithm ( case insensitive ) + /*! + \overload + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline SequenceT ireplace_all_copy( + const SequenceT& Input, + const Range1T& Search, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::find_format_all_copy( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace all algorithm ( case insensitive ) + /*! + Replace all occurrences of the search string in the input + with the format string.The input sequence is modified in-place. + Searching is case insensitive. + + \param Input An input string + \param Search A substring to be searched for + \param Format A substitute string + \param Loc A locale used for case insensitive comparison + */ + template<typename SequenceT, typename Range1T, typename Range2T> + inline void ireplace_all( + SequenceT& Input, + const Range1T& Search, + const Range2T& Format, + const std::locale& Loc=std::locale() ) + { + ::boost::algorithm::find_format_all( + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc)), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_head --------------------------------------------------------------------// + + //! Replace head algorithm + /*! + Replace the head of the input with the given format string. + The head is a prefix of a string of given size. + If the sequence is shorter then required, whole string if + considered to be the head. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param N Length of the head. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT replace_head_copy( + OutputIteratorT Output, + const Range1T& Input, + int N, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace head algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT replace_head_copy( + const SequenceT& Input, + int N, + const RangeT& Format ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace head algorithm + /*! + Replace the head of the input with the given format string. + The head is a prefix of a string of given size. + If the sequence is shorter then required, the whole string is + considered to be the head. The input sequence is modified in-place. + + \param Input An input string + \param N Length of the head. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \param Format A substitute string + */ + template<typename SequenceT, typename RangeT> + inline void replace_head( + SequenceT& Input, + int N, + const RangeT& Format ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::head_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + +// replace_tail --------------------------------------------------------------------// + + //! Replace tail algorithm + /*! + Replace the tail of the input with the given format string. + The tail is a suffix of a string of given size. + If the sequence is shorter then required, whole string is + considered to be the tail. + The result is a modified copy of the input. It is returned as a sequence + or copied to the output iterator. + + \param Output An output iterator to which the result will be copied + \param Input An input string + \param N Length of the tail. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \param Format A substitute string + \return An output iterator pointing just after the last inserted character or + a modified copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template< + typename OutputIteratorT, + typename Range1T, + typename Range2T> + inline OutputIteratorT replace_tail_copy( + OutputIteratorT Output, + const Range1T& Input, + int N, + const Range2T& Format ) + { + return ::boost::algorithm::find_format_copy( + Output, + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace tail algorithm + /*! + \overload + */ + template<typename SequenceT, typename RangeT> + inline SequenceT replace_tail_copy( + const SequenceT& Input, + int N, + const RangeT& Format ) + { + return ::boost::algorithm::find_format_copy( + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + + //! Replace tail algorithm + /*! + Replace the tail of the input with the given format sequence. + The tail is a suffix of a string of given size. + If the sequence is shorter then required, the whole string is + considered to be the tail. The input sequence is modified in-place. + + \param Input An input string + \param N Length of the tail. + For N>=0, at most N characters are extracted. + For N<0, size(Input)-|N| characters are extracted. + \param Format A substitute string + */ + template<typename SequenceT, typename RangeT> + inline void replace_tail( + SequenceT& Input, + int N, + const RangeT& Format ) + { + ::boost::algorithm::find_format( + Input, + ::boost::algorithm::tail_finder(N), + ::boost::algorithm::const_formatter(Format) ); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::replace_range_copy; + using algorithm::replace_range; + using algorithm::replace_first_copy; + using algorithm::replace_first; + using algorithm::ireplace_first_copy; + using algorithm::ireplace_first; + using algorithm::replace_last_copy; + using algorithm::replace_last; + using algorithm::ireplace_last_copy; + using algorithm::ireplace_last; + using algorithm::replace_nth_copy; + using algorithm::replace_nth; + using algorithm::ireplace_nth_copy; + using algorithm::ireplace_nth; + using algorithm::replace_all_copy; + using algorithm::replace_all; + using algorithm::ireplace_all_copy; + using algorithm::ireplace_all; + using algorithm::replace_head_copy; + using algorithm::replace_head; + using algorithm::replace_tail_copy; + using algorithm::replace_tail; + +} // namespace boost + +#endif // BOOST_REPLACE_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/sequence_traits.hpp b/boost_1_45_0/boost/algorithm/string/sequence_traits.hpp new file mode 100644 index 0000000..b1ac67e --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/sequence_traits.hpp
@@ -0,0 +1,193 @@ +// Boost string_algo library sequence_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP +#define BOOST_STRING_SEQUENCE_TRAITS_HPP + +#include <boost/config.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/algorithm/string/yes_no_type.hpp> + +/*! \file + Traits defined in this header are used by various algorithms to achieve + better performance for specific containers. + Traits provide fail-safe defaults. If a container supports some of these + features, it is possible to specialize the specific trait for this container. + For lacking compilers, it is possible of define an override for a specific tester + function. + + Due to a language restriction, it is not currently possible to define specializations for + stl containers without including the corresponding header. To decrease the overhead + needed by this inclusion, user can selectively include a specialization + header for a specific container. They are located in boost/algorithm/string/stl + directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp + header which contains specializations for all stl containers. +*/ + +namespace boost { + namespace algorithm { + +// sequence traits -----------------------------------------------// + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + //! Native replace tester + /*! + Declare an override of this tester function with return + type boost::string_algo::yes_type for a sequence with this property. + + \return yes_type if the container has basic_string like native replace + method. + */ + no_type has_native_replace_tester(...); + + //! Stable iterators tester + /*! + Declare an override of this tester function with return + type boost::string_algo::yes_type for a sequence with this property. + + \return yes_type if the sequence's insert/replace/erase methods do not invalidate + existing iterators. + */ + no_type has_stable_iterators_tester(...); + + //! const time insert tester + /*! + Declare an override of this tester function with return + type boost::string_algo::yes_type for a sequence with this property. + + \return yes_type if the sequence's insert method is working in constant time + */ + no_type has_const_time_insert_tester(...); + + //! const time erase tester + /*! + Declare an override of this tester function with return + type boost::string_algo::yes_type for a sequence with this property. + + \return yes_type if the sequence's erase method is working in constant time + */ + no_type has_const_time_erase_tester(...); + +#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + //! Native replace trait + /*! + This trait specifies that the sequence has \c std::string like replace method + */ + template< typename T > + class has_native_replace + { + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + private: + static T* t; + public: + BOOST_STATIC_CONSTANT(bool, value=( + sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) ); +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + public: +# if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = false }; +# else + BOOST_STATIC_CONSTANT(bool, value=false); +# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + + typedef mpl::bool_<has_native_replace<T>::value> type; + }; + + + //! Stable iterators trait + /*! + This trait specifies that the sequence has stable iterators. It means + that operations like insert/erase/replace do not invalidate iterators. + */ + template< typename T > + class has_stable_iterators + { +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + private: + static T* t; + public: + BOOST_STATIC_CONSTANT(bool, value=( + sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) ); +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + public: +# if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = false }; +# else + BOOST_STATIC_CONSTANT(bool, value=false); +# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + typedef mpl::bool_<has_stable_iterators<T>::value> type; + }; + + + //! Const time insert trait + /*! + This trait specifies that the sequence's insert method has + constant time complexity. + */ + template< typename T > + class has_const_time_insert + { +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + private: + static T* t; + public: + BOOST_STATIC_CONSTANT(bool, value=( + sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) ); +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + public: +# if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = false }; +# else + BOOST_STATIC_CONSTANT(bool, value=false); +# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + typedef mpl::bool_<has_const_time_insert<T>::value> type; + }; + + + //! Const time erase trait + /*! + This trait specifies that the sequence's erase method has + constant time complexity. + */ + template< typename T > + class has_const_time_erase + { +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + private: + static T* t; + public: + BOOST_STATIC_CONSTANT(bool, value=( + sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) ); +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + public: +# if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = false }; +# else + BOOST_STATIC_CONSTANT(bool, value=false); +# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + typedef mpl::bool_<has_const_time_erase<T>::value> type; + }; + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_SEQUENCE_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/split.hpp b/boost_1_45_0/boost/algorithm/string/split.hpp new file mode 100644 index 0000000..cae712c --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/split.hpp
@@ -0,0 +1,163 @@ +// Boost string_algo library split.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2006. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_SPLIT_HPP +#define BOOST_STRING_SPLIT_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/algorithm/string/iter_find.hpp> +#include <boost/algorithm/string/finder.hpp> +#include <boost/algorithm/string/compare.hpp> + +/*! \file + Defines basic split algorithms. + Split algorithms can be used to divide a string + into several parts according to given criteria. + + Each part is copied and added as a new element to the + output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> +*/ + +namespace boost { + namespace algorithm { + +// find_all ------------------------------------------------------------// + + //! Find all algorithm + /*! + This algorithm finds all occurrences of the search string + in the input. + + Each part is copied and added as a new element to the + output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings + \param Input A container which will be searched. + \param Search A substring to be searched for. + \return A reference the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< typename SequenceSequenceT, typename Range1T, typename Range2T > + inline SequenceSequenceT& find_all( + SequenceSequenceT& Result, + Range1T& Input, + const Range2T& Search) + { + return ::boost::algorithm::iter_find( + Result, + Input, + ::boost::algorithm::first_finder(Search) ); + } + + //! Find all algorithm ( case insensitive ) + /*! + This algorithm finds all occurrences of the search string + in the input. + Each part is copied and added as a new element to the + output container. Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + Searching is case insensitive. + + \param Result A container that can hold copies of references to the substrings + \param Input A container which will be searched. + \param Search A substring to be searched for. + \param Loc A locale used for case insensitive comparison + \return A reference the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< typename SequenceSequenceT, typename Range1T, typename Range2T > + inline SequenceSequenceT& ifind_all( + SequenceSequenceT& Result, + Range1T& Input, + const Range2T& Search, + const std::locale& Loc=std::locale() ) + { + return ::boost::algorithm::iter_find( + Result, + Input, + ::boost::algorithm::first_finder(Search, is_iequal(Loc) ) ); + } + + +// tokenize -------------------------------------------------------------// + + //! Split algorithm + /*! + Tokenize expression. This function is equivalent to C strtok. Input + sequence is split into tokens, separated by separators. Separators + are given by means of the predicate. + + Each part is copied and added as a new element to the + output container. + Thus the result container must be able to hold copies + of the matches (in a compatible structure like std::string) or + a reference to it (e.g. using the iterator range class). + Examples of such a container are \c std::vector<std::string> + or \c std::list<boost::iterator_range<std::string::iterator>> + + \param Result A container that can hold copies of references to the substrings + \param Input A container which will be searched. + \param Pred A predicate to identify separators. This predicate is + supposed to return true if a given element is a separator. + \param eCompress If eCompress argument is set to token_compress_on, adjacent + separators are merged together. Otherwise, every two separators + delimit a token. + \return A reference the result + + \note Prior content of the result will be overwritten. + + \note This function provides the strong exception-safety guarantee + */ + template< typename SequenceSequenceT, typename RangeT, typename PredicateT > + inline SequenceSequenceT& split( + SequenceSequenceT& Result, + RangeT& Input, + PredicateT Pred, + token_compress_mode_type eCompress=token_compress_off ) + { + return ::boost::algorithm::iter_split( + Result, + Input, + ::boost::algorithm::token_finder( Pred, eCompress ) ); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::find_all; + using algorithm::ifind_all; + using algorithm::split; + +} // namespace boost + + +#endif // BOOST_STRING_SPLIT_HPP +
diff --git a/boost_1_45_0/boost/algorithm/string/std/list_traits.hpp b/boost_1_45_0/boost/algorithm/string/std/list_traits.hpp new file mode 100644 index 0000000..ce2379d --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/std/list_traits.hpp
@@ -0,0 +1,85 @@ +// Boost string_algo library list_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_LIST_TRAITS_HPP +#define BOOST_STRING_STD_LIST_TRAITS_HPP + +#include <boost/algorithm/string/yes_no_type.hpp> +#include <list> +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + +// std::list<> traits -----------------------------------------------// + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // stable iterators tester + template<typename T, typename AllocT> + yes_type has_stable_iterators_tester( const ::std::list<T,AllocT>* ); + + // const time insert tester + template<typename T, typename AllocT> + yes_type has_const_time_insert_tester( const ::std::list<T,AllocT>* ); + + // const time erase tester + template<typename T, typename AllocT> + yes_type has_const_time_erase_tester( const ::std::list<T,AllocT>* ); + + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // stable iterators trait + template<typename T, typename AllocT> + class has_stable_iterators< ::std::list<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_stable_iterators<T>::value> type; + }; + + // const time insert trait + template<typename T, typename AllocT> + class has_const_time_insert< ::std::list<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_const_time_insert<T>::value> type; + }; + + // const time erase trait + template<typename T, typename AllocT> + class has_const_time_erase< ::std::list<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_const_time_erase<T>::value> type; + }; +#endif + + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/std/rope_traits.hpp b/boost_1_45_0/boost/algorithm/string/std/rope_traits.hpp new file mode 100644 index 0000000..c2cd549 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/std/rope_traits.hpp
@@ -0,0 +1,101 @@ +// Boost string_algo library string_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_ROPE_TRAITS_HPP +#define BOOST_STRING_STD_ROPE_TRAITS_HPP + +#include <boost/algorithm/string/yes_no_type.hpp> +#include <rope> +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + +// SGI's std::rope<> traits -----------------------------------------------// + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // native replace tester + template<typename T, typename TraitsT, typename AllocT> + yes_type has_native_replace_tester( const std::rope<T, TraitsT, AllocT>* ); + + // stable iterators tester + template<typename T, typename TraitsT, typename AllocT> + yes_type has_stable_iterators_tester( const std::rope<T, TraitsT, AllocT>* ); + + // const time insert tester + template<typename T, typename TraitsT, typename AllocT> + yes_type has_const_time_insert_tester( const std::rope<T, TraitsT, AllocT>* ); + + // const time erase tester + template<typename T, typename TraitsT, typename AllocT> + yes_type has_const_time_erase_tester( const std::rope<T, TraitsT, AllocT>* ); + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // native replace trait + template<typename T, typename TraitsT, typename AllocT> + class has_native_replace< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // stable iterators trait + template<typename T, typename TraitsT, typename AllocT> + class has_stable_iterators< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // const time insert trait + template<typename T, typename TraitsT, typename AllocT> + class has_const_time_insert< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; + + // const time erase trait + template<typename T, typename TraitsT, typename AllocT> + class has_const_time_erase< std::rope<T,TraitsT,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<value> type; + }; +#endif + + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_ROPE_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/std/slist_traits.hpp b/boost_1_45_0/boost/algorithm/string/std/slist_traits.hpp new file mode 100644 index 0000000..7b915a3 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/std/slist_traits.hpp
@@ -0,0 +1,85 @@ +// Boost string_algo library slist_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_SLIST_TRAITS_HPP +#define BOOST_STRING_STD_SLIST_TRAITS_HPP + +#include <boost/algorithm/string/config.hpp> +#include <boost/algorithm/string/yes_no_type.hpp> +#include BOOST_SLIST_HEADER +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + +// SGI's std::slist<> traits -----------------------------------------------// + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // stable iterators tester + template<typename T, typename AllocT> + yes_type has_stable_iterators_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* ); + + // const time insert tester + template<typename T, typename AllocT> + yes_type has_const_time_insert_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* ); + + // const time erase tester + template<typename T, typename AllocT> + yes_type has_const_time_erase_tester( const BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT>* ); + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // stable iterators trait + template<typename T, typename AllocT> + class has_stable_iterators< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_stable_iterators<T>::value> type; + }; + + // const time insert trait + template<typename T, typename AllocT> + class has_const_time_insert< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_const_time_insert<T>::value> type; + }; + + // const time erase trait + template<typename T, typename AllocT> + class has_const_time_erase< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true }; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + typedef mpl::bool_<has_const_time_erase<T>::value> type; + }; +#endif + + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/std/string_traits.hpp b/boost_1_45_0/boost/algorithm/string/std/string_traits.hpp new file mode 100644 index 0000000..c466d26 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/std/string_traits.hpp
@@ -0,0 +1,52 @@ +// Boost string_algo library string_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_STRING_TRAITS_HPP +#define BOOST_STRING_STD_STRING_TRAITS_HPP + +#include <boost/algorithm/string/yes_no_type.hpp> +#include <string> +#include <boost/algorithm/string/sequence_traits.hpp> + +namespace boost { + namespace algorithm { + +// std::basic_string<> traits -----------------------------------------------// + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // native replace tester + template<typename T, typename TraitsT, typename AllocT> + yes_type has_native_replace_tester( const std::basic_string<T, TraitsT, AllocT>* ); + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // native replace trait + template<typename T, typename TraitsT, typename AllocT> + class has_native_replace< std::basic_string<T, TraitsT, AllocT> > + { + public: +#if BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + enum { value = true } ; +#else + BOOST_STATIC_CONSTANT(bool, value=true); +#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 ) + + typedef mpl::bool_<has_native_replace<T>::value> type; + }; + + +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_LIST_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/std_containers_traits.hpp b/boost_1_45_0/boost/algorithm/string/std_containers_traits.hpp new file mode 100644 index 0000000..3f02246 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/std_containers_traits.hpp
@@ -0,0 +1,26 @@ +// Boost string_algo library std_containers_traits.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_STD_CONTAINERS_TRAITS_HPP +#define BOOST_STRING_STD_CONTAINERS_TRAITS_HPP + +/*!\file + This file includes sequence traits for stl containers. +*/ + +#include <boost/config.hpp> +#include <boost/algorithm/string/std/string_traits.hpp> +#include <boost/algorithm/string/std/list_traits.hpp> + +#ifdef BOOST_HAS_SLIST +# include <boost/algorithm/string/std/slist_traits.hpp> +#endif + +#endif // BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/trim.hpp b/boost_1_45_0/boost/algorithm/string/trim.hpp new file mode 100644 index 0000000..eb408a3 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/trim.hpp
@@ -0,0 +1,398 @@ +// Boost string_algo library trim.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_TRIM_HPP +#define BOOST_STRING_TRIM_HPP + +#include <boost/algorithm/string/config.hpp> + +#include <boost/range/begin.hpp> +#include <boost/range/end.hpp> +#include <boost/range/const_iterator.hpp> +#include <boost/range/as_literal.hpp> +#include <boost/range/iterator_range.hpp> + +#include <boost/algorithm/string/detail/trim.hpp> +#include <boost/algorithm/string/classification.hpp> +#include <locale> + +/*! \file + Defines trim algorithms. + Trim algorithms are used to remove trailing and leading spaces from a + sequence (string). Space is recognized using given locales. + + Parametric (\c _if) variants use a predicate (functor) to select which characters + are to be trimmed.. + Functions take a selection predicate as a parameter, which is used to determine + whether a character is a space. Common predicates are provided in classification.hpp header. + +*/ + +namespace boost { + namespace algorithm { + + // left trim -----------------------------------------------// + + + //! Left trim - parametric + /*! + Remove all leading spaces from the input. + The supplied predicate is used to determine which characters are considered spaces. + The result is a trimmed copy of the input. It is returned as a sequence + or copied to the output iterator + + \param Output An output iterator to which the result will be copied + \param Input An input range + \param IsSpace An unary predicate identifying spaces + \return + An output iterator pointing just after the last inserted character or + a copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template<typename OutputIteratorT, typename RangeT, typename PredicateT> + inline OutputIteratorT trim_left_copy_if( + OutputIteratorT Output, + const RangeT& Input, + PredicateT IsSpace) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(::boost::as_literal(Input)); + + std::copy( + ::boost::algorithm::detail::trim_begin( + ::boost::begin(lit_range), + ::boost::end(lit_range), + IsSpace ), + ::boost::end(lit_range), + Output); + + return Output; + } + + //! Left trim - parametric + /*! + \overload + */ + template<typename SequenceT, typename PredicateT> + inline SequenceT trim_left_copy_if(const SequenceT& Input, PredicateT IsSpace) + { + return SequenceT( + ::boost::algorithm::detail::trim_begin( + ::boost::begin(Input), + ::boost::end(Input), + IsSpace ), + ::boost::end(Input)); + } + + //! Left trim - parametric + /*! + Remove all leading spaces from the input. + The result is a trimmed copy of the input. + + \param Input An input sequence + \param Loc a locale used for 'space' classification + \return A trimmed copy of the input + + \note This function provides the strong exception-safety guarantee + */ + template<typename SequenceT> + inline SequenceT trim_left_copy(const SequenceT& Input, const std::locale& Loc=std::locale()) + { + return + ::boost::algorithm::trim_left_copy_if( + Input, + is_space(Loc)); + } + + //! Left trim + /*! + Remove all leading spaces from the input. The supplied predicate is + used to determine which characters are considered spaces. + The input sequence is modified in-place. + + \param Input An input sequence + \param IsSpace An unary predicate identifying spaces + */ + template<typename SequenceT, typename PredicateT> + inline void trim_left_if(SequenceT& Input, PredicateT IsSpace) + { + Input.erase( + ::boost::begin(Input), + ::boost::algorithm::detail::trim_begin( + ::boost::begin(Input), + ::boost::end(Input), + IsSpace)); + } + + //! Left trim + /*! + Remove all leading spaces from the input. + The Input sequence is modified in-place. + + \param Input An input sequence + \param Loc A locale used for 'space' classification + */ + template<typename SequenceT> + inline void trim_left(SequenceT& Input, const std::locale& Loc=std::locale()) + { + ::boost::algorithm::trim_left_if( + Input, + is_space(Loc)); + } + + // right trim -----------------------------------------------// + + //! Right trim - parametric + /*! + Remove all trailing spaces from the input. + The supplied predicate is used to determine which characters are considered spaces. + The result is a trimmed copy of the input. It is returned as a sequence + or copied to the output iterator + + \param Output An output iterator to which the result will be copied + \param Input An input range + \param IsSpace An unary predicate identifying spaces + \return + An output iterator pointing just after the last inserted character or + a copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template<typename OutputIteratorT, typename RangeT, typename PredicateT> + inline OutputIteratorT trim_right_copy_if( + OutputIteratorT Output, + const RangeT& Input, + PredicateT IsSpace ) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(::boost::as_literal(Input)); + + std::copy( + ::boost::begin(lit_range), + ::boost::algorithm::detail::trim_end( + ::boost::begin(lit_range), + ::boost::end(lit_range), + IsSpace ), + Output ); + + return Output; + } + + //! Right trim - parametric + /*! + \overload + */ + template<typename SequenceT, typename PredicateT> + inline SequenceT trim_right_copy_if(const SequenceT& Input, PredicateT IsSpace) + { + return SequenceT( + ::boost::begin(Input), + ::boost::algorithm::detail::trim_end( + ::boost::begin(Input), + ::boost::end(Input), + IsSpace) + ); + } + + //! Right trim + /*! + Remove all trailing spaces from the input. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + + \note This function provides the strong exception-safety guarantee + */ + template<typename SequenceT> + inline SequenceT trim_right_copy(const SequenceT& Input, const std::locale& Loc=std::locale()) + { + return + ::boost::algorithm::trim_right_copy_if( + Input, + is_space(Loc)); + } + + + //! Right trim - parametric + /*! + Remove all trailing spaces from the input. + The supplied predicate is used to determine which characters are considered spaces. + The input sequence is modified in-place. + + \param Input An input sequence + \param IsSpace An unary predicate identifying spaces + */ + template<typename SequenceT, typename PredicateT> + inline void trim_right_if(SequenceT& Input, PredicateT IsSpace) + { + Input.erase( + ::boost::algorithm::detail::trim_end( + ::boost::begin(Input), + ::boost::end(Input), + IsSpace ), + ::boost::end(Input) + ); + } + + + //! Right trim + /*! + Remove all trailing spaces from the input. + The input sequence is modified in-place. + + \param Input An input sequence + \param Loc A locale used for 'space' classification + */ + template<typename SequenceT> + inline void trim_right(SequenceT& Input, const std::locale& Loc=std::locale()) + { + ::boost::algorithm::trim_right_if( + Input, + is_space(Loc) ); + } + + // both side trim -----------------------------------------------// + + //! Trim - parametric + /*! + Remove all trailing and leading spaces from the input. + The supplied predicate is used to determine which characters are considered spaces. + The result is a trimmed copy of the input. It is returned as a sequence + or copied to the output iterator + + \param Output An output iterator to which the result will be copied + \param Input An input range + \param IsSpace An unary predicate identifying spaces + \return + An output iterator pointing just after the last inserted character or + a copy of the input + + \note The second variant of this function provides the strong exception-safety guarantee + */ + template<typename OutputIteratorT, typename RangeT, typename PredicateT> + inline OutputIteratorT trim_copy_if( + OutputIteratorT Output, + const RangeT& Input, + PredicateT IsSpace) + { + iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(::boost::as_literal(Input)); + + BOOST_STRING_TYPENAME + range_const_iterator<RangeT>::type TrimEnd= + ::boost::algorithm::detail::trim_end( + ::boost::begin(lit_range), + ::boost::end(lit_range), + IsSpace); + + std::copy( + detail::trim_begin( + ::boost::begin(lit_range), TrimEnd, IsSpace), + TrimEnd, + Output + ); + + return Output; + } + + //! Trim - parametric + /*! + \overload + */ + template<typename SequenceT, typename PredicateT> + inline SequenceT trim_copy_if(const SequenceT& Input, PredicateT IsSpace) + { + BOOST_STRING_TYPENAME + range_const_iterator<SequenceT>::type TrimEnd= + ::boost::algorithm::detail::trim_end( + ::boost::begin(Input), + ::boost::end(Input), + IsSpace); + + return SequenceT( + detail::trim_begin( + ::boost::begin(Input), + TrimEnd, + IsSpace), + TrimEnd + ); + } + + //! Trim + /*! + Remove all leading and trailing spaces from the input. + The result is a trimmed copy of the input + + \param Input An input sequence + \param Loc A locale used for 'space' classification + \return A trimmed copy of the input + + \note This function provides the strong exception-safety guarantee + */ + template<typename SequenceT> + inline SequenceT trim_copy( const SequenceT& Input, const std::locale& Loc=std::locale() ) + { + return + ::boost::algorithm::trim_copy_if( + Input, + is_space(Loc) ); + } + + //! Trim + /*! + Remove all leading and trailing spaces from the input. + The supplied predicate is used to determine which characters are considered spaces. + The input sequence is modified in-place. + + \param Input An input sequence + \param IsSpace An unary predicate identifying spaces + */ + template<typename SequenceT, typename PredicateT> + inline void trim_if(SequenceT& Input, PredicateT IsSpace) + { + ::boost::algorithm::trim_right_if( Input, IsSpace ); + ::boost::algorithm::trim_left_if( Input, IsSpace ); + } + + //! Trim + /*! + Remove all leading and trailing spaces from the input. + The input sequence is modified in-place. + + \param Input An input sequence + \param Loc A locale used for 'space' classification + */ + template<typename SequenceT> + inline void trim(SequenceT& Input, const std::locale& Loc=std::locale()) + { + ::boost::algorithm::trim_if( + Input, + is_space( Loc ) ); + } + + } // namespace algorithm + + // pull names to the boost namespace + using algorithm::trim_left; + using algorithm::trim_left_if; + using algorithm::trim_left_copy; + using algorithm::trim_left_copy_if; + using algorithm::trim_right; + using algorithm::trim_right_if; + using algorithm::trim_right_copy; + using algorithm::trim_right_copy_if; + using algorithm::trim; + using algorithm::trim_if; + using algorithm::trim_copy; + using algorithm::trim_copy_if; + +} // namespace boost + +#endif // BOOST_STRING_TRIM_HPP
diff --git a/boost_1_45_0/boost/algorithm/string/yes_no_type.hpp b/boost_1_45_0/boost/algorithm/string/yes_no_type.hpp new file mode 100644 index 0000000..b76cc6c --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string/yes_no_type.hpp
@@ -0,0 +1,33 @@ +// Boost string_algo library yes_no_type.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2003. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_YES_NO_TYPE_DETAIL_HPP +#define BOOST_STRING_YES_NO_TYPE_DETAIL_HPP + +namespace boost { + namespace algorithm { + + // taken from boost mailing-list + // when yes_no_type will become officially + // a part of boost distribution, this header + // will be deprecated + template<int I> struct size_descriptor + { + typedef char (& type)[I]; + }; + + typedef size_descriptor<1>::type yes_type; + typedef size_descriptor<2>::type no_type; + + } // namespace algorithm +} // namespace boost + + +#endif // BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
diff --git a/boost_1_45_0/boost/algorithm/string_regex.hpp b/boost_1_45_0/boost/algorithm/string_regex.hpp new file mode 100644 index 0000000..6fd8ad9 --- /dev/null +++ b/boost_1_45_0/boost/algorithm/string_regex.hpp
@@ -0,0 +1,23 @@ +// Boost string_algo library string_regex.hpp header file ---------------------------// + +// Copyright Pavol Droba 2002-2004. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/ for updates, documentation, and revision history. + +#ifndef BOOST_STRING_ALGO_REGEX_HPP +#define BOOST_STRING_ALGO_REGEX_HPP + +/*! \file + Cumulative include for string_algo library. + In addtion to string.hpp contains also regex-related stuff. +*/ + +#include <boost/regex.hpp> +#include <boost/algorithm/string.hpp> +#include <boost/algorithm/string/regex.hpp> + +#endif // BOOST_STRING_ALGO_REGEX_HPP
diff --git a/boost_1_45_0/boost/aligned_storage.hpp b/boost_1_45_0/boost/aligned_storage.hpp new file mode 100644 index 0000000..ce277ab --- /dev/null +++ b/boost_1_45_0/boost/aligned_storage.hpp
@@ -0,0 +1,181 @@ +//----------------------------------------------------------------------------- +// boost aligned_storage.hpp header file +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2002-2003 +// Eric Friedman, Itay Maman +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ALIGNED_STORAGE_HPP +#define BOOST_ALIGNED_STORAGE_HPP + +#include <cstddef> // for std::size_t + +#include "boost/config.hpp" +#include "boost/detail/workaround.hpp" +#include "boost/type_traits/alignment_of.hpp" +#include "boost/type_traits/type_with_alignment.hpp" +#include "boost/type_traits/is_pod.hpp" + +#include "boost/mpl/eval_if.hpp" +#include "boost/mpl/identity.hpp" + +#include "boost/type_traits/detail/bool_trait_def.hpp" + +namespace boost { + +namespace detail { namespace aligned_storage { + +BOOST_STATIC_CONSTANT( + std::size_t + , alignment_of_max_align = ::boost::alignment_of<max_align>::value + ); + +// +// To be TR1 conforming this must be a POD type: +// +template < + std::size_t size_ + , std::size_t alignment_ +> +struct aligned_storage_imp +{ + union data_t + { + char buf[size_]; + + typename mpl::eval_if_c< + alignment_ == std::size_t(-1) + , mpl::identity<detail::max_align> + , type_with_alignment<alignment_> + >::type align_; + } data_; + void* address() const { return const_cast<aligned_storage_imp*>(this); } +}; + +template< std::size_t alignment_ > +struct aligned_storage_imp<0u,alignment_> +{ + /* intentionally empty */ + void* address() const { return 0; } +}; + +}} // namespace detail::aligned_storage + +template < + std::size_t size_ + , std::size_t alignment_ = std::size_t(-1) +> +class aligned_storage : +#ifndef __BORLANDC__ + private +#else + public +#endif + detail::aligned_storage::aligned_storage_imp<size_, alignment_> +{ + +public: // constants + + typedef detail::aligned_storage::aligned_storage_imp<size_, alignment_> type; + + BOOST_STATIC_CONSTANT( + std::size_t + , size = size_ + ); + BOOST_STATIC_CONSTANT( + std::size_t + , alignment = ( + alignment_ == std::size_t(-1) + ? ::boost::detail::aligned_storage::alignment_of_max_align + : alignment_ + ) + ); + +#if defined(__GNUC__) &&\ + (__GNUC__ > 3) ||\ + (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 ||\ + (__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >=3))) + +private: // noncopyable + + aligned_storage(const aligned_storage&); + aligned_storage& operator=(const aligned_storage&); + +#else // gcc less than 3.2.3 + +public: // _should_ be noncopyable, but GCC compiler emits error + + aligned_storage(const aligned_storage&); + aligned_storage& operator=(const aligned_storage&); + +#endif // gcc < 3.2.3 workaround + +public: // structors + + aligned_storage() + { + } + + ~aligned_storage() + { + } + +public: // accessors + + void* address() + { + return static_cast<type*>(this)->address(); + } + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + + const void* address() const + { + return static_cast<const type*>(this)->address(); + } + +#else // MSVC6 + + const void* address() const; + +#endif // MSVC6 workaround + +}; + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +// MSVC6 seems not to like inline functions with const void* returns, so we +// declare the following here: + +template <std::size_t S, std::size_t A> +const void* aligned_storage<S,A>::address() const +{ + return const_cast< aligned_storage<S,A>* >(this)->address(); +} + +#endif // MSVC6 workaround + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// +// Make sure that is_pod recognises aligned_storage<>::type +// as a POD (Note that aligned_storage<> itself is not a POD): +// +template <std::size_t size_, std::size_t alignment_> +struct is_pod<boost::detail::aligned_storage::aligned_storage_imp<size_,alignment_> > + BOOST_TT_AUX_BOOL_C_BASE(true) +{ + BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true) +}; +#endif + + +} // namespace boost + +#include "boost/type_traits/detail/bool_trait_undef.hpp" + +#endif // BOOST_ALIGNED_STORAGE_HPP
diff --git a/boost_1_45_0/boost/any.hpp b/boost_1_45_0/boost/any.hpp new file mode 100644 index 0000000..a8c654c --- /dev/null +++ b/boost_1_45_0/boost/any.hpp
@@ -0,0 +1,253 @@ +// See http://www.boost.org/libs/any for Documentation. + +#ifndef BOOST_ANY_INCLUDED +#define BOOST_ANY_INCLUDED + +// what: variant type boost::any +// who: contributed by Kevlin Henney, +// with features contributed and bugs found by +// Ed Brey, Mark Rodgers, Peter Dimov, and James Curran +// when: July 2001 +// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95 + +#include <algorithm> +#include <typeinfo> + +#include "boost/config.hpp" +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/is_reference.hpp> +#include <boost/throw_exception.hpp> +#include <boost/static_assert.hpp> + +// See boost/python/type_id.hpp +// TODO: add BOOST_TYPEID_COMPARE_BY_NAME to config.hpp +# if (defined(__GNUC__) && __GNUC__ >= 3) \ + || defined(_AIX) \ + || ( defined(__sgi) && defined(__host_mips)) \ + || (defined(__hpux) && defined(__HP_aCC)) \ + || (defined(linux) && defined(__INTEL_COMPILER) && defined(__ICC)) +# define BOOST_AUX_ANY_TYPE_ID_NAME +#include <cstring> +# endif + +namespace boost +{ + class any + { + public: // structors + + any() + : content(0) + { + } + + template<typename ValueType> + any(const ValueType & value) + : content(new holder<ValueType>(value)) + { + } + + any(const any & other) + : content(other.content ? other.content->clone() : 0) + { + } + + ~any() + { + delete content; + } + + public: // modifiers + + any & swap(any & rhs) + { + std::swap(content, rhs.content); + return *this; + } + + template<typename ValueType> + any & operator=(const ValueType & rhs) + { + any(rhs).swap(*this); + return *this; + } + + any & operator=(any rhs) + { + rhs.swap(*this); + return *this; + } + + public: // queries + + bool empty() const + { + return !content; + } + + const std::type_info & type() const + { + return content ? content->type() : typeid(void); + } + +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + private: // types +#else + public: // types (public so any_cast can be non-friend) +#endif + + class placeholder + { + public: // structors + + virtual ~placeholder() + { + } + + public: // queries + + virtual const std::type_info & type() const = 0; + + virtual placeholder * clone() const = 0; + + }; + + template<typename ValueType> + class holder : public placeholder + { + public: // structors + + holder(const ValueType & value) + : held(value) + { + } + + public: // queries + + virtual const std::type_info & type() const + { + return typeid(ValueType); + } + + virtual placeholder * clone() const + { + return new holder(held); + } + + public: // representation + + ValueType held; + + private: // intentionally left unimplemented + holder & operator=(const holder &); + }; + +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + + private: // representation + + template<typename ValueType> + friend ValueType * any_cast(any *); + + template<typename ValueType> + friend ValueType * unsafe_any_cast(any *); + +#else + + public: // representation (public so any_cast can be non-friend) + +#endif + + placeholder * content; + + }; + + class bad_any_cast : public std::bad_cast + { + public: + virtual const char * what() const throw() + { + return "boost::bad_any_cast: " + "failed conversion using boost::any_cast"; + } + }; + + template<typename ValueType> + ValueType * any_cast(any * operand) + { + return operand && +#ifdef BOOST_AUX_ANY_TYPE_ID_NAME + std::strcmp(operand->type().name(), typeid(ValueType).name()) == 0 +#else + operand->type() == typeid(ValueType) +#endif + ? &static_cast<any::holder<ValueType> *>(operand->content)->held + : 0; + } + + template<typename ValueType> + inline const ValueType * any_cast(const any * operand) + { + return any_cast<ValueType>(const_cast<any *>(operand)); + } + + template<typename ValueType> + ValueType any_cast(any & operand) + { + typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // If 'nonref' is still reference type, it means the user has not + // specialized 'remove_reference'. + + // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro + // to generate specialization of remove_reference for your class + // See type traits library documentation for details + BOOST_STATIC_ASSERT(!is_reference<nonref>::value); +#endif + + nonref * result = any_cast<nonref>(&operand); + if(!result) + boost::throw_exception(bad_any_cast()); + return *result; + } + + template<typename ValueType> + inline ValueType any_cast(const any & operand) + { + typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // The comment in the above version of 'any_cast' explains when this + // assert is fired and what to do. + BOOST_STATIC_ASSERT(!is_reference<nonref>::value); +#endif + + return any_cast<const nonref &>(const_cast<any &>(operand)); + } + + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template<typename ValueType> + inline ValueType * unsafe_any_cast(any * operand) + { + return &static_cast<any::holder<ValueType> *>(operand->content)->held; + } + + template<typename ValueType> + inline const ValueType * unsafe_any_cast(const any * operand) + { + return unsafe_any_cast<ValueType>(const_cast<any *>(operand)); + } +} + +// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#endif
diff --git a/boost_1_45_0/boost/archive/add_facet.hpp b/boost_1_45_0/boost/archive/add_facet.hpp new file mode 100644 index 0000000..6bafe9b --- /dev/null +++ b/boost_1_45_0/boost/archive/add_facet.hpp
@@ -0,0 +1,55 @@ +#ifndef BOOST_ARCHIVE_ADD_FACET_HPP +#define BOOST_ARCHIVE_ADD_FACET_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// add_facet.hpp + +// (C) Copyright 2003 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <locale> +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> + +// does STLport uses native STL for locales? +#if (defined(__SGI_STL_PORT)&& defined(_STLP_NO_OWN_IOSTREAMS)) +// and this native STL lib is old Dinkumware (has not defined _CPPLIB_VER) +# if (defined(_YVALS) && !defined(__IBMCPP__)) || !defined(_CPPLIB_VER) +# define BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT +# endif +#endif + +namespace boost { +namespace archive { + +template<class Facet> +inline std::locale * +add_facet(const std::locale &l, Facet * f){ + return + #if defined BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT + // std namespace used for native locale + new std::locale(std::_Addfac(l, f)); + #elif BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) // old Dinkumwar + // std namespace used for native locale + new std::locale(std::_Addfac(l, f)); + #else + // standard compatible + new std::locale(l, f); + #endif +} + +} // namespace archive +} // namespace boost + +#undef BOOST_ARCHIVE_OLD_DINKUMWARE_BENEATH_STLPORT + +#endif // BOOST_ARCHIVE_ADD_FACET_HPP
diff --git a/boost_1_45_0/boost/archive/archive_exception.hpp b/boost_1_45_0/boost/archive/archive_exception.hpp new file mode 100644 index 0000000..242f752 --- /dev/null +++ b/boost_1_45_0/boost/archive/archive_exception.hpp
@@ -0,0 +1,97 @@ +#ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP +#define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// archive/archive_exception.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <exception> +#include <cassert> +#include <string> + +#include <boost/config.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/archive/detail/decl.hpp> + +// note: the only reason this is in here is that windows header +// includes #define exception_code _exception_code (arrrgghhhh!). +// the most expedient way to address this is be sure that this +// header is always included whenever this header file is included. +#if defined(BOOST_WINDOWS) +#include <excpt.h> +#endif + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// exceptions thrown by archives +// +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) archive_exception : + public virtual std::exception +{ +public: + typedef enum { + no_exception, // initialized without code + other_exception, // any excepton not listed below + unregistered_class, // attempt to serialize a pointer of an + // an unregistered class + invalid_signature, // first line of archive does not contain + // expected string + unsupported_version,// archive created with library version + // subsequent to this one + pointer_conflict, // an attempt has been made to directly + // serialize an object which has + // already been serialzed through a pointer. + // Were this permited, the archive load would result + // in the creation of an extra copy of the obect. + incompatible_native_format, // attempt to read native binary format + // on incompatible platform + array_size_too_short,// array being loaded doesn't fit in array allocated + input_stream_error, // error on input stream + invalid_class_name, // class name greater than the maximum permitted. + // most likely a corrupted archive or an attempt + // to insert virus via buffer overrun method. + unregistered_cast, // base - derived relationship not registered with + // void_cast_register + unsupported_class_version, // type saved with a version # greater than the + // one used by the program. This indicates that the proggram + // needs to be rebuilt. + multiple_code_instantiation, // code for implementing serialization for some + // type has been instantiated in more than one module. + output_stream_error // error on input stream + } exception_code; +protected: + std::string m_msg; +public: + exception_code code; + archive_exception( + exception_code c, + const char * e1 = NULL, + const char * e2 = NULL + ); + ~archive_exception() throw (); + virtual const char *what( ) const throw(); +protected: + archive_exception(); +}; + +}// namespace archive +}// namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
diff --git a/boost_1_45_0/boost/archive/basic_archive.hpp b/boost_1_45_0/boost/archive/basic_archive.hpp new file mode 100644 index 0000000..0b26ea5 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_archive.hpp
@@ -0,0 +1,300 @@ +#ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_archive.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <boost/config.hpp> +#include <boost/cstdint.hpp> // size_t +#include <boost/noncopyable.hpp> +#include <boost/integer_traits.hpp> + +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4244 4267 ) +#endif + +/* NOTE : Warning : Warning : Warning : Warning : Warning + * Don't ever changes this. If you do, they previously created + * binary archives won't be readable !!! + */ +class library_version_type { +private: + typedef uint_least16_t base_type; + base_type t; +public: + library_version_type(): t(0) {}; + explicit library_version_type(const unsigned int & t_) : t(t_){ + assert(t_ <= boost::integer_traits<base_type>::const_max); + } + library_version_type(const library_version_type & t_) : + t(t_.t) + {} + library_version_type & operator=(const library_version_type & rhs){ + t = rhs.t; + return *this; + } + // used for text output + operator base_type () const { + return t; + } + // used for text input + operator base_type & (){ + return t; + } + bool operator==(const library_version_type & rhs) const { + return t == rhs.t; + } + bool operator<(const library_version_type & rhs) const { + return t < rhs.t; + } +}; + +BOOST_ARCHIVE_DECL(library_version_type) +BOOST_ARCHIVE_VERSION(); + +class version_type { +private: + typedef uint_least32_t base_type; + base_type t; +public: + // should be private - but MPI fails if it's not!!! + version_type(): t(0) {}; + explicit version_type(const unsigned int & t_) : t(t_){ + assert(t_ <= boost::integer_traits<base_type>::const_max); + } + version_type(const version_type & t_) : + t(t_.t) + {} + version_type & operator=(const version_type & rhs){ + t = rhs.t; + return *this; + } + // used for text output + operator base_type () const { + return t; + } + // used for text intput + operator base_type & (){ + return t; + } + bool operator==(const version_type & rhs) const { + return t == rhs.t; + } + bool operator<(const version_type & rhs) const { + return t < rhs.t; + } +}; + +class class_id_type { +private: + typedef int_least16_t base_type; + base_type t; +public: + // should be private - but then can't use BOOST_STRONG_TYPE below + class_id_type() : t(0) {}; + explicit class_id_type(const int t_) : t(t_){ + assert(t_ <= boost::integer_traits<base_type>::const_max); + } + explicit class_id_type(const std::size_t t_) : t(t_){ + // assert(t_ <= boost::integer_traits<base_type>::const_max); + } + class_id_type(const class_id_type & t_) : + t(t_.t) + {} + class_id_type & operator=(const class_id_type & rhs){ + t = rhs.t; + return *this; + } + + // used for text output + operator int () const { + return t; + } + // used for text input + operator int_least16_t &() { + return t; + } + bool operator==(const class_id_type & rhs) const { + return t == rhs.t; + } + bool operator<(const class_id_type & rhs) const { + return t < rhs.t; + } +}; + +#define NULL_POINTER_TAG boost::archive::class_id_type(-1) + +class object_id_type { +private: + typedef uint_least32_t base_type; + base_type t; +public: + object_id_type(): t(0) {}; + explicit object_id_type(const unsigned int & t_) : t(t_){ + assert(t_ <= boost::integer_traits<base_type>::const_max); + } + object_id_type(const object_id_type & t_) : + t(t_.t) + {} + object_id_type & operator=(const object_id_type & rhs){ + t = rhs.t; + return *this; + } + // used for text output + operator uint_least32_t () const { + return t; + } + // used for text input + operator uint_least32_t & () { + return t; + } + bool operator==(const object_id_type & rhs) const { + return t == rhs.t; + } + bool operator<(const object_id_type & rhs) const { + return t < rhs.t; + } +}; + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + +struct tracking_type { + bool t; + explicit tracking_type(const bool t_ = false) + : t(t_) + {}; + tracking_type(const tracking_type & t_) + : t(t_.t) + {} + operator bool () const { + return t; + }; + operator bool & () { + return t; + }; + tracking_type & operator=(const bool t_){ + t = t_; + return *this; + } + bool operator==(const tracking_type & rhs) const { + return t == rhs.t; + } + bool operator==(const bool & rhs) const { + return t == rhs; + } + tracking_type & operator=(const tracking_type & rhs){ + t = rhs.t; + return *this; + } +}; + +struct class_name_type : + private boost::noncopyable +{ + char *t; + operator const char * & () const { + return const_cast<const char * &>(t); + } + operator char * () { + return t; + } + explicit class_name_type(const char *key_) + : t(const_cast<char *>(key_)){} + explicit class_name_type(char *key_) + : t(key_){} + class_name_type & operator=(const class_name_type & rhs){ + t = rhs.t; + return *this; + } +}; + +enum archive_flags { + no_header = 1, // suppress archive header info + no_codecvt = 2, // suppress alteration of codecvt facet + no_xml_tag_checking = 4, // suppress checking of xml tags + no_tracking = 8, // suppress ALL tracking + flags_last = 8 +}; + +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_SIGNATURE(); + +/* NOTE : Warning : Warning : Warning : Warning : Warning + * If any of these are changed to different sized types, + * binary_iarchive won't be able to read older archives + * unless you rev the library version and include conditional + * code based on the library version. There is nothing + * inherently wrong in doing this - but you have to be super + * careful because it's easy to get wrong and start breaking + * old archives !!! + */ + +#define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \ + class D : public T { \ + public: \ + explicit D(const T t) : T(type){} \ + }; \ +/**/ + +BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_reference_type) +BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type, class_id_optional_type) +BOOST_ARCHIVE_STRONG_TYPEDEF(object_id_type, object_reference_type) + +}// namespace archive +}// namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#include <boost/serialization/level.hpp> + +// set implementation level to primitive for all types +// used internally by the serialization library + +BOOST_CLASS_IMPLEMENTATION(boost::archive::library_version_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type) +BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type) + +#include <boost/serialization/is_bitwise_serializable.hpp> + +// set types used internally by the serialization library +// to be bitwise serializable + +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::library_version_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::version_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_reference_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_optional_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_name_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_id_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_reference_type) +BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::tracking_type) + +#endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_binary_iarchive.hpp b/boost_1_45_0/boost/archive/basic_binary_iarchive.hpp new file mode 100644 index 0000000..9567395 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_binary_iarchive.hpp
@@ -0,0 +1,196 @@ +#ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_iarchive.hpp +// +// archives stored as native binary - this should be the fastest way +// to archive the state of a group of obects. It makes no attempt to +// convert to any canonical form. + +// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE +// ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/basic_archive.hpp> +#include <boost/archive/detail/common_iarchive.hpp> +#include <boost/serialization/collection_size_type.hpp> +#include <boost/serialization/string.hpp> +#include <boost/serialization/item_version_type.hpp> +#include <boost/integer_traits.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class basic_binary_iarchive - read serialized objects from a input binary stream +template<class Archive> +class basic_binary_iarchive : + public detail::common_iarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_iarchive<Archive>; +#else + friend class detail::interface_iarchive<Archive>; +#endif + // intermediate level to support override of operators + // fot templates in the absence of partial function + // template ordering. If we get here pass to base class + // note extra nonsense to sneak it pass the borland compiers + typedef detail::common_iarchive<Archive> detail_common_iarchive; + template<class T> + void load_override(T & t, BOOST_PFTO int version){ + this->detail_common_iarchive::load_override(t, static_cast<int>(version)); + } + + // include these to trap a change in binary format which + // isn't specifically handled + BOOST_STATIC_ASSERT(sizeof(tracking_type) == sizeof(bool)); + // upto 32K classes + BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t)); + BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t)); + // upto 2G objects + BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t)); + BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t)); + + // binary files don't include the optional information + void load_override(class_id_optional_type & /* t */, int){} + + void load_override(class_id_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_iarchive::load_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + int_least16_t x=0; + * this->This() >> x; + t = boost::archive::class_id_type(x); + } + else{ + int x=0; + * this->This() >> x; + t = boost::archive::class_id_type(x); + } + } + void load_override(class_id_reference_type & t, int version){ + load_override(static_cast<class_id_type &>(t), version); + } +#if 0 + void load_override(class_id_reference_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_iarchive::load_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + int_least16_t x=0; + * this->This() >> x; + t = boost::archive::class_id_reference_type( + boost::archive::class_id_type(x) + ); + } + else{ + int x=0; + * this->This() >> x; + t = boost::archive::class_id_reference_type( + boost::archive::class_id_type(x) + ); + } + } +#endif + + void load_override(version_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_iarchive::load_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + uint_least16_t x=0; + * this->This() >> x; + t = boost::archive::version_type(x); + } + else{ + unsigned int x=0; + * this->This() >> x; + t = boost::archive::version_type(x); + } + } + + void load_override(boost::serialization::item_version_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_iarchive::load_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + uint_least16_t x=0; + * this->This() >> x; + t = boost::serialization::item_version_type(x); + } + else{ + unsigned int x=0; + * this->This() >> x; + t = boost::serialization::item_version_type(x); + } + } + + void load_override(serialization::collection_size_type & t, int version){ + if(boost::archive::library_version_type(5) < this->get_library_version()){ + this->detail_common_iarchive::load_override(t, version); + } + else{ + unsigned int x=0; + * this->This() >> x; + t = serialization::collection_size_type(x); + } + } + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(class_name_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + + basic_binary_iarchive(unsigned int flags) : + detail::common_iarchive<Archive>(flags) + {} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_binary_iprimitive.hpp b/boost_1_45_0/boost/archive/basic_binary_iprimitive.hpp new file mode 100644 index 0000000..a5b6bd4 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_binary_iprimitive.hpp
@@ -0,0 +1,190 @@ +#ifndef BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP +#define BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#if defined(_MSC_VER) +#pragma warning( disable : 4800 ) +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_iprimitive.hpp +// +// archives stored as native binary - this should be the fastest way +// to archive the state of a group of obects. It makes no attempt to +// convert to any canonical form. + +// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE +// ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <iosfwd> +#include <cassert> +#include <locale> +#include <cstring> // std::memcpy +#include <cstddef> // std::size_t +#include <streambuf> // basic_streambuf +#include <string> + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/serialization/throw_exception.hpp> +#include <boost/integer.hpp> +#include <boost/integer_traits.hpp> + +#include <boost/archive/basic_streambuf_locale_saver.hpp> +#include <boost/archive/archive_exception.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/serialization/is_bitwise_serializable.hpp> +#include <boost/serialization/array.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////////// +// class binary_iarchive - read serialized objects from a input binary stream +template<class Archive, class Elem, class Tr> +class basic_binary_iprimitive +{ +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + friend class load_access; +protected: +#else +public: +#endif + std::basic_streambuf<Elem, Tr> & m_sb; + // return a pointer to the most derived class + Archive * This(){ + return static_cast<Archive *>(this); + } + + #ifndef BOOST_NO_STD_LOCALE + boost::scoped_ptr<std::locale> archive_locale; + basic_streambuf_locale_saver<Elem, Tr> locale_saver; + #endif + + // main template for serilization of primitive types + template<class T> + void load(T & t){ + load_binary(& t, sizeof(T)); + } + + ///////////////////////////////////////////////////////// + // fundamental types that need special treatment + + // trap usage of invalid uninitialized boolean + void load(bool & t){ + load_binary(& t, sizeof(t)); + int i = t; + assert(0 == i || 1 == i); + (void)i; // warning suppression for release builds. + } + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load(std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load(std::wstring &ws); + #endif + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load(char * t); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load(wchar_t * t); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_binary_iprimitive( + std::basic_streambuf<Elem, Tr> & sb, + bool no_codecvt + ); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_binary_iprimitive(); +public: + // we provide an optimized load for all fundamental types + // typedef serialization::is_bitwise_serializable<mpl::_1> + // use_array_optimization; + struct use_array_optimization { + template <class T> + #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) + struct apply { + typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable< T >::type type; + }; + #else + struct apply : public boost::serialization::is_bitwise_serializable< T > {}; + #endif + }; + + // the optimized load_array dispatches to load_binary + template <class ValueType> + void load_array(serialization::array<ValueType>& a, unsigned int) + { + load_binary(a.address(),a.count()*sizeof(ValueType)); + } + + void + load_binary(void *address, std::size_t count); +}; + +template<class Archive, class Elem, class Tr> +inline void +basic_binary_iprimitive<Archive, Elem, Tr>::load_binary( + void *address, + std::size_t count +){ + // note: an optimizer should eliminate the following for char files + assert( + static_cast<std::streamsize>(count / sizeof(Elem)) + <= boost::integer_traits<std::streamsize>::const_max + ); + std::streamsize s = static_cast<std::streamsize>(count / sizeof(Elem)); + std::streamsize scount = m_sb.sgetn( + static_cast<Elem *>(address), + s + ); + if(scount != s) + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + // note: an optimizer should eliminate the following for char files + assert(count % sizeof(Elem) <= boost::integer_traits<std::streamsize>::const_max); + s = static_cast<std::streamsize>(count % sizeof(Elem)); + if(0 < s){ +// if(is.fail()) +// boost::serialization::throw_exception( +// archive_exception(archive_exception::stream_error) +// ); + Elem t; + scount = m_sb.sgetn(& t, 1); + if(scount != 1) + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + std::memcpy(static_cast<char*>(address) + (count - s), &t, s); + } +} + +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas + +#endif // BOOST_ARCHIVE_BINARY_IPRIMITIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_binary_oarchive.hpp b/boost_1_45_0/boost/archive/basic_binary_oarchive.hpp new file mode 100644 index 0000000..5321bf0 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_binary_oarchive.hpp
@@ -0,0 +1,180 @@ +#ifndef BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as native binary - this should be the fastest way +// to archive the state of a group of obects. It makes no attempt to +// convert to any canonical form. + +// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE +// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON + +#include <cassert> +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/integer.hpp> +#include <boost/integer_traits.hpp> + +#include <boost/archive/detail/common_oarchive.hpp> +#include <boost/serialization/string.hpp> +#include <boost/serialization/collection_size_type.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// class basic_binary_oarchive - write serialized objects to a binary output stream +// note: this archive has no pretensions to portability. Archive format +// may vary across machine architectures and compilers. About the only +// guarentee is that an archive created with this code will be readable +// by a program built with the same tools for the same machne. This class +// does have the virtue of buiding the smalles archive in the minimum amount +// of time. So under some circumstances it may be he right choice. +template<class Archive> +class basic_binary_oarchive : + public archive::detail::common_oarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_oarchive<Archive>; +#else + friend class detail::interface_oarchive<Archive>; +#endif + // any datatype not specifed below will be handled by base class + typedef detail::common_oarchive<Archive> detail_common_oarchive; + template<class T> + void save_override(const T & t, BOOST_PFTO int version){ + this->detail_common_oarchive::save_override(t, static_cast<int>(version)); + } + + // include these to trap a change in binary format which + // isn't specifically handled + BOOST_STATIC_ASSERT(sizeof(tracking_type) == sizeof(bool)); + // upto 32K classes + BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t)); + BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t)); + // upto 2G objects + BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t)); + BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t)); + + // binary files don't include the optional information + void save_override(const class_id_optional_type & /* t */, int){} + + // enable this if we decide to support generation of previous versions + #if 0 + void save_override(const boost::archive::version_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_oarchive::save_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + const boost::uint_least16_t x = t; + * this->This() << x; + } + else{ + const unsigned int x = t; + * this->This() << x; + } + } + void save_override(const boost::serialization::item_version_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_oarchive::save_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + const boost::uint_least16_t x = t; + * this->This() << x; + } + else{ + const unsigned int x = t; + * this->This() << x; + } + } + + void save_override(class_id_type & t, int version){ + library_version_type lvt = this->get_library_version(); + if(boost::archive::library_version_type(7) < lvt){ + this->detail_common_oarchive::save_override(t, version); + } + else + if(boost::archive::library_version_type(6) < lvt){ + const boost::int_least16_t x = t; + * this->This() << x; + } + else{ + const int x = t; + * this->This() << x; + } + } + void save_override(class_id_reference_type & t, int version){ + save_override(static_cast<class_id_type &>(t), version); + } + + #endif + + // explicitly convert to char * to avoid compile ambiguities + void save_override(const class_name_type & t, int){ + const std::string s(t); + * this->This() << s; + } + + #if 0 + void save_override(const serialization::collection_size_type & t, int){ + if (get_library_version() < boost::archive::library_version_type(6)){ + unsigned int x=0; + * this->This() >> x; + t = serialization::collection_size_type(x); + } + else{ + * this->This() >> t; + } + } + #endif + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + + basic_binary_oarchive(unsigned int flags) : + detail::common_oarchive<Archive>(flags) + {} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_BINARY_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_binary_oprimitive.hpp b/boost_1_45_0/boost/archive/basic_binary_oprimitive.hpp new file mode 100644 index 0000000..fb04858 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_binary_oprimitive.hpp
@@ -0,0 +1,184 @@ +#ifndef BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP +#define BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_oprimitive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as native binary - this should be the fastest way +// to archive the state of a group of obects. It makes no attempt to +// convert to any canonical form. + +// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE +// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON + +#include <iosfwd> +#include <cassert> +#include <locale> +#include <streambuf> // basic_streambuf +#include <string> +#include <cstddef> // size_t + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> +#include <boost/integer.hpp> +#include <boost/integer_traits.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/serialization/throw_exception.hpp> + +#include <boost/archive/basic_streambuf_locale_saver.hpp> +#include <boost/archive/archive_exception.hpp> +#include <boost/serialization/is_bitwise_serializable.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/serialization/array.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class basic_binary_oprimitive - binary output of prmitives + +template<class Archive, class Elem, class Tr> +class basic_binary_oprimitive +{ +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS + friend class save_access; +protected: +#else +public: +#endif + std::basic_streambuf<Elem, Tr> & m_sb; + // return a pointer to the most derived class + Archive * This(){ + return static_cast<Archive *>(this); + } + #ifndef BOOST_NO_STD_LOCALE + boost::scoped_ptr<std::locale> archive_locale; + basic_streambuf_locale_saver<Elem, Tr> locale_saver; + #endif + // default saving of primitives. + template<class T> + void save(const T & t) + { + save_binary(& t, sizeof(T)); + } + + ///////////////////////////////////////////////////////// + // fundamental types that need special treatment + + // trap usage of invalid uninitialized boolean which would + // otherwise crash on load. + void save(const bool t){ + assert(0 == static_cast<int>(t) || 1 == static_cast<int>(t)); + save_binary(& t, sizeof(t)); + } + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save(const std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save(const std::wstring &ws); + #endif + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save(const char * t); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save(const wchar_t * t); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_binary_oprimitive( + std::basic_streambuf<Elem, Tr> & sb, + bool no_codecvt + ); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_binary_oprimitive(); +public: + + // we provide an optimized save for all fundamental types + // typedef serialization::is_bitwise_serializable<mpl::_1> + // use_array_optimization; + // workaround without using mpl lambdas + struct use_array_optimization { + template <class T> + #if defined(BOOST_NO_DEPENDENT_NESTED_DERIVATIONS) + struct apply { + typedef BOOST_DEDUCED_TYPENAME boost::serialization::is_bitwise_serializable< T >::type type; + }; + #else + struct apply : public boost::serialization::is_bitwise_serializable< T > {}; + #endif + }; + + + // the optimized save_array dispatches to save_binary + template <class ValueType> + void save_array(boost::serialization::array<ValueType> const& a, unsigned int) + { + save_binary(a.address(),a.count()*sizeof(ValueType)); + } + + void save_binary(const void *address, std::size_t count); +}; + +template<class Archive, class Elem, class Tr> +inline void +basic_binary_oprimitive<Archive, Elem, Tr>::save_binary( + const void *address, + std::size_t count +){ + //assert( + // static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count + //); + // note: if the following assertions fail + // a likely cause is that the output stream is set to "text" + // mode where by cr characters recieve special treatment. + // be sure that the output stream is opened with ios::binary + //if(os.fail()) + // boost::serialization::throw_exception( + // archive_exception(archive_exception::output_stream_error) + // ); + // figure number of elements to output - round up + count = ( count + sizeof(Elem) - 1) + / sizeof(Elem); + assert(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max)); + std::streamsize scount = m_sb.sputn( + static_cast<const Elem *>(address), + static_cast<std::streamsize>(count) + ); + if(count != static_cast<std::size_t>(scount)) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + //os.write( + // static_cast<const BOOST_DEDUCED_TYPENAME OStream::char_type *>(address), + // count + //); + //assert(os.good()); +} + +} //namespace boost +} //namespace archive + +#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas + +#endif // BOOST_ARCHIVE_BASIC_BINARY_OPRIMITIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_streambuf_locale_saver.hpp b/boost_1_45_0/boost/archive/basic_streambuf_locale_saver.hpp new file mode 100644 index 0000000..ca764e1 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_streambuf_locale_saver.hpp
@@ -0,0 +1,73 @@ +#ifndef BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP +#define BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_streambuf_local_saver.hpp + +// (C) Copyright 2005 Robert Ramey - http://www.rrsd.com + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// note derived from boost/io/ios_state.hpp +// Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution +// are subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.) + +// See <http://www.boost.org/libs/io/> for the library's home page. + +#ifndef BOOST_NO_STD_LOCALE + +#include <locale> // for std::locale +#include <streambuf> // for std::basic_streambuf + +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost{ +namespace archive{ + +template < typename Ch, class Tr > +class basic_streambuf_locale_saver : + private boost::noncopyable +{ +public: + typedef ::std::basic_streambuf<Ch, Tr> state_type; + typedef ::std::locale aspect_type; + explicit basic_streambuf_locale_saver( state_type &s ) + : s_save_( s ), a_save_( s.getloc() ) + {} + basic_streambuf_locale_saver( state_type &s, aspect_type const &a ) + : s_save_( s ), a_save_( s.pubimbue(a) ) + {} + ~basic_streambuf_locale_saver() + { this->restore(); } + void restore() + { s_save_.pubimbue( a_save_ ); } +private: + state_type & s_save_; + aspect_type const a_save_; +}; + +} // archive +} // boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_NO_STD_LOCALE +#endif // BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
diff --git a/boost_1_45_0/boost/archive/basic_text_iarchive.hpp b/boost_1_45_0/boost/archive/basic_text_iarchive.hpp new file mode 100644 index 0000000..729d51a --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_text_iarchive.hpp
@@ -0,0 +1,91 @@ +#ifndef BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as text - note these ar templated on the basic +// stream templates to accommodate wide (and other?) kind of characters +// +// note the fact that on libraries without wide characters, ostream is +// is not a specialization of basic_ostream which in fact is not defined +// in such cases. So we can't use basic_ostream<IStream::char_type> but rather +// use two template parameters + +#include <boost/config.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/archive/detail/common_iarchive.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class basic_text_iarchive - read serialized objects from a input text stream +template<class Archive> +class basic_text_iarchive : + public detail::common_iarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_iarchive<Archive>; +#else + friend class detail::interface_iarchive<Archive>; +#endif + // intermediate level to support override of operators + // fot templates in the absence of partial function + // template ordering + typedef detail::common_iarchive<Archive> detail_common_iarchive; + template<class T> + void load_override(T & t, BOOST_PFTO int){ + this->detail_common_iarchive::load_override(t, 0); + } + // text file don't include the optional information + void load_override(class_id_optional_type & /*t*/, int){} + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(class_name_type & t, int); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(void); + + basic_text_iarchive(unsigned int flags) : + detail::common_iarchive<Archive>(flags) + {} + ~basic_text_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_TEXT_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_text_iprimitive.hpp b/boost_1_45_0/boost/archive/basic_text_iprimitive.hpp new file mode 100644 index 0000000..67ba7db --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_text_iprimitive.hpp
@@ -0,0 +1,144 @@ +#ifndef BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP +#define BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_iprimitive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as text - note these are templated on the basic +// stream templates to accommodate wide (and other?) kind of characters +// +// Note the fact that on libraries without wide characters, ostream is +// not a specialization of basic_ostream which in fact is not defined +// in such cases. So we can't use basic_ostream<IStream::char_type> but rather +// use two template parameters + +#include <cassert> +#include <locale> +#include <cstddef> // size_t + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; + #if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT) + using ::locale; + #endif +} // namespace std +#endif + +#include <boost/detail/workaround.hpp> +#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) +#include <boost/archive/dinkumware.hpp> +#endif + +#include <boost/limits.hpp> +#include <boost/io/ios_state.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/static_assert.hpp> + +#include <boost/serialization/throw_exception.hpp> +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/basic_streambuf_locale_saver.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class basic_text_iarchive - load serialized objects from a input text stream +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4244 4267 ) +#endif + +template<class IStream> +class basic_text_iprimitive +{ +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +protected: +#else +public: +#endif + IStream &is; + io::ios_flags_saver flags_saver; + io::ios_precision_saver precision_saver; + + #ifndef BOOST_NO_STD_LOCALE + boost::scoped_ptr<std::locale> archive_locale; + basic_streambuf_locale_saver< + BOOST_DEDUCED_TYPENAME IStream::char_type, + BOOST_DEDUCED_TYPENAME IStream::traits_type + > locale_saver; + #endif + + template<class T> + void load(T & t) + { + if(! is.fail()){ + is >> t; + return; + } + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + } + + void load(char & t) + { + short int i; + load(i); + t = i; + } + void load(signed char & t) + { + short int i; + load(i); + t = i; + } + void load(unsigned char & t) + { + unsigned short int i; + load(i); + t = i; + } + + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + void load(wchar_t & t) + { + BOOST_STATIC_ASSERT(sizeof(wchar_t) <= sizeof(int)); + int i; + load(i); + t = i; + } + #endif + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_text_iprimitive(IStream &is, bool no_codecvt); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_text_iprimitive(); +public: + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_binary(void *address, std::size_t count); +}; + +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif + +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas + +#endif // BOOST_ARCHIVE_BASIC_TEXT_IPRIMITIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_text_oarchive.hpp b/boost_1_45_0/boost/archive/basic_text_oarchive.hpp new file mode 100644 index 0000000..f6ec534 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_text_oarchive.hpp
@@ -0,0 +1,116 @@ +#ifndef BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as text - note these ar templated on the basic +// stream templates to accommodate wide (and other?) kind of characters +// +// note the fact that on libraries without wide characters, ostream is +// is not a specialization of basic_ostream which in fact is not defined +// in such cases. So we can't use basic_ostream<OStream::char_type> but rather +// use two template parameters + +#include <cassert> +#include <boost/config.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/archive/detail/common_oarchive.hpp> +#include <boost/serialization/string.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class basic_text_oarchive +template<class Archive> +class basic_text_oarchive : + public detail::common_oarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ +|| BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x560)) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_oarchive<Archive>; +#else + friend class detail::interface_oarchive<Archive>; +#endif + enum { + none, + eol, + space + } delimiter; + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + newtoken(); + + void newline(){ + delimiter = eol; + } + + // default processing - kick back to base class. Note the + // extra stuff to get it passed borland compilers + typedef detail::common_oarchive<Archive> detail_common_oarchive; + template<class T> + void save_override(T & t, BOOST_PFTO int){ + this->detail_common_oarchive::save_override(t, 0); + } + + // start new objects on a new line + void save_override(const object_id_type & t, int){ + this->This()->newline(); + this->detail_common_oarchive::save_override(t, 0); + } + + // text file don't include the optional information + void save_override(const class_id_optional_type & /* t */, int){} + + void save_override(const class_name_type & t, int){ + const std::string s(t); + * this->This() << s; + } + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + + basic_text_oarchive(unsigned int flags) : + detail::common_oarchive<Archive>(flags), + delimiter(none) + {} + ~basic_text_oarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_text_oprimitive.hpp b/boost_1_45_0/boost/archive/basic_text_oprimitive.hpp new file mode 100644 index 0000000..c0e884a --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_text_oprimitive.hpp
@@ -0,0 +1,173 @@ +#ifndef BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP +#define BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_oprimitive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// archives stored as text - note these ar templated on the basic +// stream templates to accommodate wide (and other?) kind of characters +// +// note the fact that on libraries without wide characters, ostream is +// is not a specialization of basic_ostream which in fact is not defined +// in such cases. So we can't use basic_ostream<OStream::char_type> but rather +// use two template parameters + +#include <iomanip> +#include <locale> +#include <boost/config/no_tr1/cmath.hpp> // isnan +#include <cassert> +#include <cstddef> // size_t + +#include <boost/config.hpp> +#include <boost/static_assert.hpp> +#include <boost/detail/workaround.hpp> +#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) +#include <boost/archive/dinkumware.hpp> +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; + #if ! defined(BOOST_DINKUMWARE_STDLIB) && ! defined(__SGI_STL_PORT) + using ::locale; + #endif +} // namespace std +#endif + +#include <boost/limits.hpp> +#include <boost/integer.hpp> +#include <boost/io/ios_state.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/serialization/throw_exception.hpp> +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/basic_streambuf_locale_saver.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +class save_access; + +///////////////////////////////////////////////////////////////////////// +// class basic_text_oprimitive - output of prmitives to stream +template<class OStream> +class basic_text_oprimitive +{ +#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +protected: +#else +public: +#endif + OStream &os; + io::ios_flags_saver flags_saver; + io::ios_precision_saver precision_saver; + + #ifndef BOOST_NO_STD_LOCALE + boost::scoped_ptr<std::locale> archive_locale; + basic_streambuf_locale_saver< + BOOST_DEDUCED_TYPENAME OStream::char_type, + BOOST_DEDUCED_TYPENAME OStream::traits_type + > locale_saver; + #endif + + // default saving of primitives. + template<class T> + void save(const T &t){ + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + os << t; + } + + ///////////////////////////////////////////////////////// + // fundamental types that need special treatment + void save(const bool t){ + // trap usage of invalid uninitialized boolean which would + // otherwise crash on load. + assert(0 == static_cast<int>(t) || 1 == static_cast<int>(t)); + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + os << t; + } + void save(const signed char t) + { + save(static_cast<short int>(t)); + } + void save(const unsigned char t) + { + save(static_cast<short unsigned int>(t)); + } + void save(const char t) + { + save(static_cast<short int>(t)); + } + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + void save(const wchar_t t) + { + BOOST_STATIC_ASSERT(sizeof(wchar_t) <= sizeof(int)); + save(static_cast<int>(t)); + } + #endif + void save(const float t) + { + // must be a user mistake - can't serialize un-initialized data + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + os << std::setprecision(std::numeric_limits<float>::digits10 + 2); + os << t; + } + void save(const double t) + { + // must be a user mistake - can't serialize un-initialized data + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + os << std::setprecision(std::numeric_limits<double>::digits10 + 2); + os << t; + } + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_text_oprimitive(OStream & os, bool no_codecvt); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_text_oprimitive(); +public: + // unformatted append of one character + void put(BOOST_DEDUCED_TYPENAME OStream::char_type c){ + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + os.put(c); + } + // unformatted append of null terminated string + void put(const char * s){ + while('\0' != *s) + os.put(*s++); + } + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_binary(const void *address, std::size_t count); +}; + +} //namespace boost +} //namespace archive + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_TEXT_OPRIMITIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_xml_archive.hpp b/boost_1_45_0/boost/archive/basic_xml_archive.hpp new file mode 100644 index 0000000..c99d94f --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_xml_archive.hpp
@@ -0,0 +1,67 @@ +#ifndef BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_archive.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/archive/archive_exception.hpp> + +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +// constant strings used in xml i/o + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_OBJECT_ID(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_OBJECT_REFERENCE(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_CLASS_ID(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_CLASS_NAME(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_TRACKING(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_VERSION(); + +extern +BOOST_ARCHIVE_DECL(const char *) +BOOST_ARCHIVE_XML_SIGNATURE(); + +}// namespace archive +}// namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_XML_TEXT_ARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/basic_xml_iarchive.hpp b/boost_1_45_0/boost/archive/basic_xml_iarchive.hpp new file mode 100644 index 0000000..d7b8bfd --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_xml_iarchive.hpp
@@ -0,0 +1,127 @@ +#ifndef BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/archive/detail/common_iarchive.hpp> + +#include <boost/serialization/nvp.hpp> +#include <boost/serialization/string.hpp> + +#include <boost/mpl/assert.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +///////////////////////////////////////////////////////////////////////// +// class xml_iarchive - read serialized objects from a input text stream +template<class Archive> +class basic_xml_iarchive : + public detail::common_iarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_oarchive<Archive>; +#else + friend class detail::interface_oarchive<Archive>; +#endif + unsigned int depth; + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_start(const char *name); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_end(const char *name); + + // Anything not an attribute and not a name-value pair is an + // should be trapped here. + template<class T> + void load_override(T & t, BOOST_PFTO int) + { + // If your program fails to compile here, its most likely due to + // not specifying an nvp wrapper around the variable to + // be serialized. + BOOST_MPL_ASSERT((serialization::is_wrapper< T >)); + this->detail_common_iarchive::load_override(t, 0); + } + + // Anything not an attribute - see below - should be a name value + // pair and be processed here + typedef detail::common_iarchive<Archive> detail_common_iarchive; + template<class T> + void load_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + boost::serialization::nvp< T > & t, + int + ){ + this->This()->load_start(t.name()); + this->detail_common_iarchive::load_override(t.value(), 0); + this->This()->load_end(t.name()); + } + + // specific overrides for attributes - handle as + // primitives. These are not name-value pairs + // so they have to be intercepted here and passed on to load. + // although the class_id is included in the xml text file in order + // to make the file self describing, it isn't used when loading + // an xml archive. So we can skip it here. Note: we MUST override + // it otherwise it will be loaded as a normal primitive w/o tag and + // leaving the archive in an undetermined state + void load_override(class_id_optional_type & /* t */, int){} + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(object_id_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(version_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(class_id_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + load_override(tracking_type & t, int); + // class_name_type can't be handled here as it depends upon the + // char type used by the stream. So require the derived implementation + // handle this. + // void load_override(class_name_type & t, int); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_xml_iarchive(unsigned int flags); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_xml_iarchive(); +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_XML_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/basic_xml_oarchive.hpp b/boost_1_45_0/boost/archive/basic_xml_oarchive.hpp new file mode 100644 index 0000000..b571372 --- /dev/null +++ b/boost_1_45_0/boost/archive/basic_xml_oarchive.hpp
@@ -0,0 +1,145 @@ +#ifndef BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> + +#include <boost/archive/detail/common_oarchive.hpp> + +#include <boost/serialization/nvp.hpp> +#include <boost/serialization/tracking.hpp> +#include <boost/serialization/string.hpp> + +#include <boost/mpl/assert.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// class basic_xml_oarchive - write serialized objects to a xml output stream +template<class Archive> +class basic_xml_oarchive : + public detail::common_oarchive<Archive> +{ +protected: +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +public: +#elif defined(BOOST_MSVC) + // for some inexplicable reason insertion of "class" generates compile erro + // on msvc 7.1 + friend detail::interface_oarchive<Archive>; + friend class save_access; +#else + friend class detail::interface_oarchive<Archive>; + friend class save_access; +#endif + // special stuff for xml output + unsigned int depth; + bool indent_next; + bool pending_preamble; + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + indent(); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + init(); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + write_attribute( + const char *attribute_name, + int t, + const char *conjunction = "=\"" + ); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + write_attribute( + const char *attribute_name, + const char *key + ); + // helpers used below + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_start(const char *name); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_end(const char *name); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + end_preamble(); + + // Anything not an attribute and not a name-value pair is an + // error and should be trapped here. + template<class T> + void save_override(T & t, BOOST_PFTO int) + { + // If your program fails to compile here, its most likely due to + // not specifying an nvp wrapper around the variable to + // be serialized. + BOOST_MPL_ASSERT((serialization::is_wrapper< T >)); + this->detail_common_oarchive::save_override(t, 0); + } + + // special treatment for name-value pairs. + typedef detail::common_oarchive<Archive> detail_common_oarchive; + template<class T> + void save_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + ::boost::serialization::nvp< T > & t, + int + ){ + this->This()->save_start(t.name()); + this->detail_common_oarchive::save_override(t.const_value(), 0); + this->This()->save_end(t.name()); + } + + // specific overrides for attributes - not name value pairs so we + // want to trap them before the above "fall through" + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const object_id_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const object_reference_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const version_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const class_id_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const class_id_optional_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const class_id_reference_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const class_name_type & t, int); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) + save_override(const tracking_type & t, int); + + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + basic_xml_oarchive(unsigned int flags); + BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~basic_xml_oarchive(); +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_XML_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/binary_iarchive.hpp b/boost_1_45_0/boost/archive/binary_iarchive.hpp new file mode 100644 index 0000000..638d996 --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_iarchive.hpp
@@ -0,0 +1,103 @@ +#ifndef BOOST_ARCHIVE_BINARY_IARCHIVE_HPP +#define BOOST_ARCHIVE_BINARY_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <istream> +#include <boost/archive/binary_iarchive_impl.hpp> +#include <boost/archive/detail/register_archive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +// do not derive from the classes below. If you want to extend this functionality +// via inhertance, derived from text_iarchive_impl instead. This will +// preserve correct static polymorphism. + +// same as binary_iarchive below - without the shared_ptr_helper +class naked_binary_iarchive : + public binary_iarchive_impl< + boost::archive::naked_binary_iarchive, + std::istream::char_type, + std::istream::traits_type + > +{ +public: + naked_binary_iarchive(std::istream & is, unsigned int flags = 0) : + binary_iarchive_impl< + naked_binary_iarchive, std::istream::char_type, std::istream::traits_type + >(is, flags) + {} + naked_binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) : + binary_iarchive_impl< + naked_binary_iarchive, std::istream::char_type, std::istream::traits_type + >(bsb, flags) + {} +}; + +} // namespace archive +} // namespace boost + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +namespace boost { +namespace archive { + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from binary_iarchive_impl instead. This will +// preserve correct static polymorphism. +class binary_iarchive : + public binary_iarchive_impl< + boost::archive::binary_iarchive, + std::istream::char_type, + std::istream::traits_type + >, + public detail::shared_ptr_helper +{ +public: + binary_iarchive(std::istream & is, unsigned int flags = 0) : + binary_iarchive_impl< + binary_iarchive, std::istream::char_type, std::istream::traits_type + >(is, flags) + {} + binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) : + binary_iarchive_impl< + binary_iarchive, std::istream::char_type, std::istream::traits_type + >(bsb, flags) + {} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_iarchive) +BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(boost::archive::binary_iarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/binary_iarchive_impl.hpp b/boost_1_45_0/boost/archive/binary_iarchive_impl.hpp new file mode 100644 index 0000000..32c476d --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_iarchive_impl.hpp
@@ -0,0 +1,96 @@ +#ifndef BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP +#define BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_iarchive_impl.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <istream> +#include <boost/serialization/pfto.hpp> +#include <boost/archive/basic_binary_iprimitive.hpp> +#include <boost/archive/basic_binary_iarchive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive, class Elem, class Tr> +class binary_iarchive_impl : + public basic_binary_iprimitive<Archive, Elem, Tr>, + public basic_binary_iarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<Archive>; + friend class basic_binary_iarchive<Archive>; + friend class load_access; +protected: +#endif + // note: the following should not needed - but one compiler (vc 7.1) + // fails to compile one test (test_shared_ptr) without it !!! + // make this protected so it can be called from a derived archive + template<class T> + void load_override(T & t, BOOST_PFTO int){ + this->basic_binary_iarchive<Archive>::load_override(t, 0L); + } + void init(unsigned int flags){ + if(0 != (flags & no_header)) + return; + #if ! defined(__MWERKS__) + this->basic_binary_iarchive<Archive>::init(); + this->basic_binary_iprimitive<Archive, Elem, Tr>::init(); + #else + basic_binary_iarchive<Archive>::init(); + basic_binary_iprimitive<Archive, Elem, Tr>::init(); + #endif + } + binary_iarchive_impl( + std::basic_streambuf<Elem, Tr> & bsb, + unsigned int flags + ) : + basic_binary_iprimitive<Archive, Elem, Tr>( + bsb, + 0 != (flags & no_codecvt) + ), + basic_binary_iarchive<Archive>(flags) + { + init(flags); + } + binary_iarchive_impl( + std::basic_istream<Elem, Tr> & is, + unsigned int flags + ) : + basic_binary_iprimitive<Archive, Elem, Tr>( + * is.rdbuf(), + 0 != (flags & no_codecvt) + ), + basic_binary_iarchive<Archive>(flags) + { + init(flags); + } +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_IMPL_HPP
diff --git a/boost_1_45_0/boost/archive/binary_oarchive.hpp b/boost_1_45_0/boost/archive/binary_oarchive.hpp new file mode 100644 index 0000000..2aac14f --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_oarchive.hpp
@@ -0,0 +1,66 @@ +#ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_HPP +#define BOOST_ARCHIVE_BINARY_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <ostream> +#include <boost/config.hpp> +#include <boost/archive/binary_oarchive_impl.hpp> +#include <boost/archive/detail/register_archive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from binary_oarchive_impl instead. This will +// preserve correct static polymorphism. +class binary_oarchive : + public binary_oarchive_impl< + binary_oarchive, std::ostream::char_type, std::ostream::traits_type + > +{ +public: + binary_oarchive(std::ostream & os, unsigned int flags = 0) : + binary_oarchive_impl< + binary_oarchive, std::ostream::char_type, std::ostream::traits_type + >(os, flags) + {} + binary_oarchive(std::streambuf & bsb, unsigned int flags = 0) : + binary_oarchive_impl< + binary_oarchive, std::ostream::char_type, std::ostream::traits_type + >(bsb, flags) + {} +}; + +typedef binary_oarchive naked_binary_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_oarchive) +BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(boost::archive::binary_oarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/binary_oarchive_impl.hpp b/boost_1_45_0/boost/archive/binary_oarchive_impl.hpp new file mode 100644 index 0000000..7ca773b --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_oarchive_impl.hpp
@@ -0,0 +1,97 @@ +#ifndef BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP +#define BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_oarchive_impl.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <ostream> +#include <boost/config.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/archive/basic_binary_oprimitive.hpp> +#include <boost/archive/basic_binary_oarchive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive, class Elem, class Tr> +class binary_oarchive_impl : + public basic_binary_oprimitive<Archive, Elem, Tr>, + public basic_binary_oarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<Archive>; + friend class basic_binary_oarchive<Archive>; + friend class save_access; +protected: +#endif + // note: the following should not needed - but one compiler (vc 7.1) + // fails to compile one test (test_shared_ptr) without it !!! + // make this protected so it can be called from a derived archive + template<class T> + void save_override(T & t, BOOST_PFTO int){ + this->basic_binary_oarchive<Archive>::save_override(t, 0L); + } + void init(unsigned int flags) { + if(0 != (flags & no_header)) + return; + #if ! defined(__MWERKS__) + this->basic_binary_oarchive<Archive>::init(); + this->basic_binary_oprimitive<Archive, Elem, Tr>::init(); + #else + basic_binary_oarchive<Archive>::init(); + basic_binary_oprimitive<Archive, Elem, Tr>::init(); + #endif + } + binary_oarchive_impl( + std::basic_streambuf<Elem, Tr> & bsb, + unsigned int flags + ) : + basic_binary_oprimitive<Archive, Elem, Tr>( + bsb, + 0 != (flags & no_codecvt) + ), + basic_binary_oarchive<Archive>(flags) + { + init(flags); + } + binary_oarchive_impl( + std::basic_ostream<Elem, Tr> & os, + unsigned int flags + ) : + basic_binary_oprimitive<Archive, Elem, Tr>( + * os.rdbuf(), + 0 != (flags & no_codecvt) + ), + basic_binary_oarchive<Archive>(flags) + { + init(flags); + } +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_IMPL_HPP
diff --git a/boost_1_45_0/boost/archive/binary_wiarchive.hpp b/boost_1_45_0/boost/archive/binary_wiarchive.hpp new file mode 100644 index 0000000..b5f6a71 --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_wiarchive.hpp
@@ -0,0 +1,93 @@ +#ifndef BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP +#define BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_wiarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <istream> // wistream +#include <boost/archive/binary_iarchive_impl.hpp> +#include <boost/archive/detail/register_archive.hpp> + +namespace boost { +namespace archive { + +// same as binary_wiarchive below - without the shared_ptr_helper +class naked_binary_wiarchive : + public binary_iarchive_impl< + boost::archive::naked_binary_wiarchive, + std::wistream::char_type, + std::wistream::traits_type + > +{ +public: + naked_binary_wiarchive(std::wistream & is, unsigned int flags = 0) : + binary_iarchive_impl< + naked_binary_wiarchive, + std::wistream::char_type, + std::wistream::traits_type + >(is, flags) + {} + naked_binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) : + binary_iarchive_impl< + naked_binary_wiarchive, + std::wistream::char_type, + std::wistream::traits_type + >(bsb, flags) + {} +}; + +} // namespace archive +} // namespace boost + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +namespace boost { +namespace archive { + +class binary_wiarchive : + public binary_iarchive_impl< + binary_wiarchive, std::wistream::char_type, std::wistream::traits_type + > +{ +public: + binary_wiarchive(std::wistream & is, unsigned int flags = 0) : + binary_iarchive_impl< + binary_wiarchive, std::wistream::char_type, std::wistream::traits_type + >(is, flags) + {} + binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) : + binary_iarchive_impl< + binary_wiarchive, std::wistream::char_type, std::wistream::traits_type + >(bsb, flags) + {} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_wiarchive) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/binary_woarchive.hpp b/boost_1_45_0/boost/archive/binary_woarchive.hpp new file mode 100644 index 0000000..2075dac --- /dev/null +++ b/boost_1_45_0/boost/archive/binary_woarchive.hpp
@@ -0,0 +1,61 @@ +#ifndef BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP +#define BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_woarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <ostream> +#include <boost/archive/binary_oarchive_impl.hpp> +#include <boost/archive/detail/register_archive.hpp> + +namespace boost { +namespace archive { + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from binary_oarchive_impl instead. This will +// preserve correct static polymorphism. +class binary_woarchive : + public binary_oarchive_impl< + binary_woarchive, std::wostream::char_type, std::wostream::traits_type + > +{ +public: + binary_woarchive(std::wostream & os, unsigned int flags = 0) : + binary_oarchive_impl< + binary_woarchive, std::wostream::char_type, std::wostream::traits_type + >(os, flags) + {} + binary_woarchive(std::wstreambuf & bsb, unsigned int flags = 0) : + binary_oarchive_impl< + binary_woarchive, std::wostream::char_type, std::wostream::traits_type + >(bsb, flags) + {} +}; + +typedef binary_woarchive naked_binary_woarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_woarchive) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/codecvt_null.hpp b/boost_1_45_0/boost/archive/codecvt_null.hpp new file mode 100644 index 0000000..910b261 --- /dev/null +++ b/boost_1_45_0/boost/archive/codecvt_null.hpp
@@ -0,0 +1,100 @@ +#ifndef BOOST_ARCHIVE_CODECVT_NULL_HPP +#define BOOST_ARCHIVE_CODECVT_NULL_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// codecvt_null.hpp: + +// (C) Copyright 2004 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <locale> +#include <cstddef> // NULL, size_t +#include <cwchar> // for mbstate_t +#include <boost/config.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std { +// For STLport on WinCE, BOOST_NO_STDC_NAMESPACE can get defined if STLport is putting symbols in its own namespace. +// In the case of codecvt, however, this does not mean that codecvt is in the global namespace (it will be in STLport's namespace) +# if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) + using ::codecvt; +# endif + using ::mbstate_t; + using ::size_t; +} // namespace +#endif + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Ch> +class codecvt_null; + +template<> +class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t> +{ + virtual bool do_always_noconv() const throw() { + return true; + } +public: + explicit codecvt_null(std::size_t no_locale_manage = 0) : + std::codecvt<char, char, std::mbstate_t>(no_locale_manage) + {} +}; + +template<> +class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t> +{ + virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result) + do_out( + std::mbstate_t & state, + const wchar_t * first1, + const wchar_t * last1, + const wchar_t * & next1, + char * first2, + char * last2, + char * & next2 + ) const; + virtual BOOST_WARCHIVE_DECL(std::codecvt_base::result) + do_in( + std::mbstate_t & state, + const char * first1, + const char * last1, + const char * & next1, + wchar_t * first2, + wchar_t * last2, + wchar_t * & next2 + ) const; + virtual int do_encoding( ) const throw( ){ + return sizeof(wchar_t) / sizeof(char); + } + virtual int do_max_length( ) const throw( ){ + return do_encoding(); + } +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif +#include <boost/archive/detail/abi_suffix.hpp> // pop pragmas + +#endif //BOOST_ARCHIVE_CODECVT_NULL_HPP
diff --git a/boost_1_45_0/boost/archive/detail/abi_prefix.hpp b/boost_1_45_0/boost/archive/detail/abi_prefix.hpp new file mode 100644 index 0000000..e39ef11 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/abi_prefix.hpp
@@ -0,0 +1,20 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// abi_prefix.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config/abi_prefix.hpp> // must be the last header +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4251 4231 4660 4275) +#endif + +#if defined( __BORLANDC__ ) +#pragma nopushoptwarn +#endif +
diff --git a/boost_1_45_0/boost/archive/detail/abi_suffix.hpp b/boost_1_45_0/boost/archive/detail/abi_suffix.hpp new file mode 100644 index 0000000..a283b36 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/abi_suffix.hpp
@@ -0,0 +1,19 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// abi_suffix.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#if defined( __BORLANDC__ ) +#pragma nopushoptwarn +#endif +
diff --git a/boost_1_45_0/boost/archive/detail/archive_serializer_map.hpp b/boost_1_45_0/boost/archive/detail/archive_serializer_map.hpp new file mode 100644 index 0000000..6d2eec4 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/archive_serializer_map.hpp
@@ -0,0 +1,55 @@ +#ifndef BOOST_ARCHIVE_SERIALIZER_MAP_HPP +#define BOOST_ARCHIVE_SERIALIZER_MAP_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// archive_serializer_map.hpp: extenstion of type_info required for +// serialization. + +// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// note: this is nothing more than the thinest of wrappers around +// basic_serializer_map so we can have a one map / archive type. + +#include <boost/config.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { + +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { +namespace detail { + +class basic_serializer; + +template<class Archive> +class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +archive_serializer_map { +public: + static bool insert(const basic_serializer * bs); + static void erase(const basic_serializer * bs); + static const basic_serializer * find( + const boost::serialization::extended_type_info & type_ + ); +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // must be the last header + +#endif //BOOST_ARCHIVE_SERIALIZER_MAP_HPP
diff --git a/boost_1_45_0/boost/archive/detail/auto_link_archive.hpp b/boost_1_45_0/boost/archive/detail/auto_link_archive.hpp new file mode 100644 index 0000000..05956f0 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/auto_link_archive.hpp
@@ -0,0 +1,48 @@ +#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// auto_link_archive.hpp +// +// (c) Copyright Robert Ramey 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/serialization + +//----------------------------------------------------------------------------// + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +// enable automatic library variant selection ------------------------------// + +#include <boost/archive/detail/decl.hpp> + +#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) \ +&& !defined(BOOST_ARCHIVE_SOURCE) && !defined(BOOST_WARCHIVE_SOURCE) \ +&& !defined(BOOST_SERIALIZATION_SOURCE) + + // Set the name of our library, this will get undef'ed by auto_link.hpp + // once it's done with it: + // + #define BOOST_LIB_NAME boost_serialization + // + // If we're importing code from a dll, then tell auto_link.hpp about it: + // + #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK) + # define BOOST_DYN_LINK + #endif + // + // And include the header that does the work: + // + #include <boost/config/auto_link.hpp> +#endif // auto-linking disabled + +#endif // BOOST_ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/auto_link_warchive.hpp b/boost_1_45_0/boost/archive/detail/auto_link_warchive.hpp new file mode 100644 index 0000000..4d4efcd --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/auto_link_warchive.hpp
@@ -0,0 +1,47 @@ +#ifndef BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_AUTO_LINK_WARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// auto_link_warchive.hpp +// +// (c) Copyright Robert Ramey 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/serialization + +//----------------------------------------------------------------------------// + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +// enable automatic library variant selection ------------------------------// + +#include <boost/archive/detail/decl.hpp> + +#if !defined(BOOST_WARCHIVE_SOURCE) \ +&& !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) + +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_wserialization +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include <boost/config/auto_link.hpp> +#endif // auto-linking disabled + +#endif // ARCHIVE_DETAIL_AUTO_LINK_ARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_archive_impl.hpp b/boost_1_45_0/boost/archive/detail/basic_archive_impl.hpp new file mode 100644 index 0000000..589368d --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_archive_impl.hpp
@@ -0,0 +1,48 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP +#define BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_archive_impl.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// can't use this - much as I'd like to as borland doesn't support it +// #include <boost/scoped_ptr.hpp> + +#include <set> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { +namespace detail { + +////////////////////////////////////////////////////////////////////// +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_archive_impl +{ +}; + +} // namespace detail +} // namespace serialization +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif //BOOST_ARCHIVE_DETAIL_BASIC_ARCHIVE_IMPL_HPP + + +
diff --git a/boost_1_45_0/boost/archive/detail/basic_config.hpp b/boost_1_45_0/boost/archive/detail/basic_config.hpp new file mode 100644 index 0000000..5e37cae --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_config.hpp
@@ -0,0 +1,45 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP +#define BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// basic_config.hpp ---------------------------------------------// + +// (c) Copyright Robert Ramey 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/serialization + +//----------------------------------------------------------------------------// + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +#include <boost/config.hpp> + +#ifdef BOOST_HAS_DECLSPEC // defined in config system +// we need to import/export our code only if the user has specifically +// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost +// libraries to be dynamically linked, or BOOST_ARCHIVE_DYN_LINK +// if they want just this one to be dynamically linked: +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ARCHIVE_DYN_LINK) +// export if this is our own source, otherwise import: +#ifdef BOOST_ARCHIVE_SOURCE +# define BOOST_ARCHIVE_DECL __declspec(dllexport) +#else +# define BOOST_ARCHIVE_DECL __declspec(dllimport) +#endif // BOOST_ARCHIVE_SOURCE +#endif // DYN_LINK +#endif // BOOST_HAS_DECLSPEC +// +// if BOOST_ARCHIVE_DECL isn't defined yet define it now: +#ifndef BOOST_ARCHIVE_DECL +#define BOOST_ARCHIVE_DECL +#endif + +#endif // BOOST_ARCHIVE_DETAIL_BASIC_CONFIG_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_iarchive.hpp b/boost_1_45_0/boost/archive/detail/basic_iarchive.hpp new file mode 100644 index 0000000..f62987e --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_iarchive.hpp
@@ -0,0 +1,110 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_IARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_BASIC_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_iarchive.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// can't use this - much as I'd like to as borland doesn't support it +// #include <boost/scoped_ptr.hpp> + +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> + +#include <boost/type_traits/broken_compiler_spec.hpp> +#include <boost/serialization/tracking_enum.hpp> +#include <boost/archive/basic_archive.hpp> +#include <boost/archive/detail/decl.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { +namespace detail { + +class basic_iarchive_impl; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer; +////////////////////////////////////////////////////////////////////// +// class basic_iarchive - read serialized objects from a input stream +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive : + private boost::noncopyable +{ + friend class basic_iarchive_impl; + // hide implementation of this class to minimize header conclusion + // in client code. I couldn't used scoped pointer with borland + // boost::scoped_ptr<basic_iarchive_impl> pimpl; + basic_iarchive_impl * pimpl; + + virtual void vload(version_type &t) = 0; + virtual void vload(object_id_type &t) = 0; + virtual void vload(class_id_type &t) = 0; + virtual void vload(class_id_optional_type &t) = 0; + virtual void vload(class_name_type &t) = 0; + virtual void vload(tracking_type &t) = 0; +protected: + basic_iarchive(unsigned int flags); + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_iarchive(); +public: + // note: NOT part of the public API. + void next_object_pointer(void *t); + void register_basic_serializer( + const basic_iserializer & bis + ); + void load_object( + void *t, + const basic_iserializer & bis + ); + const basic_pointer_iserializer * + load_pointer( + void * & t, + const basic_pointer_iserializer * bpis_ptr, + const basic_pointer_iserializer * (*finder)( + const boost::serialization::extended_type_info & eti + ) + + ); + // real public API starts here + void + set_library_version(library_version_type archive_library_version); + library_version_type + get_library_version() const; + unsigned int + get_flags() const; + void + reset_object_address(const void * new_address, const void * old_address); + void + delete_created_pointers(); +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +// required by smart_cast for compilers not implementing +// partial template specialization +BOOST_TT_BROKEN_COMPILER_SPEC( + boost::archive::detail::basic_iarchive +) + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif //BOOST_ARCHIVE_DETAIL_BASIC_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_iserializer.hpp b/boost_1_45_0/boost/archive/detail/basic_iserializer.hpp new file mode 100644 index 0000000..2f4f6d8 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_iserializer.hpp
@@ -0,0 +1,95 @@ +#ifndef BOOST_ARCHIVE_DETAIL_BASIC_ISERIALIZER_HPP +#define BOOST_ARCHIVE_DETAIL_BASIC_ISERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_iserializer.hpp: extenstion of type_info required for serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstdlib> // NULL +#include <boost/config.hpp> + +#include <boost/archive/basic_archive.hpp> +#include <boost/archive/detail/decl.hpp> +#include <boost/archive/detail/basic_serializer.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +// forward declarations +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer; + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer : + public basic_serializer +{ +private: + basic_pointer_iserializer *m_bpis; +protected: + explicit basic_iserializer( + const boost::serialization::extended_type_info & type + ); + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_iserializer(); +public: + bool serialized_as_pointer() const { + return m_bpis != NULL; + } + void set_bpis(basic_pointer_iserializer *bpis){ + m_bpis = bpis; + } + const basic_pointer_iserializer * get_bpis_ptr() const { + return m_bpis; + } + virtual void load_object_data( + basic_iarchive & ar, + void *x, + const unsigned int file_version + ) const = 0; + // returns true if class_info should be saved + virtual bool class_info() const = 0 ; + // returns true if objects should be tracked + virtual bool tracking(const unsigned int) const = 0 ; + // returns class version + virtual version_type version() const = 0 ; + // returns true if this class is polymorphic + virtual bool is_polymorphic() const = 0; + virtual void destroy(/*const*/ void *address) const = 0 ; +}; + +} // namespae detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_DETAIL_BASIC_ISERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_oarchive.hpp b/boost_1_45_0/boost/archive/detail/basic_oarchive.hpp new file mode 100644 index 0000000..402e569 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_oarchive.hpp
@@ -0,0 +1,106 @@ +#ifndef BOOST_ARCHIVE_BASIC_OARCHIVE_HPP +#define BOOST_ARCHIVE_BASIC_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_oarchive.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // NULL +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> + +#include <boost/type_traits/broken_compiler_spec.hpp> + +// can't use this - much as I'd like to as borland doesn't support it +// #include <boost/scoped_ptr.hpp> + +#include <boost/archive/basic_archive.hpp> +#include <boost/serialization/tracking_enum.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { +namespace detail { + +class basic_oarchive_impl; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer; +////////////////////////////////////////////////////////////////////// +// class basic_oarchive - write serialized objects to an output stream +class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive : + private boost::noncopyable +{ + friend class basic_oarchive_impl; + // hide implementation of this class to minimize header conclusion + // in client code. note: borland can't use scoped_ptr + //boost::scoped_ptr<basic_oarchive_impl> pimpl; + basic_oarchive_impl * pimpl; + + // overload these to bracket object attributes. Used to implement + // xml archives + virtual void vsave(const version_type t) = 0; + virtual void vsave(const object_id_type t) = 0; + virtual void vsave(const object_reference_type t) = 0; + virtual void vsave(const class_id_type t) = 0; + virtual void vsave(const class_id_optional_type t) = 0; + virtual void vsave(const class_id_reference_type t) = 0; + virtual void vsave(const class_name_type & t) = 0; + virtual void vsave(const tracking_type t) = 0; +protected: + basic_oarchive(unsigned int flags = 0); + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_oarchive(); +public: + // note: NOT part of the public interface + void register_basic_serializer( + const basic_oserializer & bos + ); + void save_object( + const void *x, + const basic_oserializer & bos + ); + void save_pointer( + const void * t, + const basic_pointer_oserializer * bpos_ptr + ); + void save_null_pointer(){ + vsave(NULL_POINTER_TAG); + } + // real public interface starts here + void end_preamble(); // default implementation does nothing + library_version_type get_library_version() const; + unsigned int get_flags() const; +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +// required by smart_cast for compilers not implementing +// partial template specialization +BOOST_TT_BROKEN_COMPILER_SPEC( + boost::archive::detail::basic_oarchive +) + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif //BOOST_ARCHIVE_BASIC_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_oserializer.hpp b/boost_1_45_0/boost/archive/detail/basic_oserializer.hpp new file mode 100644 index 0000000..74af7e6 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_oserializer.hpp
@@ -0,0 +1,93 @@ +#ifndef BOOST_SERIALIZATION_BASIC_OSERIALIZER_HPP +#define BOOST_SERIALIZATION_BASIC_OSERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_oserializer.hpp: extenstion of type_info required for serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // NULL +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> + +#include <boost/archive/basic_archive.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/basic_serializer.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +// forward declarations +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer; + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer : + public basic_serializer +{ +private: + basic_pointer_oserializer *m_bpos; +protected: + explicit basic_oserializer( + const boost::serialization::extended_type_info & type_ + ); + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_oserializer(); +public: + bool serialized_as_pointer() const { + return m_bpos != NULL; + } + void set_bpos(basic_pointer_oserializer *bpos){ + m_bpos = bpos; + } + const basic_pointer_oserializer * get_bpos() const { + return m_bpos; + } + virtual void save_object_data( + basic_oarchive & ar, const void * x + ) const = 0; + // returns true if class_info should be saved + virtual bool class_info() const = 0; + // returns true if objects should be tracked + virtual bool tracking(const unsigned int flags) const = 0; + // returns class version + virtual version_type version() const = 0; + // returns true if this class is polymorphic + virtual bool is_polymorphic() const = 0; +}; + +} // namespace detail +} // namespace serialization +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_SERIALIZATION_BASIC_OSERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_pointer_iserializer.hpp b/boost_1_45_0/boost/archive/detail/basic_pointer_iserializer.hpp new file mode 100644 index 0000000..d957b83 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_pointer_iserializer.hpp
@@ -0,0 +1,73 @@ +#ifndef BOOST_ARCHIVE_BASIC_POINTER_ISERIALIZER_HPP +#define BOOST_ARCHIVE_BASIC_POINTER_ISERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_pointer_oserializer.hpp: extenstion of type_info required for +// serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/basic_serializer.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +// forward declarations +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer; + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer + : public basic_serializer { +protected: + explicit basic_pointer_iserializer( + const boost::serialization::extended_type_info & type_ + ); + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_pointer_iserializer(); +public: + virtual const basic_iserializer & get_basic_serializer() const = 0; + virtual void load_object_ptr( + basic_iarchive & ar, + void * & x, + const unsigned int file_version + ) const = 0; +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_POINTER_ISERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_pointer_oserializer.hpp b/boost_1_45_0/boost/archive/detail/basic_pointer_oserializer.hpp new file mode 100644 index 0000000..b0d3fb9 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_pointer_oserializer.hpp
@@ -0,0 +1,72 @@ +#ifndef BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP +#define BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_pointer_oserializer.hpp: extenstion of type_info required for +// serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <boost/config.hpp> +#include <boost/noncopyable.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/basic_serializer.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer; + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer : + public basic_serializer +{ +protected: + explicit basic_pointer_oserializer( + const boost::serialization::extended_type_info & type_ + ); +public: + // account for bogus gcc warning + #if defined(__GNUC__) + virtual + #endif + ~basic_pointer_oserializer(); + virtual const basic_oserializer & get_basic_serializer() const = 0; + virtual void save_object_ptr( + basic_oarchive & ar, + const void * x + ) const = 0; +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_BASIC_POINTER_OSERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_serializer.hpp b/boost_1_45_0/boost/archive/detail/basic_serializer.hpp new file mode 100644 index 0000000..ab2ffe9 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_serializer.hpp
@@ -0,0 +1,79 @@ +#ifndef BOOST_ARCHIVE_BASIC_SERIALIZER_HPP +#define BOOST_ARCHIVE_BASIC_SERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_serializer.hpp: extenstion of type_info required for serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // NULL + +#include <boost/noncopyable.hpp> +#include <boost/config.hpp> +#include <boost/serialization/extended_type_info.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { +namespace detail { + +class basic_serializer : + private boost::noncopyable +{ + const boost::serialization::extended_type_info * m_eti; +protected: + explicit basic_serializer( + const boost::serialization::extended_type_info & eti + ) : + m_eti(& eti) + { + assert(NULL != & eti); + } +public: + inline bool + operator<(const basic_serializer & rhs) const { + // can't compare address since there can be multiple eti records + // for the same type in different execution modules (that is, DLLS) + // leave this here as a reminder not to do this! + // return & lhs.get_eti() < & rhs.get_eti(); + return get_eti() < rhs.get_eti(); + } + const char * get_debug_info() const { + return m_eti->get_debug_info(); + } + const boost::serialization::extended_type_info & get_eti() const { + return * m_eti; + } +}; + +class basic_serializer_arg : public basic_serializer { +public: + basic_serializer_arg(const serialization::extended_type_info & eti) : + basic_serializer(eti) + {} +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_BASIC_SERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/basic_serializer_map.hpp b/boost_1_45_0/boost/archive/detail/basic_serializer_map.hpp new file mode 100644 index 0000000..19defcb --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/basic_serializer_map.hpp
@@ -0,0 +1,69 @@ +#ifndef BOOST_SERIALIZER_MAP_HPP +#define BOOST_SERIALIZER_MAP_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_serializer_map.hpp: extenstion of type_info required for serialization. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <set> + +#include <boost/config.hpp> +#include <boost/utility.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} + +namespace archive { +namespace detail { + +class basic_serializer; + +class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_serializer_map : public + boost::noncopyable +{ + struct type_info_pointer_compare + { + bool operator()( + const basic_serializer * lhs, const basic_serializer * rhs + ) const ; + }; + typedef std::set< + const basic_serializer *, + type_info_pointer_compare + > map_type; + map_type m_map; +public: + bool insert(const basic_serializer * bs); + void erase(const basic_serializer * bs); + const basic_serializer * find( + const boost::serialization::extended_type_info & type_ + ) const; +private: + // cw 8.3 requires this + basic_serializer_map& operator=(basic_serializer_map const&); +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // must be the last header + +#endif // BOOST_SERIALIZER_MAP_HPP
diff --git a/boost_1_45_0/boost/archive/detail/check.hpp b/boost_1_45_0/boost/archive/detail/check.hpp new file mode 100644 index 0000000..c9cba51 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/check.hpp
@@ -0,0 +1,169 @@ +#ifndef BOOST_ARCHIVE_DETAIL_CHECK_HPP +#define BOOST_ARCHIVE_DETAIL_CHECK_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#pragma inline_depth(511) +#pragma inline_recursion(on) +#endif + +#if defined(__MWERKS__) +#pragma inline_depth(511) +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// check.hpp: interface for serialization system. + +// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> + +#include <boost/static_assert.hpp> +#include <boost/type_traits/is_const.hpp> + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/not.hpp> +#include <boost/mpl/greater.hpp> +#include <boost/mpl/assert.hpp> + +#include <boost/serialization/static_warning.hpp> +#include <boost/serialization/version.hpp> +#include <boost/serialization/level.hpp> +#include <boost/serialization/tracking.hpp> +#include <boost/serialization/wrapper.hpp> + +namespace boost { +namespace archive { +namespace detail { + +// checks for objects + +template<class T> +inline void check_object_level(){ + typedef + BOOST_DEDUCED_TYPENAME mpl::greater_equal< + serialization::implementation_level< T >, + mpl::int_<serialization::primitive_type> + >::type typex; + + // trap attempts to serialize objects marked + // not_serializable + BOOST_STATIC_ASSERT(typex::value); +} + +template<class T> +inline void check_object_versioning(){ + typedef + BOOST_DEDUCED_TYPENAME mpl::or_< + BOOST_DEDUCED_TYPENAME mpl::greater< + serialization::implementation_level< T >, + mpl::int_<serialization::object_serializable> + >, + BOOST_DEDUCED_TYPENAME mpl::equal_to< + serialization::version< T >, + mpl::int_<0> + > + > typex; + // trap attempts to serialize with objects that don't + // save class information in the archive with versioning. + BOOST_STATIC_ASSERT(typex::value); +} + +template<class T> +inline void check_object_tracking(){ + // presume it has already been determined that + // T is not a const + BOOST_STATIC_ASSERT(! boost::is_const< T >::value); + typedef BOOST_DEDUCED_TYPENAME mpl::equal_to< + serialization::tracking_level< T >, + mpl::int_<serialization::track_never> + >::type typex; + // saving an non-const object of a type not marked "track_never) + + // may be an indicator of an error usage of the + // serialization library and should be double checked. + // See documentation on object tracking. Also, see the + // "rationale" section of the documenation + // for motivation for this checking. + + BOOST_STATIC_WARNING(typex::value); +} + +// checks for pointers + +template<class T> +inline void check_pointer_level(){ + // we should only invoke this once we KNOW that T + // has been used as a pointer!! + typedef + BOOST_DEDUCED_TYPENAME mpl::or_< + BOOST_DEDUCED_TYPENAME mpl::greater< + serialization::implementation_level< T >, + mpl::int_<serialization::object_serializable> + >, + BOOST_DEDUCED_TYPENAME mpl::not_< + BOOST_DEDUCED_TYPENAME mpl::equal_to< + serialization::tracking_level< T >, + mpl::int_<serialization::track_selectively> + > + > + > typex; + // Address the following when serializing to a pointer: + + // a) This type doesn't save class information in the + // archive. That is, the serialization trait implementation + // level <= object_serializable. + // b) Tracking for this type is set to "track selectively" + + // in this case, indication that an object is tracked is + // not stored in the archive itself - see level == object_serializable + // but rather the existence of the operation ar >> T * is used to + // infer that an object of this type should be tracked. So, if + // you save via a pointer but don't load via a pointer the operation + // will fail on load without given any valid reason for the failure. + + // So if your program traps here, consider changing the + // tracking or implementation level traits - or not + // serializing via a pointer. + BOOST_STATIC_WARNING(typex::value); +} + +template<class T> +void inline check_pointer_tracking(){ + typedef BOOST_DEDUCED_TYPENAME mpl::greater< + serialization::tracking_level< T >, + mpl::int_<serialization::track_never> + >::type typex; + // serializing an object of a type marked "track_never" through a pointer + // could result in creating more objects than were saved! + BOOST_STATIC_WARNING(typex::value); +} + +template<class T> +inline void check_const_loading(){ + typedef + BOOST_DEDUCED_TYPENAME mpl::or_< + BOOST_DEDUCED_TYPENAME boost::serialization::is_wrapper< T >, + BOOST_DEDUCED_TYPENAME mpl::not_< + BOOST_DEDUCED_TYPENAME boost::is_const< T > + > + >::type typex; + // cannot load data into a "const" object unless it's a + // wrapper around some other non-const object. + BOOST_STATIC_ASSERT(typex::value); +} + +} // detail +} // archive +} // boost + +#endif // BOOST_ARCHIVE_DETAIL_CHECK_HPP
diff --git a/boost_1_45_0/boost/archive/detail/common_iarchive.hpp b/boost_1_45_0/boost/archive/detail/common_iarchive.hpp new file mode 100644 index 0000000..54c07c3 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/common_iarchive.hpp
@@ -0,0 +1,88 @@ +#ifndef BOOST_ARCHIVE_DETAIL_COMMON_IARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_COMMON_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// common_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> + +#include <boost/archive/detail/basic_iarchive.hpp> +#include <boost/archive/detail/basic_pointer_iserializer.hpp> +#include <boost/archive/detail/interface_iarchive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { +namespace detail { + +class extended_type_info; + +// note: referred to as Curiously Recurring Template Patter (CRTP) +template<class Archive> +class common_iarchive : + public basic_iarchive, + public interface_iarchive<Archive> +{ + friend class interface_iarchive<Archive>; +private: + virtual void vload(version_type & t){ + * this->This() >> t; + } + virtual void vload(object_id_type & t){ + * this->This() >> t; + } + virtual void vload(class_id_type & t){ + * this->This() >> t; + } + virtual void vload(class_id_optional_type & t){ + * this->This() >> t; + } + virtual void vload(tracking_type & t){ + * this->This() >> t; + } + virtual void vload(class_name_type &s){ + * this->This() >> s; + } +protected: + // default processing - invoke serialization library + template<class T> + void load_override(T & t, BOOST_PFTO int){ + archive::load(* this->This(), t); + } + // default implementations of functions which emit start/end tags for + // archive types that require them. + void load_start(const char * /*name*/){} + void load_end(const char * /*name*/){} + // default archive initialization + common_iarchive(unsigned int flags = 0) : + basic_iarchive(flags), + interface_iarchive<Archive>() + {} +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_DETAIL_COMMON_IARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/detail/common_oarchive.hpp b/boost_1_45_0/boost/archive/detail/common_oarchive.hpp new file mode 100644 index 0000000..7962063 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/common_oarchive.hpp
@@ -0,0 +1,87 @@ +#ifndef BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// common_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> + +#include <boost/archive/detail/basic_oarchive.hpp> +#include <boost/archive/detail/interface_oarchive.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { +namespace detail { + +// note: referred to as Curiously Recurring Template Patter (CRTP) +template<class Archive> +class common_oarchive : + public basic_oarchive, + public interface_oarchive<Archive> +{ + friend class interface_oarchive<Archive>; +private: + virtual void vsave(const version_type t){ + * this->This() << t; + } + virtual void vsave(const object_id_type t){ + * this->This() << t; + } + virtual void vsave(const object_reference_type t){ + * this->This() << t; + } + virtual void vsave(const class_id_type t){ + * this->This() << t; + } + virtual void vsave(const class_id_reference_type t){ + * this->This() << t; + } + virtual void vsave(const class_id_optional_type t){ + * this->This() << t; + } + virtual void vsave(const class_name_type & t){ + * this->This() << t; + } + virtual void vsave(const tracking_type t){ + * this->This() << t; + } +protected: + // default processing - invoke serialization library + template<class T> + void save_override(T & t, BOOST_PFTO int){ + archive::save(* this->This(), t); + } + void save_start(const char * /*name*/){} + void save_end(const char * /*name*/){} + common_oarchive(unsigned int flags = 0) : + basic_oarchive(flags), + interface_oarchive<Archive>() + {} +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/decl.hpp b/boost_1_45_0/boost/archive/detail/decl.hpp new file mode 100644 index 0000000..9695001 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/decl.hpp
@@ -0,0 +1,79 @@ +#ifndef BOOST_ARCHIVE_DETAIL_DECL_HPP +#define BOOST_ARCHIVE_DETAIL_DECL_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2///////// 3/////////4/////////5/////////6/////////7/////////8 +// decl.hpp +// +// (c) Copyright Robert Ramey 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/serialization + +//----------------------------------------------------------------------------// + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +#include <boost/config.hpp> +#include <boost/preprocessor/facilities/empty.hpp> + +#if defined(BOOST_HAS_DECLSPEC) + #if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)) + #if defined(BOOST_ARCHIVE_SOURCE) + #if defined(__BORLANDC__) + #define BOOST_ARCHIVE_DECL(T) T __export + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __export + #else + #define BOOST_ARCHIVE_DECL(T) __declspec(dllexport) T + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllexport) T + #endif + #else + #if defined(__BORLANDC__) + #define BOOST_ARCHIVE_DECL(T) T __import + #else + #define BOOST_ARCHIVE_DECL(T) __declspec(dllimport) T + #endif + #endif + #if defined(BOOST_WARCHIVE_SOURCE) + #if defined(__BORLANDC__) + #define BOOST_WARCHIVE_DECL(T) T __export + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __export + #else + #define BOOST_WARCHIVE_DECL(T) __declspec(dllexport) T + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllexport) T + #endif + #else + #if defined(__BORLANDC__) + #define BOOST_WARCHIVE_DECL(T) T __import + #else + #define BOOST_WARCHIVE_DECL(T) __declspec(dllimport) T + #endif + #endif + #if !defined(BOOST_WARCHIVE_SOURCE) && !defined(BOOST_ARCHIVE_SOURCE) + #if defined(__BORLANDC__) + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T __import + #else + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) __declspec(dllimport) T + #endif + #endif + #endif +#endif // BOOST_HAS_DECLSPEC + +#if ! defined(BOOST_ARCHIVE_DECL) + #define BOOST_ARCHIVE_DECL(T) T +#endif +#if ! defined(BOOST_WARCHIVE_DECL) + #define BOOST_WARCHIVE_DECL(T) T +#endif +#if ! defined(BOOST_ARCHIVE_OR_WARCHIVE_DECL) + #define BOOST_ARCHIVE_OR_WARCHIVE_DECL(T) T +#endif + +#endif // BOOST_ARCHIVE_DETAIL_DECL_HPP
diff --git a/boost_1_45_0/boost/archive/detail/interface_iarchive.hpp b/boost_1_45_0/boost/archive/detail/interface_iarchive.hpp new file mode 100644 index 0000000..0648752 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/interface_iarchive.hpp
@@ -0,0 +1,77 @@ +#ifndef BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// interface_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <cstddef> // NULL +#include <boost/cstdint.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/iserializer.hpp> +#include <boost/serialization/singleton.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer; + +template<class Archive> +class interface_iarchive +{ +protected: + interface_iarchive(){}; +public: + ///////////////////////////////////////////////////////// + // archive public interface + typedef mpl::bool_<true> is_loading; + typedef mpl::bool_<false> is_saving; + + // return a pointer to the most derived class + Archive * This(){ + return static_cast<Archive *>(this); + } + + template<class T> + const basic_pointer_iserializer * + register_type(T * = NULL){ + const basic_pointer_iserializer & bpis = + boost::serialization::singleton< + pointer_iserializer<Archive, T> + >::get_const_instance(); + this->This()->register_basic_serializer(bpis.get_basic_serializer()); + return & bpis; + } + template<class T> + Archive & operator>>(T & t){ + this->This()->load_override(t, 0); + return * this->This(); + } + + // the & operator + template<class T> + Archive & operator&(T & t){ + return *(this->This()) >> t; + } +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/interface_oarchive.hpp b/boost_1_45_0/boost/archive/detail/interface_oarchive.hpp new file mode 100644 index 0000000..e8db7a2 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/interface_oarchive.hpp
@@ -0,0 +1,84 @@ +#ifndef BOOST_ARCHIVE_DETAIL_INTERFACE_OARCHIVE_HPP +#define BOOST_ARCHIVE_DETAIL_INTERFACE_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// interface_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <cstddef> // NULL +#include <boost/cstdint.hpp> +#include <boost/mpl/bool.hpp> + +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/detail/oserializer.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#include <boost/serialization/singleton.hpp> + +namespace boost { +namespace archive { +namespace detail { + +class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer; + +template<class Archive> +class interface_oarchive +{ +protected: + interface_oarchive(){}; +public: + ///////////////////////////////////////////////////////// + // archive public interface + typedef mpl::bool_<false> is_loading; + typedef mpl::bool_<true> is_saving; + + // return a pointer to the most derived class + Archive * This(){ + return static_cast<Archive *>(this); + } + + template<class T> + const basic_pointer_oserializer * + register_type(const T * = NULL){ + const basic_pointer_oserializer & bpos = + boost::serialization::singleton< + pointer_oserializer<Archive, T> + >::get_const_instance(); + this->This()->register_basic_serializer(bpos.get_basic_serializer()); + return & bpos; + } + + template<class T> + Archive & operator<<(T & t){ + this->This()->save_override(t, 0); + return * this->This(); + } + + // the & operator + template<class T> + Archive & operator&(T & t){ + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + return * this->This() << const_cast<const T &>(t); + #else + return * this->This() << t; + #endif + } +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_DETAIL_INTERFACE_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/detail/iserializer.hpp b/boost_1_45_0/boost/archive/detail/iserializer.hpp new file mode 100644 index 0000000..46033fd --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/iserializer.hpp
@@ -0,0 +1,632 @@ +#ifndef BOOST_ARCHIVE_DETAIL_ISERIALIZER_HPP +#define BOOST_ARCHIVE_DETAIL_ISERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#pragma inline_depth(511) +#pragma inline_recursion(on) +#endif + +#if defined(__MWERKS__) +#pragma inline_depth(511) +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// iserializer.hpp: interface for serialization system. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <new> // for placement new +#include <memory> // for auto_ptr +#include <cstddef> // size_t, NULL + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/static_assert.hpp> + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/greater_equal.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/detail/no_exceptions_support.hpp> + +#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO + #include <boost/serialization/extended_type_info_typeid.hpp> +#endif +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/smart_cast.hpp> +#include <boost/serialization/static_warning.hpp> + +#include <boost/type_traits/is_pointer.hpp> +#include <boost/type_traits/is_enum.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_extent.hpp> +#include <boost/type_traits/is_polymorphic.hpp> + +#include <boost/serialization/assume_abstract.hpp> + +#define DONT_USE_HAS_NEW_OPERATOR ( \ + defined(__BORLANDC__) \ + || defined(__IBMCPP__) \ + || defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) \ + || defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x590) \ +) + +#if ! DONT_USE_HAS_NEW_OPERATOR +#include <boost/type_traits/has_new_operator.hpp> +#endif + +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/version.hpp> +#include <boost/serialization/level.hpp> +#include <boost/serialization/tracking.hpp> +#include <boost/serialization/type_info_implementation.hpp> +#include <boost/serialization/nvp.hpp> +#include <boost/serialization/void_cast.hpp> +#include <boost/serialization/array.hpp> +#include <boost/serialization/collection_size_type.hpp> +#include <boost/serialization/singleton.hpp> +#include <boost/serialization/wrapper.hpp> + +// the following is need only for dynamic cast of polymorphic pointers +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/detail/basic_iarchive.hpp> +#include <boost/archive/detail/basic_iserializer.hpp> +#include <boost/archive/detail/basic_pointer_iserializer.hpp> +#include <boost/archive/detail/archive_serializer_map.hpp> +#include <boost/archive/detail/check.hpp> + +namespace boost { + +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { + +// an accessor to permit friend access to archives. Needed because +// some compilers don't handle friend templates completely +class load_access { +public: + template<class Archive, class T> + static void load_primitive(Archive &ar, T &t){ + ar.load(t); + } +}; + +namespace detail { + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class Archive, class T> +class iserializer : public basic_iserializer +{ +private: + virtual void destroy(/*const*/ void *address) const { + boost::serialization::access::destroy(static_cast<T *>(address)); + } +protected: + // protected constructor since it's always created by singleton + explicit iserializer() : + basic_iserializer( + boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance() + ) + {} +public: + virtual BOOST_DLLEXPORT void load_object_data( + basic_iarchive & ar, + void *x, + const unsigned int file_version + ) const BOOST_USED; + virtual bool class_info() const { + return boost::serialization::implementation_level< T >::value + >= boost::serialization::object_class_info; + } + virtual bool tracking(const unsigned int /* flags */) const { + return boost::serialization::tracking_level< T >::value + == boost::serialization::track_always + || ( boost::serialization::tracking_level< T >::value + == boost::serialization::track_selectively + && serialized_as_pointer()); + } + virtual version_type version() const { + return version_type(::boost::serialization::version< T >::value); + } + virtual bool is_polymorphic() const { + return boost::is_polymorphic< T >::value; + } + virtual ~iserializer(){}; +}; + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +template<class Archive, class T> +BOOST_DLLEXPORT void iserializer<Archive, T>::load_object_data( + basic_iarchive & ar, + void *x, + const unsigned int file_version +) const { + // note: we now comment this out. Before we permited archive + // version # to be very large. Now we don't. To permit + // readers of these old archives, we have to suppress this + // code. Perhaps in the future we might re-enable it but + // permit its suppression with a runtime switch. + #if 0 + // trap case where the program cannot handle the current version + if(file_version > static_cast<const unsigned int>(version())) + boost::serialization::throw_exception( + archive::archive_exception( + boost::archive::archive_exception::unsupported_class_version, + get_debug_info() + ) + ); + #endif + // make sure call is routed through the higest interface that might + // be specialized by the user. + boost::serialization::serialize_adl( + boost::serialization::smart_cast_reference<Archive &>(ar), + * static_cast<T *>(x), + file_version + ); +} + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class Archive, class T> +class pointer_iserializer : + public basic_pointer_iserializer +{ +private: + virtual const basic_iserializer & get_basic_serializer() const { + return boost::serialization::singleton< + iserializer<Archive, T> + >::get_const_instance(); + } + BOOST_DLLEXPORT virtual void load_object_ptr( + basic_iarchive & ar, + void * & x, + const unsigned int file_version + ) const BOOST_USED; +protected: + // this should alway be a singleton so make the constructor protected + pointer_iserializer(); + ~pointer_iserializer(); +}; + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +// note trick to be sure that operator new is using class specific +// version if such exists. Due to Peter Dimov. +// note: the following fails if T has no default constructor. +// otherwise it would have been ideal +//struct heap_allocator : public T +//{ +// T * invoke(){ +// return ::new(sizeof(T)); +// } +//} + +template<class T> +struct heap_allocator +{ + // boost::has_new_operator< T > doesn't work on these compilers + #if DONT_USE_HAS_NEW_OPERATOR + // This doesn't handle operator new overload for class T + static T * invoke(){ + return static_cast<T *>(operator new(sizeof(T))); + } + #else + struct has_new_operator { + static T* invoke() { + return static_cast<T *>((T::operator new)(sizeof(T))); + } + }; + struct doesnt_have_new_operator { + static T* invoke() { + return static_cast<T *>(operator new(sizeof(T))); + } + }; + static T * invoke() { + typedef BOOST_DEDUCED_TYPENAME + mpl::eval_if< + boost::has_new_operator< T >, + mpl::identity<has_new_operator >, + mpl::identity<doesnt_have_new_operator > + >::type typex; + return typex::invoke(); + } + #endif +}; + +// due to Martin Ecker +template <typename T> +class auto_ptr_with_deleter +{ +public: + explicit auto_ptr_with_deleter(T* p) : + m_p(p) + {} + ~auto_ptr_with_deleter(){ + if (m_p) + boost::serialization::access::destroy(m_p); + } + T* get() const { + return m_p; + } + + T* release() { + T* p = m_p; + m_p = NULL; + return p; + } +private: + T* m_p; +}; + +// note: BOOST_DLLEXPORT is so that code for polymorphic class +// serialized only through base class won't get optimized out +template<class Archive, class T> +BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr( + basic_iarchive & ar, + void * & x, + const unsigned int file_version +) const +{ + Archive & ar_impl = + boost::serialization::smart_cast_reference<Archive &>(ar); + + auto_ptr_with_deleter< T > ap(heap_allocator< T >::invoke()); + if(NULL == ap.get()) + boost::serialization::throw_exception(std::bad_alloc()) ; + + T * t = ap.get(); + x = t; + + // catch exception during load_construct_data so that we don't + // automatically delete the t which is most likely not fully + // constructed + BOOST_TRY { + // this addresses an obscure situtation that occurs when + // load_constructor de-serializes something through a pointer. + ar.next_object_pointer(t); + boost::serialization::load_construct_data_adl<Archive, T>( + ar_impl, + t, + file_version + ); + } + BOOST_CATCH(...){ + ap.release(); + BOOST_RETHROW; + } + BOOST_CATCH_END + + ar_impl >> boost::serialization::make_nvp(NULL, * t); + ap.release(); +} + +template<class Archive, class T> +pointer_iserializer<Archive, T>::pointer_iserializer() : + basic_pointer_iserializer( + boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance() + ) +{ + boost::serialization::singleton< + iserializer<Archive, T> + >::get_mutable_instance().set_bpis(this); + archive_serializer_map<Archive>::insert(this); +} + +template<class Archive, class T> +pointer_iserializer<Archive, T>::~pointer_iserializer(){ + archive_serializer_map<Archive>::erase(this); +} + +template<class Archive> +struct load_non_pointer_type { + // note this bounces the call right back to the archive + // with no runtime overhead + struct load_primitive { + template<class T> + static void invoke(Archive & ar, T & t){ + load_access::load_primitive(ar, t); + } + }; + // note this bounces the call right back to the archive + // with no runtime overhead + struct load_only { + template<class T> + static void invoke(Archive & ar, const T & t){ + // short cut to user's serializer + // make sure call is routed through the higest interface that might + // be specialized by the user. + boost::serialization::serialize_adl( + ar, + const_cast<T &>(t), + boost::serialization::version< T >::value + ); + } + }; + + // note this save class information including version + // and serialization level to the archive + struct load_standard { + template<class T> + static void invoke(Archive &ar, const T & t){ + void * x = & const_cast<T &>(t); + ar.load_object( + x, + boost::serialization::singleton< + iserializer<Archive, T> + >::get_const_instance() + ); + } + }; + + struct load_conditional { + template<class T> + static void invoke(Archive &ar, T &t){ + //if(0 == (ar.get_flags() & no_tracking)) + load_standard::invoke(ar, t); + //else + // load_only::invoke(ar, t); + } + }; + + template<class T> + static void invoke(Archive & ar, T &t){ + typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< + // if its primitive + mpl::equal_to< + boost::serialization::implementation_level< T >, + mpl::int_<boost::serialization::primitive_type> + >, + mpl::identity<load_primitive>, + // else + BOOST_DEDUCED_TYPENAME mpl::eval_if< + // class info / version + mpl::greater_equal< + boost::serialization::implementation_level< T >, + mpl::int_<boost::serialization::object_class_info> + >, + // do standard load + mpl::identity<load_standard>, + // else + BOOST_DEDUCED_TYPENAME mpl::eval_if< + // no tracking + mpl::equal_to< + boost::serialization::tracking_level< T >, + mpl::int_<boost::serialization::track_never> + >, + // do a fast load + mpl::identity<load_only>, + // else + // do a fast load only tracking is turned off + mpl::identity<load_conditional> + > > >::type typex; + check_object_versioning< T >(); + check_object_level< T >(); + typex::invoke(ar, t); + } +}; + +template<class Archive> +struct load_pointer_type { + struct abstract + { + template<class T> + static const basic_pointer_iserializer * register_type(Archive & /* ar */){ + // it has? to be polymorphic + BOOST_STATIC_ASSERT(boost::is_polymorphic< T >::value); + return static_cast<basic_pointer_iserializer *>(NULL); + } + }; + + struct non_abstract + { + template<class T> + static const basic_pointer_iserializer * register_type(Archive & ar){ + return ar.register_type(static_cast<T *>(NULL)); + } + }; + + template<class T> + static const basic_pointer_iserializer * register_type(Archive &ar, const T & /*t*/){ + // there should never be any need to load an abstract polymorphic + // class pointer. Inhibiting code generation for this + // permits abstract base classes to be used - note: exception + // virtual serialize functions used for plug-ins + typedef BOOST_DEDUCED_TYPENAME + mpl::eval_if< + boost::serialization::is_abstract<const T>, + boost::mpl::identity<abstract>, + boost::mpl::identity<non_abstract> + >::type typex; + return typex::template register_type< T >(ar); + } + + template<class T> + static T * pointer_tweak( + const boost::serialization::extended_type_info & eti, + void const * const t, + const T & + ) { + // tweak the pointer back to the base class + return static_cast<T *>( + const_cast<void *>( + boost::serialization::void_upcast( + eti, + boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance(), + t + ) + ) + ); + } + + template<class T> + static void check_load(T & /* t */){ + check_pointer_level< T >(); + check_pointer_tracking< T >(); + } + + static const basic_pointer_iserializer * + find(const boost::serialization::extended_type_info & type){ + return static_cast<const basic_pointer_iserializer *>( + archive_serializer_map<Archive>::find(type) + ); + } + + template<class Tptr> + static void invoke(Archive & ar, Tptr & t){ + check_load(*t); + const basic_pointer_iserializer * bpis_ptr = register_type(ar, *t); + const basic_pointer_iserializer * newbpis_ptr = ar.load_pointer( + // note major hack here !!! + // I tried every way to convert Tptr &t (where Tptr might + // include const) to void * &. This is the only way + // I could make it work. RR + (void * & )t, + bpis_ptr, + find + ); + // if the pointer isn't that of the base class + if(newbpis_ptr != bpis_ptr){ + t = pointer_tweak(newbpis_ptr->get_eti(), t, *t); + } + } +}; + +template<class Archive> +struct load_enum_type { + template<class T> + static void invoke(Archive &ar, T &t){ + // convert integers to correct enum to load + int i; + ar >> boost::serialization::make_nvp(NULL, i); + t = static_cast< T >(i); + } +}; + +template<class Archive> +struct load_array_type { + template<class T> + static void invoke(Archive &ar, T &t){ + typedef BOOST_DEDUCED_TYPENAME remove_extent< T >::type value_type; + + // convert integers to correct enum to load + // determine number of elements in the array. Consider the + // fact that some machines will align elements on boundries + // other than characters. + std::size_t current_count = sizeof(t) / ( + static_cast<char *>(static_cast<void *>(&t[1])) + - static_cast<char *>(static_cast<void *>(&t[0])) + ); + boost::serialization::collection_size_type count; + ar >> BOOST_SERIALIZATION_NVP(count); + if(static_cast<std::size_t>(count) > current_count) + boost::serialization::throw_exception( + archive::archive_exception( + boost::archive::archive_exception::array_size_too_short + ) + ); + ar >> serialization::make_array(static_cast<value_type*>(&t[0]),count); + } +}; + +} // detail + +template<class Archive, class T> +inline void load(Archive & ar, T &t){ + // if this assertion trips. It means we're trying to load a + // const object with a compiler that doesn't have correct + // funtion template ordering. On other compilers, this is + // handled below. + detail::check_const_loading< T >(); + typedef + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_pointer< T >, + mpl::identity<detail::load_pointer_type<Archive> > + ,//else + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_array< T >, + mpl::identity<detail::load_array_type<Archive> > + ,//else + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_enum< T >, + mpl::identity<detail::load_enum_type<Archive> > + ,//else + mpl::identity<detail::load_non_pointer_type<Archive> > + > + > + >::type typex; + typex::invoke(ar, t); +} + +#if 0 + +// BORLAND +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560)) +// borland has a couple of problems +// a) if function is partially specialized - see below +// const paramters are transformed to non-const ones +// b) implementation of base_object can't be made to work +// correctly which results in all base_object s being const. +// So, strip off the const for borland. This breaks the trap +// for loading const objects - but I see no alternative +template<class Archive, class T> +inline void load(Archive &ar, const T & t){ + load(ar, const_cast<T &>(t)); +} +#endif + +// let wrappers through. +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING +template<class Archive, class T> +inline void load_wrapper(Archive &ar, const T&t, mpl::true_){ + boost::archive::load(ar, const_cast<T&>(t)); +} + +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560)) +template<class Archive, class T> +inline void load(Archive &ar, const T&t){ + load_wrapper(ar,t,serialization::is_wrapper< T >()); +} +#endif +#endif + +#endif + +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_DETAIL_ISERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/oserializer.hpp b/boost_1_45_0/boost/archive/detail/oserializer.hpp new file mode 100644 index 0000000..e676f63 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/oserializer.hpp
@@ -0,0 +1,531 @@ +#ifndef BOOST_ARCHIVE_OSERIALIZER_HPP +#define BOOST_ARCHIVE_OSERIALIZER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#pragma inline_depth(511) +#pragma inline_recursion(on) +#endif + +#if defined(__MWERKS__) +#pragma inline_depth(511) +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// oserializer.hpp: interface for serialization system. + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // NULL + +#include <boost/config.hpp> +#include <boost/static_assert.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/greater_equal.hpp> +#include <boost/mpl/identity.hpp> + +#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO + #include <boost/serialization/extended_type_info_typeid.hpp> +#endif +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/smart_cast.hpp> +#include <boost/serialization/assume_abstract.hpp> +#include <boost/serialization/static_warning.hpp> + +#include <boost/type_traits/is_pointer.hpp> +#include <boost/type_traits/is_enum.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_polymorphic.hpp> +#include <boost/type_traits/remove_extent.hpp> + +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/version.hpp> +#include <boost/serialization/level.hpp> +#include <boost/serialization/tracking.hpp> +#include <boost/serialization/type_info_implementation.hpp> +#include <boost/serialization/nvp.hpp> +#include <boost/serialization/void_cast.hpp> +#include <boost/serialization/array.hpp> +#include <boost/serialization/collection_size_type.hpp> +#include <boost/serialization/singleton.hpp> + +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/detail/basic_oarchive.hpp> +#include <boost/archive/detail/basic_oserializer.hpp> +#include <boost/archive/detail/basic_pointer_oserializer.hpp> +#include <boost/archive/detail/archive_serializer_map.hpp> +#include <boost/archive/detail/check.hpp> + +namespace boost { + +namespace serialization { + class extended_type_info; +} // namespace serialization + +namespace archive { + +// an accessor to permit friend access to archives. Needed because +// some compilers don't handle friend templates completely +class save_access { +public: + template<class Archive> + static void end_preamble(Archive & ar){ + ar.end_preamble(); + } + template<class Archive, class T> + static void save_primitive(Archive & ar, const T & t){ + ar.end_preamble(); + ar.save(t); + } +}; + +namespace detail { + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class Archive, class T> +class oserializer : public basic_oserializer +{ +private: + // private constructor to inhibit any existence other than the + // static one +public: + explicit BOOST_DLLEXPORT oserializer() : + basic_oserializer( + boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance() + ) + {} + virtual BOOST_DLLEXPORT void save_object_data( + basic_oarchive & ar, + const void *x + ) const BOOST_USED; + virtual bool class_info() const { + return boost::serialization::implementation_level< T >::value + >= boost::serialization::object_class_info; + } + virtual bool tracking(const unsigned int /* flags */) const { + return boost::serialization::tracking_level< T >::value == boost::serialization::track_always + || (boost::serialization::tracking_level< T >::value == boost::serialization::track_selectively + && serialized_as_pointer()); + } + virtual version_type version() const { + return version_type(::boost::serialization::version< T >::value); + } + virtual bool is_polymorphic() const { + return boost::is_polymorphic< T >::value; + } + virtual ~oserializer(){} +}; + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +template<class Archive, class T> +BOOST_DLLEXPORT void oserializer<Archive, T>::save_object_data( + basic_oarchive & ar, + const void *x +) const { + // make sure call is routed through the highest interface that might + // be specialized by the user. + BOOST_STATIC_ASSERT(boost::is_const< T >::value == false); + boost::serialization::serialize_adl( + boost::serialization::smart_cast_reference<Archive &>(ar), + * static_cast<T *>(const_cast<void *>(x)), + version() + ); +} + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class Archive, class T> +class pointer_oserializer : + public basic_pointer_oserializer +{ +private: + const basic_oserializer & + get_basic_serializer() const { + return boost::serialization::singleton< + oserializer<Archive, T> + >::get_const_instance(); + } + virtual BOOST_DLLEXPORT void save_object_ptr( + basic_oarchive & ar, + const void * x + ) const BOOST_USED; +public: + pointer_oserializer(); + ~pointer_oserializer(); +}; + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +template<class Archive, class T> +BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr( + basic_oarchive & ar, + const void * x +) const { + assert(NULL != x); + // make sure call is routed through the highest interface that might + // be specialized by the user. + T * t = static_cast<T *>(const_cast<void *>(x)); + const unsigned int file_version = boost::serialization::version< T >::value; + Archive & ar_impl + = boost::serialization::smart_cast_reference<Archive &>(ar); + boost::serialization::save_construct_data_adl<Archive, T>( + ar_impl, + t, + file_version + ); + ar_impl << boost::serialization::make_nvp(NULL, * t); +} + +template<class Archive, class T> +pointer_oserializer<Archive, T>::pointer_oserializer() : + basic_pointer_oserializer( + boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance() + ) +{ + // make sure appropriate member function is instantiated + boost::serialization::singleton< + oserializer<Archive, T> + >::get_mutable_instance().set_bpos(this); + archive_serializer_map<Archive>::insert(this); +} + +template<class Archive, class T> +pointer_oserializer<Archive, T>::~pointer_oserializer(){ + archive_serializer_map<Archive>::erase(this); +} + +template<class Archive> +struct save_non_pointer_type { + // note this bounces the call right back to the archive + // with no runtime overhead + struct save_primitive { + template<class T> + static void invoke(Archive & ar, const T & t){ + save_access::save_primitive(ar, t); + } + }; + // same as above but passes through serialization + struct save_only { + template<class T> + static void invoke(Archive & ar, const T & t){ + // make sure call is routed through the highest interface that might + // be specialized by the user. + boost::serialization::serialize_adl( + ar, + const_cast<T &>(t), + ::boost::serialization::version< T >::value + ); + } + }; + // adds class information to the archive. This includes + // serialization level and class version + struct save_standard { + template<class T> + static void invoke(Archive &ar, const T & t){ + ar.save_object( + & t, + boost::serialization::singleton< + oserializer<Archive, T> + >::get_const_instance() + ); + } + }; + + // adds class information to the archive. This includes + // serialization level and class version + struct save_conditional { + template<class T> + static void invoke(Archive &ar, const T &t){ + //if(0 == (ar.get_flags() & no_tracking)) + save_standard::invoke(ar, t); + //else + // save_only::invoke(ar, t); + } + }; + + + template<class T> + static void invoke(Archive & ar, const T & t){ + typedef + BOOST_DEDUCED_TYPENAME mpl::eval_if< + // if its primitive + mpl::equal_to< + boost::serialization::implementation_level< T >, + mpl::int_<boost::serialization::primitive_type> + >, + mpl::identity<save_primitive>, + // else + BOOST_DEDUCED_TYPENAME mpl::eval_if< + // class info / version + mpl::greater_equal< + boost::serialization::implementation_level< T >, + mpl::int_<boost::serialization::object_class_info> + >, + // do standard save + mpl::identity<save_standard>, + // else + BOOST_DEDUCED_TYPENAME mpl::eval_if< + // no tracking + mpl::equal_to< + boost::serialization::tracking_level< T >, + mpl::int_<boost::serialization::track_never> + >, + // do a fast save + mpl::identity<save_only>, + // else + // do a fast save only tracking is turned off + mpl::identity<save_conditional> + > > >::type typex; + check_object_versioning< T >(); + typex::invoke(ar, t); + } + template<class T> + static void invoke(Archive & ar, T & t){ + check_object_level< T >(); + check_object_tracking< T >(); + invoke(ar, const_cast<const T &>(t)); + } +}; + +template<class Archive> +struct save_pointer_type { + struct abstract + { + template<class T> + static const basic_pointer_oserializer * register_type(Archive & /* ar */){ + // it has? to be polymorphic + BOOST_STATIC_ASSERT(boost::is_polymorphic< T >::value); + return NULL; + } + }; + + struct non_abstract + { + template<class T> + static const basic_pointer_oserializer * register_type(Archive & ar){ + return ar.register_type(static_cast<T *>(NULL)); + } + }; + + template<class T> + static const basic_pointer_oserializer * register_type(Archive &ar, T & /*t*/){ + // there should never be any need to save an abstract polymorphic + // class pointer. Inhibiting code generation for this + // permits abstract base classes to be used - note: exception + // virtual serialize functions used for plug-ins + typedef + BOOST_DEDUCED_TYPENAME mpl::eval_if< + boost::serialization::is_abstract< T >, + mpl::identity<abstract>, + mpl::identity<non_abstract> + >::type typex; + return typex::template register_type< T >(ar); + } + + struct non_polymorphic + { + template<class T> + static void save( + Archive &ar, + T & t + ){ + const basic_pointer_oserializer & bpos = + boost::serialization::singleton< + pointer_oserializer<Archive, T> + >::get_const_instance(); + // save the requested pointer type + ar.save_pointer(& t, & bpos); + } + }; + + struct polymorphic + { + template<class T> + static void save( + Archive &ar, + T & t + ){ + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type const + & i = boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance(); + + boost::serialization::extended_type_info const * const this_type = & i; + + // retrieve the true type of the object pointed to + // if this assertion fails its an error in this library + assert(NULL != this_type); + + const boost::serialization::extended_type_info * true_type = + i.get_derived_extended_type_info(t); + + // note:if this exception is thrown, be sure that derived pointer + // is either registered or exported. + if(NULL == true_type){ + boost::serialization::throw_exception( + archive_exception( + archive_exception::unregistered_class, + "derived class not registered or exported" + ) + ); + } + + // if its not a pointer to a more derived type + const void *vp = static_cast<const void *>(&t); + if(*this_type == *true_type){ + const basic_pointer_oserializer * bpos = register_type(ar, t); + ar.save_pointer(vp, bpos); + return; + } + // convert pointer to more derived type. if this is thrown + // it means that the base/derived relationship hasn't be registered + vp = serialization::void_downcast( + *true_type, + *this_type, + static_cast<const void *>(&t) + ); + if(NULL == vp){ + boost::serialization::throw_exception( + archive_exception( + archive_exception::unregistered_cast, + true_type->get_debug_info(), + this_type->get_debug_info() + ) + ); + } + + // since true_type is valid, and this only gets made if the + // pointer oserializer object has been created, this should never + // fail + const basic_pointer_oserializer * bpos + = static_cast<const basic_pointer_oserializer *>( + boost::serialization::singleton< + archive_serializer_map<Archive> + >::get_const_instance().find(*true_type) + ); + assert(NULL != bpos); + if(NULL == bpos) + boost::serialization::throw_exception( + archive_exception( + archive_exception::unregistered_class, + bpos->get_debug_info() + ) + ); + ar.save_pointer(vp, bpos); + } + }; + + template<class T> + static void save( + Archive & ar, + const T & t + ){ + check_pointer_level< T >(); + check_pointer_tracking< T >(); + typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< + is_polymorphic< T >, + mpl::identity<polymorphic>, + mpl::identity<non_polymorphic> + >::type type; + type::save(ar, const_cast<T &>(t)); + } + + template<class TPtr> + static void invoke(Archive &ar, const TPtr t){ + register_type(ar, * t); + if(NULL == t){ + basic_oarchive & boa + = boost::serialization::smart_cast_reference<basic_oarchive &>(ar); + boa.save_null_pointer(); + save_access::end_preamble(ar); + return; + } + save(ar, * t); + } +}; + +template<class Archive> +struct save_enum_type +{ + template<class T> + static void invoke(Archive &ar, const T &t){ + // convert enum to integers on save + const int i = static_cast<int>(t); + ar << boost::serialization::make_nvp(NULL, i); + } +}; + +template<class Archive> +struct save_array_type +{ + template<class T> + static void invoke(Archive &ar, const T &t){ + typedef BOOST_DEDUCED_TYPENAME boost::remove_extent< T >::type value_type; + + save_access::end_preamble(ar); + // consider alignment + std::size_t c = sizeof(t) / ( + static_cast<const char *>(static_cast<const void *>(&t[1])) + - static_cast<const char *>(static_cast<const void *>(&t[0])) + ); + boost::serialization::collection_size_type count(c); + ar << BOOST_SERIALIZATION_NVP(count); + ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count); + } +}; + +} // detail + +template<class Archive, class T> +inline void save(Archive & ar, /*const*/ T &t){ + typedef + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_pointer< T >, + mpl::identity<detail::save_pointer_type<Archive> >, + //else + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_enum< T >, + mpl::identity<detail::save_enum_type<Archive> >, + //else + BOOST_DEDUCED_TYPENAME mpl::eval_if<is_array< T >, + mpl::identity<detail::save_array_type<Archive> >, + //else + mpl::identity<detail::save_non_pointer_type<Archive> > + > + > + >::type typex; + typex::invoke(ar, t); +} + +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_OSERIALIZER_HPP
diff --git a/boost_1_45_0/boost/archive/detail/polymorphic_iarchive_route.hpp b/boost_1_45_0/boost/archive/detail/polymorphic_iarchive_route.hpp new file mode 100644 index 0000000..d93bb79 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/polymorphic_iarchive_route.hpp
@@ -0,0 +1,215 @@ +#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_ROUTE_HPP +#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_ROUTE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_iarchive_route.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <string> +#include <ostream> +#include <cstddef> + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> +#include <boost/integer_traits.hpp> +#include <boost/archive/polymorphic_iarchive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization +namespace archive { +namespace detail{ + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer; + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class ArchiveImplementation> +class polymorphic_iarchive_route : + public polymorphic_iarchive, + // note: gcc dynamic cross cast fails if the the derivation below is + // not public. I think this is a mistake. + public /*protected*/ ArchiveImplementation +{ +private: + // these are used by the serialization library. + virtual void load_object( + void *t, + const basic_iserializer & bis + ){ + ArchiveImplementation::load_object(t, bis); + } + virtual const basic_pointer_iserializer * load_pointer( + void * & t, + const basic_pointer_iserializer * bpis_ptr, + const basic_pointer_iserializer * (*finder)( + const boost::serialization::extended_type_info & type + ) + ){ + return ArchiveImplementation::load_pointer(t, bpis_ptr, finder); + } + virtual void set_library_version(library_version_type archive_library_version){ + ArchiveImplementation::set_library_version(archive_library_version); + } + virtual library_version_type get_library_version() const{ + return ArchiveImplementation::get_library_version(); + } + virtual unsigned int get_flags() const { + return ArchiveImplementation::get_flags(); + } + virtual void delete_created_pointers(){ + ArchiveImplementation::delete_created_pointers(); + } + virtual void reset_object_address( + const void * new_address, + const void * old_address + ){ + ArchiveImplementation::reset_object_address(new_address, old_address); + } + virtual void load_binary(void * t, std::size_t size){ + ArchiveImplementation::load_binary(t, size); + } + // primitive types the only ones permitted by polymorphic archives + virtual void load(bool & t){ + ArchiveImplementation::load(t); + } + virtual void load(char & t){ + ArchiveImplementation::load(t); + } + virtual void load(signed char & t){ + ArchiveImplementation::load(t); + } + virtual void load(unsigned char & t){ + ArchiveImplementation::load(t); + } + #ifndef BOOST_NO_CWCHAR + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + virtual void load(wchar_t & t){ + ArchiveImplementation::load(t); + } + #endif + #endif + virtual void load(short & t){ + ArchiveImplementation::load(t); + } + virtual void load(unsigned short & t){ + ArchiveImplementation::load(t); + } + virtual void load(int & t){ + ArchiveImplementation::load(t); + } + virtual void load(unsigned int & t){ + ArchiveImplementation::load(t); + } + virtual void load(long & t){ + ArchiveImplementation::load(t); + } + virtual void load(unsigned long & t){ + ArchiveImplementation::load(t); + } + #if defined(BOOST_HAS_LONG_LONG) + virtual void load(boost::long_long_type & t){ + ArchiveImplementation::load(t); + } + virtual void load(boost::ulong_long_type & t){ + ArchiveImplementation::load(t); + } + #elif defined(BOOST_HAS_MS_INT64) + virtual void load(__int64 & t){ + ArchiveImplementation::load(t); + } + virtual void load(unsigned __int64 & t){ + ArchiveImplementation::load(t); + } + #endif + virtual void load(float & t){ + ArchiveImplementation::load(t); + } + virtual void load(double & t){ + ArchiveImplementation::load(t); + } + virtual void load(std::string & t){ + ArchiveImplementation::load(t); + } + #ifndef BOOST_NO_STD_WSTRING + virtual void load(std::wstring & t){ + ArchiveImplementation::load(t); + } + #endif + // used for xml and other tagged formats default does nothing + virtual void load_start(const char * name){ + ArchiveImplementation::load_start(name); + } + virtual void load_end(const char * name){ + ArchiveImplementation::load_end(name); + } + + virtual void register_basic_serializer(const basic_iserializer & bis){ + ArchiveImplementation::register_basic_serializer(bis); + } +public: + // this can't be inheriteded because they appear in mulitple + // parents + typedef mpl::bool_<true> is_loading; + typedef mpl::bool_<false> is_saving; + // the >> operator + template<class T> + polymorphic_iarchive & operator>>(T & t){ + return polymorphic_iarchive::operator>>(t); + } + // the & operator + template<class T> + polymorphic_iarchive & operator&(T & t){ + return polymorphic_iarchive::operator&(t); + } + // register type function + template<class T> + const basic_pointer_iserializer * + register_type(T * t = NULL){ + return ArchiveImplementation::register_type(t); + } + // all current archives take a stream as constructor argument + template <class _Elem, class _Tr> + polymorphic_iarchive_route( + std::basic_istream<_Elem, _Tr> & is, + unsigned int flags = 0 + ) : + ArchiveImplementation(is, flags) + {} + virtual ~polymorphic_iarchive_route(){}; +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_IARCHIVE_DISPATCH_HPP
diff --git a/boost_1_45_0/boost/archive/detail/polymorphic_oarchive_route.hpp b/boost_1_45_0/boost/archive/detail/polymorphic_oarchive_route.hpp new file mode 100644 index 0000000..f1b20f8 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/polymorphic_oarchive_route.hpp
@@ -0,0 +1,205 @@ +#ifndef BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_ROUTE_HPP +#define BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_ROUTE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_oarchive_route.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <string> +#include <ostream> +#include <cstddef> // size_t + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> +#include <boost/integer_traits.hpp> +#include <boost/archive/polymorphic_oarchive.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace serialization { + class extended_type_info; +} // namespace serialization +namespace archive { +namespace detail{ + +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer; +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer; + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +template<class ArchiveImplementation> +class polymorphic_oarchive_route : + public polymorphic_oarchive, + // note: gcc dynamic cross cast fails if the the derivation below is + // not public. I think this is a mistake. + public /*protected*/ ArchiveImplementation +{ +private: + // these are used by the serialization library. + virtual void save_object( + const void *x, + const detail::basic_oserializer & bos + ){ + ArchiveImplementation::save_object(x, bos); + } + virtual void save_pointer( + const void * t, + const detail::basic_pointer_oserializer * bpos_ptr + ){ + ArchiveImplementation::save_pointer(t, bpos_ptr); + } + virtual void save_null_pointer(){ + ArchiveImplementation::save_null_pointer(); + } + // primitive types the only ones permitted by polymorphic archives + virtual void save(const bool t){ + ArchiveImplementation::save(t); + } + virtual void save(const char t){ + ArchiveImplementation::save(t); + } + virtual void save(const signed char t){ + ArchiveImplementation::save(t); + } + virtual void save(const unsigned char t){ + ArchiveImplementation::save(t); + } + #ifndef BOOST_NO_CWCHAR + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + virtual void save(const wchar_t t){ + ArchiveImplementation::save(t); + } + #endif + #endif + virtual void save(const short t){ + ArchiveImplementation::save(t); + } + virtual void save(const unsigned short t){ + ArchiveImplementation::save(t); + } + virtual void save(const int t){ + ArchiveImplementation::save(t); + } + virtual void save(const unsigned int t){ + ArchiveImplementation::save(t); + } + virtual void save(const long t){ + ArchiveImplementation::save(t); + } + virtual void save(const unsigned long t){ + ArchiveImplementation::save(t); + } + #if defined(BOOST_HAS_LONG_LONG) + virtual void save(const boost::long_long_type t){ + ArchiveImplementation::save(t); + } + virtual void save(const boost::ulong_long_type t){ + ArchiveImplementation::save(t); + } + #elif defined(BOOST_HAS_MS_INT64) + virtual void save(const boost::int64_t t){ + ArchiveImplementation::save(t); + } + virtual void save(const boost::uint64_t t){ + ArchiveImplementation::save(t); + } + #endif + virtual void save(const float t){ + ArchiveImplementation::save(t); + } + virtual void save(const double t){ + ArchiveImplementation::save(t); + } + virtual void save(const std::string & t){ + ArchiveImplementation::save(t); + } + #ifndef BOOST_NO_STD_WSTRING + virtual void save(const std::wstring & t){ + ArchiveImplementation::save(t); + } + #endif + virtual library_version_type get_library_version() const{ + return ArchiveImplementation::get_library_version(); + } + virtual unsigned int get_flags() const { + return ArchiveImplementation::get_flags(); + } + virtual void save_binary(const void * t, std::size_t size){ + ArchiveImplementation::save_binary(t, size); + } + // used for xml and other tagged formats default does nothing + virtual void save_start(const char * name){ + ArchiveImplementation::save_start(name); + } + virtual void save_end(const char * name){ + ArchiveImplementation::save_end(name); + } + virtual void end_preamble(){ + ArchiveImplementation::end_preamble(); + } + virtual void register_basic_serializer(const detail::basic_oserializer & bos){ + ArchiveImplementation::register_basic_serializer(bos); + } +public: + // this can't be inheriteded because they appear in mulitple + // parents + typedef mpl::bool_<false> is_loading; + typedef mpl::bool_<true> is_saving; + // the << operator + template<class T> + polymorphic_oarchive & operator<<(T & t){ + return polymorphic_oarchive::operator<<(t); + } + // the & operator + template<class T> + polymorphic_oarchive & operator&(T & t){ + return polymorphic_oarchive::operator&(t); + } + // register type function + template<class T> + const basic_pointer_oserializer * + register_type(T * t = NULL){ + return ArchiveImplementation::register_type(t); + } + // all current archives take a stream as constructor argument + template <class _Elem, class _Tr> + polymorphic_oarchive_route( + std::basic_ostream<_Elem, _Tr> & os, + unsigned int flags = 0 + ) : + ArchiveImplementation(os, flags) + {} + virtual ~polymorphic_oarchive_route(){}; +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_DETAIL_POLYMORPHIC_OARCHIVE_DISPATCH_HPP
diff --git a/boost_1_45_0/boost/archive/detail/register_archive.hpp b/boost_1_45_0/boost/archive/detail/register_archive.hpp new file mode 100644 index 0000000..e31ae46 --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/register_archive.hpp
@@ -0,0 +1,91 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP +# define BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP + +namespace boost { namespace archive { namespace detail { + +// No instantiate_ptr_serialization overloads generated by +// BOOST_SERIALIZATION_REGISTER_ARCHIVE that lexically follow the call +// will be seen *unless* they are in an associated namespace of one of +// the arguments, so we pass one of these along to make sure this +// namespace is considered. See temp.dep.candidate (14.6.4.2) in the +// standard. +struct adl_tag {}; + +template <class Archive, class Serializable> +struct ptr_serialization_support; + +// We could've just used ptr_serialization_support, above, but using +// it with only a forward declaration causes vc6/7 to complain about a +// missing instantiate member, even if it has one. This is just a +// friendly layer of indirection. +template <class Archive, class Serializable> +struct _ptr_serialization_support + : ptr_serialization_support<Archive,Serializable> +{ + typedef int type; +}; + +#ifdef __SUNPRO_CC + +template<int N> +struct counter : counter<N-1> {}; +template<> +struct counter<0> {}; + +template<class Serializable> +void instantiate_ptr_serialization(Serializable* s, int, adl_tag) { + instantiate_ptr_serialization(s, counter<20>()); +} + +template<class Archive> +struct get_counter { + static const int value = sizeof(adjust_counter(counter<20>())); + typedef counter<value> type; + typedef counter<value - 1> prior; + typedef char (&next)[value+1]; +}; + +char adjust_counter(counter<0>); +template<class Serializable> +void instantiate_ptr_serialization(Serializable*, counter<0>) {} + +#define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive) \ +namespace boost { namespace archive { namespace detail { \ + get_counter<Archive >::next adjust_counter(get_counter<Archive >::type);\ + template<class Serializable> \ + void instantiate_ptr_serialization(Serializable* s, \ + get_counter<Archive >::type) { \ + ptr_serialization_support<Archive, Serializable> x; \ + instantiate_ptr_serialization(s, get_counter<Archive >::prior()); \ + }\ +}}} + + +#else + +// This function gets called, but its only purpose is to participate +// in overload resolution with the functions declared by +// BOOST_SERIALIZATION_REGISTER_ARCHIVE, below. +template <class Serializable> +void instantiate_ptr_serialization(Serializable*, int, adl_tag ) {} + +// The function declaration generated by this macro never actually +// gets called, but its return type gets instantiated, and that's +// enough to cause registration of serialization functions between +// Archive and any exported Serializable type. See also: +// boost/serialization/export.hpp +# define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive) \ +namespace boost { namespace archive { namespace detail { \ + \ +template <class Serializable> \ +BOOST_DEDUCED_TYPENAME _ptr_serialization_support<Archive, Serializable>::type \ +instantiate_ptr_serialization( Serializable*, Archive*, adl_tag ); \ + \ +}}} +#endif +}}} // namespace boost::archive::detail + +#endif // BOOST_ARCHIVE_DETAIL_INSTANTIATE_SERIALIZE_DWA2006521_HPP
diff --git a/boost_1_45_0/boost/archive/detail/utf8_codecvt_facet.hpp b/boost_1_45_0/boost/archive/detail/utf8_codecvt_facet.hpp new file mode 100644 index 0000000..bd859ff --- /dev/null +++ b/boost_1_45_0/boost/archive/detail/utf8_codecvt_facet.hpp
@@ -0,0 +1,21 @@ +// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu) +// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu). +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP +#define BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP + +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace archive { namespace detail { +#define BOOST_UTF8_DECL +#define BOOST_UTF8_END_NAMESPACE }}} + +#include <boost/detail/utf8_codecvt_facet.hpp> + +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#undef BOOST_UTF8_BEGIN_NAMESPACE + +#endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
diff --git a/boost_1_45_0/boost/archive/dinkumware.hpp b/boost_1_45_0/boost/archive/dinkumware.hpp new file mode 100644 index 0000000..bfa828d --- /dev/null +++ b/boost_1_45_0/boost/archive/dinkumware.hpp
@@ -0,0 +1,224 @@ +#ifndef BOOST_ARCHIVE_DINKUMWARE_HPP +#define BOOST_ARCHIVE_DINKUMWARE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// dinkumware.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// this file adds a couple of things that are missing from the dinkumware +// implementation of the standard library. + +#include <iterator> +#include <string> + +#include <boost/config.hpp> +#include <boost/cstdint.hpp> + +namespace std { + +// define i/o operators for 64 bit integers +template<class CharType> +basic_ostream<CharType> & +operator<<(basic_ostream<CharType> & os, boost::uint64_t t){ + // octal rendering of 64 bit number would be 22 octets + eos + CharType d[23]; + unsigned int radix; + + if(os.flags() & (int)std::ios_base::hex) + radix = 16; + else + if(os.flags() & (int)std::ios_base::oct) + radix = 8; + else + //if(s.flags() & (int)std::ios_base::dec) + radix = 10; + unsigned int i = 0; + do{ + unsigned int j = t % radix; + d[i++] = j + ((j < 10) ? '0' : ('a' - 10)); + t /= radix; + } + while(t > 0); + d[i--] = '\0'; + + // reverse digits + unsigned int j = 0; + while(j < i){ + CharType k = d[i]; + d[i] = d[j]; + d[j] = k; + --i;++j; + } + os << d; + return os; + +} + +template<class CharType> +basic_ostream<CharType> & +operator<<(basic_ostream<CharType> &os, boost::int64_t t){ + if(0 <= t){ + os << static_cast<boost::uint64_t>(t); + } + else{ + os.put('-'); + os << -t; + } + return os; +} + +template<class CharType> +basic_istream<CharType> & +operator>>(basic_istream<CharType> &is, boost::int64_t & t){ + CharType d; + do{ + d = is.get(); + } + while(::isspace(d)); + bool negative = (d == '-'); + if(negative) + d = is.get(); + unsigned int radix; + if(is.flags() & (int)std::ios_base::hex) + radix = 16; + else + if(is.flags() & (int)std::ios_base::oct) + radix = 8; + else + //if(s.flags() & (int)std::ios_base::dec) + radix = 10; + t = 0; + do{ + if('0' <= d && d <= '9') + t = t * radix + (d - '0'); + else + if('a' <= d && d <= 'f') + t = t * radix + (d - 'a' + 10); + else + break; + d = is.get(); + } + while(!is.fail()); + // restore the delimiter + is.putback(d); + is.clear(); + if(negative) + t = -t; + return is; +} + +template<class CharType> +basic_istream<CharType> & +operator>>(basic_istream<CharType> &is, boost::uint64_t & t){ + boost::int64_t it; + is >> it; + t = it; + return is; +} + +//#endif + +template<> +class back_insert_iterator<basic_string<char> > : public + iterator<output_iterator_tag, char> +{ +public: + typedef basic_string<char> container_type; + typedef container_type::reference reference; + + explicit back_insert_iterator(container_type & s) + : container(& s) + {} // construct with container + + back_insert_iterator<container_type> & operator=( + container_type::const_reference Val_ + ){ // push value into container + //container->push_back(Val_); + *container += Val_; + return (*this); + } + + back_insert_iterator<container_type> & operator*(){ + return (*this); + } + + back_insert_iterator<container_type> & operator++(){ + // pretend to preincrement + return (*this); + } + + back_insert_iterator<container_type> operator++(int){ + // pretend to postincrement + return (*this); + } + +protected: + container_type *container; // pointer to container +}; + +template<char> +inline back_insert_iterator<basic_string<char> > back_inserter( + basic_string<char> & s +){ + return (std::back_insert_iterator<basic_string<char> >(s)); +} + +template<> +class back_insert_iterator<basic_string<wchar_t> > : public + iterator<output_iterator_tag, wchar_t> +{ +public: + typedef basic_string<wchar_t> container_type; + typedef container_type::reference reference; + + explicit back_insert_iterator(container_type & s) + : container(& s) + {} // construct with container + + back_insert_iterator<container_type> & operator=( + container_type::const_reference Val_ + ){ // push value into container + //container->push_back(Val_); + *container += Val_; + return (*this); + } + + back_insert_iterator<container_type> & operator*(){ + return (*this); + } + + back_insert_iterator<container_type> & operator++(){ + // pretend to preincrement + return (*this); + } + + back_insert_iterator<container_type> operator++(int){ + // pretend to postincrement + return (*this); + } + +protected: + container_type *container; // pointer to container +}; + +template<wchar_t> +inline back_insert_iterator<basic_string<wchar_t> > back_inserter( + basic_string<wchar_t> & s +){ + return (std::back_insert_iterator<basic_string<wchar_t> >(s)); +} + +} // namespace std + +#endif //BOOST_ARCHIVE_DINKUMWARE_HPP
diff --git a/boost_1_45_0/boost/archive/impl/archive_serializer_map.ipp b/boost_1_45_0/boost/archive/impl/archive_serializer_map.ipp new file mode 100644 index 0000000..c8ad96b --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/archive_serializer_map.ipp
@@ -0,0 +1,71 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// archive_serializer_map.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +////////////////////////////////////////////////////////////////////// +// implementation of basic_text_iprimitive overrides for the combination +// of template parameters used to implement a text_iprimitive + +#include <boost/config.hpp> +#include <boost/archive/detail/archive_serializer_map.hpp> +#include <boost/archive/detail/basic_serializer_map.hpp> +#include <boost/serialization/singleton.hpp> + +namespace boost { +namespace archive { +namespace detail { + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace extra_detail { // anon + template<class Archive> + class map : public basic_serializer_map + {}; +} + +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(bool) +archive_serializer_map<Archive>::insert(const basic_serializer * bs){ + return boost::serialization::singleton< + extra_detail::map<Archive> + >::get_mutable_instance().insert(bs); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +archive_serializer_map<Archive>::erase(const basic_serializer * bs){ + if(boost::serialization::singleton< + extra_detail::map<Archive> + >::is_destroyed()) + return; + boost::serialization::singleton< + extra_detail::map<Archive> + >::get_mutable_instance().erase(bs); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(const basic_serializer *) +archive_serializer_map<Archive>::find( + const boost::serialization::extended_type_info & eti +) { + return boost::serialization::singleton< + extra_detail::map<Archive> + >::get_const_instance().find(eti); +} + +} // namespace detail +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_binary_iarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_binary_iarchive.ipp new file mode 100644 index 0000000..a9757b3 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_binary_iarchive.ipp
@@ -0,0 +1,129 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_iarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <string> +#include <cassert> +#include <algorithm> +#include <cstring> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; + using ::strlen; + using ::size_t; +} +#endif + +#include <boost/detail/workaround.hpp> +#include <boost/detail/endian.hpp> + +#include <boost/archive/basic_binary_iarchive.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation of binary_binary_archive +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iarchive<Archive>::load_override(class_name_type & t, int){ + std::string cn; + cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE); + load_override(cn, 0); + if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_class_name) + ); + std::memcpy(t, cn.data(), cn.size()); + // borland tweak + t.t[cn.size()] = '\0'; +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iarchive<Archive>::init(){ + // read signature in an archive version independent manner + std::string file_signature; + try { + std::size_t l; + this->This()->load(l); + if(l == std::strlen(BOOST_ARCHIVE_SIGNATURE())) { + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != file_signature.data()) + #endif + file_signature.resize(l); + // note breaking a rule here - could be a problem on some platform + if(0 < l) + this->This()->load_binary(&(*file_signature.begin()), l); + } + } + catch(archive_exception const &) { // catch stream_error archive exceptions + // will cause invalid_signature archive exception to be thrown below + file_signature = ""; + } + if(file_signature != BOOST_ARCHIVE_SIGNATURE()) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_signature) + ); + + // make sure the version of the reading archive library can + // support the format of the archive being read + library_version_type input_library_version; + //* this->This() >> input_library_version; + { + int v = 0; + v = this->This()->m_sb.sbumpc(); + #if defined(BOOST_LITTLE_ENDIAN) + if(v < 6){ + ; + } + else + if(v < 7){ + // version 6 - next byte should be zero + this->This()->m_sb.sbumpc(); + } + else + if(v < 8){ + int x1; + // version 7 = might be followed by zero or some other byte + x1 = this->This()->m_sb.sgetc(); + // it's =a zero, push it back + if(0 == x1) + this->This()->m_sb.sbumpc(); + } + else{ + // version 8+ followed by a zero + this->This()->m_sb.sbumpc(); + } + #elif defined(BOOST_BIG_ENDIAN) + if(v == 0) + v = this->This()->m_sb.sbumpc(); + #endif + input_library_version = static_cast<library_version_type>(v); + } + + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) + this->set_library_version(input_library_version); + #else + #if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + detail:: + #endif + basic_iarchive::set_library_version(input_library_version); + #endif + + if(BOOST_ARCHIVE_VERSION() < input_library_version) + boost::serialization::throw_exception( + archive_exception(archive_exception::unsupported_version) + ); +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_binary_iprimitive.ipp b/boost_1_45_0/boost/archive/impl/basic_binary_iprimitive.ipp new file mode 100644 index 0000000..f609571 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_binary_iprimitive.ipp
@@ -0,0 +1,209 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_iprimitive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // size_t, NULL +#include <cstring> // memcpy + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; + using ::memcpy; +} // namespace std +#endif + +#include <boost/detail/workaround.hpp> // fixup for RogueWave + +#include <boost/serialization/throw_exception.hpp> +#include <boost/scoped_ptr.hpp> + +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/codecvt_null.hpp> +#include <boost/archive/add_facet.hpp> + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// implementation of basic_binary_iprimitive + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iprimitive<Archive, Elem, Tr>::init() +{ + // Detect attempts to pass native binary archives across + // incompatible platforms. This is not fool proof but its + // better than nothing. + unsigned char size; + this->This()->load(size); + if(sizeof(int) != size) + boost::serialization::throw_exception( + archive_exception( + archive_exception::incompatible_native_format, + "size of int" + ) + ); + this->This()->load(size); + if(sizeof(long) != size) + boost::serialization::throw_exception( + archive_exception( + archive_exception::incompatible_native_format, + "size of long" + ) + ); + this->This()->load(size); + if(sizeof(float) != size) + boost::serialization::throw_exception( + archive_exception( + archive_exception::incompatible_native_format, + "size of float" + ) + ); + this->This()->load(size); + if(sizeof(double) != size) + boost::serialization::throw_exception( + archive_exception( + archive_exception::incompatible_native_format, + "size of double" + ) + ); + + // for checking endian + int i; + this->This()->load(i); + if(1 != i) + boost::serialization::throw_exception( + archive_exception( + archive_exception::incompatible_native_format, + "endian setting" + ) + ); +} + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws) +{ + std::size_t l; // number of wchar_t !!! + this->This()->load(l); + load_binary(ws, l * sizeof(wchar_t) / sizeof(char)); + ws[l] = L'\0'; +} + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iprimitive<Archive, Elem, Tr>::load(std::string & s) +{ + std::size_t l; + this->This()->load(l); + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != s.data()) + #endif + s.resize(l); + // note breaking a rule here - could be a problem on some platform + if(0 < l) + load_binary(&(*s.begin()), l); +} + +#ifndef BOOST_NO_CWCHAR +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iprimitive<Archive, Elem, Tr>::load(char * s) +{ + std::size_t l; + this->This()->load(l); + load_binary(s, l); + s[l] = '\0'; +} +#endif + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_iprimitive<Archive, Elem, Tr>::load(std::wstring & ws) +{ + std::size_t l; + this->This()->load(l); + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != ws.data()) + #endif + ws.resize(l); + // note breaking a rule here - is could be a problem on some platform + load_binary(const_cast<wchar_t *>(ws.data()), l * sizeof(wchar_t) / sizeof(char)); +} +#endif + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_binary_iprimitive<Archive, Elem, Tr>::basic_binary_iprimitive( + std::basic_streambuf<Elem, Tr> & sb, + bool no_codecvt +) : +#ifndef BOOST_NO_STD_LOCALE + m_sb(sb), + archive_locale(NULL), + locale_saver(m_sb) +{ + if(! no_codecvt){ + archive_locale.reset( + boost::archive::add_facet( + std::locale::classic(), + new codecvt_null<Elem> + ) + ); + m_sb.pubimbue(* archive_locale); + } +} +#else + m_sb(sb) +{} +#endif + +// some libraries including stl and libcomo fail if the +// buffer isn't flushed before the code_cvt facet is changed. +// I think this is a bug. We explicity invoke sync to when +// we're done with the streambuf to work around this problem. +// Note that sync is a protected member of stream buff so we +// have to invoke it through a contrived derived class. +namespace detail { +// note: use "using" to get past msvc bug +using namespace std; +template<class Elem, class Tr> +class input_streambuf_access : public std::basic_streambuf<Elem, Tr> { + public: + virtual int sync(){ +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) + return this->basic_streambuf::sync(); +#else + return this->basic_streambuf<Elem, Tr>::sync(); +#endif + } +}; +} // detail + +// scoped_ptr requires that archive_locale be a complete type at time of +// destruction so define destructor here rather than in the header +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_binary_iprimitive<Archive, Elem, Tr>::~basic_binary_iprimitive(){ + // push back unread characters + //destructor can't throw ! + try{ + static_cast<detail::input_streambuf_access<Elem, Tr> &>(m_sb).sync(); + } + catch(...){ + } +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_binary_oarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_binary_oarchive.ipp new file mode 100644 index 0000000..cd12c4c --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_binary_oarchive.ipp
@@ -0,0 +1,46 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_oarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <string> +#include <cassert> +#include <algorithm> +#include <cstring> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; +} +#endif + +#include <boost/archive/basic_binary_oarchive.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation of binary_binary_oarchive + +template<class Archive> +#if !defined(__BORLANDC__) +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +#else +void +#endif +basic_binary_oarchive<Archive>::init(){ + // write signature in an archive version independent manner + const std::string file_signature(BOOST_ARCHIVE_SIGNATURE()); + * this->This() << file_signature; + // write library version + const library_version_type v(BOOST_ARCHIVE_VERSION()); + * this->This() << v; +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_binary_oprimitive.ipp b/boost_1_45_0/boost/archive/impl/basic_binary_oprimitive.ipp new file mode 100644 index 0000000..02b5ffa --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_binary_oprimitive.ipp
@@ -0,0 +1,160 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_binary_oprimitive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <ostream> +#include <cstddef> // NULL +#include <cstring> + +#include <boost/config.hpp> + +#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__) +namespace std{ + using ::strlen; +} // namespace std +#endif + +#ifndef BOOST_NO_CWCHAR +#include <cwchar> +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ using ::wcslen; } +#endif +#endif + +#include <boost/detail/workaround.hpp> + +#include <boost/archive/add_facet.hpp> +#include <boost/archive/codecvt_null.hpp> + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// implementation of basic_binary_oprimitive + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_oprimitive<Archive, Elem, Tr>::init() +{ + // record native sizes of fundamental types + // this is to permit detection of attempts to pass + // native binary archives accross incompatible machines. + // This is not foolproof but its better than nothing. + this->This()->save(static_cast<unsigned char>(sizeof(int))); + this->This()->save(static_cast<unsigned char>(sizeof(long))); + this->This()->save(static_cast<unsigned char>(sizeof(float))); + this->This()->save(static_cast<unsigned char>(sizeof(double))); + // for checking endianness + this->This()->save(int(1)); +} + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_oprimitive<Archive, Elem, Tr>::save(const char * s) +{ + std::size_t l = std::strlen(s); + this->This()->save(l); + save_binary(s, l); +} + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::string &s) +{ + std::size_t l = static_cast<std::size_t>(s.size()); + this->This()->save(l); + save_binary(s.data(), l); +} + +#ifndef BOOST_NO_CWCHAR +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_oprimitive<Archive, Elem, Tr>::save(const wchar_t * ws) +{ + std::size_t l = std::wcslen(ws); + this->This()->save(l); + save_binary(ws, l * sizeof(wchar_t) / sizeof(char)); +} +#endif + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_binary_oprimitive<Archive, Elem, Tr>::save(const std::wstring &ws) +{ + std::size_t l = ws.size(); + this->This()->save(l); + save_binary(ws.data(), l * sizeof(wchar_t) / sizeof(char)); +} +#endif + +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_binary_oprimitive<Archive, Elem, Tr>::basic_binary_oprimitive( + std::basic_streambuf<Elem, Tr> & sb, + bool no_codecvt +) : +#ifndef BOOST_NO_STD_LOCALE + m_sb(sb), + archive_locale(NULL), + locale_saver(m_sb) +{ + if(! no_codecvt){ + archive_locale.reset( + add_facet( + std::locale::classic(), + new codecvt_null<Elem> + ) + ); + m_sb.pubimbue(* archive_locale); + } +} +#else + m_sb(sb) +{} +#endif + +// some libraries including stl and libcomo fail if the +// buffer isn't flushed before the code_cvt facet is changed. +// I think this is a bug. We explicity invoke sync to when +// we're done with the streambuf to work around this problem. +// Note that sync is a protected member of stream buff so we +// have to invoke it through a contrived derived class. +namespace detail { +// note: use "using" to get past msvc bug +using namespace std; +template<class Elem, class Tr> +class output_streambuf_access : public std::basic_streambuf<Elem, Tr> { + public: + virtual int sync(){ +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) + return this->basic_streambuf::sync(); +#else + return this->basic_streambuf<Elem, Tr>::sync(); +#endif + } +}; +} // detail + +// scoped_ptr requires that g be a complete type at time of +// destruction so define destructor here rather than in the header +template<class Archive, class Elem, class Tr> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_binary_oprimitive<Archive, Elem, Tr>::~basic_binary_oprimitive(){ + // flush buffer + //destructor can't throw + try{ + static_cast<detail::output_streambuf_access<Elem, Tr> &>(m_sb).sync(); + } + catch(...){ + } +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_text_iarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_text_iarchive.ipp new file mode 100644 index 0000000..0a246b7 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_text_iarchive.ipp
@@ -0,0 +1,79 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_iarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <string> +#include <algorithm> +#include <cstring> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; +} +#endif + +#include <boost/detail/workaround.hpp> +#include <boost/serialization/string.hpp> +#include <boost/archive/basic_text_iarchive.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation of text_text_archive + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_iarchive<Archive>::load_override(class_name_type & t, int){ + std::string cn; + cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE); + load_override(cn, 0); + if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_class_name) + ); + std::memcpy(t, cn.data(), cn.size()); + // borland tweak + t.t[cn.size()] = '\0'; +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_iarchive<Archive>::init(void){ + // read signature in an archive version independent manner + std::string file_signature; + * this->This() >> file_signature; + if(file_signature != BOOST_ARCHIVE_SIGNATURE()) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_signature) + ); + + // make sure the version of the reading archive library can + // support the format of the archive being read + library_version_type input_library_version; + * this->This() >> input_library_version; + + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) + this->set_library_version(input_library_version); + #else + #if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + detail:: + #endif + basic_iarchive::set_library_version(input_library_version); + #endif + + // extra little .t is to get around borland quirk + if(BOOST_ARCHIVE_VERSION() < input_library_version) + boost::serialization::throw_exception( + archive_exception(archive_exception::unsupported_version) + ); +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_text_iprimitive.ipp b/boost_1_45_0/boost/archive/impl/basic_text_iprimitive.ipp new file mode 100644 index 0000000..581dbfb --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_text_iprimitive.ipp
@@ -0,0 +1,154 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_iprimitive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // size_t +#include <cstddef> // NULL + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/basic_text_iprimitive.hpp> +#include <boost/archive/codecvt_null.hpp> +#include <boost/archive/add_facet.hpp> + +#include <boost/archive/iterators/remove_whitespace.hpp> +#include <boost/archive/iterators/istream_iterator.hpp> +#include <boost/archive/iterators/binary_from_base64.hpp> +#include <boost/archive/iterators/transform_width.hpp> + +namespace boost { +namespace archive { + +namespace { + template<class CharType> + bool is_whitespace(CharType c); + + template<> + bool is_whitespace(char t){ + return 0 != std::isspace(t); + } + + #ifndef BOOST_NO_CWCHAR + template<> + bool is_whitespace(wchar_t t){ + return 0 != std::iswspace(t); + } + #endif +} + +// translate base64 text into binary and copy into buffer +// until buffer is full. +template<class IStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_iprimitive<IStream>::load_binary( + void *address, + std::size_t count +){ + typedef BOOST_DEDUCED_TYPENAME IStream::char_type CharType; + + if(0 == count) + return; + + assert( + static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) + > (count + sizeof(CharType) - 1)/sizeof(CharType) + ); + + if(is.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + // convert from base64 to binary + typedef BOOST_DEDUCED_TYPENAME + iterators::transform_width< + iterators::binary_from_base64< + iterators::remove_whitespace< + iterators::istream_iterator<CharType> + > + ,CharType + > + ,8 + ,6 + ,CharType + > + binary; + + binary ti_begin = binary( + BOOST_MAKE_PFTO_WRAPPER( + iterators::istream_iterator<CharType>(is) + ) + ); + + char * caddr = static_cast<char *>(address); + + // take care that we don't increment anymore than necessary + while(--count > 0){ + *caddr++ = static_cast<char>(*ti_begin); + ++ti_begin; + } + *caddr++ = static_cast<char>(*ti_begin); + + iterators::istream_iterator<CharType> i; + for(;;){ + BOOST_DEDUCED_TYPENAME IStream::int_type r; + r = is.get(); + if(is.eof()) + break; + if(is_whitespace(static_cast<CharType>(r))) + break; + } +} + +template<class IStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_text_iprimitive<IStream>::basic_text_iprimitive( + IStream &is_, + bool no_codecvt +) : +#ifndef BOOST_NO_STD_LOCALE + is(is_), + flags_saver(is_), + precision_saver(is_), + archive_locale(NULL), + locale_saver(* is_.rdbuf()) +{ + if(! no_codecvt){ + archive_locale.reset( + add_facet( + std::locale::classic(), + new codecvt_null<BOOST_DEDUCED_TYPENAME IStream::char_type> + ) + ); + is.imbue(* archive_locale); + } + is >> std::noboolalpha; +} +#else + is(is_), + flags_saver(is_), + precision_saver(is_) +{} +#endif + +template<class IStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_text_iprimitive<IStream>::~basic_text_iprimitive(){ + is.sync(); +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_text_oarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_text_oarchive.ipp new file mode 100644 index 0000000..fb8d18e --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_text_oarchive.ipp
@@ -0,0 +1,62 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_oarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. +#include <string> +#include <cassert> +#include <cstring> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; +} +#endif + +#include <boost/archive/basic_text_oarchive.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation of basic_text_oarchive + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_oarchive<Archive>::newtoken() +{ + switch(delimiter){ + default: + assert(false); + break; + case eol: + this->This()->put('\n'); + delimiter = space; + break; + case space: + this->This()->put(' '); + break; + case none: + delimiter = space; + break; + } +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_oarchive<Archive>::init(){ + // write signature in an archive version independent manner + const std::string file_signature(BOOST_ARCHIVE_SIGNATURE()); + * this->This() << file_signature; + // write library version + const library_version_type v(BOOST_ARCHIVE_VERSION()); + * this->This() << v; +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_text_oprimitive.ipp b/boost_1_45_0/boost/archive/impl/basic_text_oprimitive.ipp new file mode 100644 index 0000000..cacab61 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_text_oprimitive.ipp
@@ -0,0 +1,114 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_text_oprimitive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // NULL +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/codecvt_null.hpp> +#include <boost/archive/add_facet.hpp> + +#include <boost/archive/iterators/base64_from_binary.hpp> +#include <boost/archive/iterators/insert_linebreaks.hpp> +#include <boost/archive/iterators/transform_width.hpp> +#include <boost/archive/iterators/ostream_iterator.hpp> + +namespace boost { +namespace archive { + +// translate to base64 and copy in to buffer. +template<class OStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_text_oprimitive<OStream>::save_binary( + const void *address, + std::size_t count +){ + typedef BOOST_DEDUCED_TYPENAME OStream::char_type CharType; + + if(0 == count) + return; + + if(os.fail()) + boost::serialization::throw_exception( + archive_exception(archive_exception::output_stream_error) + ); + + os.put('\n'); + + typedef + boost::archive::iterators::insert_linebreaks< + boost::archive::iterators::base64_from_binary< + boost::archive::iterators::transform_width< + const char *, + 6, + 8 + > + > + ,72 + ,const char // cwpro8 needs this + > + base64_text; + + boost::archive::iterators::ostream_iterator<CharType> oi(os); + std::copy( + base64_text(BOOST_MAKE_PFTO_WRAPPER(static_cast<const char *>(address))), + base64_text( + BOOST_MAKE_PFTO_WRAPPER(static_cast<const char *>(address) + count) + ), + oi + ); + + std::size_t tail = count % 3; + if(tail > 0){ + *oi++ = '='; + if(tail < 2) + *oi = '='; + } +} + +template<class OStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_text_oprimitive<OStream>::basic_text_oprimitive( + OStream & os_, + bool no_codecvt +) : +#ifndef BOOST_NO_STD_LOCALE + os(os_), + flags_saver(os_), + precision_saver(os_), + archive_locale(NULL), + locale_saver(* os_.rdbuf()) +{ + if(! no_codecvt){ + archive_locale.reset( + add_facet( + std::locale::classic(), + new codecvt_null<BOOST_DEDUCED_TYPENAME OStream::char_type> + ) + ); + os.imbue(* archive_locale); + } + os << std::noboolalpha; +} +#else + os(os_), + flags_saver(os_), + precision_saver(os_) +{} +#endif + +template<class OStream> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_text_oprimitive<OStream>::~basic_text_oprimitive(){ + os << std::endl; +} + +} //namespace boost +} //namespace archive
diff --git a/boost_1_45_0/boost/archive/impl/basic_xml_grammar.hpp b/boost_1_45_0/boost/archive/impl/basic_xml_grammar.hpp new file mode 100644 index 0000000..ca6182e --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_xml_grammar.hpp
@@ -0,0 +1,196 @@ +#ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP +#define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_grammar.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// this module is derived from simplexml.cpp - an example shipped as part of +// the spirit parser. This example contains the following notice: +/*============================================================================= + simplexml.cpp + + Spirit V1.3 + URL: http://spirit.sourceforge.net/ + + Copyright (c) 2001, Daniel C. Nuffer + + This software is provided 'as-is', without any express or implied + warranty. In no event will the copyright holder be held liable for + any damages arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +=============================================================================*/ +#include <string> + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> + +// supress noise +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +# pragma warning (disable : 4786) // too long name, harmless warning +#endif + +//#define BOOST_SPIRIT_DEBUG +#include <boost/spirit/core/non_terminal/rule.hpp> + +// the following hack is to evade a bogus error generated by using the +// word "arg" when bind.hpp has been included +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +#define arg xarg +#endif + +// spirit stuff +#if (defined __BORLANDC__) && (__BORLANDC__ < 0x593) \ + || (defined _MSC_VER) && (_MSC_VER <= 1300) +#include <boost/spirit/utility/chset.hpp> +#else +#include <boost/spirit/include/classic_chset.hpp> +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +#undef arg +#endif + +#include <boost/archive/basic_archive.hpp> +#include <boost/serialization/tracking.hpp> +#include <boost/serialization/version.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// XML grammar parsing + +template<class CharType> +class basic_xml_grammar { +public: + // The following is not necessary according to DR45, but at least + // one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise. + struct return_values; + friend struct return_values; + +private: + typedef BOOST_DEDUCED_TYPENAME std::basic_istream<CharType> IStream; + typedef BOOST_DEDUCED_TYPENAME std::basic_string<CharType> StringType; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::chset<CharType> chset_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::chlit<CharType> chlit_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::scanner< + BOOST_DEDUCED_TYPENAME std::basic_string<CharType>::iterator + > scanner_t; + typedef BOOST_DEDUCED_TYPENAME boost::spirit::rule<scanner_t> rule_t; + // Start grammar definition + rule_t + Reference, + Eq, + STag, + ETag, + LetterOrUnderscoreOrColon, + AttValue, + CharRef1, + CharRef2, + CharRef, + AmpRef, + LTRef, + GTRef, + AposRef, + QuoteRef, + CharData, + CharDataChars, + content, + AmpName, + LTName, + GTName, + ClassNameChar, + ClassName, + Name, + XMLDecl, + XMLDeclChars, + DocTypeDecl, + DocTypeDeclChars, + ClassIDAttribute, + ObjectIDAttribute, + ClassNameAttribute, + TrackingAttribute, + VersionAttribute, + UnusedAttribute, + Attribute, + SignatureAttribute, + SerializationWrapper, + NameHead, + NameTail, + AttributeList, + S; + + // XML Character classes + chset_t + BaseChar, + Ideographic, + Char, + Letter, + Digit, + CombiningChar, + Extender, + Sch, + NameChar; + + void init_chset(); + + bool my_parse( + IStream & is, + const rule_t &rule_, + const CharType delimiter = L'>' + ) const ; +public: + struct return_values { + StringType object_name; + StringType contents; + //class_id_type class_id; + int_least16_t class_id; + //object_id_type object_id; + uint_least32_t object_id; + //version_type version; + unsigned int version; + tracking_type tracking_level; + StringType class_name; + return_values() : + version(0), + tracking_level(false) + {} + } rv; + bool parse_start_tag(IStream & is) /*const*/; + bool parse_end_tag(IStream & is) const; + bool parse_string(IStream & is, StringType & s) /*const*/; + void init(IStream & is); + void windup(IStream & is); + basic_xml_grammar(); +}; + +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
diff --git a/boost_1_45_0/boost/archive/impl/basic_xml_iarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_xml_iarchive.ipp new file mode 100644 index 0000000..9528c4a --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_xml_iarchive.ipp
@@ -0,0 +1,114 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_iarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // NULL +#include <algorithm> + +#include <boost/serialization/throw_exception.hpp> +#include <boost/archive/xml_archive_exception.hpp> +#include <boost/archive/basic_xml_iarchive.hpp> +#include <boost/serialization/tracking.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation of xml_text_archive + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_start(const char *name){ + // if there's no name + if(NULL == name) + return; + bool result = this->This()->gimpl->parse_start_tag(this->This()->get_is()); + if(true != result){ + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + } + // don't check start tag at highest level + ++depth; + return; +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_end(const char *name){ + // if there's no name + if(NULL == name) + return; + bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is()); + if(true != result){ + boost::serialization::throw_exception( + archive_exception(archive_exception::input_stream_error) + ); + } + + // don't check start tag at highest level + if(0 == --depth) + return; + + if(0 == (this->get_flags() & no_xml_tag_checking)){ + // double check that the tag matches what is expected - useful for debug + if(0 != name[this->This()->gimpl->rv.object_name.size()] + || ! std::equal( + this->This()->gimpl->rv.object_name.begin(), + this->This()->gimpl->rv.object_name.end(), + name + ) + ){ + boost::serialization::throw_exception( + xml_archive_exception( + xml_archive_exception::xml_archive_tag_mismatch, + name + ) + ); + } + } +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_override(object_id_type & t, int){ + t = object_id_type(this->This()->gimpl->rv.object_id); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_override(version_type & t, int){ + t = version_type(this->This()->gimpl->rv.version); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_override(class_id_type & t, int){ + t = class_id_type(this->This()->gimpl->rv.class_id); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_iarchive<Archive>::load_override(tracking_type & t, int){ + t = this->This()->gimpl->rv.tracking_level; +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) : + detail::common_iarchive<Archive>(flags), + depth(0) +{} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_xml_iarchive<Archive>::~basic_xml_iarchive(){} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/basic_xml_oarchive.ipp b/boost_1_45_0/boost/archive/impl/basic_xml_oarchive.ipp new file mode 100644 index 0000000..e2cc8d4 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/basic_xml_oarchive.ipp
@@ -0,0 +1,275 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// basic_xml_oarchive.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <algorithm> +#include <cstddef> // NULL +#include <cstring> +#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__) +namespace std{ + using ::strlen; +} // namespace std +#endif + +#include <boost/archive/basic_xml_archive.hpp> +#include <boost/archive/basic_xml_oarchive.hpp> +#include <boost/archive/xml_archive_exception.hpp> +#include <boost/detail/no_exceptions_support.hpp> + +namespace boost { +namespace archive { + +namespace detail { +template<class CharType> +struct XML_name { + void operator()(CharType t) const{ + const unsigned char lookup_table[] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0, // -. + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, // 0-9 + 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // A- + 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, // -Z _ + 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // a- + 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, // -z + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + }; + if((unsigned)t > 127) + return; + if(0 == lookup_table[(unsigned)t]) + boost::serialization::throw_exception( + xml_archive_exception( + xml_archive_exception::xml_archive_tag_name_error + ) + ); + } +}; + +} // namespace detail + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implemenations of functions common to both types of xml output + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::write_attribute( + const char *attribute_name, + int t, + const char *conjunction +){ + this->This()->put(' '); + this->This()->put(attribute_name); + this->This()->put(conjunction); + this->This()->save(t); + this->This()->put('"'); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::write_attribute( + const char *attribute_name, + const char *key +){ + this->This()->put(' '); + this->This()->put(attribute_name); + this->This()->put("=\""); + this->This()->save(key); + this->This()->put('"'); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::indent(){ + int i; + for(i = depth; i-- > 0;) + this->This()->put('\t'); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_start(const char *name) +{ + if(NULL == name) + return; + + // be sure name has no invalid characters + std::for_each(name, name + std::strlen(name), detail::XML_name<const char>()); + + end_preamble(); + if(depth > 0){ + this->This()->put('\n'); + indent(); + } + ++depth; + this->This()->put('<'); + this->This()->save(name); + pending_preamble = true; + indent_next = false; +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_end(const char *name) +{ + if(NULL == name) + return; + + // be sure name has no invalid characters + std::for_each(name, name + std::strlen(name), detail::XML_name<const char>()); + + end_preamble(); + --depth; + if(indent_next){ + this->This()->put('\n'); + indent(); + } + indent_next = true; + this->This()->put("</"); + this->This()->save(name); + this->This()->put('>'); + if(0 == depth) + this->This()->put('\n'); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::end_preamble(){ + if(pending_preamble){ + this->This()->put('>'); + pending_preamble = false; + } +} +#if 0 +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int) +{ + int i = t.t; // extra .t is for borland + write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_"); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override( + const object_reference_type & t, + int +){ + int i = t.t; // extra .t is for borland + write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_"); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const version_type & t, int) +{ + int i = t.t; // extra .t is for borland + write_attribute(BOOST_ARCHIVE_XML_VERSION(), i); +} +#endif + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int) +{ + // borland doesn't do conversion of STRONG_TYPEDEFs very well + const unsigned int i = t; + write_attribute(BOOST_ARCHIVE_XML_OBJECT_ID(), i, "=\"_"); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override( + const object_reference_type & t, + int +){ + const unsigned int i = t; + write_attribute(BOOST_ARCHIVE_XML_OBJECT_REFERENCE(), i, "=\"_"); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const version_type & t, int) +{ + const unsigned int i = t; + write_attribute(BOOST_ARCHIVE_XML_VERSION(), i); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const class_id_type & t, int) +{ + write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override( + const class_id_reference_type & t, + int +){ + write_attribute(BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE(), t); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override( + const class_id_optional_type & t, + int +){ + write_attribute(BOOST_ARCHIVE_XML_CLASS_ID(), t); +} +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const class_name_type & t, int) +{ + const char * key = t; + if(NULL == key) + return; + write_attribute(BOOST_ARCHIVE_XML_CLASS_NAME(), key); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::save_override(const tracking_type & t, int) +{ + write_attribute(BOOST_ARCHIVE_XML_TRACKING(), t.t); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(void) +basic_xml_oarchive<Archive>::init(){ + // xml header + this->This()->put("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"); + this->This()->put("<!DOCTYPE boost_serialization>\n"); + // xml document wrapper - outer root + this->This()->put("<boost_serialization"); + write_attribute("signature", BOOST_ARCHIVE_SIGNATURE()); + write_attribute("version", BOOST_ARCHIVE_VERSION()); + this->This()->put(">\n"); +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_xml_oarchive<Archive>::basic_xml_oarchive(unsigned int flags) : + detail::common_oarchive<Archive>(flags), + depth(0), + indent_next(false), + pending_preamble(false) +{ +} + +template<class Archive> +BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) +basic_xml_oarchive<Archive>::~basic_xml_oarchive(){ + if(0 == (this->get_flags() & no_header)){ + BOOST_TRY{ + this->This()->put("</boost_serialization>\n"); + } + BOOST_CATCH(...){} + BOOST_CATCH_END + } +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/text_iarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/text_iarchive_impl.ipp new file mode 100644 index 0000000..f14c0d8 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/text_iarchive_impl.ipp
@@ -0,0 +1,128 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_iarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +////////////////////////////////////////////////////////////////////// +// implementation of basic_text_iprimitive overrides for the combination +// of template parameters used to implement a text_iprimitive + +#include <cstddef> // size_t, NULL +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/detail/workaround.hpp> // RogueWave + +#include <boost/archive/text_iarchive.hpp> + +namespace boost { +namespace archive { + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::load(char *s) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + // Works on all tested platforms + is.read(s, size); + s[size] = '\0'; +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::load(std::string &s) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != s.data()) + #endif + s.resize(size); + if(0 < size) + is.read(&(*s.begin()), size); +} + +#ifndef BOOST_NO_CWCHAR +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::load(wchar_t *ws) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + is.read((char *)ws, size * sizeof(wchar_t)/sizeof(char)); + ws[size] = L'\0'; +} +#endif // BOOST_NO_INTRINSIC_WCHAR_T + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::load(std::wstring &ws) +{ + std::size_t size; + * this->This() >> size; + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != ws.data()) + #endif + ws.resize(size); + // skip separating space + is.get(); + is.read((char *)ws.data(), size * sizeof(wchar_t)/sizeof(char)); +} + +#endif // BOOST_NO_STD_WSTRING +#endif // BOOST_NO_CWCHAR + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::load_override(class_name_type & t, int){ + basic_text_iarchive<Archive>::load_override(t, 0); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_iarchive_impl<Archive>::init(){ + basic_text_iarchive<Archive>::init(); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) +text_iarchive_impl<Archive>::text_iarchive_impl( + std::istream & is, + unsigned int flags +) : + basic_text_iprimitive<std::istream>( + is, + 0 != (flags & no_codecvt) + ), + basic_text_iarchive<Archive>(flags) +{ + if(0 == (flags & no_header)) + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) + this->init(); + #else + this->basic_text_iarchive<Archive>::init(); + #endif +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/text_oarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/text_oarchive_impl.ipp new file mode 100644 index 0000000..2df0b46 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/text_oarchive_impl.ipp
@@ -0,0 +1,124 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_oarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <string> +#include <boost/config.hpp> +#include <locale> +#include <cstddef> // size_t + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#ifndef BOOST_NO_CWCHAR +#include <cwchar> +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ using ::wcslen; } +#endif +#endif + +#include <boost/archive/add_facet.hpp> +#include <boost/archive/text_oarchive.hpp> + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// implementation of basic_text_oprimitive overrides for the combination +// of template parameters used to create a text_oprimitive + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_oarchive_impl<Archive>::save(const char * s) +{ + const std::size_t len = std::ostream::traits_type::length(s); + *this->This() << len; + this->This()->newtoken(); + os << s; +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_oarchive_impl<Archive>::save(const std::string &s) +{ + const std::size_t size = s.size(); + *this->This() << size; + this->This()->newtoken(); + os << s; +} + +#ifndef BOOST_NO_CWCHAR +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_oarchive_impl<Archive>::save(const wchar_t * ws) +{ + const std::size_t l = std::wcslen(ws); + * this->This() << l; + this->This()->newtoken(); + os.write((const char *)ws, l * sizeof(wchar_t)/sizeof(char)); +} +#endif + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_oarchive_impl<Archive>::save(const std::wstring &ws) +{ + const std::size_t l = ws.size(); + * this->This() << l; + this->This()->newtoken(); + os.write((const char *)(ws.data()), l * sizeof(wchar_t)/sizeof(char)); +} +#endif +#endif // BOOST_NO_CWCHAR + +template<class Archive> +BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) +text_oarchive_impl<Archive>::text_oarchive_impl( + std::ostream & os, + unsigned int flags +) : + basic_text_oprimitive<std::ostream>( + os, + 0 != (flags & no_codecvt) + ), + basic_text_oarchive<Archive>(flags) +{ + if(0 == (flags & no_header)) + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) + this->init(); + #else + this->basic_text_oarchive<Archive>::init(); + #endif +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +text_oarchive_impl<Archive>::save_binary(const void *address, std::size_t count){ + put('\n'); + this->end_preamble(); + #if ! defined(__MWERKS__) + this->basic_text_oprimitive<std::ostream>::save_binary( + #else + this->basic_text_oprimitive::save_binary( + #endif + address, + count + ); + this->delimiter = this->eol; +} + +} // namespace archive +} // namespace boost +
diff --git a/boost_1_45_0/boost/archive/impl/text_wiarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/text_wiarchive_impl.ipp new file mode 100644 index 0000000..6938c22 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/text_wiarchive_impl.ipp
@@ -0,0 +1,118 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_text_wiarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // size_t, NULL + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/detail/workaround.hpp> // fixup for RogueWave + +#ifndef BOOST_NO_STD_WSTREAMBUF +#include <boost/archive/basic_text_iprimitive.hpp> + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// implementation of wiprimtives functions +// +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_wiarchive_impl<Archive>::load(char *s) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + while(size-- > 0){ + *s++ = is.narrow(is.get(), '\0'); + } + *s = '\0'; +} + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_wiarchive_impl<Archive>::load(std::string &s) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != s.data()) + #endif + s.resize(0); + s.reserve(size); + while(size-- > 0){ + int x = is.narrow(is.get(), '\0'); + s += x; + } +} + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_wiarchive_impl<Archive>::load(wchar_t *s) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + // Works on all tested platforms + is.read(s, size); + s[size] = L'\0'; +} +#endif + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_wiarchive_impl<Archive>::load(std::wstring &ws) +{ + std::size_t size; + * this->This() >> size; + // skip separating space + is.get(); + // borland complains about resize + // borland de-allocator fixup + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != ws.data()) + #endif + ws.resize(size); + // note breaking a rule here - is this a problem on some platform + is.read(const_cast<wchar_t *>(ws.data()), size); +} +#endif + +template<class Archive> +BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) +text_wiarchive_impl<Archive>::text_wiarchive_impl( + std::wistream & is, + unsigned int flags +) : + basic_text_iprimitive<std::wistream>( + is, + 0 != (flags & no_codecvt) + ), + basic_text_iarchive<Archive>(flags) +{ + if(0 == (flags & no_header)) + basic_text_iarchive<Archive>::init(); +} + +} // archive +} // boost + +#endif // BOOST_NO_STD_WSTREAMBUF
diff --git a/boost_1_45_0/boost/archive/impl/text_woarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/text_woarchive_impl.ipp new file mode 100644 index 0000000..6683f52 --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/text_woarchive_impl.ipp
@@ -0,0 +1,85 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_woarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifndef BOOST_NO_STD_WSTREAMBUF + +#include <cstring> +#include <cstddef> // size_t +#if defined(BOOST_NO_STDC_NAMESPACE) && ! defined(__LIBCOMO__) +namespace std{ + using ::strlen; + using ::size_t; +} // namespace std +#endif + +#include <ostream> + +#include <boost/archive/text_woarchive.hpp> + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// implementation of woarchive functions +// +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_woarchive_impl<Archive>::save(const char *s) +{ + // note: superfluous local variable fixes borland warning + const std::size_t size = std::strlen(s); + * this->This() << size; + this->This()->newtoken(); + while(*s != '\0') + os.put(os.widen(*s++)); +} + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_woarchive_impl<Archive>::save(const std::string &s) +{ + const std::size_t size = s.size(); + * this->This() << size; + this->This()->newtoken(); + const char * cptr = s.data(); + for(std::size_t i = size; i-- > 0;) + os.put(os.widen(*cptr++)); +} + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_woarchive_impl<Archive>::save(const wchar_t *ws) +{ + const std::size_t size = std::wostream::traits_type::length(ws); + * this->This() << size; + this->This()->newtoken(); + os.write(ws, size); +} +#endif + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_WARCHIVE_DECL(void) +text_woarchive_impl<Archive>::save(const std::wstring &ws) +{ + const std::size_t size = ws.length(); + * this->This() << size; + this->This()->newtoken(); + os.write(ws.data(), size); +} +#endif + +} // namespace archive +} // namespace boost + +#endif +
diff --git a/boost_1_45_0/boost/archive/impl/xml_iarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/xml_iarchive_impl.ipp new file mode 100644 index 0000000..c7cbc7f --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/xml_iarchive_impl.ipp
@@ -0,0 +1,204 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_iarchive_impl.cpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <cstring> // memcpy +#include <cstddef> // NULL +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; +} // namespace std +#endif + +#ifndef BOOST_NO_CWCHAR +#include <cstdlib> // mbtowc +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::mbtowc; + } // namespace std +#endif +#endif // BOOST_NO_CWCHAR + +#include <boost/detail/workaround.hpp> // RogueWave and Dinkumware +#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) +#include <boost/archive/dinkumware.hpp> +#endif + +#include <boost/detail/no_exceptions_support.hpp> + +#include <boost/archive/xml_archive_exception.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> +#include <boost/archive/basic_xml_archive.hpp> +#include <boost/archive/xml_iarchive.hpp> + +#include "basic_xml_grammar.hpp" + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implemenations of functions specific to char archives + +// wide char stuff used by char archives + +#ifndef BOOST_NO_CWCHAR +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::load(std::wstring &ws){ + std::string s; + bool result = gimpl->parse_string(is, s); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != ws.data()) + #endif + ws.resize(0); + const char * start = s.data(); + const char * end = start + s.size(); + while(start < end){ + wchar_t wc; + int resultx = std::mbtowc(&wc, start, end - start); + if(0 < resultx){ + start += resultx; + ws += wc; + continue; + } + boost::serialization::throw_exception( + iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + ) + ); + } +} +#endif // BOOST_NO_STD_WSTRING + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::load(wchar_t * ws){ + std::string s; + bool result = gimpl->parse_string(is, s); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + + const char * start = s.data(); + const char * end = start + s.size(); + while(start < end){ + wchar_t wc; + int result = std::mbtowc(&wc, start, end - start); + if(0 < result){ + start += result; + *ws++ = wc; + continue; + } + boost::serialization::throw_exception( + iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + ) + ); + } + *ws = L'\0'; +} +#endif // BOOST_NO_INTRINSIC_WCHAR_T + +#endif // BOOST_NO_CWCHAR + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::load(std::string &s){ + bool result = gimpl->parse_string(is, s); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::load(char * s){ + std::string tstring; + bool result = gimpl->parse_string(is, tstring); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + std::memcpy(s, tstring.data(), tstring.size()); + s[tstring.size()] = 0; +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::load_override(class_name_type & t, int){ + const std::string & s = gimpl->rv.class_name; + if(s.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_class_name) + ); + char * tptr = t; + std::memcpy(tptr, s.data(), s.size()); + tptr[s.size()] = '\0'; +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_iarchive_impl<Archive>::init(){ + gimpl->init(is); + this->set_library_version( + library_version_type(gimpl->rv.version) + ); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_iarchive_impl<Archive>::xml_iarchive_impl( + std::istream &is_, + unsigned int flags +) : + basic_text_iprimitive<std::istream>( + is_, + 0 != (flags & no_codecvt) + ), + basic_xml_iarchive<Archive>(flags), + gimpl(new xml_grammar()) +{ + if(0 == (flags & no_header)){ + BOOST_TRY{ + init(); + } + BOOST_CATCH(...){ + delete gimpl; + #ifndef BOOST_NO_EXCEPTIONS + throw; // re-throw + #endif + } + BOOST_CATCH_END + } +} + +template<class Archive> +BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_iarchive_impl<Archive>::~xml_iarchive_impl(){ + if(0 == (this->get_flags() & no_header)){ + BOOST_TRY{ + gimpl->windup(is); + } + BOOST_CATCH(...){} + BOOST_CATCH_END + } + delete gimpl; +} +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/xml_oarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/xml_oarchive_impl.ipp new file mode 100644 index 0000000..8ab954f --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/xml_oarchive_impl.ipp
@@ -0,0 +1,117 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_oarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <ostream> +#include <iomanip> +#include <algorithm> +#include <string> + +#include <cstring> // strlen +#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::strlen; +} // namespace std +#endif + +#include <boost/archive/iterators/xml_escape.hpp> +#include <boost/archive/iterators/ostream_iterator.hpp> + +#ifndef BOOST_NO_CWCHAR +#include <boost/archive/wcslen.hpp> +#include <boost/archive/iterators/mb_from_wchar.hpp> +#endif + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implemenations of functions specific to char archives + +// wide char stuff used by char archives +#ifndef BOOST_NO_CWCHAR +// copy chars to output escaping to xml and translating wide chars to mb chars +template<class InputIterator> +void save_iterator(std::ostream &os, InputIterator begin, InputIterator end){ + typedef boost::archive::iterators::mb_from_wchar< + boost::archive::iterators::xml_escape<InputIterator> + > translator; + std::copy( + translator(BOOST_MAKE_PFTO_WRAPPER(begin)), + translator(BOOST_MAKE_PFTO_WRAPPER(end)), + boost::archive::iterators::ostream_iterator<char>(os) + ); +} + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_oarchive_impl<Archive>::save(const std::wstring & ws){ +// at least one library doesn't typedef value_type for strings +// so rather than using string directly make a pointer iterator out of it +// save_iterator(os, ws.data(), ws.data() + std::wcslen(ws.data())); + save_iterator(os, ws.data(), ws.data() + ws.size()); +} +#endif + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_oarchive_impl<Archive>::save(const wchar_t * ws){ + save_iterator(os, ws, ws + std::wcslen(ws)); +} +#endif + +#endif // BOOST_NO_CWCHAR + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_oarchive_impl<Archive>::save(const std::string & s){ +// at least one library doesn't typedef value_type for strings +// so rather than using string directly make a pointer iterator out of it + typedef boost::archive::iterators::xml_escape< + const char * + > xml_escape_translator; + std::copy( + xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s.data())), + xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s.data()+ s.size())), + boost::archive::iterators::ostream_iterator<char>(os) + ); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(void) +xml_oarchive_impl<Archive>::save(const char * s){ + typedef boost::archive::iterators::xml_escape< + const char * + > xml_escape_translator; + std::copy( + xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s)), + xml_escape_translator(BOOST_MAKE_PFTO_WRAPPER(s + std::strlen(s))), + boost::archive::iterators::ostream_iterator<char>(os) + ); +} + +template<class Archive> +BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_oarchive_impl<Archive>::xml_oarchive_impl( + std::ostream & os_, + unsigned int flags +) : + basic_text_oprimitive<std::ostream>( + os_, + 0 != (flags & no_codecvt) + ), + basic_xml_oarchive<Archive>(flags) +{ + if(0 == (flags & no_header)) + this->init(); +} + +} // namespace archive +} // namespace boost
diff --git a/boost_1_45_0/boost/archive/impl/xml_wiarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/xml_wiarchive_impl.ipp new file mode 100644 index 0000000..58498db --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/xml_wiarchive_impl.ipp
@@ -0,0 +1,206 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_wiprimitive.cpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME + +#include <cstring> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; +} //std +#endif + +#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings +#ifndef BOOST_NO_STD_WSTREAMBUF + +#include <cassert> +#include <algorithm> + +#include <boost/detail/workaround.hpp> // Dinkumware and RogueWave +#if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) +#include <boost/archive/dinkumware.hpp> +#endif + +#include <boost/io/ios_state.hpp> +#include <boost/detail/no_exceptions_support.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/serialization/string.hpp> +#include <boost/archive/add_facet.hpp> +#include <boost/archive/xml_archive_exception.hpp> +#include <boost/archive/detail/utf8_codecvt_facet.hpp> + +#include <boost/archive/iterators/mb_from_wchar.hpp> + +#include <boost/archive/basic_xml_archive.hpp> +#include <boost/archive/xml_wiarchive.hpp> + +#include "basic_xml_grammar.hpp" + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implemenations of functions specific to wide char archives + +namespace { // anonymous + +void copy_to_ptr(char * s, const std::wstring & ws){ + std::copy( + iterators::mb_from_wchar<std::wstring::const_iterator>( + BOOST_MAKE_PFTO_WRAPPER(ws.begin()) + ), + iterators::mb_from_wchar<std::wstring::const_iterator>( + BOOST_MAKE_PFTO_WRAPPER(ws.end()) + ), + s + ); + s[ws.size()] = 0; +} + +} // anonymous + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::load(std::string & s){ + std::wstring ws; + bool result = gimpl->parse_string(is, ws); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + #if BOOST_WORKAROUND(_RWSTD_VER, BOOST_TESTED_AT(20101)) + if(NULL != s.data()) + #endif + s.resize(0); + s.reserve(ws.size()); + std::copy( + iterators::mb_from_wchar<std::wstring::iterator>( + BOOST_MAKE_PFTO_WRAPPER(ws.begin()) + ), + iterators::mb_from_wchar<std::wstring::iterator>( + BOOST_MAKE_PFTO_WRAPPER(ws.end()) + ), + std::back_inserter(s) + ); +} + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::load(std::wstring & ws){ + bool result = gimpl->parse_string(is, ws); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); +} +#endif + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::load(char * s){ + std::wstring ws; + bool result = gimpl->parse_string(is, ws); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + copy_to_ptr(s, ws); +} + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::load(wchar_t * ws){ + std::wstring twstring; + bool result = gimpl->parse_string(is, twstring); + if(! result) + boost::serialization::throw_exception( + xml_archive_exception(xml_archive_exception::xml_archive_parsing_error) + ); + std::memcpy(ws, twstring.c_str(), twstring.size()); + ws[twstring.size()] = L'\0'; +} +#endif + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::load_override(class_name_type & t, int){ + const std::wstring & ws = gimpl->rv.class_name; + if(ws.size() > BOOST_SERIALIZATION_MAX_KEY_SIZE - 1) + boost::serialization::throw_exception( + archive_exception(archive_exception::invalid_class_name) + ); + copy_to_ptr(t, ws); +} + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_wiarchive_impl<Archive>::init(){ + gimpl->init(is); + this->set_library_version( + library_version_type(gimpl->rv.version) + ); +} + +template<class Archive> +BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_wiarchive_impl<Archive>::xml_wiarchive_impl( + std::wistream &is_, + unsigned int flags +) : + basic_text_iprimitive<std::wistream>( + is_, + true // don't change the codecvt - use the one below + ), + basic_xml_iarchive<Archive>(flags), + gimpl(new xml_wgrammar()) +{ + if(0 == (flags & no_codecvt)){ + archive_locale.reset( + add_facet( + std::locale::classic(), + new boost::archive::detail::utf8_codecvt_facet + ) + ); + is.imbue(* archive_locale); + } + if(0 == (flags & no_header)){ + BOOST_TRY{ + this->init(); + } + BOOST_CATCH(...){ + delete gimpl; + #ifndef BOOST_NO_EXCEPTIONS + throw; // re-throw + #endif + } + BOOST_CATCH_END + } +} + +template<class Archive> +BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_wiarchive_impl<Archive>::~xml_wiarchive_impl(){ + if(0 == (this->get_flags() & no_header)){ + BOOST_TRY{ + gimpl->windup(is); + } + BOOST_CATCH(...){} + BOOST_CATCH_END + } + delete gimpl; +} + +} // namespace archive +} // namespace boost + +#endif // BOOST_NO_STD_WSTREAMBUF
diff --git a/boost_1_45_0/boost/archive/impl/xml_woarchive_impl.ipp b/boost_1_45_0/boost/archive/impl/xml_woarchive_impl.ipp new file mode 100644 index 0000000..3bf42bd --- /dev/null +++ b/boost_1_45_0/boost/archive/impl/xml_woarchive_impl.ipp
@@ -0,0 +1,160 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_woarchive_impl.ipp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/config.hpp> +#ifndef BOOST_NO_STD_WSTREAMBUF + +#include <ostream> +#include <string> +#include <algorithm> +#include <locale> + +#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings + // for BOOST_DEDUCED_TYPENAME +#include <cstring> // strlen +#include <cstdlib> // mbtowc +#include <cwchar> // wcslen + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::strlen; + #if ! defined(BOOST_NO_INTRINSIC_WCHAR_T) + using ::mbtowc; + using ::wcslen; + #endif +} // namespace std +#endif + +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/iterators/xml_escape.hpp> +#include <boost/archive/iterators/wchar_from_mb.hpp> +#include <boost/archive/iterators/ostream_iterator.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> + +#include <boost/archive/add_facet.hpp> +#include <boost/archive/detail/utf8_codecvt_facet.hpp> + +namespace boost { +namespace archive { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implemenations of functions specific to wide char archives + +// copy chars to output escaping to xml and widening characters as we go +template<class InputIterator> +void save_iterator(std::wostream &os, InputIterator begin, InputIterator end){ + typedef iterators::wchar_from_mb< + iterators::xml_escape<InputIterator> + > xmbtows; + std::copy( + xmbtows(BOOST_MAKE_PFTO_WRAPPER(begin)), + xmbtows(BOOST_MAKE_PFTO_WRAPPER(end)), + boost::archive::iterators::ostream_iterator<wchar_t>(os) + ); +} + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_woarchive_impl<Archive>::save(const std::string & s){ + // note: we don't use s.begin() and s.end() because dinkumware + // doesn't have string::value_type defined. So use a wrapper + // around these values to implement the definitions. + const char * begin = s.data(); + const char * end = begin + s.size(); + save_iterator(os, begin, end); +} + +#ifndef BOOST_NO_STD_WSTRING +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_woarchive_impl<Archive>::save(const std::wstring & ws){ +#if 0 + typedef iterators::xml_escape<std::wstring::const_iterator> xmbtows; + std::copy( + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.begin())), + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.end())), + boost::archive::iterators::ostream_iterator<wchar_t>(os) + ); +#endif + typedef iterators::xml_escape<const wchar_t *> xmbtows; + std::copy( + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data())), + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws.data() + ws.size())), + boost::archive::iterators::ostream_iterator<wchar_t>(os) + ); +} +#endif //BOOST_NO_STD_WSTRING + +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_woarchive_impl<Archive>::save(const char * s){ + save_iterator(os, s, s + std::strlen(s)); +} + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<class Archive> +BOOST_WARCHIVE_DECL(void) +xml_woarchive_impl<Archive>::save(const wchar_t * ws){ + os << ws; + typedef iterators::xml_escape<const wchar_t *> xmbtows; + std::copy( + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws)), + xmbtows(BOOST_MAKE_PFTO_WRAPPER(ws + std::wcslen(ws))), + boost::archive::iterators::ostream_iterator<wchar_t>(os) + ); +} +#endif + +template<class Archive> +BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) +xml_woarchive_impl<Archive>::xml_woarchive_impl( + std::wostream & os_, + unsigned int flags +) : + basic_text_oprimitive<std::wostream>( + os_, + true // don't change the codecvt - use the one below + ), + basic_xml_oarchive<Archive>(flags) +{ + // Standard behavior is that imbue can be called + // a) before output is invoked or + // b) after flush has been called. This prevents one-to-many + // transforms (such as one to many transforms from getting + // mixed up. Unfortunately, STLPort doesn't respect b) above + // so the restoration of the original archive locale done by + // the locale_saver doesn't get processed, + // before the current one is destroyed. + // so the codecvt doesn't get replaced with the orginal + // so closing the stream invokes codecvt::do_unshift + // so it crashes because the corresponding locale that contained + // the codecvt isn't around any more. + // we can hack around this by using a static codecvt that never + // gets destroyed. + if(0 == (flags & no_codecvt)){ + boost::archive::detail::utf8_codecvt_facet *pfacet; + #if defined(__SGI_STL_PORT) + static boost::archive::detail::utf8_codecvt_facet + facet(static_cast<size_t>(1)); + pfacet = & facet; + #else + pfacet = new boost::archive::detail::utf8_codecvt_facet; + #endif + archive_locale.reset(add_facet(std::locale::classic(), pfacet)); + os.imbue(* archive_locale); + } + if(0 == (flags & no_header)) + this->init(); +} + +} // namespace archive +} // namespace boost + +#endif //BOOST_NO_STD_WSTREAMBUF
diff --git a/boost_1_45_0/boost/archive/iterators/base64_exception.hpp b/boost_1_45_0/boost/archive/iterators/base64_exception.hpp new file mode 100644 index 0000000..eb2d2e1 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/base64_exception.hpp
@@ -0,0 +1,68 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP +#define BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// base64_exception.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifndef BOOST_NO_EXCEPTIONS +#include <exception> + +#include <cassert> + +namespace boost { +namespace archive { +namespace iterators { + +////////////////////////////////////////////////////////////////////// +// exceptions thrown by base64s +// +class base64_exception : public std::exception +{ +public: + typedef enum { + invalid_code, // attempt to encode a value > 6 bits + invalid_character, // decode a value not in base64 char set + other_exception + } exception_code; + exception_code code; + + base64_exception(exception_code c = other_exception) : code(c) + {} + + virtual const char *what( ) const throw( ) + { + const char *msg = "unknown exception code"; + switch(code){ + case invalid_code: + msg = "attempt to encode a value > 6 bits"; + break; + case invalid_character: + msg = "attempt to decode a value not in base64 char set"; + break; + default: + assert(false); + break; + } + return msg; + } +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif //BOOST_NO_EXCEPTIONS +#endif //BOOST_ARCHIVE_ITERATORS_ARCHIVE_EXCEPTION_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/base64_from_binary.hpp b/boost_1_45_0/boost/archive/iterators/base64_from_binary.hpp new file mode 100644 index 0000000..4e6023a --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/base64_from_binary.hpp
@@ -0,0 +1,112 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP +#define BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// base64_from_binary.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <cstddef> // size_t +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/serialization/pfto.hpp> + +#include <boost/iterator/transform_iterator.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// convert binary integers to base64 characters + +namespace detail { + +template<class CharType> +struct from_6_bit { + typedef CharType result_type; + CharType operator()(CharType t) const{ + const char * lookup_table = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/"; + assert(t < 64); + return lookup_table[static_cast<size_t>(t)]; + } +}; + +} // namespace detail + +// note: what we would like to do is +// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type> +// typedef transform_iterator< +// from_6_bit<CharType>, +// transform_width<Base, 6, sizeof(Base::value_type) * 8, CharType> +// > base64_from_binary; +// but C++ won't accept this. Rather than using a "type generator" and +// using a different syntax, make a derivation which should be equivalent. +// +// Another issue addressed here is that the transform_iterator doesn't have +// a templated constructor. This makes it incompatible with the dataflow +// ideal. This is also addressed here. + +//template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type> +template< + class Base, + class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type +> +class base64_from_binary : + public transform_iterator< + detail::from_6_bit<CharType>, + Base + > +{ + friend class boost::iterator_core_access; + typedef transform_iterator< + BOOST_DEDUCED_TYPENAME detail::from_6_bit<CharType>, + Base + > super_t; + +public: + // make composible buy using templated constructor + template<class T> + base64_from_binary(BOOST_PFTO_WRAPPER(T) start) : + super_t( + Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))), + detail::from_6_bit<CharType>() + ) + {} + // intel 7.1 doesn't like default copy constructor + base64_from_binary(const base64_from_binary & rhs) : + super_t( + Base(rhs.base_reference()), + detail::from_6_bit<CharType>() + ) + {} +// base64_from_binary(){}; +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_BASE64_FROM_BINARY_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/binary_from_base64.hpp b/boost_1_45_0/boost/archive/iterators/binary_from_base64.hpp new file mode 100644 index 0000000..d14439f --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/binary_from_base64.hpp
@@ -0,0 +1,120 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP +#define BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// binary_from_base64.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/static_assert.hpp> + +#include <boost/iterator/transform_iterator.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// convert base64 characters to binary data + +namespace detail { + +template<class CharType> +struct to_6_bit { + typedef CharType result_type; + CharType operator()(CharType t) const{ + const char lookup_table[] = { + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, + 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, + -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, + 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1 + }; + // metrowerks trips this assertion - how come? + #if ! defined(__MWERKS__) + BOOST_STATIC_ASSERT(128 == sizeof(lookup_table)); + #endif + signed char value = -1; + if((unsigned)t <= 127) + value = lookup_table[(unsigned)t]; + if(-1 == value) + boost::serialization::throw_exception( + dataflow_exception(dataflow_exception::invalid_base64_character) + ); + return value; + } +}; + +} // namespace detail + +// note: what we would like to do is +// template<class Base, class CharType = BOOST_DEDUCED_TYPENAME Base::value_type> +// typedef transform_iterator< +// from_6_bit<CharType>, +// transform_width<Base, 6, sizeof(Base::value_type) * 8, CharType> +// > base64_from_binary; +// but C++ won't accept this. Rather than using a "type generator" and +// using a different syntax, make a derivation which should be equivalent. +// +// Another issue addressed here is that the transform_iterator doesn't have +// a templated constructor. This makes it incompatible with the dataflow +// ideal. This is also addressed here. + +template< + class Base, + class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type +> +class binary_from_base64 : public + transform_iterator< + detail::to_6_bit<CharType>, + Base + > +{ + friend class boost::iterator_core_access; + typedef transform_iterator< + detail::to_6_bit<CharType>, + Base + > super_t; +public: + // make composible buy using templated constructor + template<class T> + binary_from_base64(BOOST_PFTO_WRAPPER(T) start) : + super_t( + Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))), + detail::to_6_bit<CharType>() + ) + {} + // intel 7.1 doesn't like default copy constructor + binary_from_base64(const binary_from_base64 & rhs) : + super_t( + Base(rhs.base_reference()), + detail::to_6_bit<CharType>() + ) + {} +// binary_from_base64(){}; +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_BINARY_FROM_BASE64_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/dataflow.hpp b/boost_1_45_0/boost/archive/iterators/dataflow.hpp new file mode 100644 index 0000000..7958482 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/dataflow.hpp
@@ -0,0 +1,105 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP +#define BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// dataflow.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/plus.hpp> +#include <boost/mpl/int.hpp> + +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/is_base_and_derived.hpp> +#include <boost/type_traits/is_pointer.hpp> +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/iterator_traits.hpp> +#include <boost/static_assert.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +// poor man's tri-state +struct tri_state { + enum state_enum { + is_false = false, + is_true = true, + is_indeterminant + } m_state; + // convert to bool + operator bool (){ + assert(is_indeterminant != m_state); + return is_true == m_state ? true : false; + } + // assign from bool + tri_state & operator=(bool rhs) { + m_state = rhs ? is_true : is_false; + return *this; + } + tri_state(bool rhs) : + m_state(rhs ? is_true : is_false) + {} + tri_state(state_enum state) : + m_state(state) + {} + bool operator==(const tri_state & rhs) const { + return m_state == rhs.m_state; + } + bool operator!=(const tri_state & rhs) const { + return m_state != rhs.m_state; + } +}; + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implement functions common to dataflow iterators +template<class Derived> +class dataflow { + bool m_eoi; +protected: + // test for iterator equality + tri_state equal(const Derived & rhs) const { + if(m_eoi && rhs.m_eoi) + return true; + if(m_eoi || rhs.m_eoi) + return false; + return tri_state(tri_state::is_indeterminant); + } + void eoi(bool tf){ + m_eoi = tf; + } + bool eoi() const { + return m_eoi; + } +public: + dataflow(bool tf) : + m_eoi(tf) + {} + dataflow() : // used for iterator end + m_eoi(true) + {} +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_DATAFLOW_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/dataflow_exception.hpp b/boost_1_45_0/boost/archive/iterators/dataflow_exception.hpp new file mode 100644 index 0000000..765661e --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/dataflow_exception.hpp
@@ -0,0 +1,80 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP +#define BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// dataflow_exception.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifndef BOOST_NO_EXCEPTIONS +#include <exception> +#endif //BOOST_NO_EXCEPTIONS + +#include <cassert> + +namespace boost { +namespace archive { +namespace iterators { + +////////////////////////////////////////////////////////////////////// +// exceptions thrown by dataflows +// +class dataflow_exception : public std::exception +{ +public: + typedef enum { + invalid_6_bitcode, + invalid_base64_character, + invalid_xml_escape_sequence, + comparison_not_permitted, + invalid_conversion, + other_exception + } exception_code; + exception_code code; + + dataflow_exception(exception_code c = other_exception) : code(c) + {} + + virtual const char *what( ) const throw( ) + { + const char *msg = "unknown exception code"; + switch(code){ + case invalid_6_bitcode: + msg = "attempt to encode a value > 6 bits"; + break; + case invalid_base64_character: + msg = "attempt to decode a value not in base64 char set"; + break; + case invalid_xml_escape_sequence: + msg = "invalid xml escape_sequence"; + break; + case comparison_not_permitted: + msg = "cannot invoke iterator comparison now"; + break; + case invalid_conversion: + msg = "invalid multbyte/wide char conversion"; + break; + default: + assert(false); + break; + } + return msg; + } +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif //BOOST_ARCHIVE_ITERATORS_DATAFLOW_EXCEPTION_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/escape.hpp b/boost_1_45_0/boost/archive/iterators/escape.hpp new file mode 100644 index 0000000..b11d1a6 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/escape.hpp
@@ -0,0 +1,115 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP +#define BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// escape.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // NULL + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/iterator_traits.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// insert escapes into text + +template<class Derived, class Base> +class escape : + public boost::iterator_adaptor< + Derived, + Base, + BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type, + single_pass_traversal_tag, + BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type + > +{ + typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type base_value_type; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<Base>::type reference_type; + friend class boost::iterator_core_access; + + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + Derived, + Base, + base_value_type, + single_pass_traversal_tag, + base_value_type + > super_t; + + typedef escape<Derived, Base> this_t; + + void dereference_impl() { + m_current_value = static_cast<Derived *>(this)->fill(m_bnext, m_bend); + m_full = true; + } + + //Access the value referred to + reference_type dereference() const { + if(!m_full) + const_cast<this_t *>(this)->dereference_impl(); + return m_current_value; + } + + bool equal(const this_t & rhs) const { + if(m_full){ + if(! rhs.m_full) + const_cast<this_t *>(& rhs)->dereference_impl(); + } + else{ + if(rhs.m_full) + const_cast<this_t *>(this)->dereference_impl(); + } + if(m_bnext != rhs.m_bnext) + return false; + if(this->base_reference() != rhs.base_reference()) + return false; + return true; + } + + void increment(){ + if(++m_bnext < m_bend){ + m_current_value = *m_bnext; + return; + } + ++(this->base_reference()); + m_bnext = NULL; + m_bend = NULL; + m_full = false; + } + + // buffer to handle pending characters + const base_value_type *m_bnext; + const base_value_type *m_bend; + bool m_full; + base_value_type m_current_value; +public: + escape(Base base) : + super_t(base), + m_bnext(NULL), + m_bend(NULL), + m_full(false) + { + } +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_ESCAPE_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/head_iterator.hpp b/boost_1_45_0/boost/archive/iterators/head_iterator.hpp new file mode 100644 index 0000000..7d39a35 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/head_iterator.hpp
@@ -0,0 +1,80 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP +#define BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// head_iterator.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/iterator_traits.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +template<class Predicate, class Base> +class head_iterator + : public boost::iterator_adaptor< + head_iterator<Predicate, Base>, + Base, + use_default, + single_pass_traversal_tag + > +{ +private: + friend class iterator_core_access; + typedef boost::iterator_adaptor< + head_iterator<Predicate, Base>, + Base, + use_default, + single_pass_traversal_tag + > super_t; + + typedef head_iterator<Predicate, Base> this_t; + typedef BOOST_DEDUCED_TYPENAME super_t::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME super_t::reference reference_type; + + reference_type dereference_impl(){ + if(! m_end){ + while(! m_predicate(* this->base_reference())) + ++ this->base_reference(); + m_end = true; + } + return * this->base_reference(); + } + + reference_type dereference() const { + return const_cast<this_t *>(this)->dereference_impl(); + } + + void increment(){ + ++base_reference(); + } + Predicate m_predicate; + bool m_end; +public: + template<class T> + head_iterator(Predicate f, T start) : + super_t(Base(start)), + m_predicate(f), + m_end(false) + {} + +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/insert_linebreaks.hpp b/boost_1_45_0/boost/archive/iterators/insert_linebreaks.hpp new file mode 100644 index 0000000..09b13e5 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/insert_linebreaks.hpp
@@ -0,0 +1,101 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP +#define BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// insert_linebreaks.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ using ::memcpy; } +#endif + +#include <boost/serialization/pfto.hpp> + +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/iterator_traits.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// insert line break every N characters +template< + class Base, + int N, + class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type +> +class insert_linebreaks : + public iterator_adaptor< + insert_linebreaks<Base, N, CharType>, + Base, + CharType, + single_pass_traversal_tag, + CharType + > +{ +private: + friend class boost::iterator_core_access; + typedef iterator_adaptor< + insert_linebreaks<Base, N, CharType>, + Base, + CharType, + single_pass_traversal_tag, + CharType + > super_t; + + bool equal(const insert_linebreaks<Base, N, CharType> & rhs) const { + return +// m_count == rhs.m_count +// && base_reference() == rhs.base_reference() + this->base_reference() == rhs.base_reference() + ; + } + + void increment() { + if(m_count == N){ + m_count = 0; + return; + } + ++m_count; + ++(this->base_reference()); + } + CharType dereference() const { + if(m_count == N) + return '\n'; + return * (this->base_reference()); + } + unsigned int m_count; +public: + // make composible buy using templated constructor + template<class T> + insert_linebreaks(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))), + m_count(0) + {} + // intel 7.1 doesn't like default copy constructor + insert_linebreaks(const insert_linebreaks & rhs) : + super_t(rhs.base_reference()), + m_count(rhs.m_count) + {} +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/istream_iterator.hpp b/boost_1_45_0/boost/archive/iterators/istream_iterator.hpp new file mode 100644 index 0000000..1df612d --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/istream_iterator.hpp
@@ -0,0 +1,95 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP +#define BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// istream_iterator.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// note: this is a custom version of the standard istream_iterator. +// This is necessary as the standard version doesn't work as expected +// for wchar_t based streams on systems for which wchar_t not a true +// type but rather a synonym for some integer type. + +#include <cstddef> // NULL +#include <istream> +#include <boost/iterator/iterator_facade.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +// given a type, make an input iterator based on a pointer to that type +template<class Elem = char> +class istream_iterator : + public boost::iterator_facade< + istream_iterator<Elem>, + Elem, + std::input_iterator_tag, + Elem + > +{ + friend class boost::iterator_core_access; + typedef istream_iterator this_t ; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_facade< + istream_iterator<Elem>, + Elem, + std::input_iterator_tag, + Elem + > super_t; + typedef BOOST_DEDUCED_TYPENAME std::basic_istream<Elem> istream_type; + + //Access the value referred to + Elem dereference() const { + return m_current_value; + } + + bool equal(const this_t & rhs) const { + // note: only works for comparison against end of stream + return m_istream == rhs.m_istream; + } + + void increment(){ + if(NULL != m_istream){ + m_current_value = static_cast<Elem>(m_istream->get()); + if(! m_istream->good()){ + const_cast<this_t *>(this)->m_istream = NULL; + } + } + } + + istream_type *m_istream; + Elem m_current_value; +public: + istream_iterator(istream_type & is) : + m_istream(& is) + { + increment(); + } + + istream_iterator() : + m_istream(NULL) + {} + + istream_iterator(const istream_iterator<Elem> & rhs) : + m_istream(rhs.m_istream), + m_current_value(rhs.m_current_value) + {} + +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_ISTREAM_ITERATOR_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/mb_from_wchar.hpp b/boost_1_45_0/boost/archive/iterators/mb_from_wchar.hpp new file mode 100644 index 0000000..4b34c0f --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/mb_from_wchar.hpp
@@ -0,0 +1,136 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP +#define BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// mb_from_wchar.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cstddef> // size_t +#include <cstdlib> // for wctomb() + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; + using ::wctomb; +} // namespace std +#endif + +#include <boost/serialization/pfto.hpp> +#include <boost/iterator/iterator_adaptor.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// class used by text archives to translate wide strings and to char +// strings of the currently selected locale +template<class Base> // the input iterator +class mb_from_wchar + : public boost::iterator_adaptor< + mb_from_wchar<Base>, + Base, + wchar_t, + single_pass_traversal_tag, + char + > +{ + friend class boost::iterator_core_access; + + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + mb_from_wchar<Base>, + Base, + wchar_t, + single_pass_traversal_tag, + char + > super_t; + + typedef mb_from_wchar<Base> this_t; + + char dereference_impl() { + if(! m_full){ + fill(); + m_full = true; + } + return m_buffer[m_bnext]; + } + char dereference() const { + return (const_cast<this_t *>(this))->dereference_impl(); + } + + // test for iterator equality + bool equal(const mb_from_wchar<Base> & rhs) const { + // once the value is filled, the base_reference has been incremented + // so don't permit comparison anymore. + return + 0 == m_bend + && 0 == m_bnext + && this->base_reference() == rhs.base_reference() + ; + } + + void fill(){ + wchar_t value = * this->base_reference(); + #if (defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 3) \ + || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION >= 8)))) + m_bend = std::wcrtomb(m_buffer, value, 0); + #else + m_bend = std::wctomb(m_buffer, value); + #endif + assert(-1 != m_bend); + assert((std::size_t)m_bend <= sizeof(m_buffer)); + assert(m_bend > 0); + m_bnext = 0; + } + + void increment(){ + if(++m_bnext < m_bend) + return; + m_bend = + m_bnext = 0; + ++(this->base_reference()); + m_full = false; + } + + // buffer to handle pending characters + int m_bend; + int m_bnext; + char m_buffer[9]; + bool m_full; + +public: + // make composible buy using templated constructor + template<class T> + mb_from_wchar(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))), + m_bend(0), + m_bnext(0), + m_full(false) + {} + // intel 7.1 doesn't like default copy constructor + mb_from_wchar(const mb_from_wchar & rhs) : + super_t(rhs.base_reference()), + m_bend(rhs.m_bend), + m_bnext(rhs.m_bnext), + m_full(rhs.m_full) + {} +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_MB_FROM_WCHAR_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/ostream_iterator.hpp b/boost_1_45_0/boost/archive/iterators/ostream_iterator.hpp new file mode 100644 index 0000000..7c3203f --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/ostream_iterator.hpp
@@ -0,0 +1,83 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP +#define BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// ostream_iterator.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// note: this is a custom version of the standard ostream_iterator. +// This is necessary as the standard version doesn't work as expected +// for wchar_t based streams on systems for which wchar_t not a true +// type but rather a synonym for some integer type. + +#include <ostream> +#include <boost/iterator/iterator_facade.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +// given a type, make an input iterator based on a pointer to that type +template<class Elem> +class ostream_iterator : + public boost::iterator_facade< + ostream_iterator<Elem>, + Elem, + std::output_iterator_tag, + ostream_iterator<Elem> & + > +{ + friend class boost::iterator_core_access; + typedef ostream_iterator this_t ; + typedef Elem char_type; + typedef std::basic_ostream<char_type> ostream_type; + + //emulate the behavior of std::ostream + ostream_iterator & dereference() const { + return const_cast<ostream_iterator &>(*this); + } + bool equal(const this_t & rhs) const { + return m_ostream == rhs.m_ostream; + } + void increment(){} +protected: + ostream_type *m_ostream; + void put_val(char_type e){ + if(NULL != m_ostream){ + m_ostream->put(e); + if(! m_ostream->good()) + m_ostream = NULL; + } + } +public: + this_t & operator=(char_type c){ + put_val(c); + return *this; + } + ostream_iterator(ostream_type & os) : + m_ostream (& os) + {} + ostream_iterator() : + m_ostream (NULL) + {} + ostream_iterator(const ostream_iterator & rhs) : + m_ostream (rhs.m_ostream) + {} +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_OSTREAM_ITERATOR_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/remove_whitespace.hpp b/boost_1_45_0/boost/archive/iterators/remove_whitespace.hpp new file mode 100644 index 0000000..2ccc373 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/remove_whitespace.hpp
@@ -0,0 +1,169 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP +#define BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// remove_whitespace.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME + +#include <boost/serialization/pfto.hpp> + +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/filter_iterator.hpp> + +//#include <boost/detail/workaround.hpp> +//#if ! BOOST_WORKAROUND(BOOST_MSVC, <=1300) + +// here is the default standard implementation of the functor used +// by the filter iterator to remove spaces. Unfortunately usage +// of this implementation in combination with spirit trips a bug +// VC 6.5. The only way I can find to work around it is to +// implement a special non-standard version for this platform + +#ifndef BOOST_NO_CWCTYPE +#include <cwctype> // iswspace +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ using ::iswspace; } +#endif +#endif + +#include <cctype> // isspace +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ using ::isspace; } +#endif + +#if defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// this is required for the RW STL on Linux and Tru64. +#undef isspace +#undef iswspace +#endif + +//#endif // BOOST_WORKAROUND + +namespace { // anonymous + +template<class CharType> +struct remove_whitespace_predicate; + +template<> +struct remove_whitespace_predicate<char> +{ + bool operator()(unsigned char t){ + return ! std::isspace(t); + } +}; + +#ifndef BOOST_NO_CWCHAR +template<> +struct remove_whitespace_predicate<wchar_t> +{ + bool operator()(wchar_t t){ + return ! std::iswspace(t); + } +}; +#endif + +} // namespace anonymous + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// convert base64 file data (including whitespace and padding) to binary + +namespace boost { +namespace archive { +namespace iterators { + +// custom version of filter iterator which doesn't look ahead further than +// necessary + +template<class Predicate, class Base> +class filter_iterator + : public boost::iterator_adaptor< + filter_iterator<Predicate, Base>, + Base, + use_default, + single_pass_traversal_tag + > +{ + friend class boost::iterator_core_access; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + filter_iterator<Predicate, Base>, + Base, + use_default, + single_pass_traversal_tag + > super_t; + typedef filter_iterator<Predicate, Base> this_t; + typedef BOOST_DEDUCED_TYPENAME super_t::reference reference_type; + + reference_type dereference_impl(){ + if(! m_full){ + while(! m_predicate(* this->base_reference())) + ++(this->base_reference()); + m_full = true; + } + return * this->base_reference(); + } + + reference_type dereference() const { + return const_cast<this_t *>(this)->dereference_impl(); + } + + Predicate m_predicate; + bool m_full; +public: + // note: this function is public only because comeau compiler complained + // I don't know if this is because the compiler is wrong or what + void increment(){ + m_full = false; + ++(this->base_reference()); + } + filter_iterator(Base start) : + super_t(start), + m_full(false) + {} + filter_iterator(){} +}; + +template<class Base> +class remove_whitespace : + public filter_iterator< + remove_whitespace_predicate<BOOST_DEDUCED_TYPENAME Base::value_type>, + Base + > +{ + friend class boost::iterator_core_access; + typedef filter_iterator< + remove_whitespace_predicate<BOOST_DEDUCED_TYPENAME Base::value_type>, + Base + > super_t; +public: +// remove_whitespace(){} // why is this needed? + // make composible buy using templated constructor + template<class T> + remove_whitespace(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))) + {} + // intel 7.1 doesn't like default copy constructor + remove_whitespace(const remove_whitespace & rhs) : + super_t(rhs.base_reference()) + {} +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_REMOVE_WHITESPACE_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/transform_width.hpp b/boost_1_45_0/boost/archive/iterators/transform_width.hpp new file mode 100644 index 0000000..7ffc06d --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/transform_width.hpp
@@ -0,0 +1,168 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP +#define BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// transform_width.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +// iterator which takes elements of x bits and returns elements of y bits. +// used to change streams of 8 bit characters into streams of 6 bit characters. +// and vice-versa for implementing base64 encodeing/decoding. Be very careful +// when using and end iterator. end is only reliable detected when the input +// stream length is some common multiple of x and y. E.G. Base64 6 bit +// character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters +// or 3 8 bit characters + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME & PTFO +#include <boost/serialization/pfto.hpp> + +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/iterator/iterator_traits.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// class used by text archives to translate char strings to wchar_t +// strings of the currently selected locale +template< + class Base, + int BitsOut, + int BitsIn, + class CharType = BOOST_DEDUCED_TYPENAME boost::iterator_value<Base>::type // output character +> +class transform_width : + public boost::iterator_adaptor< + transform_width<Base, BitsOut, BitsIn, CharType>, + Base, + CharType, + single_pass_traversal_tag, + CharType + > +{ + friend class boost::iterator_core_access; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + transform_width<Base, BitsOut, BitsIn, CharType>, + Base, + CharType, + single_pass_traversal_tag, + CharType + > super_t; + + typedef transform_width<Base, BitsOut, BitsIn, CharType> this_t; + typedef BOOST_DEDUCED_TYPENAME iterator_value<Base>::type base_value_type; + + CharType fill(); + + CharType dereference_impl(){ + if(! m_full){ + m_current_value = fill(); + m_full = true; + } + return m_current_value; + } + + CharType dereference() const { + return const_cast<this_t *>(this)->dereference_impl(); + } + + // test for iterator equality + bool equal(const this_t & rhs) const { + return + this->base_reference() == rhs.base_reference(); + ; + } + + void increment(){ + m_displacement += BitsOut; + + while(m_displacement >= BitsIn){ + m_displacement -= BitsIn; + if(0 == m_displacement) + m_bufferfull = false; + if(! m_bufferfull){ + // note: suspect that this is not invoked for borland + ++(this->base_reference()); + } + } + m_full = false; + } + + CharType m_current_value; + // number of bits left in current input character buffer + unsigned int m_displacement; + base_value_type m_buffer; + // flag to current output character is ready - just used to save time + bool m_full; + // flag to indicate that m_buffer has data + bool m_bufferfull; + +public: + // make composible buy using templated constructor + template<class T> + transform_width(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))), + m_displacement(0), + m_full(false), + m_bufferfull(false) + {} + // intel 7.1 doesn't like default copy constructor + transform_width(const transform_width & rhs) : + super_t(rhs.base_reference()), + m_current_value(rhs.m_current_value), + m_displacement(rhs.m_displacement), + m_buffer(rhs.m_buffer), + m_full(rhs.m_full), + m_bufferfull(rhs.m_bufferfull) + {} +}; + +template<class Base, int BitsOut, int BitsIn, class CharType> +CharType transform_width<Base, BitsOut, BitsIn, CharType>::fill(){ + CharType retval = 0; + unsigned int missing_bits = BitsOut; + for(;;){ + unsigned int bcount; + if(! m_bufferfull){ + m_buffer = * this->base_reference(); + m_bufferfull = true; + bcount = BitsIn; + } + else + bcount = BitsIn - m_displacement; + unsigned int i = (std::min)(bcount, missing_bits); + // shift interesting bits to least significant position + unsigned int j = m_buffer >> (bcount - i); + // strip off uninteresting bits + // (note presumption of two's complement arithmetic) + j &= ~(-(1 << i)); + // append then interesting bits to the output value + retval <<= i; + retval |= j; + missing_bits -= i; + if(0 == missing_bits) + break; + // note: suspect that this is not invoked for borland 5.51 + ++(this->base_reference()); + m_bufferfull = false; + } + return retval; +} + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_TRANSFORM_WIDTH_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/unescape.hpp b/boost_1_45_0/boost/archive/iterators/unescape.hpp new file mode 100644 index 0000000..f437c38 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/unescape.hpp
@@ -0,0 +1,91 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP +#define BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// unescape.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#include <boost/iterator/iterator_adaptor.hpp> +//#include <boost/iterator/iterator_traits.hpp> +#include <boost/pointee.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// class used by text archives to translate char strings to wchar_t +// strings of the currently selected locale +template<class Derived, class Base> +class unescape + : public boost::iterator_adaptor< + unescape<Derived, Base>, + Base, + BOOST_DEDUCED_TYPENAME pointee<Base>::type, + single_pass_traversal_tag, + BOOST_DEDUCED_TYPENAME pointee<Base>::type + > +{ + friend class boost::iterator_core_access; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + unescape<Derived, Base>, + Base, + BOOST_DEDUCED_TYPENAME pointee<Base>::type, + single_pass_traversal_tag, + BOOST_DEDUCED_TYPENAME pointee<Base>::type + > super_t; + + typedef unescape<Derived, Base> this_t; +public: + typedef BOOST_DEDUCED_TYPENAME this_t::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME this_t::reference reference; +private: + value_type dereference_impl() { + if(! m_full){ + m_current_value = static_cast<Derived *>(this)->drain(); + m_full = true; + } + return m_current_value; + } + + reference dereference() const { + return const_cast<this_t *>(this)->dereference_impl(); + } + + value_type m_current_value; + bool m_full; + + void increment(){ + ++(this->base_reference()); + dereference_impl(); + m_full = false; + }; + +public: + + unescape(Base base) : + super_t(base), + m_full(false) + {} + +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/wchar_from_mb.hpp b/boost_1_45_0/boost/archive/iterators/wchar_from_mb.hpp new file mode 100644 index 0000000..12e7d57 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/wchar_from_mb.hpp
@@ -0,0 +1,129 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP +#define BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// wchar_from_mb.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> +#include <cctype> +#include <cstddef> // size_t +#include <cstdlib> // mblen + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::mblen; + using ::mbtowc; +} // namespace std +#endif + +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/iterator/iterator_adaptor.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// class used by text archives to translate char strings to wchar_t +// strings of the currently selected locale +template<class Base> +class wchar_from_mb + : public boost::iterator_adaptor< + wchar_from_mb<Base>, + Base, + wchar_t, + single_pass_traversal_tag, + wchar_t + > +{ + friend class boost::iterator_core_access; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_adaptor< + wchar_from_mb<Base>, + Base, + wchar_t, + single_pass_traversal_tag, + wchar_t + > super_t; + + typedef wchar_from_mb<Base> this_t; + + wchar_t drain(); + + wchar_t dereference_impl() { + if(! m_full){ + m_current_value = drain(); + m_full = true; + } + return m_current_value; + } + + wchar_t dereference() const { + return const_cast<this_t *>(this)->dereference_impl(); + } + + void increment(){ + dereference_impl(); + m_full = false; + ++(this->base_reference()); + }; + + wchar_t m_current_value; + bool m_full; + +public: + // make composible buy using templated constructor + template<class T> + wchar_from_mb(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))), + m_full(false) + {} + // intel 7.1 doesn't like default copy constructor + wchar_from_mb(const wchar_from_mb & rhs) : + super_t(rhs.base_reference()), + m_full(rhs.m_full) + {} +}; + +template<class Base> +wchar_t wchar_from_mb<Base>::drain(){ + char buffer[9]; + char * bptr = buffer; + char val; + for(std::size_t i = 0; i++ < (unsigned)MB_CUR_MAX;){ + val = * this->base_reference(); + *bptr++ = val; + int result = std::mblen(buffer, i); + if(-1 != result) + break; + ++(this->base_reference()); + } + wchar_t retval; + int result = std::mbtowc(& retval, buffer, MB_CUR_MAX); + if(0 >= result) + boost::serialization::throw_exception(iterators::dataflow_exception( + iterators::dataflow_exception::invalid_conversion + )); + return retval; +} + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_WCHAR_FROM_MB_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/xml_escape.hpp b/boost_1_45_0/boost/archive/iterators/xml_escape.hpp new file mode 100644 index 0000000..fd40c02 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/xml_escape.hpp
@@ -0,0 +1,125 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP +#define BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_escape.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/iterators/escape.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// insert escapes into xml text + +template<class Base> +class xml_escape + : public escape<xml_escape<Base>, Base> +{ + friend class boost::iterator_core_access; + + typedef escape<xml_escape<Base>, Base> super_t; + +public: + char fill(const char * & bstart, const char * & bend); + wchar_t fill(const wchar_t * & bstart, const wchar_t * & bend); + + template<class T> + xml_escape(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))) + {} + // intel 7.1 doesn't like default copy constructor + xml_escape(const xml_escape & rhs) : + super_t(rhs.base_reference()) + {} +}; + +template<class Base> +char xml_escape<Base>::fill( + const char * & bstart, + const char * & bend +){ + char current_value = * this->base_reference(); + switch(current_value){ + case '<': + bstart = "<"; + bend = bstart + 4; + break; + case '>': + bstart = ">"; + bend = bstart + 4; + break; + case '&': + bstart = "&"; + bend = bstart + 5; + break; + case '"': + bstart = """; + bend = bstart + 6; + break; + case '\'': + bstart = "'"; + bend = bstart + 6; + break; + default: + return current_value; + } + return *bstart; +} + +template<class Base> +wchar_t xml_escape<Base>::fill( + const wchar_t * & bstart, + const wchar_t * & bend +){ + wchar_t current_value = * this->base_reference(); + switch(current_value){ + case '<': + bstart = L"<"; + bend = bstart + 4; + break; + case '>': + bstart = L">"; + bend = bstart + 4; + break; + case '&': + bstart = L"&"; + bend = bstart + 5; + break; + case '"': + bstart = L"""; + bend = bstart + 6; + break; + case '\'': + bstart = L"'"; + bend = bstart + 6; + break; + default: + return current_value; + } + return *bstart; +} + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_XML_ESCAPE_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/xml_unescape.hpp b/boost_1_45_0/boost/archive/iterators/xml_unescape.hpp new file mode 100644 index 0000000..375e7d2 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/xml_unescape.hpp
@@ -0,0 +1,128 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP +#define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_unescape.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cassert> + +#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME + +#include <boost/serialization/throw_exception.hpp> +#include <boost/serialization/pfto.hpp> + +#include <boost/archive/iterators/unescape.hpp> +#include <boost/archive/iterators/dataflow_exception.hpp> + +namespace boost { +namespace archive { +namespace iterators { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// replace &??? xml escape sequences with the corresponding characters +template<class Base> +class xml_unescape + : public unescape<xml_unescape<Base>, Base> +{ + friend class boost::iterator_core_access; + typedef xml_unescape<Base> this_t; + typedef unescape<this_t, Base> super_t; + typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<this_t> reference_type; + + reference_type dereference() const { + return unescape<xml_unescape<Base>, Base>::dereference(); + } +public: + // workaround msvc 7.1 ICU crash + #if defined(BOOST_MSVC) + typedef int value_type; + #else + typedef BOOST_DEDUCED_TYPENAME this_t::value_type value_type; + #endif + + void drain_residue(const char *literal); + value_type drain(); + + template<class T> + xml_unescape(BOOST_PFTO_WRAPPER(T) start) : + super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))) + {} + // intel 7.1 doesn't like default copy constructor + xml_unescape(const xml_unescape & rhs) : + super_t(rhs.base_reference()) + {} +}; + +template<class Base> +void xml_unescape<Base>::drain_residue(const char * literal){ + do{ + if(* literal != * ++(this->base_reference())) + boost::serialization::throw_exception( + dataflow_exception( + dataflow_exception::invalid_xml_escape_sequence + ) + ); + } + while('\0' != * ++literal); +} + +// note key constraint on this function is that can't "look ahead" any +// more than necessary into base iterator. Doing so would alter the base +// iterator refenence which would make subsequent iterator comparisons +// incorrect and thereby break the composiblity of iterators. +template<class Base> +BOOST_DEDUCED_TYPENAME xml_unescape<Base>::value_type +//int +xml_unescape<Base>::drain(){ + value_type retval = * this->base_reference(); + if('&' != retval){ + return retval; + } + retval = * ++(this->base_reference()); + switch(retval){ + case 'l': // < + drain_residue("t;"); + retval = '<'; + break; + case 'g': // > + drain_residue("t;"); + retval = '>'; + break; + case 'a': + retval = * ++(this->base_reference()); + switch(retval){ + case 'p': // ' + drain_residue("os;"); + retval = '\''; + break; + case 'm': // & + drain_residue("p;"); + retval = '&'; + break; + } + break; + case 'q': + drain_residue("uot;"); + retval = '"'; + break; + } + return retval; +} + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif // BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_HPP
diff --git a/boost_1_45_0/boost/archive/iterators/xml_unescape_exception.hpp b/boost_1_45_0/boost/archive/iterators/xml_unescape_exception.hpp new file mode 100644 index 0000000..a141737 --- /dev/null +++ b/boost_1_45_0/boost/archive/iterators/xml_unescape_exception.hpp
@@ -0,0 +1,49 @@ +#ifndef BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP +#define BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_unescape_exception.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifndef BOOST_NO_EXCEPTIONS +#include <exception> + +#include <cassert> + +namespace boost { +namespace archive { +namespace iterators { + +////////////////////////////////////////////////////////////////////// +// exceptions thrown by xml_unescapes +// +class xml_unescape_exception : public std::exception +{ +public: + xml_unescape_exception() + {} + + virtual const char *what( ) const throw( ) + { + return "xml contained un-recognized escape code"; + } +}; + +} // namespace iterators +} // namespace archive +} // namespace boost + +#endif //BOOST_NO_EXCEPTIONS +#endif //BOOST_ARCHIVE_ITERATORS_XML_UNESCAPE_EXCEPTION_HPP
diff --git a/boost_1_45_0/boost/archive/polymorphic_binary_iarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_binary_iarchive.hpp new file mode 100644 index 0000000..ce7e3b0 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_binary_iarchive.hpp
@@ -0,0 +1,54 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_BINARY_IARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_BINARY_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_binary_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/binary_iarchive.hpp> +#include <boost/archive/detail/polymorphic_iarchive_route.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class polymorphic_binary_iarchive : + public detail::polymorphic_iarchive_route<naked_binary_iarchive> +{ +public: + polymorphic_binary_iarchive(std::istream & is, unsigned int flags = 0) : + detail::polymorphic_iarchive_route<naked_binary_iarchive>(is, flags) + {} + ~polymorphic_binary_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_binary_iarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_BINARY_IARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_binary_oarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_binary_oarchive.hpp new file mode 100644 index 0000000..a66ebdd --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_binary_oarchive.hpp
@@ -0,0 +1,43 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_BINARY_OARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_BINARY_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_binary_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/binary_oarchive.hpp> +#include <boost/archive/detail/polymorphic_oarchive_route.hpp> + +namespace boost { +namespace archive { + +typedef detail::polymorphic_oarchive_route< + binary_oarchive_impl< + naked_binary_oarchive, + std::ostream::char_type, + std::ostream::traits_type + > + > polymorphic_binary_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_binary_oarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_BINARY_OARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_iarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_iarchive.hpp new file mode 100644 index 0000000..2f76cf2 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_iarchive.hpp
@@ -0,0 +1,181 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // std::size_t +#include <climits> // ULONG_MAX +#include <string> + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> + +#include <boost/serialization/pfto.hpp> +#include <boost/archive/detail/iserializer.hpp> +#include <boost/archive/detail/interface_iarchive.hpp> +#include <boost/serialization/nvp.hpp> +#include <boost/archive/detail/register_archive.hpp> + +#include <boost/archive/detail/decl.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +template<class T> +class shared_ptr; +namespace serialization { + class extended_type_info; +} // namespace serialization +namespace archive { +namespace detail { + class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive; + class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive; +} + +class polymorphic_iarchive; + +class polymorphic_iarchive_impl : + public detail::interface_iarchive<polymorphic_iarchive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<polymorphic_iarchive>; + friend class load_access; +#endif + // primitive types the only ones permitted by polymorphic archives + virtual void load(bool & t) = 0; + + virtual void load(char & t) = 0; + virtual void load(signed char & t) = 0; + virtual void load(unsigned char & t) = 0; + #ifndef BOOST_NO_CWCHAR + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + virtual void load(wchar_t & t) = 0; + #endif + #endif + virtual void load(short & t) = 0; + virtual void load(unsigned short & t) = 0; + virtual void load(int & t) = 0; + virtual void load(unsigned int & t) = 0; + virtual void load(long & t) = 0; + virtual void load(unsigned long & t) = 0; + + #if defined(BOOST_HAS_LONG_LONG) + virtual void load(boost::long_long_type & t) = 0; + virtual void load(boost::ulong_long_type & t) = 0; + #elif defined(BOOST_HAS_MS_INT64) + virtual void load(__int64 & t) = 0; + virtual void load(unsigned __int64 & t) = 0; + #endif + + virtual void load(float & t) = 0; + virtual void load(double & t) = 0; + + // string types are treated as primitives + virtual void load(std::string & t) = 0; + #ifndef BOOST_NO_STD_WSTRING + virtual void load(std::wstring & t) = 0; + #endif + + // used for xml and other tagged formats + virtual void load_start(const char * name) = 0; + virtual void load_end(const char * name) = 0; + virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0; + + // msvc and borland won't automatically pass these to the base class so + // make it explicit here + template<class T> + void load_override(T & t, BOOST_PFTO int) + { + archive::load(* this->This(), t); + } + // special treatment for name-value pairs. + template<class T> + void load_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + boost::serialization::nvp< T > & t, + int + ){ + load_start(t.name()); + archive::load(* this->This(), t.value()); + load_end(t.name()); + } +protected: + virtual ~polymorphic_iarchive_impl(){}; +public: + // utility function implemented by all legal archives + virtual void set_library_version(library_version_type archive_library_version) = 0; + virtual library_version_type get_library_version() const = 0; + virtual unsigned int get_flags() const = 0; + virtual void delete_created_pointers() = 0; + virtual void reset_object_address( + const void * new_address, + const void * old_address + ) = 0; + + virtual void load_binary(void * t, std::size_t size) = 0; + + // these are used by the serialization library implementation. + virtual void load_object( + void *t, + const detail::basic_iserializer & bis + ) = 0; + virtual const detail::basic_pointer_iserializer * load_pointer( + void * & t, + const detail::basic_pointer_iserializer * bpis_ptr, + const detail::basic_pointer_iserializer * (*finder)( + const boost::serialization::extended_type_info & type + ) + ) = 0; +}; + +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +namespace boost { +namespace archive { + +class polymorphic_iarchive : + public polymorphic_iarchive_impl, + public detail::shared_ptr_helper +{ +public: + virtual ~polymorphic_iarchive(){}; +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/polymorphic_oarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_oarchive.hpp new file mode 100644 index 0000000..420029b --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_oarchive.hpp
@@ -0,0 +1,159 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // size_t +#include <climits> // ULONG_MAX +#include <string> + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/cstdint.hpp> +#include <boost/serialization/pfto.hpp> +#include <boost/archive/detail/oserializer.hpp> +#include <boost/archive/detail/interface_oarchive.hpp> +#include <boost/serialization/nvp.hpp> +#include <boost/archive/detail/register_archive.hpp> + +#include <boost/archive/detail/decl.hpp> +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +template<class T> +class shared_ptr; +namespace serialization { + class extended_type_info; +} // namespace serialization +namespace archive { +namespace detail { + class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive; + class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oserializer; +} + +class polymorphic_oarchive; + +class polymorphic_oarchive_impl : + public detail::interface_oarchive<polymorphic_oarchive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<polymorphic_oarchive>; + friend class save_access; +#endif + // primitive types the only ones permitted by polymorphic archives + virtual void save(const bool t) = 0; + + virtual void save(const char t) = 0; + virtual void save(const signed char t) = 0; + virtual void save(const unsigned char t) = 0; + #ifndef BOOST_NO_CWCHAR + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + virtual void save(const wchar_t t) = 0; + #endif + #endif + virtual void save(const short t) = 0; + virtual void save(const unsigned short t) = 0; + virtual void save(const int t) = 0; + virtual void save(const unsigned int t) = 0; + virtual void save(const long t) = 0; + virtual void save(const unsigned long t) = 0; + + #if defined(BOOST_HAS_LONG_LONG) + virtual void save(const boost::long_long_type t) = 0; + virtual void save(const boost::ulong_long_type t) = 0; + #elif defined(BOOST_HAS_MS_INT64) + virtual void save(const __int64 t) = 0; + virtual void save(const unsigned __int64 t) = 0; + #endif + + virtual void save(const float t) = 0; + virtual void save(const double t) = 0; + + // string types are treated as primitives + virtual void save(const std::string & t) = 0; + #ifndef BOOST_NO_STD_WSTRING + virtual void save(const std::wstring & t) = 0; + #endif + + virtual void save_null_pointer() = 0; + // used for xml and other tagged formats + virtual void save_start(const char * name) = 0; + virtual void save_end(const char * name) = 0; + virtual void register_basic_serializer(const detail::basic_oserializer & bos) = 0; + + virtual void end_preamble() = 0; + + // msvc and borland won't automatically pass these to the base class so + // make it explicit here + template<class T> + void save_override(T & t, BOOST_PFTO int) + { + archive::save(* this->This(), t); + } + // special treatment for name-value pairs. + template<class T> + void save_override( + #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + const + #endif + ::boost::serialization::nvp< T > & t, int + ){ + save_start(t.name()); + archive::save(* this->This(), t.const_value()); + save_end(t.name()); + } +protected: + virtual ~polymorphic_oarchive_impl(){}; +public: + // utility functions implemented by all legal archives + virtual unsigned int get_flags() const = 0; + virtual library_version_type get_library_version() const = 0; + virtual void save_binary(const void * t, std::size_t size) = 0; + + virtual void save_object( + const void *x, + const detail::basic_oserializer & bos + ) = 0; + virtual void save_pointer( + const void * t, + const detail::basic_pointer_oserializer * bpos_ptr + ) = 0; +}; + +// note: preserve naming symmetry +class polymorphic_oarchive : + public polymorphic_oarchive_impl +{ +public: + virtual ~polymorphic_oarchive(){}; +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive) + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/polymorphic_text_iarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_text_iarchive.hpp new file mode 100644 index 0000000..931a928 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_text_iarchive.hpp
@@ -0,0 +1,54 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_TEXT_IARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_TEXT_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/archive/detail/polymorphic_iarchive_route.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class polymorphic_text_iarchive : + public detail::polymorphic_iarchive_route<naked_text_iarchive> +{ +public: + polymorphic_text_iarchive(std::istream & is, unsigned int flags = 0) : + detail::polymorphic_iarchive_route<naked_text_iarchive>(is, flags) + {} + ~polymorphic_text_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_text_iarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_TEXT_IARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_text_oarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_text_oarchive.hpp new file mode 100644 index 0000000..82b4892 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_text_oarchive.hpp
@@ -0,0 +1,39 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_TEXT_OARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_TEXT_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/detail/polymorphic_oarchive_route.hpp> + +namespace boost { +namespace archive { + +typedef detail::polymorphic_oarchive_route< + text_oarchive_impl<naked_text_oarchive> +> polymorphic_text_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_text_oarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_TEXT_OARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_text_wiarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_text_wiarchive.hpp new file mode 100644 index 0000000..4df3d47 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_text_wiarchive.hpp
@@ -0,0 +1,59 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_TEXT_WIARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_TEXT_WIARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_wiarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <boost/archive/text_wiarchive.hpp> +#include <boost/archive/detail/polymorphic_iarchive_route.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class polymorphic_text_wiarchive : + public detail::polymorphic_iarchive_route<naked_text_wiarchive> +{ +public: + polymorphic_text_wiarchive(std::wistream & is, unsigned int flags = 0) : + detail::polymorphic_iarchive_route<naked_text_wiarchive>(is, flags) + {} + ~polymorphic_text_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_text_wiarchive +) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_POLYMORPHIC_TEXT_WIARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_text_woarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_text_woarchive.hpp new file mode 100644 index 0000000..bc44947 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_text_woarchive.hpp
@@ -0,0 +1,44 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_TEXT_WOARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_TEXT_WOARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_text_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <boost/archive/text_woarchive.hpp> +#include <boost/archive/detail/polymorphic_oarchive_route.hpp> + +namespace boost { +namespace archive { + +typedef detail::polymorphic_oarchive_route< + text_woarchive_impl<naked_text_woarchive> +> polymorphic_text_woarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_text_woarchive +) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_POLYMORPHIC_TEXT_WOARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_xml_iarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_xml_iarchive.hpp new file mode 100644 index 0000000..feb0b99 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_xml_iarchive.hpp
@@ -0,0 +1,54 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_XML_IARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_XML_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/xml_iarchive.hpp> +#include <boost/archive/detail/polymorphic_iarchive_route.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class polymorphic_xml_iarchive : + public detail::polymorphic_iarchive_route<naked_xml_iarchive> +{ +public: + polymorphic_xml_iarchive(std::istream & is, unsigned int flags = 0) : + detail::polymorphic_iarchive_route<naked_xml_iarchive>(is, flags) + {} + ~polymorphic_xml_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_xml_iarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_XML_IARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_xml_oarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_xml_oarchive.hpp new file mode 100644 index 0000000..8576694 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_xml_oarchive.hpp
@@ -0,0 +1,39 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_XML_OARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_XML_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#include <boost/archive/xml_oarchive.hpp> +#include <boost/archive/detail/polymorphic_oarchive_route.hpp> + +namespace boost { +namespace archive { + +typedef detail::polymorphic_oarchive_route< + xml_oarchive_impl<naked_xml_oarchive> +> polymorphic_xml_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_xml_oarchive +) + +#endif // BOOST_ARCHIVE_POLYMORPHIC_XML_OARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_xml_wiarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_xml_wiarchive.hpp new file mode 100644 index 0000000..b3f7db2 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_xml_wiarchive.hpp
@@ -0,0 +1,50 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_XML_WIARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_XML_WIARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_wiarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <boost/archive/xml_wiarchive.hpp> +#include <boost/archive/detail/polymorphic_iarchive_route.hpp> + +namespace boost { +namespace archive { + +class polymorphic_xml_wiarchive : + public detail::polymorphic_iarchive_route<naked_xml_wiarchive> +{ +public: + polymorphic_xml_wiarchive(std::wistream & is, unsigned int flags = 0) : + detail::polymorphic_iarchive_route<naked_xml_wiarchive>(is, flags) + {} + ~polymorphic_xml_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_xml_wiarchive +) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_POLYMORPHIC_XML_WIARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/polymorphic_xml_woarchive.hpp b/boost_1_45_0/boost/archive/polymorphic_xml_woarchive.hpp new file mode 100644 index 0000000..8884b43 --- /dev/null +++ b/boost_1_45_0/boost/archive/polymorphic_xml_woarchive.hpp
@@ -0,0 +1,44 @@ +#ifndef BOOST_ARCHIVE_POLYMORPHIC_XML_WOARCHIVE_HPP +#define BOOST_ARCHIVE_POLYMORPHIC_XML_WOARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// polymorphic_xml_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <boost/archive/xml_woarchive.hpp> +#include <boost/archive/detail/polymorphic_oarchive_route.hpp> + +namespace boost { +namespace archive { + +typedef detail::polymorphic_oarchive_route< + xml_woarchive_impl<naked_xml_woarchive> +> polymorphic_xml_woarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE( + boost::archive::polymorphic_xml_woarchive +) + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_POLYMORPHIC_XML_WOARCHIVE_HPP +
diff --git a/boost_1_45_0/boost/archive/shared_ptr_helper.hpp b/boost_1_45_0/boost/archive/shared_ptr_helper.hpp new file mode 100644 index 0000000..0e5f4f2 --- /dev/null +++ b/boost_1_45_0/boost/archive/shared_ptr_helper.hpp
@@ -0,0 +1,219 @@ +#ifndef BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP +#define BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// shared_ptr_helper.hpp: serialization for boost shared pointern + +// (C) Copyright 2004-2009 Robert Ramey, Martin Ecker and Takatoshi Kondo +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <set> +#include <list> +#include <utility> +#include <cstddef> // NULL + +#include <boost/config.hpp> +#include <boost/shared_ptr.hpp> + +#include <boost/type_traits/is_polymorphic.hpp> +#include <boost/serialization/type_info_implementation.hpp> +#include <boost/serialization/shared_ptr_132.hpp> +#include <boost/serialization/throw_exception.hpp> + +#include <boost/archive/archive_exception.hpp> +#include <boost/archive/detail/decl.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last headern + +namespace boost_132 { + template<class T> class shared_ptr; +} +namespace boost { + template<class T> class shared_ptr; + namespace serialization { + class extended_type_info; + template<class Archive, class T> + inline void load( + Archive & ar, + boost::shared_ptr< T > &t, + const unsigned int file_version + ); + } +namespace archive{ +namespace detail { + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// a common class for holding various types of shared pointers + +class shared_ptr_helper { + struct collection_type_compare { + bool operator()( + const shared_ptr<const void> &lhs, + const shared_ptr<const void> &rhs + )const{ + return lhs.get() < rhs.get(); + } + }; + typedef std::set< + boost::shared_ptr<const void>, + collection_type_compare + > collection_type; + typedef collection_type::const_iterator iterator_type; + // list of shared_pointers create accessable by raw pointer. This + // is used to "match up" shared pointers loaded at different + // points in the archive. Note, we delay construction until + // it is actually used since this is by default included as + // a "mix-in" even if shared_ptr isn't used. + collection_type * m_pointers; + + struct null_deleter { + void operator()(void const *) const {} + }; + + struct void_deleter { + const boost::serialization::extended_type_info * m_eti; + void_deleter(const boost::serialization::extended_type_info *eti) : + m_eti(eti) + {} + void operator()(void *vp) const { + m_eti->destroy(vp); + } + }; + +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + template<class Archive, class T> + friend inline void boost::serialization::load( + Archive & ar, + boost::shared_ptr< T > &t, + const unsigned int file_version + ); +#endif + +// #ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP + // list of loaded pointers. This is used to be sure that the pointers + // stay around long enough to be "matched" with other pointers loaded + // by the same archive. These are created with a "null_deleter" so that + // when this list is destroyed - the underlaying raw pointers are not + // destroyed. This has to be done because the pointers are also held by + // new system which is disjoint from this set. This is implemented + // by a change in load_construct_data below. It makes this file suitable + // only for loading pointers into a 1.33 or later boost system. + std::list<boost_132::shared_ptr<const void> > * m_pointers_132; +// #endif + + // returns pointer to object and an indicator whether this is a + // new entry (true) or a previous one (false) + BOOST_ARCHIVE_DECL(shared_ptr<void>) + get_od( + const void * od, + const boost::serialization::extended_type_info * true_type, + const boost::serialization::extended_type_info * this_type + ); + + BOOST_ARCHIVE_DECL(void) + append(const boost::shared_ptr<const void> &); + + template<class T> + struct non_polymorphic { + static const boost::serialization::extended_type_info * + get_object_identifier(T & t){ + return & boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance(); + } + }; + template<class T> + struct polymorphic { + static const boost::serialization::extended_type_info * + get_object_identifier(T & t){ + return boost::serialization::singleton< + BOOST_DEDUCED_TYPENAME + boost::serialization::type_info_implementation< T >::type + >::get_const_instance().get_derived_extended_type_info(t); + } + }; +public: + template<class T> + void reset(shared_ptr< T > & s, T * t){ + if(NULL == t){ + s.reset(); + return; + } + const boost::serialization::extended_type_info * this_type + = & boost::serialization::type_info_implementation< T >::type + ::get_const_instance(); + + // get pointer to the most derived object. This is effectively + // the object identifern + typedef BOOST_DEDUCED_TYPENAME mpl::eval_if< + is_polymorphic< T >, + mpl::identity<polymorphic< T > >, + mpl::identity<non_polymorphic< T > > + >::type type; + + const boost::serialization::extended_type_info * true_type + = type::get_object_identifier(*t); + + // note:if this exception is thrown, be sure that derived pointern + // is either registered or exported. + if(NULL == true_type) + boost::serialization::throw_exception( + archive_exception( + archive_exception::unregistered_class, + this_type->get_debug_info() + ) + ); + shared_ptr<void> r = + get_od( + static_cast<const void *>(t), + true_type, + this_type + ); + if(!r){ + s.reset(t); + const void * od = void_downcast( + *true_type, + *this_type, + static_cast<const void *>(t) + ); + shared_ptr<const void> sp(s, od); + append(sp); + } + else{ + s = shared_ptr< T >( + r, + static_cast<T *>(r.get()) + ); + } + } + +// #ifdef BOOST_SERIALIZATION_SHARED_PTR_132_HPP + BOOST_ARCHIVE_DECL(void) + append(const boost_132::shared_ptr<const void> & t); +// #endif +public: + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + shared_ptr_helper(); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + ~shared_ptr_helper(); +}; + +} // namespace detail +} // namespace archive +} // namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
diff --git a/boost_1_45_0/boost/archive/text_iarchive.hpp b/boost_1_45_0/boost/archive/text_iarchive.hpp new file mode 100644 index 0000000..6e60105 --- /dev/null +++ b/boost_1_45_0/boost/archive/text_iarchive.hpp
@@ -0,0 +1,155 @@ +#ifndef BOOST_ARCHIVE_TEXT_IARCHIVE_HPP +#define BOOST_ARCHIVE_TEXT_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <istream> + +#include <boost/config.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/basic_text_iprimitive.hpp> +#include <boost/archive/basic_text_iarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class text_iarchive_impl : + public basic_text_iprimitive<std::istream>, + public basic_text_iarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<Archive>; + friend class basic_text_iarchive<Archive>; + friend class load_access; +protected: +#endif + template<class T> + void load(T & t){ + basic_text_iprimitive<std::istream>::load(t); + } + void load(version_type & t){ + unsigned int v; + load(v); + t = version_type(v); + } + void load(boost::serialization::item_version_type & t){ + unsigned int v; + load(v); + t = boost::serialization::item_version_type(v); + } + BOOST_ARCHIVE_DECL(void) + load(char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_ARCHIVE_DECL(void) + load(wchar_t * t); + #endif + BOOST_ARCHIVE_DECL(void) + load(std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_DECL(void) + load(std::wstring &ws); + #endif + // note: the following should not needed - but one compiler (vc 7.1) + // fails to compile one test (test_shared_ptr) without it !!! + // make this protected so it can be called from a derived archive + template<class T> + void load_override(T & t, BOOST_PFTO int){ + basic_text_iarchive<Archive>::load_override(t, 0); + } + BOOST_ARCHIVE_DECL(void) + load_override(class_name_type & t, int); + BOOST_ARCHIVE_DECL(void) + init(); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + text_iarchive_impl(std::istream & is, unsigned int flags); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + ~text_iarchive_impl(){}; +}; + +// do not derive from the classes below. If you want to extend this functionality +// via inhertance, derived from text_iarchive_impl instead. This will +// preserve correct static polymorphism. + +// same as text_iarchive below - without the shared_ptr_helper +class naked_text_iarchive : + public text_iarchive_impl<naked_text_iarchive> +{ +public: + naked_text_iarchive(std::istream & is_, unsigned int flags = 0) : + // note: added _ to suppress useless gcc warning + text_iarchive_impl<naked_text_iarchive>(is_, flags) + {} + ~naked_text_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class text_iarchive : + public text_iarchive_impl<text_iarchive>, + public detail::shared_ptr_helper +{ +public: + text_iarchive(std::istream & is_, unsigned int flags = 0) : + // note: added _ to suppress useless gcc warning + text_iarchive_impl<text_iarchive>(is_, flags) + {} + ~text_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_iarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_TEXT_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/text_oarchive.hpp b/boost_1_45_0/boost/archive/text_oarchive.hpp new file mode 100644 index 0000000..183a767 --- /dev/null +++ b/boost_1_45_0/boost/archive/text_oarchive.hpp
@@ -0,0 +1,118 @@ +#ifndef BOOST_ARCHIVE_TEXT_OARCHIVE_HPP +#define BOOST_ARCHIVE_TEXT_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <ostream> +#include <cstddef> // std::size_t + +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/basic_text_oarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class text_oarchive_impl : + /* protected ? */ public basic_text_oprimitive<std::ostream>, + public basic_text_oarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<Archive>; + friend class basic_text_oarchive<Archive>; + friend class save_access; +protected: +#endif + template<class T> + void save(const T & t){ + this->newtoken(); + basic_text_oprimitive<std::ostream>::save(t); + } + void save(const version_type & t){ + save(static_cast<const unsigned int>(t)); + } + void save(const boost::serialization::item_version_type & t){ + save(static_cast<const unsigned int>(t)); + } + BOOST_ARCHIVE_DECL(void) + save(const char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_ARCHIVE_DECL(void) + save(const wchar_t * t); + #endif + BOOST_ARCHIVE_DECL(void) + save(const std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_DECL(void) + save(const std::wstring &ws); + #endif + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + text_oarchive_impl(std::ostream & os, unsigned int flags); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + ~text_oarchive_impl(){}; +public: + BOOST_ARCHIVE_DECL(void) + save_binary(const void *address, std::size_t count); +}; + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from text_oarchive_impl instead. This will +// preserve correct static polymorphism. +class text_oarchive : + public text_oarchive_impl<text_oarchive> +{ +public: + text_oarchive(std::ostream & os_, unsigned int flags = 0) : + // note: added _ to suppress useless gcc warning + text_oarchive_impl<text_oarchive>(os_, flags) + {} + ~text_oarchive(){} +}; + +typedef text_oarchive naked_text_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_TEXT_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/text_wiarchive.hpp b/boost_1_45_0/boost/archive/text_wiarchive.hpp new file mode 100644 index 0000000..7451f3a --- /dev/null +++ b/boost_1_45_0/boost/archive/text_wiarchive.hpp
@@ -0,0 +1,152 @@ +#ifndef BOOST_ARCHIVE_TEXT_WIARCHIVE_HPP +#define BOOST_ARCHIVE_TEXT_WIARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_wiarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <istream> + +#include <boost/archive/detail/auto_link_warchive.hpp> +#include <boost/archive/basic_text_iprimitive.hpp> +#include <boost/archive/basic_text_iarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class text_wiarchive_impl : + public basic_text_iprimitive<std::wistream>, + public basic_text_iarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<Archive>; + friend class basic_text_iarchive<Archive>; + friend class load_access; +protected: +#endif + template<class T> + void load(T & t){ + basic_text_iprimitive<std::wistream>::load(t); + } + void load(version_type & t){ + unsigned int v; + load(v); + t = version_type(v); + } + void load(boost::serialization::item_version_type & t){ + unsigned int v; + load(v); + t = boost::serialization::item_version_type(v); + } + BOOST_WARCHIVE_DECL(void) + load(char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_WARCHIVE_DECL(void) + load(wchar_t * t); + #endif + BOOST_WARCHIVE_DECL(void) + load(std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_WARCHIVE_DECL(void) + load(std::wstring &ws); + #endif + // note: the following should not needed - but one compiler (vc 7.1) + // fails to compile one test (test_shared_ptr) without it !!! + template<class T> + void load_override(T & t, BOOST_PFTO int){ + basic_text_iarchive<Archive>::load_override(t, 0); + } + BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) + text_wiarchive_impl(std::wistream & is, unsigned int flags); + ~text_wiarchive_impl(){}; +}; + +// do not derive from the classes below. If you want to extend this functionality +// via inhertance, derived from text_iarchive_impl instead. This will +// preserve correct static polymorphism. + +// same as text_wiarchive below - without the shared_ptr_helper +class naked_text_wiarchive : + public text_wiarchive_impl<naked_text_wiarchive> +{ +public: + naked_text_wiarchive(std::wistream & is, unsigned int flags = 0) : + text_wiarchive_impl<naked_text_wiarchive>(is, flags) + {} + ~naked_text_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class text_wiarchive : + public text_wiarchive_impl<text_wiarchive>, + public detail::shared_ptr_helper +{ +public: + text_wiarchive(std::wistream & is, unsigned int flags = 0) : + text_wiarchive_impl<text_wiarchive>(is, flags) + {} + ~text_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_wiarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_TEXT_WIARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/text_woarchive.hpp b/boost_1_45_0/boost/archive/text_woarchive.hpp new file mode 100644 index 0000000..7ed0c82 --- /dev/null +++ b/boost_1_45_0/boost/archive/text_woarchive.hpp
@@ -0,0 +1,145 @@ +#ifndef BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP +#define BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// text_woarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> + +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <ostream> +#include <cstddef> // size_t + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/archive/detail/auto_link_warchive.hpp> +#include <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/basic_text_oarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class text_woarchive_impl : + public basic_text_oprimitive<std::wostream>, + public basic_text_oarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<Archive>; + friend class basic_text_oarchive<Archive>; + friend class save_access; +protected: +#endif + template<class T> + void save(const T & t){ + this->newtoken(); + basic_text_oprimitive<std::wostream>::save(t); + } + void save(const version_type & t){ + save(static_cast<const unsigned int>(t)); + } + void save(const boost::serialization::item_version_type & t){ + save(static_cast<const unsigned int>(t)); + } + BOOST_WARCHIVE_DECL(void) + save(const char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_WARCHIVE_DECL(void) + save(const wchar_t * t); + #endif + BOOST_WARCHIVE_DECL(void) + save(const std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_WARCHIVE_DECL(void) + save(const std::wstring &ws); + #endif + text_woarchive_impl(std::wostream & os, unsigned int flags) : + basic_text_oprimitive<std::wostream>( + os, + 0 != (flags & no_codecvt) + ), + basic_text_oarchive<Archive>(flags) + { + if(0 == (flags & no_header)) + basic_text_oarchive<Archive>::init(); + } +public: + void save_binary(const void *address, std::size_t count){ + put(static_cast<wchar_t>('\n')); + this->end_preamble(); + #if ! defined(__MWERKS__) + this->basic_text_oprimitive<std::wostream>::save_binary( + #else + this->basic_text_oprimitive::save_binary( + #endif + address, + count + ); + put(static_cast<wchar_t>('\n')); + this->delimiter = this->none; + } + +}; + +// we use the following because we can't use +// typedef text_oarchive_impl<text_oarchive_impl<...> > text_oarchive; + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from text_oarchive_impl instead. This will +// preserve correct static polymorphism. +class text_woarchive : + public text_woarchive_impl<text_woarchive> +{ +public: + text_woarchive(std::wostream & os, unsigned int flags = 0) : + text_woarchive_impl<text_woarchive>(os, flags) + {} + ~text_woarchive(){} +}; + +typedef text_woarchive naked_text_woarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_TEXT_WOARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/tmpdir.hpp b/boost_1_45_0/boost/archive/tmpdir.hpp new file mode 100644 index 0000000..f962e11 --- /dev/null +++ b/boost_1_45_0/boost/archive/tmpdir.hpp
@@ -0,0 +1,50 @@ +#ifndef BOOST_ARCHIVE_TMPDIR_HPP +#define BOOST_ARCHIVE_TMPDIR_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// tmpdir.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstdlib> // getenv +#include <cstddef> // NULL +//#include <cassert> + +#include <boost/config.hpp> +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std { + using ::getenv; +} +#endif + +namespace boost { +namespace archive { + +inline const char * tmpdir(){ + const char *dirname; + dirname = std::getenv("TMP"); + if(NULL == dirname) + dirname = std::getenv("TMPDIR"); + if(NULL == dirname) + dirname = std::getenv("TEMP"); + if(NULL == dirname){ + //assert(false); // no temp directory found + dirname = "."; + } + return dirname; +} + +} // archive +} // boost + +#endif // BOOST_ARCHIVE_TMPDIR_HPP
diff --git a/boost_1_45_0/boost/archive/wcslen.hpp b/boost_1_45_0/boost/archive/wcslen.hpp new file mode 100644 index 0000000..5c14acf --- /dev/null +++ b/boost_1_45_0/boost/archive/wcslen.hpp
@@ -0,0 +1,56 @@ +#ifndef BOOST_ARCHIVE_WCSLEN_HPP +#define BOOST_ARCHIVE_WCSLEN_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// wcslen.hpp: + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <cstddef> // size_t +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#ifndef BOOST_NO_CWCHAR + +// a couple of libraries which include wchar_t don't include +// wcslen + +#if defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB < 306 \ +|| defined(__LIBCOMO__) + +namespace std { +inline std::size_t wcslen(const wchar_t * ws) +{ + const wchar_t * eows = ws; + while(* eows != 0) + ++eows; + return eows - ws; +} +} // namespace std + +#else + +#include <cwchar> +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ using ::wcslen; } +#endif + +#endif // wcslen + +#endif //BOOST_NO_CWCHAR + +#endif //BOOST_ARCHIVE_WCSLEN_HPP
diff --git a/boost_1_45_0/boost/archive/xml_archive_exception.hpp b/boost_1_45_0/boost/archive/xml_archive_exception.hpp new file mode 100644 index 0000000..c8d65e0 --- /dev/null +++ b/boost_1_45_0/boost/archive/xml_archive_exception.hpp
@@ -0,0 +1,56 @@ +#ifndef BOOST_ARCHIVE_XML_ARCHIVE_EXCEPTION_HPP +#define BOOST_ARCHIVE_XML_ARCHIVE_EXCEPTION_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_archive_exception.hpp: + +// (C) Copyright 2007 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <exception> +#include <cassert> + +#include <boost/config.hpp> +#include <boost/preprocessor/empty.hpp> +#include <boost/archive/detail/decl.hpp> +#include <boost/archive/archive_exception.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +namespace boost { +namespace archive { + +////////////////////////////////////////////////////////////////////// +// exceptions thrown by xml archives +// +class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) xml_archive_exception : + public virtual boost::archive::archive_exception +{ +public: + typedef enum { + xml_archive_parsing_error, // see save_register + xml_archive_tag_mismatch, + xml_archive_tag_name_error + } exception_code; + xml_archive_exception( + exception_code c, + const char * e1 = NULL, + const char * e2 = NULL + ); +}; + +}// namespace archive +}// namespace boost + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif //BOOST_XML_ARCHIVE_ARCHIVE_EXCEPTION_HPP
diff --git a/boost_1_45_0/boost/archive/xml_iarchive.hpp b/boost_1_45_0/boost/archive/xml_iarchive.hpp new file mode 100644 index 0000000..be6cfe4 --- /dev/null +++ b/boost_1_45_0/boost/archive/xml_iarchive.hpp
@@ -0,0 +1,164 @@ +#ifndef BOOST_ARCHIVE_XML_IARCHIVE_HPP +#define BOOST_ARCHIVE_XML_IARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_iarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <istream> + +//#include <boost/scoped_ptr.hpp> +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/basic_text_iprimitive.hpp> +#include <boost/archive/basic_xml_iarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class CharType> +class basic_xml_grammar; +typedef basic_xml_grammar<char> xml_grammar; + +template<class Archive> +class xml_iarchive_impl : + public basic_text_iprimitive<std::istream>, + public basic_xml_iarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<Archive>; + friend class basic_xml_iarchive<Archive>; + friend class load_access; +protected: +#endif + // instances of micro xml parser to parse start preambles + // scoped_ptr doesn't play nice with borland - so use a naked pointer + // scoped_ptr<xml_grammar> gimpl; + xml_grammar *gimpl; + + std::istream & get_is(){ + return is; + } + template<class T> + void load(T & t){ + basic_text_iprimitive<std::istream>::load(t); + } + void + load(version_type & t){ + unsigned int v; + load(v); + t = version_type(v); + } + void + load(boost::serialization::item_version_type & t){ + unsigned int v; + load(v); + t = boost::serialization::item_version_type(v); + } + BOOST_ARCHIVE_DECL(void) + load(char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_ARCHIVE_DECL(void) + load(wchar_t * t); + #endif + BOOST_ARCHIVE_DECL(void) + load(std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_DECL(void) + load(std::wstring &ws); + #endif + template<class T> + void load_override(T & t, BOOST_PFTO int){ + basic_xml_iarchive<Archive>::load_override(t, 0); + } + BOOST_ARCHIVE_DECL(void) + load_override(class_name_type & t, int); + BOOST_ARCHIVE_DECL(void) + init(); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + xml_iarchive_impl(std::istream & is, unsigned int flags); + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + ~xml_iarchive_impl(); +}; + +// do not derive from the classes below. If you want to extend this functionality +// via inhertance, derived from text_iarchive_impl instead. This will +// preserve correct static polymorphism. + +// same as xml_iarchive below - without the shared_ptr_helper +class naked_xml_iarchive : + public xml_iarchive_impl<naked_xml_iarchive> +{ +public: + naked_xml_iarchive(std::istream & is, unsigned int flags = 0) : + xml_iarchive_impl<naked_xml_iarchive>(is, flags) + {} + ~naked_xml_iarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class xml_iarchive : + public xml_iarchive_impl<xml_iarchive>, + public detail::shared_ptr_helper +{ +public: + xml_iarchive(std::istream & is, unsigned int flags = 0) : + xml_iarchive_impl<xml_iarchive>(is, flags) + {} + ~xml_iarchive(){}; +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_ARCHIVE_XML_IARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/xml_oarchive.hpp b/boost_1_45_0/boost/archive/xml_oarchive.hpp new file mode 100644 index 0000000..167ba09 --- /dev/null +++ b/boost_1_45_0/boost/archive/xml_oarchive.hpp
@@ -0,0 +1,133 @@ +#ifndef BOOST_ARCHIVE_XML_OARCHIVE_HPP +#define BOOST_ARCHIVE_XML_OARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_oarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <ostream> + +#include <cstddef> // size_t +#include <boost/config.hpp> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <boost/archive/detail/auto_link_archive.hpp> +#include <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/basic_xml_oarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class xml_oarchive_impl : + public basic_text_oprimitive<std::ostream>, + public basic_xml_oarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<Archive>; + friend class basic_xml_oarchive<Archive>; + friend class save_access; +protected: +#endif + //void end_preamble(){ + // basic_xml_oarchive<Archive>::end_preamble(); + //} + template<class T> + void save(const T & t){ + basic_text_oprimitive<std::ostream>::save(t); + } + void + save(const version_type & t){ + save(static_cast<const unsigned int>(t)); + } + void + save(const boost::serialization::item_version_type & t){ + save(static_cast<const unsigned int>(t)); + } + BOOST_ARCHIVE_DECL(void) + save(const char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_ARCHIVE_DECL(void) + save(const wchar_t * t); + #endif + BOOST_ARCHIVE_DECL(void) + save(const std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_ARCHIVE_DECL(void) + save(const std::wstring &ws); + #endif + BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) + xml_oarchive_impl(std::ostream & os, unsigned int flags); + ~xml_oarchive_impl(){} +public: + void save_binary(const void *address, std::size_t count){ + this->end_preamble(); + #if ! defined(__MWERKS__) + this->basic_text_oprimitive<std::ostream>::save_binary( + #else + this->basic_text_oprimitive::save_binary( + #endif + address, + count + ); + this->indent_next = true; + } +}; + +// we use the following because we can't use +// typedef xml_oarchive_impl<xml_oarchive_impl<...> > xml_oarchive; + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from xml_oarchive_impl instead. This will +// preserve correct static polymorphism. +class xml_oarchive : + public xml_oarchive_impl<xml_oarchive> +{ +public: + xml_oarchive(std::ostream & os, unsigned int flags = 0) : + xml_oarchive_impl<xml_oarchive>(os, flags) + {} + ~xml_oarchive(){} +}; + +typedef xml_oarchive naked_xml_oarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/xml_wiarchive.hpp b/boost_1_45_0/boost/archive/xml_wiarchive.hpp new file mode 100644 index 0000000..09552ce --- /dev/null +++ b/boost_1_45_0/boost/archive/xml_wiarchive.hpp
@@ -0,0 +1,171 @@ +#ifndef BOOST_ARCHIVE_XML_WIARCHIVE_HPP +#define BOOST_ARCHIVE_XML_WIARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_wiarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <istream> + +//#include <boost/scoped_ptr.hpp> +#include <boost/archive/detail/auto_link_warchive.hpp> +#include <boost/archive/basic_text_iprimitive.hpp> +#include <boost/archive/basic_xml_iarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class CharType> +class basic_xml_grammar; +typedef basic_xml_grammar<wchar_t> xml_wgrammar; + +template<class Archive> +class xml_wiarchive_impl : + public basic_text_iprimitive<std::wistream>, + public basic_xml_iarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_iarchive<Archive>; + friend class basic_xml_iarchive<Archive>; + friend class load_access; +protected: +#endif + // instances of micro xml parser to parse start preambles + // scoped_ptr doesn't play nice with borland - so use a naked pointer + // scoped_ptr<xml_wgrammar> gimpl; + xml_wgrammar *gimpl; + std::wistream & get_is(){ + return is; + } + template<class T> + void + load(T & t){ + basic_text_iprimitive<std::wistream>::load(t); + } + void + load(version_type & t){ + unsigned int v; + load(v); + t = version_type(v); + } + void + load(boost::serialization::item_version_type & t){ + unsigned int v; + load(v); + t = boost::serialization::item_version_type(v); + } + BOOST_WARCHIVE_DECL(void) + load(char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_WARCHIVE_DECL(void) + load(wchar_t * t); + #endif + BOOST_WARCHIVE_DECL(void) + load(std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_WARCHIVE_DECL(void) + load(std::wstring &ws); + #endif + template<class T> + void load_override(T & t, BOOST_PFTO int){ + basic_xml_iarchive<Archive>::load_override(t, 0); + } + BOOST_WARCHIVE_DECL(void) + load_override(class_name_type & t, int); + BOOST_WARCHIVE_DECL(void) + init(); + BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) + xml_wiarchive_impl(std::wistream & is, unsigned int flags) ; + BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) + ~xml_wiarchive_impl(); +}; + +// do not derive from the classes below. If you want to extend this functionality +// via inhertance, derived from xml_wiarchive_impl instead. This will +// preserve correct static polymorphism. + +// same as xml_wiarchive below - without the shared_ptr_helper +class naked_xml_wiarchive : + public xml_wiarchive_impl<naked_xml_wiarchive> +{ +public: + naked_xml_wiarchive(std::wistream & is, unsigned int flags = 0) : + xml_wiarchive_impl<naked_xml_wiarchive>(is, flags) + {} + ~naked_xml_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +// note special treatment of shared_ptr. This type needs a special +// structure associated with every archive. We created a "mix-in" +// class to provide this functionality. Since shared_ptr holds a +// special esteem in the boost library - we included it here by default. +#include <boost/archive/shared_ptr_helper.hpp> + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +class xml_wiarchive : + public xml_wiarchive_impl<xml_wiarchive>, + public detail::shared_ptr_helper +{ +public: + xml_wiarchive(std::wistream & is, unsigned int flags = 0) : + xml_wiarchive_impl<xml_wiarchive>(is, flags) + {} + ~xml_wiarchive(){} +}; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_wiarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_XML_WIARCHIVE_HPP
diff --git a/boost_1_45_0/boost/archive/xml_woarchive.hpp b/boost_1_45_0/boost/archive/xml_woarchive.hpp new file mode 100644 index 0000000..08c0fdc --- /dev/null +++ b/boost_1_45_0/boost/archive/xml_woarchive.hpp
@@ -0,0 +1,140 @@ +#ifndef BOOST_ARCHIVE_XML_WOARCHIVE_HPP +#define BOOST_ARCHIVE_XML_WOARCHIVE_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// xml_woarchive.hpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org for updates, documentation, and revision history. + +#include <boost/config.hpp> +#ifdef BOOST_NO_STD_WSTREAMBUF +#error "wide char i/o not supported on this platform" +#else + +#include <cstddef> // size_t +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::size_t; +} // namespace std +#endif + +#include <ostream> + +#include <boost/archive/detail/auto_link_warchive.hpp> +#include <boost/archive/basic_text_oprimitive.hpp> +#include <boost/archive/basic_xml_oarchive.hpp> +#include <boost/archive/detail/register_archive.hpp> +#include <boost/serialization/item_version_type.hpp> + +#include <boost/archive/detail/abi_prefix.hpp> // must be the last header + +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4511 4512) +#endif + +namespace boost { +namespace archive { + +template<class Archive> +class xml_woarchive_impl : + public basic_text_oprimitive<std::wostream>, + public basic_xml_oarchive<Archive> +{ +#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS +public: +#else + friend class detail::interface_oarchive<Archive>; + friend class basic_xml_oarchive<Archive>; + friend class save_access; +protected: +#endif + //void end_preamble(){ + // basic_xml_oarchive<Archive>::end_preamble(); + //} + template<class T> + void + save(const T & t){ + basic_text_oprimitive<std::wostream>::save(t); + } + void + save(const version_type & t){ + save(static_cast<const unsigned int>(t)); + } + void + save(const boost::serialization::item_version_type & t){ + save(static_cast<const unsigned int>(t)); + } + BOOST_WARCHIVE_DECL(void) + save(const char * t); + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + BOOST_WARCHIVE_DECL(void) + save(const wchar_t * t); + #endif + BOOST_WARCHIVE_DECL(void) + save(const std::string &s); + #ifndef BOOST_NO_STD_WSTRING + BOOST_WARCHIVE_DECL(void) + save(const std::wstring &ws); + #endif + BOOST_WARCHIVE_DECL(BOOST_PP_EMPTY()) + xml_woarchive_impl(std::wostream & os, unsigned int flags); + ~xml_woarchive_impl(){} +public: + void + save_binary(const void *address, std::size_t count){ + this->end_preamble(); + #if ! defined(__MWERKS__) + this->basic_text_oprimitive<std::wostream>::save_binary( + #else + this->basic_text_oprimitive::save_binary( + #endif + address, + count + ); + this->indent_next = true; + } +}; + +// we use the following because we can't use +// typedef xml_woarchive_impl<xml_woarchive_impl<...> > xml_woarchive; + +// do not derive from this class. If you want to extend this functionality +// via inhertance, derived from xml_woarchive_impl instead. This will +// preserve correct static polymorphism. +class xml_woarchive : + public xml_woarchive_impl<xml_woarchive> +{ +public: + xml_woarchive(std::wostream & os, unsigned int flags = 0) : + xml_woarchive_impl<xml_woarchive>(os, flags) + {} + ~xml_woarchive(){} +}; + +typedef xml_woarchive naked_xml_woarchive; + +} // namespace archive +} // namespace boost + +// required by export +BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive) + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas + +#endif // BOOST_NO_STD_WSTREAMBUF +#endif // BOOST_ARCHIVE_XML_OARCHIVE_HPP
diff --git a/boost_1_45_0/boost/array.hpp b/boost_1_45_0/boost/array.hpp new file mode 100644 index 0000000..7df2771 --- /dev/null +++ b/boost_1_45_0/boost/array.hpp
@@ -0,0 +1,388 @@ +/* The following code declares class array, + * an STL container (as wrapper) for arrays of constant size. + * + * See + * http://www.boost.org/libs/array/ + * for documentation. + * + * The original author site is at: http://www.josuttis.com/ + * + * (C) Copyright Nicolai M. Josuttis 2001. + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + * + * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. + * See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168 + * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) + * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) + * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) + * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. + * 05 Aug 2001 - minor update (Nico Josuttis) + * 20 Jan 2001 - STLport fix (Beman Dawes) + * 29 Sep 2000 - Initial Revision (Nico Josuttis) + * + * Jan 29, 2004 + */ +#ifndef BOOST_ARRAY_HPP +#define BOOST_ARRAY_HPP + +#include <boost/detail/workaround.hpp> + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe +# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated +# pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required +#endif + +#include <cstddef> +#include <stdexcept> +#include <boost/assert.hpp> +#include <boost/swap.hpp> + +// Handles broken standard libraries better than <iterator> +#include <boost/detail/iterator.hpp> +#include <boost/throw_exception.hpp> +#include <algorithm> + +// FIXES for broken compilers +#include <boost/config.hpp> + + +namespace boost { + + template<class T, std::size_t N> + class array { + public: + T elems[N]; // fixed-size array of elements of type T + + public: + // type definitions + typedef T value_type; + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // iterator support + iterator begin() { return elems; } + const_iterator begin() const { return elems; } + iterator end() { return elems+N; } + const_iterator end() const { return elems+N; } + + // reverse iterator support +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) + // workaround for broken reverse_iterator in VC7 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator, + reference, iterator, reference> > reverse_iterator; + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator, + const_reference, iterator, reference> > const_reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator<iterator, std::random_access_iterator_tag, + value_type, reference, iterator, difference_type> reverse_iterator; + typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag, + value_type, const_reference, const_iterator, difference_type> const_reverse_iterator; +#else + // workaround for broken reverse_iterator implementations + typedef std::reverse_iterator<iterator,T> reverse_iterator; + typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator; +#endif + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + // operator[] + reference operator[](size_type i) + { + BOOST_ASSERT( i < N && "out of range" ); + return elems[i]; + } + + const_reference operator[](size_type i) const + { + BOOST_ASSERT( i < N && "out of range" ); + return elems[i]; + } + + // at() with range check + reference at(size_type i) { rangecheck(i); return elems[i]; } + const_reference at(size_type i) const { rangecheck(i); return elems[i]; } + + // front() and back() + reference front() + { + return elems[0]; + } + + const_reference front() const + { + return elems[0]; + } + + reference back() + { + return elems[N-1]; + } + + const_reference back() const + { + return elems[N-1]; + } + + // size is constant + static size_type size() { return N; } + static bool empty() { return false; } + static size_type max_size() { return N; } + enum { static_size = N }; + + // swap (note: linear complexity) + void swap (array<T,N>& y) { + for (size_type i = 0; i < N; ++i) + boost::swap(elems[i],y.elems[i]); + } + + // direct access to data (read-only) + const T* data() const { return elems; } + T* data() { return elems; } + + // use array as C array (direct read/write access to data) + T* c_array() { return elems; } + + // assignment with type conversion + template <typename T2> + array<T,N>& operator= (const array<T2,N>& rhs) { + std::copy(rhs.begin(),rhs.end(), begin()); + return *this; + } + + // assign one value to all elements + void assign (const T& value) { fill ( value ); } // A synonym for fill + void fill (const T& value) + { + std::fill_n(begin(),size(),value); + } + + // check range (may be private because it is static) + static void rangecheck (size_type i) { + if (i >= size()) { + std::out_of_range e("array<>: index out of range"); + boost::throw_exception(e); + } + } + + }; + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + template< class T > + class array< T, 0 > { + + public: + // type definitions + typedef T value_type; + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // iterator support + iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } + const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + iterator end() { return begin(); } + const_iterator end() const { return begin(); } + + // reverse iterator support +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) + // workaround for broken reverse_iterator in VC7 + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator, + reference, iterator, reference> > reverse_iterator; + typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator, + const_reference, iterator, reference> > const_reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator<iterator, std::random_access_iterator_tag, + value_type, reference, iterator, difference_type> reverse_iterator; + typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag, + value_type, const_reference, const_iterator, difference_type> const_reverse_iterator; +#else + // workaround for broken reverse_iterator implementations + typedef std::reverse_iterator<iterator,T> reverse_iterator; + typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator; +#endif + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + // operator[] + reference operator[](size_type /*i*/) + { + return failed_rangecheck(); + } + + const_reference operator[](size_type /*i*/) const + { + return failed_rangecheck(); + } + + // at() with range check + reference at(size_type /*i*/) { return failed_rangecheck(); } + const_reference at(size_type /*i*/) const { return failed_rangecheck(); } + + // front() and back() + reference front() + { + return failed_rangecheck(); + } + + const_reference front() const + { + return failed_rangecheck(); + } + + reference back() + { + return failed_rangecheck(); + } + + const_reference back() const + { + return failed_rangecheck(); + } + + // size is constant + static size_type size() { return 0; } + static bool empty() { return true; } + static size_type max_size() { return 0; } + enum { static_size = 0 }; + + void swap (array<T,0>& /*y*/) { + } + + // direct access to data (read-only) + const T* data() const { return 0; } + T* data() { return 0; } + + // use array as C array (direct read/write access to data) + T* c_array() { return 0; } + + // assignment with type conversion + template <typename T2> + array<T,0>& operator= (const array<T2,0>& ) { + return *this; + } + + // assign one value to all elements + void assign (const T& value) { fill ( value ); } + void fill (const T& ) {} + + // check range (may be private because it is static) + static reference failed_rangecheck () { + std::out_of_range e("attempt to access element of an empty array"); + boost::throw_exception(e); +#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) + // + // We need to return something here to keep + // some compilers happy: however we will never + // actually get here.... + // + static T placeholder; + return placeholder; +#endif + } + }; +#endif + + // comparisons + template<class T, std::size_t N> + bool operator== (const array<T,N>& x, const array<T,N>& y) { + return std::equal(x.begin(), x.end(), y.begin()); + } + template<class T, std::size_t N> + bool operator< (const array<T,N>& x, const array<T,N>& y) { + return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); + } + template<class T, std::size_t N> + bool operator!= (const array<T,N>& x, const array<T,N>& y) { + return !(x==y); + } + template<class T, std::size_t N> + bool operator> (const array<T,N>& x, const array<T,N>& y) { + return y<x; + } + template<class T, std::size_t N> + bool operator<= (const array<T,N>& x, const array<T,N>& y) { + return !(y<x); + } + template<class T, std::size_t N> + bool operator>= (const array<T,N>& x, const array<T,N>& y) { + return !(x<y); + } + + // global swap() + template<class T, std::size_t N> + inline void swap (array<T,N>& x, array<T,N>& y) { + x.swap(y); + } + + // Specific for boost::array: simply returns its elems data member. + template <typename T, std::size_t N> + T(&get_c_array(boost::array<T,N>& arg))[N] + { + return arg.elems; + } + + // Const version. + template <typename T, std::size_t N> + const T(&get_c_array(const boost::array<T,N>& arg))[N] + { + return arg.elems; + } + +#if 0 + // Overload for std::array, assuming that std::array will have + // explicit conversion functions as discussed at the WG21 meeting + // in Summit, March 2009. + template <typename T, std::size_t N> + T(&get_c_array(std::array<T,N>& arg))[N] + { + return static_cast<T(&)[N]>(arg); + } + + // Const version. + template <typename T, std::size_t N> + const T(&get_c_array(const std::array<T,N>& arg))[N] + { + return static_cast<T(&)[N]>(arg); + } +#endif + +} /* namespace boost */ + + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + +#endif /*BOOST_ARRAY_HPP*/
diff --git a/boost_1_45_0/boost/asio.hpp b/boost_1_45_0/boost/asio.hpp new file mode 100644 index 0000000..f94e0d6 --- /dev/null +++ b/boost_1_45_0/boost/asio.hpp
@@ -0,0 +1,100 @@ +// +// asio.hpp +// ~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See www.boost.org/libs/asio for documentation. +// + +#ifndef BOOST_ASIO_HPP +#define BOOST_ASIO_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/basic_datagram_socket.hpp> +#include <boost/asio/basic_deadline_timer.hpp> +#include <boost/asio/basic_io_object.hpp> +#include <boost/asio/basic_raw_socket.hpp> +#include <boost/asio/basic_serial_port.hpp> +#include <boost/asio/basic_socket_acceptor.hpp> +#include <boost/asio/basic_socket_iostream.hpp> +#include <boost/asio/basic_socket_streambuf.hpp> +#include <boost/asio/basic_stream_socket.hpp> +#include <boost/asio/basic_streambuf.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/buffered_read_stream_fwd.hpp> +#include <boost/asio/buffered_read_stream.hpp> +#include <boost/asio/buffered_stream_fwd.hpp> +#include <boost/asio/buffered_stream.hpp> +#include <boost/asio/buffered_write_stream_fwd.hpp> +#include <boost/asio/buffered_write_stream.hpp> +#include <boost/asio/buffers_iterator.hpp> +#include <boost/asio/completion_condition.hpp> +#include <boost/asio/datagram_socket_service.hpp> +#include <boost/asio/deadline_timer_service.hpp> +#include <boost/asio/deadline_timer.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/handler_alloc_hook.hpp> +#include <boost/asio/handler_invoke_hook.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/ip/address.hpp> +#include <boost/asio/ip/address_v4.hpp> +#include <boost/asio/ip/address_v6.hpp> +#include <boost/asio/ip/basic_endpoint.hpp> +#include <boost/asio/ip/basic_resolver.hpp> +#include <boost/asio/ip/basic_resolver_entry.hpp> +#include <boost/asio/ip/basic_resolver_iterator.hpp> +#include <boost/asio/ip/basic_resolver_query.hpp> +#include <boost/asio/ip/host_name.hpp> +#include <boost/asio/ip/icmp.hpp> +#include <boost/asio/ip/multicast.hpp> +#include <boost/asio/ip/resolver_query_base.hpp> +#include <boost/asio/ip/resolver_service.hpp> +#include <boost/asio/ip/tcp.hpp> +#include <boost/asio/ip/udp.hpp> +#include <boost/asio/ip/unicast.hpp> +#include <boost/asio/ip/v6_only.hpp> +#include <boost/asio/is_read_buffered.hpp> +#include <boost/asio/is_write_buffered.hpp> +#include <boost/asio/local/basic_endpoint.hpp> +#include <boost/asio/local/connect_pair.hpp> +#include <boost/asio/local/datagram_protocol.hpp> +#include <boost/asio/local/stream_protocol.hpp> +#include <boost/asio/placeholders.hpp> +#include <boost/asio/posix/basic_descriptor.hpp> +#include <boost/asio/posix/basic_stream_descriptor.hpp> +#include <boost/asio/posix/descriptor_base.hpp> +#include <boost/asio/posix/stream_descriptor.hpp> +#include <boost/asio/posix/stream_descriptor_service.hpp> +#include <boost/asio/raw_socket_service.hpp> +#include <boost/asio/read.hpp> +#include <boost/asio/read_at.hpp> +#include <boost/asio/read_until.hpp> +#include <boost/asio/serial_port.hpp> +#include <boost/asio/serial_port_base.hpp> +#include <boost/asio/serial_port_service.hpp> +#include <boost/asio/socket_acceptor_service.hpp> +#include <boost/asio/socket_base.hpp> +#include <boost/asio/strand.hpp> +#include <boost/asio/stream_socket_service.hpp> +#include <boost/asio/streambuf.hpp> +#include <boost/asio/time_traits.hpp> +#include <boost/asio/version.hpp> +#include <boost/asio/windows/basic_handle.hpp> +#include <boost/asio/windows/basic_random_access_handle.hpp> +#include <boost/asio/windows/basic_stream_handle.hpp> +#include <boost/asio/windows/overlapped_ptr.hpp> +#include <boost/asio/windows/random_access_handle.hpp> +#include <boost/asio/windows/random_access_handle_service.hpp> +#include <boost/asio/windows/stream_handle.hpp> +#include <boost/asio/windows/stream_handle_service.hpp> +#include <boost/asio/write.hpp> +#include <boost/asio/write_at.hpp> + +#endif // BOOST_ASIO_HPP
diff --git a/boost_1_45_0/boost/asio/basic_datagram_socket.hpp b/boost_1_45_0/boost/asio/basic_datagram_socket.hpp new file mode 100644 index 0000000..5272809 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_datagram_socket.hpp
@@ -0,0 +1,802 @@ +// +// basic_datagram_socket.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_DATAGRAM_SOCKET_HPP +#define BOOST_ASIO_BASIC_DATAGRAM_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/basic_socket.hpp> +#include <boost/asio/datagram_socket_service.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides datagram-oriented socket functionality. +/** + * The basic_datagram_socket class template provides asynchronous and blocking + * datagram-oriented socket functionality. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template <typename Protocol, + typename DatagramSocketService = datagram_socket_service<Protocol> > +class basic_datagram_socket + : public basic_socket<Protocol, DatagramSocketService> +{ +public: + /// The native representation of a socket. + typedef typename DatagramSocketService::native_type native_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_datagram_socket without opening it. + /** + * This constructor creates a datagram socket without opening it. The open() + * function must be called before data can be sent or received on the socket. + * + * @param io_service The io_service object that the datagram socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + */ + explicit basic_datagram_socket(boost::asio::io_service& io_service) + : basic_socket<Protocol, DatagramSocketService>(io_service) + { + } + + /// Construct and open a basic_datagram_socket. + /** + * This constructor creates and opens a datagram socket. + * + * @param io_service The io_service object that the datagram socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_datagram_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_socket<Protocol, DatagramSocketService>(io_service, protocol) + { + } + + /// Construct a basic_datagram_socket, opening it and binding it to the given + /// local endpoint. + /** + * This constructor creates a datagram socket and automatically opens it bound + * to the specified endpoint on the local machine. The protocol used is the + * protocol associated with the given endpoint. + * + * @param io_service The io_service object that the datagram socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param endpoint An endpoint on the local machine to which the datagram + * socket will be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_datagram_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_socket<Protocol, DatagramSocketService>(io_service, endpoint) + { + } + + /// Construct a basic_datagram_socket on an existing native socket. + /** + * This constructor creates a datagram socket object to hold an existing + * native socket. + * + * @param io_service The io_service object that the datagram socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket The new underlying socket implementation. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_datagram_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_type& native_socket) + : basic_socket<Protocol, DatagramSocketService>( + io_service, protocol, native_socket) + { + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the datagram socket. The function + * call will block until the data has been sent successfully or an error + * occurs. + * + * @param buffers One ore more data buffers to be sent on the socket. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected datagram socket. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code socket.send(boost::asio::buffer(data, size)); @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.send(this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the datagram socket. The function + * call will block until the data has been sent successfully or an error + * occurs. + * + * @param buffers One ore more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected datagram socket. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.send( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the datagram socket. The function + * call will block until the data has been sent successfully or an error + * occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected datagram socket. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.send(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous send on a connected socket. + /** + * This function is used to send data on the datagram socket. The function + * call will block until the data has been sent successfully or an error + * occurs. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_send operation can only be used with a connected socket. + * Use the async_send_to function to send data on an unconnected datagram + * socket. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous send on a connected socket. + /** + * This function is used to send data on the datagram socket. The function + * call will block until the data has been sent successfully or an error + * occurs. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_send operation can only be used with a connected socket. + * Use the async_send_to function to send data on an unconnected datagram + * socket. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, flags, handler); + } + + /// Send a datagram to the specified endpoint. + /** + * This function is used to send a datagram to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * boost::asio::ip::udp::endpoint destination( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.send_to(boost::asio::buffer(data, size), destination); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination) + { + boost::system::error_code ec; + std::size_t s = this->service.send_to( + this->implementation, buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send a datagram to the specified endpoint. + /** + * This function is used to send a datagram to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.send_to( + this->implementation, buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send a datagram to the specified endpoint. + /** + * This function is used to send a datagram to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + boost::system::error_code& ec) + { + return this->service.send_to(this->implementation, + buffers, destination, flags, ec); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send a datagram to the specified + * remote endpoint. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param destination The remote endpoint to which the data will be sent. + * Copies will be made of the endpoint as required. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * boost::asio::ip::udp::endpoint destination( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.async_send_to( + * boost::asio::buffer(data, size), destination, handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, WriteHandler handler) + { + this->service.async_send_to(this->implementation, buffers, destination, 0, + handler); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send a datagram to the specified + * remote endpoint. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param destination The remote endpoint to which the data will be sent. + * Copies will be made of the endpoint as required. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + WriteHandler handler) + { + this->service.async_send_to(this->implementation, buffers, destination, + flags, handler); + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the datagram socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected datagram + * socket. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code socket.receive(boost::asio::buffer(data, size)); @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.receive( + this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the datagram socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected datagram + * socket. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.receive( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the datagram socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected datagram + * socket. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.receive(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous receive on a connected socket. + /** + * This function is used to asynchronously receive data from the datagram + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_receive operation can only be used with a connected socket. + * Use the async_receive_from function to receive data on an unconnected + * datagram socket. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous receive on a connected socket. + /** + * This function is used to asynchronously receive data from the datagram + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_receive operation can only be used with a connected socket. + * Use the async_receive_from function to receive data on an unconnected + * datagram socket. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, flags, handler); + } + + /// Receive a datagram with the endpoint of the sender. + /** + * This function is used to receive a datagram. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the datagram. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * boost::asio::ip::udp::endpoint sender_endpoint; + * socket.receive_from( + * boost::asio::buffer(data, size), sender_endpoint); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint) + { + boost::system::error_code ec; + std::size_t s = this->service.receive_from( + this->implementation, buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive a datagram with the endpoint of the sender. + /** + * This function is used to receive a datagram. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the datagram. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.receive_from( + this->implementation, buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive a datagram with the endpoint of the sender. + /** + * This function is used to receive a datagram. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the datagram. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags, + boost::system::error_code& ec) + { + return this->service.receive_from(this->implementation, buffers, + sender_endpoint, flags, ec); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive a datagram. The function + * call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the datagram. Ownership of the sender_endpoint object + * is retained by the caller, which must guarantee that it is valid until the + * handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code socket.async_receive_from( + * boost::asio::buffer(data, size), 0, sender_endpoint, handler); @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, ReadHandler handler) + { + this->service.async_receive_from(this->implementation, buffers, + sender_endpoint, 0, handler); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive a datagram. The function + * call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the datagram. Ownership of the sender_endpoint object + * is retained by the caller, which must guarantee that it is valid until the + * handler is called. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags, + ReadHandler handler) + { + this->service.async_receive_from(this->implementation, buffers, + sender_endpoint, flags, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_DATAGRAM_SOCKET_HPP
diff --git a/boost_1_45_0/boost/asio/basic_deadline_timer.hpp b/boost_1_45_0/boost/asio/basic_deadline_timer.hpp new file mode 100644 index 0000000..dc471e2 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_deadline_timer.hpp
@@ -0,0 +1,444 @@ +// +// basic_deadline_timer.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP +#define BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/basic_io_object.hpp> +#include <boost/asio/deadline_timer_service.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides waitable timer functionality. +/** + * The basic_deadline_timer class template provides the ability to perform a + * blocking or asynchronous wait for a timer to expire. + * + * A deadline timer is always in one of two states: "expired" or "not expired". + * If the wait() or async_wait() function is called on an expired timer, the + * wait operation will complete immediately. + * + * Most applications will use the boost::asio::deadline_timer typedef. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Examples + * Performing a blocking wait: + * @code + * // Construct a timer without setting an expiry time. + * boost::asio::deadline_timer timer(io_service); + * + * // Set an expiry time relative to now. + * timer.expires_from_now(boost::posix_time::seconds(5)); + * + * // Wait for the timer to expire. + * timer.wait(); + * @endcode + * + * @par + * Performing an asynchronous wait: + * @code + * void handler(const boost::system::error_code& error) + * { + * if (!error) + * { + * // Timer expired. + * } + * } + * + * ... + * + * // Construct a timer with an absolute expiry time. + * boost::asio::deadline_timer timer(io_service, + * boost::posix_time::time_from_string("2005-12-07 23:59:59.000")); + * + * // Start an asynchronous wait. + * timer.async_wait(handler); + * @endcode + * + * @par Changing an active deadline_timer's expiry time + * + * Changing the expiry time of a timer while there are pending asynchronous + * waits causes those wait operations to be cancelled. To ensure that the action + * associated with the timer is performed only once, use something like this: + * used: + * + * @code + * void on_some_event() + * { + * if (my_timer.expires_from_now(seconds(5)) > 0) + * { + * // We managed to cancel the timer. Start new asynchronous wait. + * my_timer.async_wait(on_timeout); + * } + * else + * { + * // Too late, timer has already expired! + * } + * } + * + * void on_timeout(const boost::system::error_code& e) + * { + * if (e != boost::asio::error::operation_aborted) + * { + * // Timer was not cancelled, take necessary action. + * } + * } + * @endcode + * + * @li The boost::asio::basic_deadline_timer::expires_from_now() function + * cancels any pending asynchronous waits, and returns the number of + * asynchronous waits that were cancelled. If it returns 0 then you were too + * late and the wait handler has already been executed, or will soon be + * executed. If it returns 1 then the wait handler was successfully cancelled. + * + * @li If a wait handler is cancelled, the boost::system::error_code passed to + * it contains the value boost::asio::error::operation_aborted. + */ +template <typename Time, + typename TimeTraits = boost::asio::time_traits<Time>, + typename TimerService = deadline_timer_service<Time, TimeTraits> > +class basic_deadline_timer + : public basic_io_object<TimerService> +{ +public: + /// The time traits type. + typedef TimeTraits traits_type; + + /// The time type. + typedef typename traits_type::time_type time_type; + + /// The duration type. + typedef typename traits_type::duration_type duration_type; + + /// Constructor. + /** + * This constructor creates a timer without setting an expiry time. The + * expires_at() or expires_from_now() functions must be called to set an + * expiry time before the timer can be waited on. + * + * @param io_service The io_service object that the timer will use to dispatch + * handlers for any asynchronous operations performed on the timer. + */ + explicit basic_deadline_timer(boost::asio::io_service& io_service) + : basic_io_object<TimerService>(io_service) + { + } + + /// Constructor to set a particular expiry time as an absolute time. + /** + * This constructor creates a timer and sets the expiry time. + * + * @param io_service The io_service object that the timer will use to dispatch + * handlers for any asynchronous operations performed on the timer. + * + * @param expiry_time The expiry time to be used for the timer, expressed + * as an absolute time. + */ + basic_deadline_timer(boost::asio::io_service& io_service, + const time_type& expiry_time) + : basic_io_object<TimerService>(io_service) + { + boost::system::error_code ec; + this->service.expires_at(this->implementation, expiry_time, ec); + boost::asio::detail::throw_error(ec); + } + + /// Constructor to set a particular expiry time relative to now. + /** + * This constructor creates a timer and sets the expiry time. + * + * @param io_service The io_service object that the timer will use to dispatch + * handlers for any asynchronous operations performed on the timer. + * + * @param expiry_time The expiry time to be used for the timer, relative to + * now. + */ + basic_deadline_timer(boost::asio::io_service& io_service, + const duration_type& expiry_time) + : basic_io_object<TimerService>(io_service) + { + boost::system::error_code ec; + this->service.expires_from_now(this->implementation, expiry_time, ec); + boost::asio::detail::throw_error(ec); + } + + /// Cancel any asynchronous operations that are waiting on the timer. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the timer. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @return The number of asynchronous operations that were cancelled. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If the timer has already expired when cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel() + { + boost::system::error_code ec; + std::size_t s = this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Cancel any asynchronous operations that are waiting on the timer. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the timer. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of asynchronous operations that were cancelled. + * + * @note If the timer has already expired when cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Get the timer's expiry time as an absolute time. + /** + * This function may be used to obtain the timer's current expiry time. + * Whether the timer has expired or not does not affect this value. + */ + time_type expires_at() const + { + return this->service.expires_at(this->implementation); + } + + /// Set the timer's expiry time as an absolute time. + /** + * This function sets the expiry time. Any pending asynchronous wait + * operations will be cancelled. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * @param expiry_time The expiry time to be used for the timer. + * + * @return The number of asynchronous operations that were cancelled. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If the timer has already expired when expires_at() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t expires_at(const time_type& expiry_time) + { + boost::system::error_code ec; + std::size_t s = this->service.expires_at( + this->implementation, expiry_time, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Set the timer's expiry time as an absolute time. + /** + * This function sets the expiry time. Any pending asynchronous wait + * operations will be cancelled. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * @param expiry_time The expiry time to be used for the timer. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of asynchronous operations that were cancelled. + * + * @note If the timer has already expired when expires_at() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t expires_at(const time_type& expiry_time, + boost::system::error_code& ec) + { + return this->service.expires_at(this->implementation, expiry_time, ec); + } + + /// Get the timer's expiry time relative to now. + /** + * This function may be used to obtain the timer's current expiry time. + * Whether the timer has expired or not does not affect this value. + */ + duration_type expires_from_now() const + { + return this->service.expires_from_now(this->implementation); + } + + /// Set the timer's expiry time relative to now. + /** + * This function sets the expiry time. Any pending asynchronous wait + * operations will be cancelled. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * @param expiry_time The expiry time to be used for the timer. + * + * @return The number of asynchronous operations that were cancelled. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If the timer has already expired when expires_from_now() is called, + * then the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t expires_from_now(const duration_type& expiry_time) + { + boost::system::error_code ec; + std::size_t s = this->service.expires_from_now( + this->implementation, expiry_time, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Set the timer's expiry time relative to now. + /** + * This function sets the expiry time. Any pending asynchronous wait + * operations will be cancelled. The handler for each cancelled operation will + * be invoked with the boost::asio::error::operation_aborted error code. + * + * @param expiry_time The expiry time to be used for the timer. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of asynchronous operations that were cancelled. + * + * @note If the timer has already expired when expires_from_now() is called, + * then the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t expires_from_now(const duration_type& expiry_time, + boost::system::error_code& ec) + { + return this->service.expires_from_now( + this->implementation, expiry_time, ec); + } + + /// Perform a blocking wait on the timer. + /** + * This function is used to wait for the timer to expire. This function + * blocks and does not return until the timer has expired. + * + * @throws boost::system::system_error Thrown on failure. + */ + void wait() + { + boost::system::error_code ec; + this->service.wait(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Perform a blocking wait on the timer. + /** + * This function is used to wait for the timer to expire. This function + * blocks and does not return until the timer has expired. + * + * @param ec Set to indicate what error occurred, if any. + */ + void wait(boost::system::error_code& ec) + { + this->service.wait(this->implementation, ec); + } + + /// Start an asynchronous wait on the timer. + /** + * This function may be used to initiate an asynchronous wait against the + * timer. It always returns immediately. + * + * For each call to async_wait(), the supplied handler will be called exactly + * once. The handler will be called when: + * + * @li The timer has expired. + * + * @li The timer was cancelled, in which case the handler is passed the error + * code boost::asio::error::operation_aborted. + * + * @param handler The handler to be called when the timer expires. Copies + * will be made of the handler as required. The function signature of the + * handler must be: + * @code void handler( + * const boost::system::error_code& error // Result of operation. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename WaitHandler> + void async_wait(WaitHandler handler) + { + this->service.async_wait(this->implementation, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
diff --git a/boost_1_45_0/boost/asio/basic_io_object.hpp b/boost_1_45_0/boost/asio/basic_io_object.hpp new file mode 100644 index 0000000..414f365 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_io_object.hpp
@@ -0,0 +1,100 @@ +// +// basic_io_object.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_IO_OBJECT_HPP +#define BOOST_ASIO_BASIC_IO_OBJECT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Base class for all I/O objects. +template <typename IoObjectService> +class basic_io_object + : private noncopyable +{ +public: + /// The type of the service that will be used to provide I/O operations. + typedef IoObjectService service_type; + + /// The underlying implementation type of I/O object. + typedef typename service_type::implementation_type implementation_type; + + /// (Deprecated: use get_io_service().) Get the io_service associated with + /// the object. + /** + * This function may be used to obtain the io_service object that the I/O + * object uses to dispatch handlers for asynchronous operations. + * + * @return A reference to the io_service object that the I/O object will use + * to dispatch handlers. Ownership is not transferred to the caller. + */ + boost::asio::io_service& io_service() + { + return service.get_io_service(); + } + + /// Get the io_service associated with the object. + /** + * This function may be used to obtain the io_service object that the I/O + * object uses to dispatch handlers for asynchronous operations. + * + * @return A reference to the io_service object that the I/O object will use + * to dispatch handlers. Ownership is not transferred to the caller. + */ + boost::asio::io_service& get_io_service() + { + return service.get_io_service(); + } + +protected: + /// Construct a basic_io_object. + /** + * Performs: + * @code service.construct(implementation); @endcode + */ + explicit basic_io_object(boost::asio::io_service& io_service) + : service(boost::asio::use_service<IoObjectService>(io_service)) + { + service.construct(implementation); + } + + /// Protected destructor to prevent deletion through this type. + /** + * Performs: + * @code service.destroy(implementation); @endcode + */ + ~basic_io_object() + { + service.destroy(implementation); + } + + /// The service associated with the I/O object. + service_type& service; + + /// The underlying implementation of the I/O object. + implementation_type implementation; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_IO_OBJECT_HPP
diff --git a/boost_1_45_0/boost/asio/basic_raw_socket.hpp b/boost_1_45_0/boost/asio/basic_raw_socket.hpp new file mode 100644 index 0000000..0b877de --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_raw_socket.hpp
@@ -0,0 +1,797 @@ +// +// basic_raw_socket.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_RAW_SOCKET_HPP +#define BOOST_ASIO_BASIC_RAW_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/basic_socket.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/raw_socket_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides raw-oriented socket functionality. +/** + * The basic_raw_socket class template provides asynchronous and blocking + * raw-oriented socket functionality. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template <typename Protocol, + typename RawSocketService = raw_socket_service<Protocol> > +class basic_raw_socket + : public basic_socket<Protocol, RawSocketService> +{ +public: + /// The native representation of a socket. + typedef typename RawSocketService::native_type native_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_raw_socket without opening it. + /** + * This constructor creates a raw socket without opening it. The open() + * function must be called before data can be sent or received on the socket. + * + * @param io_service The io_service object that the raw socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + */ + explicit basic_raw_socket(boost::asio::io_service& io_service) + : basic_socket<Protocol, RawSocketService>(io_service) + { + } + + /// Construct and open a basic_raw_socket. + /** + * This constructor creates and opens a raw socket. + * + * @param io_service The io_service object that the raw socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_raw_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_socket<Protocol, RawSocketService>(io_service, protocol) + { + } + + /// Construct a basic_raw_socket, opening it and binding it to the given + /// local endpoint. + /** + * This constructor creates a raw socket and automatically opens it bound + * to the specified endpoint on the local machine. The protocol used is the + * protocol associated with the given endpoint. + * + * @param io_service The io_service object that the raw socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param endpoint An endpoint on the local machine to which the raw + * socket will be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_raw_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_socket<Protocol, RawSocketService>(io_service, endpoint) + { + } + + /// Construct a basic_raw_socket on an existing native socket. + /** + * This constructor creates a raw socket object to hold an existing + * native socket. + * + * @param io_service The io_service object that the raw socket will use + * to dispatch handlers for any asynchronous operations performed on the + * socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket The new underlying socket implementation. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_raw_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_type& native_socket) + : basic_socket<Protocol, RawSocketService>( + io_service, protocol, native_socket) + { + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the raw socket. The function call + * will block until the data has been sent successfully or an error occurs. + * + * @param buffers One ore more data buffers to be sent on the socket. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected raw socket. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code socket.send(boost::asio::buffer(data, size)); @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.send(this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the raw socket. The function call + * will block until the data has been sent successfully or an error occurs. + * + * @param buffers One ore more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected raw socket. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.send( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on a connected socket. + /** + * This function is used to send data on the raw socket. The function call + * will block until the data has been sent successfully or an error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. + * + * @note The send operation can only be used with a connected socket. Use + * the send_to function to send data on an unconnected raw socket. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.send(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous send on a connected socket. + /** + * This function is used to send data on the raw socket. The function call + * will block until the data has been sent successfully or an error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_send operation can only be used with a connected socket. + * Use the async_send_to function to send data on an unconnected raw + * socket. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous send on a connected socket. + /** + * This function is used to send data on the raw socket. The function call + * will block until the data has been sent successfully or an error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_send operation can only be used with a connected socket. + * Use the async_send_to function to send data on an unconnected raw + * socket. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, flags, handler); + } + + /// Send raw data to the specified endpoint. + /** + * This function is used to send raw data to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * boost::asio::ip::udp::endpoint destination( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.send_to(boost::asio::buffer(data, size), destination); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination) + { + boost::system::error_code ec; + std::size_t s = this->service.send_to( + this->implementation, buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send raw data to the specified endpoint. + /** + * This function is used to send raw data to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.send_to( + this->implementation, buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send raw data to the specified endpoint. + /** + * This function is used to send raw data to the specified remote endpoint. + * The function call will block until the data has been sent successfully or + * an error occurs. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * + * @param destination The remote endpoint to which the data will be sent. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. + */ + template <typename ConstBufferSequence> + std::size_t send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + boost::system::error_code& ec) + { + return this->service.send_to(this->implementation, + buffers, destination, flags, ec); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send raw data to the specified + * remote endpoint. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param destination The remote endpoint to which the data will be sent. + * Copies will be made of the endpoint as required. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * boost::asio::ip::udp::endpoint destination( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.async_send_to( + * boost::asio::buffer(data, size), destination, handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, WriteHandler handler) + { + this->service.async_send_to(this->implementation, buffers, destination, 0, + handler); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send raw data to the specified + * remote endpoint. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent to the remote endpoint. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param destination The remote endpoint to which the data will be sent. + * Copies will be made of the endpoint as required. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send_to(const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + WriteHandler handler) + { + this->service.async_send_to(this->implementation, buffers, destination, + flags, handler); + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the raw socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected raw + * socket. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code socket.receive(boost::asio::buffer(data, size)); @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.receive( + this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the raw socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected raw + * socket. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.receive( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the raw socket. The function + * call will block until data has been received successfully or an error + * occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. + * + * @note The receive operation can only be used with a connected socket. Use + * the receive_from function to receive data on an unconnected raw + * socket. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.receive(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous receive on a connected socket. + /** + * This function is used to asynchronously receive data from the raw + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_receive operation can only be used with a connected socket. + * Use the async_receive_from function to receive data on an unconnected + * raw socket. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous receive on a connected socket. + /** + * This function is used to asynchronously receive data from the raw + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The async_receive operation can only be used with a connected socket. + * Use the async_receive_from function to receive data on an unconnected + * raw socket. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, flags, handler); + } + + /// Receive raw data with the endpoint of the sender. + /** + * This function is used to receive raw data. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the data. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * boost::asio::ip::udp::endpoint sender_endpoint; + * socket.receive_from( + * boost::asio::buffer(data, size), sender_endpoint); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint) + { + boost::system::error_code ec; + std::size_t s = this->service.receive_from( + this->implementation, buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive raw data with the endpoint of the sender. + /** + * This function is used to receive raw data. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the data. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.receive_from( + this->implementation, buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive raw data with the endpoint of the sender. + /** + * This function is used to receive raw data. The function call will block + * until data has been received successfully or an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the data. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. + */ + template <typename MutableBufferSequence> + std::size_t receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags, + boost::system::error_code& ec) + { + return this->service.receive_from(this->implementation, buffers, + sender_endpoint, flags, ec); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive raw data. The function + * call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the data. Ownership of the sender_endpoint object + * is retained by the caller, which must guarantee that it is valid until the + * handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code socket.async_receive_from( + * boost::asio::buffer(data, size), 0, sender_endpoint, handler); @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, ReadHandler handler) + { + this->service.async_receive_from(this->implementation, buffers, + sender_endpoint, 0, handler); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive raw data. The function + * call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param sender_endpoint An endpoint object that receives the endpoint of + * the remote sender of the data. Ownership of the sender_endpoint object + * is retained by the caller, which must guarantee that it is valid until the + * handler is called. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive_from(const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags, + ReadHandler handler) + { + this->service.async_receive_from(this->implementation, buffers, + sender_endpoint, flags, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_RAW_SOCKET_HPP
diff --git a/boost_1_45_0/boost/asio/basic_serial_port.hpp b/boost_1_45_0/boost/asio/basic_serial_port.hpp new file mode 100644 index 0000000..4936c9c --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_serial_port.hpp
@@ -0,0 +1,622 @@ +// +// basic_serial_port.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SERIAL_PORT_HPP +#define BOOST_ASIO_BASIC_SERIAL_PORT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_SERIAL_PORT) \ + || defined(GENERATING_DOCUMENTATION) + +#include <string> +#include <boost/asio/basic_io_object.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/serial_port_base.hpp> +#include <boost/asio/serial_port_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides serial port functionality. +/** + * The basic_serial_port class template provides functionality that is common + * to all serial ports. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template <typename SerialPortService = serial_port_service> +class basic_serial_port + : public basic_io_object<SerialPortService>, + public serial_port_base +{ +public: + /// The native representation of a serial port. + typedef typename SerialPortService::native_type native_type; + + /// A basic_serial_port is always the lowest layer. + typedef basic_serial_port<SerialPortService> lowest_layer_type; + + /// Construct a basic_serial_port without opening it. + /** + * This constructor creates a serial port without opening it. + * + * @param io_service The io_service object that the serial port will use to + * dispatch handlers for any asynchronous operations performed on the port. + */ + explicit basic_serial_port(boost::asio::io_service& io_service) + : basic_io_object<SerialPortService>(io_service) + { + } + + /// Construct and open a basic_serial_port. + /** + * This constructor creates and opens a serial port for the specified device + * name. + * + * @param io_service The io_service object that the serial port will use to + * dispatch handlers for any asynchronous operations performed on the port. + * + * @param device The platform-specific device name for this serial + * port. + */ + explicit basic_serial_port(boost::asio::io_service& io_service, + const char* device) + : basic_io_object<SerialPortService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, device, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct and open a basic_serial_port. + /** + * This constructor creates and opens a serial port for the specified device + * name. + * + * @param io_service The io_service object that the serial port will use to + * dispatch handlers for any asynchronous operations performed on the port. + * + * @param device The platform-specific device name for this serial + * port. + */ + explicit basic_serial_port(boost::asio::io_service& io_service, + const std::string& device) + : basic_io_object<SerialPortService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, device, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct a basic_serial_port on an existing native serial port. + /** + * This constructor creates a serial port object to hold an existing native + * serial port. + * + * @param io_service The io_service object that the serial port will use to + * dispatch handlers for any asynchronous operations performed on the port. + * + * @param native_serial_port A native serial port. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_serial_port(boost::asio::io_service& io_service, + const native_type& native_serial_port) + : basic_io_object<SerialPortService>(io_service) + { + boost::system::error_code ec; + this->service.assign(this->implementation, native_serial_port, ec); + boost::asio::detail::throw_error(ec); + } + + /// Get a reference to the lowest layer. + /** + * This function returns a reference to the lowest layer in a stack of + * layers. Since a basic_serial_port cannot contain any further layers, it + * simply returns a reference to itself. + * + * @return A reference to the lowest layer in the stack of layers. Ownership + * is not transferred to the caller. + */ + lowest_layer_type& lowest_layer() + { + return *this; + } + + /// Get a const reference to the lowest layer. + /** + * This function returns a const reference to the lowest layer in a stack of + * layers. Since a basic_serial_port cannot contain any further layers, it + * simply returns a reference to itself. + * + * @return A const reference to the lowest layer in the stack of layers. + * Ownership is not transferred to the caller. + */ + const lowest_layer_type& lowest_layer() const + { + return *this; + } + + /// Open the serial port using the specified device name. + /** + * This function opens the serial port for the specified device name. + * + * @param device The platform-specific device name. + * + * @throws boost::system::system_error Thrown on failure. + */ + void open(const std::string& device) + { + boost::system::error_code ec; + this->service.open(this->implementation, device, ec); + boost::asio::detail::throw_error(ec); + } + + /// Open the serial port using the specified device name. + /** + * This function opens the serial port using the given platform-specific + * device name. + * + * @param device The platform-specific device name. + * + * @param ec Set the indicate what error occurred, if any. + */ + boost::system::error_code open(const std::string& device, + boost::system::error_code& ec) + { + return this->service.open(this->implementation, device, ec); + } + + /// Assign an existing native serial port to the serial port. + /* + * This function opens the serial port to hold an existing native serial port. + * + * @param native_serial_port A native serial port. + * + * @throws boost::system::system_error Thrown on failure. + */ + void assign(const native_type& native_serial_port) + { + boost::system::error_code ec; + this->service.assign(this->implementation, native_serial_port, ec); + boost::asio::detail::throw_error(ec); + } + + /// Assign an existing native serial port to the serial port. + /* + * This function opens the serial port to hold an existing native serial port. + * + * @param native_serial_port A native serial port. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code assign(const native_type& native_serial_port, + boost::system::error_code& ec) + { + return this->service.assign(this->implementation, native_serial_port, ec); + } + + /// Determine whether the serial port is open. + bool is_open() const + { + return this->service.is_open(this->implementation); + } + + /// Close the serial port. + /** + * This function is used to close the serial port. Any asynchronous read or + * write operations will be cancelled immediately, and will complete with the + * boost::asio::error::operation_aborted error. + * + * @throws boost::system::system_error Thrown on failure. + */ + void close() + { + boost::system::error_code ec; + this->service.close(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Close the serial port. + /** + * This function is used to close the serial port. Any asynchronous read or + * write operations will be cancelled immediately, and will complete with the + * boost::asio::error::operation_aborted error. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code close(boost::system::error_code& ec) + { + return this->service.close(this->implementation, ec); + } + + /// Get the native serial port representation. + /** + * This function may be used to obtain the underlying representation of the + * serial port. This is intended to allow access to native serial port + * functionality that is not otherwise provided. + */ + native_type native() + { + return this->service.native(this->implementation); + } + + /// Cancel all asynchronous operations associated with the serial port. + /** + * This function causes all outstanding asynchronous read or write operations + * to finish immediately, and the handlers for cancelled operations will be + * passed the boost::asio::error::operation_aborted error. + * + * @throws boost::system::system_error Thrown on failure. + */ + void cancel() + { + boost::system::error_code ec; + this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Cancel all asynchronous operations associated with the serial port. + /** + * This function causes all outstanding asynchronous read or write operations + * to finish immediately, and the handlers for cancelled operations will be + * passed the boost::asio::error::operation_aborted error. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Send a break sequence to the serial port. + /** + * This function causes a break sequence of platform-specific duration to be + * sent out the serial port. + * + * @throws boost::system::system_error Thrown on failure. + */ + void send_break() + { + boost::system::error_code ec; + this->service.send_break(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Send a break sequence to the serial port. + /** + * This function causes a break sequence of platform-specific duration to be + * sent out the serial port. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code send_break(boost::system::error_code& ec) + { + return this->service.send_break(this->implementation, ec); + } + + /// Set an option on the serial port. + /** + * This function is used to set an option on the serial port. + * + * @param option The option value to be set on the serial port. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa SettableSerialPortOption @n + * boost::asio::serial_port_base::baud_rate @n + * boost::asio::serial_port_base::flow_control @n + * boost::asio::serial_port_base::parity @n + * boost::asio::serial_port_base::stop_bits @n + * boost::asio::serial_port_base::character_size + */ + template <typename SettableSerialPortOption> + void set_option(const SettableSerialPortOption& option) + { + boost::system::error_code ec; + this->service.set_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Set an option on the serial port. + /** + * This function is used to set an option on the serial port. + * + * @param option The option value to be set on the serial port. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa SettableSerialPortOption @n + * boost::asio::serial_port_base::baud_rate @n + * boost::asio::serial_port_base::flow_control @n + * boost::asio::serial_port_base::parity @n + * boost::asio::serial_port_base::stop_bits @n + * boost::asio::serial_port_base::character_size + */ + template <typename SettableSerialPortOption> + boost::system::error_code set_option(const SettableSerialPortOption& option, + boost::system::error_code& ec) + { + return this->service.set_option(this->implementation, option, ec); + } + + /// Get an option from the serial port. + /** + * This function is used to get the current value of an option on the serial + * port. + * + * @param option The option value to be obtained from the serial port. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa GettableSerialPortOption @n + * boost::asio::serial_port_base::baud_rate @n + * boost::asio::serial_port_base::flow_control @n + * boost::asio::serial_port_base::parity @n + * boost::asio::serial_port_base::stop_bits @n + * boost::asio::serial_port_base::character_size + */ + template <typename GettableSerialPortOption> + void get_option(GettableSerialPortOption& option) + { + boost::system::error_code ec; + this->service.get_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Get an option from the serial port. + /** + * This function is used to get the current value of an option on the serial + * port. + * + * @param option The option value to be obtained from the serial port. + * + * @param ec Set to indicate what error occured, if any. + * + * @sa GettableSerialPortOption @n + * boost::asio::serial_port_base::baud_rate @n + * boost::asio::serial_port_base::flow_control @n + * boost::asio::serial_port_base::parity @n + * boost::asio::serial_port_base::stop_bits @n + * boost::asio::serial_port_base::character_size + */ + template <typename GettableSerialPortOption> + boost::system::error_code get_option(GettableSerialPortOption& option, + boost::system::error_code& ec) + { + return this->service.get_option(this->implementation, option, ec); + } + + /// Write some data to the serial port. + /** + * This function is used to write data to the serial port. The function call + * will block until one or more bytes of the data has been written + * successfully, or until an error occurs. + * + * @param buffers One or more data buffers to be written to the serial port. + * + * @returns The number of bytes written. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The write_some operation may not transmit all of the data to the + * peer. Consider using the @ref write function if you need to ensure that + * all data is written before the blocking operation completes. + * + * @par Example + * To write a single data buffer use the @ref buffer function as follows: + * @code + * serial_port.write_some(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on writing multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.write_some(this->implementation, buffers, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Write some data to the serial port. + /** + * This function is used to write data to the serial port. The function call + * will block until one or more bytes of the data has been written + * successfully, or until an error occurs. + * + * @param buffers One or more data buffers to be written to the serial port. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes written. Returns 0 if an error occurred. + * + * @note The write_some operation may not transmit all of the data to the + * peer. Consider using the @ref write function if you need to ensure that + * all data is written before the blocking operation completes. + */ + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers, + boost::system::error_code& ec) + { + return this->service.write_some(this->implementation, buffers, ec); + } + + /// Start an asynchronous write. + /** + * This function is used to asynchronously write data to the serial port. + * The function call always returns immediately. + * + * @param buffers One or more data buffers to be written to the serial port. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the write operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes written. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The write operation may not transmit all of the data to the peer. + * Consider using the @ref async_write function if you need to ensure that all + * data is written before the asynchronous operation completes. + * + * @par Example + * To write a single data buffer use the @ref buffer function as follows: + * @code + * serial_port.async_write_some(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on writing multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_write_some(const ConstBufferSequence& buffers, + WriteHandler handler) + { + this->service.async_write_some(this->implementation, buffers, handler); + } + + /// Read some data from the serial port. + /** + * This function is used to read data from the serial port. The function + * call will block until one or more bytes of data has been read successfully, + * or until an error occurs. + * + * @param buffers One or more buffers into which the data will be read. + * + * @returns The number of bytes read. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The read_some operation may not read all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that + * the requested amount of data is read before the blocking operation + * completes. + * + * @par Example + * To read into a single data buffer use the @ref buffer function as follows: + * @code + * serial_port.read_some(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on reading into multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.read_some(this->implementation, buffers, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Read some data from the serial port. + /** + * This function is used to read data from the serial port. The function + * call will block until one or more bytes of data has been read successfully, + * or until an error occurs. + * + * @param buffers One or more buffers into which the data will be read. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes read. Returns 0 if an error occurred. + * + * @note The read_some operation may not read all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that + * the requested amount of data is read before the blocking operation + * completes. + */ + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return this->service.read_some(this->implementation, buffers, ec); + } + + /// Start an asynchronous read. + /** + * This function is used to asynchronously read data from the serial port. + * The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be read. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the read operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes read. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The read operation may not read all of the requested number of bytes. + * Consider using the @ref async_read function if you need to ensure that the + * requested amount of data is read before the asynchronous operation + * completes. + * + * @par Example + * To read into a single data buffer use the @ref buffer function as follows: + * @code + * serial_port.async_read_some(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on reading into multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_read_some(const MutableBufferSequence& buffers, + ReadHandler handler) + { + this->service.async_read_some(this->implementation, buffers, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT) + // || defined(GENERATING_DOCUMENTATION) + +#endif // BOOST_ASIO_BASIC_SERIAL_PORT_HPP
diff --git a/boost_1_45_0/boost/asio/basic_socket.hpp b/boost_1_45_0/boost/asio/basic_socket.hpp new file mode 100644 index 0000000..50a0c47 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_socket.hpp
@@ -0,0 +1,1062 @@ +// +// basic_socket.hpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SOCKET_HPP +#define BOOST_ASIO_BASIC_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/basic_io_object.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/socket_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides socket functionality. +/** + * The basic_socket class template provides functionality that is common to both + * stream-oriented and datagram-oriented sockets. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template <typename Protocol, typename SocketService> +class basic_socket + : public basic_io_object<SocketService>, + public socket_base +{ +public: + /// The native representation of a socket. + typedef typename SocketService::native_type native_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// A basic_socket is always the lowest layer. + typedef basic_socket<Protocol, SocketService> lowest_layer_type; + + /// Construct a basic_socket without opening it. + /** + * This constructor creates a socket without opening it. + * + * @param io_service The io_service object that the socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + */ + explicit basic_socket(boost::asio::io_service& io_service) + : basic_io_object<SocketService>(io_service) + { + } + + /// Construct and open a basic_socket. + /** + * This constructor creates and opens a socket. + * + * @param io_service The io_service object that the socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_io_object<SocketService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, protocol, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct a basic_socket, opening it and binding it to the given local + /// endpoint. + /** + * This constructor creates a socket and automatically opens it bound to the + * specified endpoint on the local machine. The protocol used is the protocol + * associated with the given endpoint. + * + * @param io_service The io_service object that the socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param endpoint An endpoint on the local machine to which the socket will + * be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_io_object<SocketService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, endpoint.protocol(), ec); + boost::asio::detail::throw_error(ec); + this->service.bind(this->implementation, endpoint, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct a basic_socket on an existing native socket. + /** + * This constructor creates a socket object to hold an existing native socket. + * + * @param io_service The io_service object that the socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket A native socket. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_type& native_socket) + : basic_io_object<SocketService>(io_service) + { + boost::system::error_code ec; + this->service.assign(this->implementation, protocol, native_socket, ec); + boost::asio::detail::throw_error(ec); + } + + /// Get a reference to the lowest layer. + /** + * This function returns a reference to the lowest layer in a stack of + * layers. Since a basic_socket cannot contain any further layers, it simply + * returns a reference to itself. + * + * @return A reference to the lowest layer in the stack of layers. Ownership + * is not transferred to the caller. + */ + lowest_layer_type& lowest_layer() + { + return *this; + } + + /// Get a const reference to the lowest layer. + /** + * This function returns a const reference to the lowest layer in a stack of + * layers. Since a basic_socket cannot contain any further layers, it simply + * returns a reference to itself. + * + * @return A const reference to the lowest layer in the stack of layers. + * Ownership is not transferred to the caller. + */ + const lowest_layer_type& lowest_layer() const + { + return *this; + } + + /// Open the socket using the specified protocol. + /** + * This function opens the socket so that it will use the specified protocol. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * socket.open(boost::asio::ip::tcp::v4()); + * @endcode + */ + void open(const protocol_type& protocol = protocol_type()) + { + boost::system::error_code ec; + this->service.open(this->implementation, protocol, ec); + boost::asio::detail::throw_error(ec); + } + + /// Open the socket using the specified protocol. + /** + * This function opens the socket so that it will use the specified protocol. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * boost::system::error_code ec; + * socket.open(boost::asio::ip::tcp::v4(), ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code open(const protocol_type& protocol, + boost::system::error_code& ec) + { + return this->service.open(this->implementation, protocol, ec); + } + + /// Assign an existing native socket to the socket. + /* + * This function opens the socket to hold an existing native socket. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param native_socket A native socket. + * + * @throws boost::system::system_error Thrown on failure. + */ + void assign(const protocol_type& protocol, const native_type& native_socket) + { + boost::system::error_code ec; + this->service.assign(this->implementation, protocol, native_socket, ec); + boost::asio::detail::throw_error(ec); + } + + /// Assign an existing native socket to the socket. + /* + * This function opens the socket to hold an existing native socket. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param native_socket A native socket. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code assign(const protocol_type& protocol, + const native_type& native_socket, boost::system::error_code& ec) + { + return this->service.assign(this->implementation, + protocol, native_socket, ec); + } + + /// Determine whether the socket is open. + bool is_open() const + { + return this->service.is_open(this->implementation); + } + + /// Close the socket. + /** + * This function is used to close the socket. Any asynchronous send, receive + * or connect operations will be cancelled immediately, and will complete + * with the boost::asio::error::operation_aborted error. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note For portable behaviour with respect to graceful closure of a + * connected socket, call shutdown() before closing the socket. + */ + void close() + { + boost::system::error_code ec; + this->service.close(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Close the socket. + /** + * This function is used to close the socket. Any asynchronous send, receive + * or connect operations will be cancelled immediately, and will complete + * with the boost::asio::error::operation_aborted error. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::system::error_code ec; + * socket.close(ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + * + * @note For portable behaviour with respect to graceful closure of a + * connected socket, call shutdown() before closing the socket. + */ + boost::system::error_code close(boost::system::error_code& ec) + { + return this->service.close(this->implementation, ec); + } + + /// Get the native socket representation. + /** + * This function may be used to obtain the underlying representation of the + * socket. This is intended to allow access to native socket functionality + * that is not otherwise provided. + */ + native_type native() + { + return this->service.native(this->implementation); + } + + /// Cancel all asynchronous operations associated with the socket. + /** + * This function causes all outstanding asynchronous connect, send and receive + * operations to finish immediately, and the handlers for cancelled operations + * will be passed the boost::asio::error::operation_aborted error. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note Calls to cancel() will always fail with + * boost::asio::error::operation_not_supported when run on Windows XP, Windows + * Server 2003, and earlier versions of Windows, unless + * BOOST_ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has + * two issues that should be considered before enabling its use: + * + * @li It will only cancel asynchronous operations that were initiated in the + * current thread. + * + * @li It can appear to complete without error, but the request to cancel the + * unfinished operations may be silently ignored by the operating system. + * Whether it works or not seems to depend on the drivers that are installed. + * + * For portable cancellation, consider using one of the following + * alternatives: + * + * @li Disable asio's I/O completion port backend by defining + * BOOST_ASIO_DISABLE_IOCP. + * + * @li Use the close() function to simultaneously cancel the outstanding + * operations and close the socket. + * + * When running on Windows Vista, Windows Server 2008, and later, the + * CancelIoEx function is always used. This function does not have the + * problems described above. + */ +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) \ + && (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \ + && !defined(BOOST_ASIO_ENABLE_CANCELIO) + __declspec(deprecated("By default, this function always fails with " + "operation_not_supported when used on Windows XP, Windows Server 2003, " + "or earlier. Consult documentation for details.")) +#endif + void cancel() + { + boost::system::error_code ec; + this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Cancel all asynchronous operations associated with the socket. + /** + * This function causes all outstanding asynchronous connect, send and receive + * operations to finish immediately, and the handlers for cancelled operations + * will be passed the boost::asio::error::operation_aborted error. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note Calls to cancel() will always fail with + * boost::asio::error::operation_not_supported when run on Windows XP, Windows + * Server 2003, and earlier versions of Windows, unless + * BOOST_ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has + * two issues that should be considered before enabling its use: + * + * @li It will only cancel asynchronous operations that were initiated in the + * current thread. + * + * @li It can appear to complete without error, but the request to cancel the + * unfinished operations may be silently ignored by the operating system. + * Whether it works or not seems to depend on the drivers that are installed. + * + * For portable cancellation, consider using one of the following + * alternatives: + * + * @li Disable asio's I/O completion port backend by defining + * BOOST_ASIO_DISABLE_IOCP. + * + * @li Use the close() function to simultaneously cancel the outstanding + * operations and close the socket. + * + * When running on Windows Vista, Windows Server 2008, and later, the + * CancelIoEx function is always used. This function does not have the + * problems described above. + */ +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) \ + && (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \ + && !defined(BOOST_ASIO_ENABLE_CANCELIO) + __declspec(deprecated("By default, this function always fails with " + "operation_not_supported when used on Windows XP, Windows Server 2003, " + "or earlier. Consult documentation for details.")) +#endif + boost::system::error_code cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Determine whether the socket is at the out-of-band data mark. + /** + * This function is used to check whether the socket input is currently + * positioned at the out-of-band data mark. + * + * @return A bool indicating whether the socket is at the out-of-band data + * mark. + * + * @throws boost::system::system_error Thrown on failure. + */ + bool at_mark() const + { + boost::system::error_code ec; + bool b = this->service.at_mark(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return b; + } + + /// Determine whether the socket is at the out-of-band data mark. + /** + * This function is used to check whether the socket input is currently + * positioned at the out-of-band data mark. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return A bool indicating whether the socket is at the out-of-band data + * mark. + */ + bool at_mark(boost::system::error_code& ec) const + { + return this->service.at_mark(this->implementation, ec); + } + + /// Determine the number of bytes available for reading. + /** + * This function is used to determine the number of bytes that may be read + * without blocking. + * + * @return The number of bytes that may be read without blocking, or 0 if an + * error occurs. + * + * @throws boost::system::system_error Thrown on failure. + */ + std::size_t available() const + { + boost::system::error_code ec; + std::size_t s = this->service.available(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Determine the number of bytes available for reading. + /** + * This function is used to determine the number of bytes that may be read + * without blocking. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of bytes that may be read without blocking, or 0 if an + * error occurs. + */ + std::size_t available(boost::system::error_code& ec) const + { + return this->service.available(this->implementation, ec); + } + + /// Bind the socket to the given local endpoint. + /** + * This function binds the socket to the specified endpoint on the local + * machine. + * + * @param endpoint An endpoint on the local machine to which the socket will + * be bound. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * socket.open(boost::asio::ip::tcp::v4()); + * socket.bind(boost::asio::ip::tcp::endpoint( + * boost::asio::ip::tcp::v4(), 12345)); + * @endcode + */ + void bind(const endpoint_type& endpoint) + { + boost::system::error_code ec; + this->service.bind(this->implementation, endpoint, ec); + boost::asio::detail::throw_error(ec); + } + + /// Bind the socket to the given local endpoint. + /** + * This function binds the socket to the specified endpoint on the local + * machine. + * + * @param endpoint An endpoint on the local machine to which the socket will + * be bound. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * socket.open(boost::asio::ip::tcp::v4()); + * boost::system::error_code ec; + * socket.bind(boost::asio::ip::tcp::endpoint( + * boost::asio::ip::tcp::v4(), 12345), ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code bind(const endpoint_type& endpoint, + boost::system::error_code& ec) + { + return this->service.bind(this->implementation, endpoint, ec); + } + + /// Connect the socket to the specified endpoint. + /** + * This function is used to connect a socket to the specified remote endpoint. + * The function call will block until the connection is successfully made or + * an error occurs. + * + * The socket is automatically opened if it is not already open. If the + * connect fails, and the socket was automatically opened, the socket is + * not returned to the closed state. + * + * @param peer_endpoint The remote endpoint to which the socket will be + * connected. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * boost::asio::ip::tcp::endpoint endpoint( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.connect(endpoint); + * @endcode + */ + void connect(const endpoint_type& peer_endpoint) + { + boost::system::error_code ec; + if (!is_open()) + { + this->service.open(this->implementation, peer_endpoint.protocol(), ec); + boost::asio::detail::throw_error(ec); + } + this->service.connect(this->implementation, peer_endpoint, ec); + boost::asio::detail::throw_error(ec); + } + + /// Connect the socket to the specified endpoint. + /** + * This function is used to connect a socket to the specified remote endpoint. + * The function call will block until the connection is successfully made or + * an error occurs. + * + * The socket is automatically opened if it is not already open. If the + * connect fails, and the socket was automatically opened, the socket is + * not returned to the closed state. + * + * @param peer_endpoint The remote endpoint to which the socket will be + * connected. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * boost::asio::ip::tcp::endpoint endpoint( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * boost::system::error_code ec; + * socket.connect(endpoint, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code connect(const endpoint_type& peer_endpoint, + boost::system::error_code& ec) + { + if (!is_open()) + { + if (this->service.open(this->implementation, + peer_endpoint.protocol(), ec)) + { + return ec; + } + } + + return this->service.connect(this->implementation, peer_endpoint, ec); + } + + /// Start an asynchronous connect. + /** + * This function is used to asynchronously connect a socket to the specified + * remote endpoint. The function call always returns immediately. + * + * The socket is automatically opened if it is not already open. If the + * connect fails, and the socket was automatically opened, the socket is + * not returned to the closed state. + * + * @param peer_endpoint The remote endpoint to which the socket will be + * connected. Copies will be made of the endpoint object as required. + * + * @param handler The handler to be called when the connection operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error // Result of operation + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * @code + * void connect_handler(const boost::system::error_code& error) + * { + * if (!error) + * { + * // Connect succeeded. + * } + * } + * + * ... + * + * boost::asio::ip::tcp::socket socket(io_service); + * boost::asio::ip::tcp::endpoint endpoint( + * boost::asio::ip::address::from_string("1.2.3.4"), 12345); + * socket.async_connect(endpoint, connect_handler); + * @endcode + */ + template <typename ConnectHandler> + void async_connect(const endpoint_type& peer_endpoint, ConnectHandler handler) + { + if (!is_open()) + { + boost::system::error_code ec; + if (this->service.open(this->implementation, + peer_endpoint.protocol(), ec)) + { + this->get_io_service().post( + boost::asio::detail::bind_handler(handler, ec)); + return; + } + } + + this->service.async_connect(this->implementation, peer_endpoint, handler); + } + + /// Set an option on the socket. + /** + * This function is used to set an option on the socket. + * + * @param option The new option value to be set on the socket. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa SettableSocketOption @n + * boost::asio::socket_base::broadcast @n + * boost::asio::socket_base::do_not_route @n + * boost::asio::socket_base::keep_alive @n + * boost::asio::socket_base::linger @n + * boost::asio::socket_base::receive_buffer_size @n + * boost::asio::socket_base::receive_low_watermark @n + * boost::asio::socket_base::reuse_address @n + * boost::asio::socket_base::send_buffer_size @n + * boost::asio::socket_base::send_low_watermark @n + * boost::asio::ip::multicast::join_group @n + * boost::asio::ip::multicast::leave_group @n + * boost::asio::ip::multicast::enable_loopback @n + * boost::asio::ip::multicast::outbound_interface @n + * boost::asio::ip::multicast::hops @n + * boost::asio::ip::tcp::no_delay + * + * @par Example + * Setting the IPPROTO_TCP/TCP_NODELAY option: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::no_delay option(true); + * socket.set_option(option); + * @endcode + */ + template <typename SettableSocketOption> + void set_option(const SettableSocketOption& option) + { + boost::system::error_code ec; + this->service.set_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Set an option on the socket. + /** + * This function is used to set an option on the socket. + * + * @param option The new option value to be set on the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa SettableSocketOption @n + * boost::asio::socket_base::broadcast @n + * boost::asio::socket_base::do_not_route @n + * boost::asio::socket_base::keep_alive @n + * boost::asio::socket_base::linger @n + * boost::asio::socket_base::receive_buffer_size @n + * boost::asio::socket_base::receive_low_watermark @n + * boost::asio::socket_base::reuse_address @n + * boost::asio::socket_base::send_buffer_size @n + * boost::asio::socket_base::send_low_watermark @n + * boost::asio::ip::multicast::join_group @n + * boost::asio::ip::multicast::leave_group @n + * boost::asio::ip::multicast::enable_loopback @n + * boost::asio::ip::multicast::outbound_interface @n + * boost::asio::ip::multicast::hops @n + * boost::asio::ip::tcp::no_delay + * + * @par Example + * Setting the IPPROTO_TCP/TCP_NODELAY option: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::no_delay option(true); + * boost::system::error_code ec; + * socket.set_option(option, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template <typename SettableSocketOption> + boost::system::error_code set_option(const SettableSocketOption& option, + boost::system::error_code& ec) + { + return this->service.set_option(this->implementation, option, ec); + } + + /// Get an option from the socket. + /** + * This function is used to get the current value of an option on the socket. + * + * @param option The option value to be obtained from the socket. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa GettableSocketOption @n + * boost::asio::socket_base::broadcast @n + * boost::asio::socket_base::do_not_route @n + * boost::asio::socket_base::keep_alive @n + * boost::asio::socket_base::linger @n + * boost::asio::socket_base::receive_buffer_size @n + * boost::asio::socket_base::receive_low_watermark @n + * boost::asio::socket_base::reuse_address @n + * boost::asio::socket_base::send_buffer_size @n + * boost::asio::socket_base::send_low_watermark @n + * boost::asio::ip::multicast::join_group @n + * boost::asio::ip::multicast::leave_group @n + * boost::asio::ip::multicast::enable_loopback @n + * boost::asio::ip::multicast::outbound_interface @n + * boost::asio::ip::multicast::hops @n + * boost::asio::ip::tcp::no_delay + * + * @par Example + * Getting the value of the SOL_SOCKET/SO_KEEPALIVE option: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::socket::keep_alive option; + * socket.get_option(option); + * bool is_set = option.get(); + * @endcode + */ + template <typename GettableSocketOption> + void get_option(GettableSocketOption& option) const + { + boost::system::error_code ec; + this->service.get_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Get an option from the socket. + /** + * This function is used to get the current value of an option on the socket. + * + * @param option The option value to be obtained from the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa GettableSocketOption @n + * boost::asio::socket_base::broadcast @n + * boost::asio::socket_base::do_not_route @n + * boost::asio::socket_base::keep_alive @n + * boost::asio::socket_base::linger @n + * boost::asio::socket_base::receive_buffer_size @n + * boost::asio::socket_base::receive_low_watermark @n + * boost::asio::socket_base::reuse_address @n + * boost::asio::socket_base::send_buffer_size @n + * boost::asio::socket_base::send_low_watermark @n + * boost::asio::ip::multicast::join_group @n + * boost::asio::ip::multicast::leave_group @n + * boost::asio::ip::multicast::enable_loopback @n + * boost::asio::ip::multicast::outbound_interface @n + * boost::asio::ip::multicast::hops @n + * boost::asio::ip::tcp::no_delay + * + * @par Example + * Getting the value of the SOL_SOCKET/SO_KEEPALIVE option: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::socket::keep_alive option; + * boost::system::error_code ec; + * socket.get_option(option, ec); + * if (ec) + * { + * // An error occurred. + * } + * bool is_set = option.get(); + * @endcode + */ + template <typename GettableSocketOption> + boost::system::error_code get_option(GettableSocketOption& option, + boost::system::error_code& ec) const + { + return this->service.get_option(this->implementation, option, ec); + } + + /// Perform an IO control command on the socket. + /** + * This function is used to execute an IO control command on the socket. + * + * @param command The IO control command to be performed on the socket. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::bytes_readable @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::socket::bytes_readable command; + * socket.io_control(command); + * std::size_t bytes_readable = command.get(); + * @endcode + */ + template <typename IoControlCommand> + void io_control(IoControlCommand& command) + { + boost::system::error_code ec; + this->service.io_control(this->implementation, command, ec); + boost::asio::detail::throw_error(ec); + } + + /// Perform an IO control command on the socket. + /** + * This function is used to execute an IO control command on the socket. + * + * @param command The IO control command to be performed on the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::bytes_readable @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::socket::bytes_readable command; + * boost::system::error_code ec; + * socket.io_control(command, ec); + * if (ec) + * { + * // An error occurred. + * } + * std::size_t bytes_readable = command.get(); + * @endcode + */ + template <typename IoControlCommand> + boost::system::error_code io_control(IoControlCommand& command, + boost::system::error_code& ec) + { + return this->service.io_control(this->implementation, command, ec); + } + + /// Get the local endpoint of the socket. + /** + * This function is used to obtain the locally bound endpoint of the socket. + * + * @returns An object that represents the local endpoint of the socket. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint(); + * @endcode + */ + endpoint_type local_endpoint() const + { + boost::system::error_code ec; + endpoint_type ep = this->service.local_endpoint(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return ep; + } + + /// Get the local endpoint of the socket. + /** + * This function is used to obtain the locally bound endpoint of the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns An object that represents the local endpoint of the socket. + * Returns a default-constructed endpoint object if an error occurred. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::system::error_code ec; + * boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + endpoint_type local_endpoint(boost::system::error_code& ec) const + { + return this->service.local_endpoint(this->implementation, ec); + } + + /// Get the remote endpoint of the socket. + /** + * This function is used to obtain the remote endpoint of the socket. + * + * @returns An object that represents the remote endpoint of the socket. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(); + * @endcode + */ + endpoint_type remote_endpoint() const + { + boost::system::error_code ec; + endpoint_type ep = this->service.remote_endpoint(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return ep; + } + + /// Get the remote endpoint of the socket. + /** + * This function is used to obtain the remote endpoint of the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns An object that represents the remote endpoint of the socket. + * Returns a default-constructed endpoint object if an error occurred. + * + * @par Example + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::system::error_code ec; + * boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + endpoint_type remote_endpoint(boost::system::error_code& ec) const + { + return this->service.remote_endpoint(this->implementation, ec); + } + + /// Disable sends or receives on the socket. + /** + * This function is used to disable send operations, receive operations, or + * both. + * + * @param what Determines what types of operation will no longer be allowed. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * Shutting down the send side of the socket: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * socket.shutdown(boost::asio::ip::tcp::socket::shutdown_send); + * @endcode + */ + void shutdown(shutdown_type what) + { + boost::system::error_code ec; + this->service.shutdown(this->implementation, what, ec); + boost::asio::detail::throw_error(ec); + } + + /// Disable sends or receives on the socket. + /** + * This function is used to disable send operations, receive operations, or + * both. + * + * @param what Determines what types of operation will no longer be allowed. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * Shutting down the send side of the socket: + * @code + * boost::asio::ip::tcp::socket socket(io_service); + * ... + * boost::system::error_code ec; + * socket.shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code shutdown(shutdown_type what, + boost::system::error_code& ec) + { + return this->service.shutdown(this->implementation, what, ec); + } + +protected: + /// Protected destructor to prevent deletion through this type. + ~basic_socket() + { + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_SOCKET_HPP
diff --git a/boost_1_45_0/boost/asio/basic_socket_acceptor.hpp b/boost_1_45_0/boost/asio/basic_socket_acceptor.hpp new file mode 100644 index 0000000..5192df7 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_socket_acceptor.hpp
@@ -0,0 +1,827 @@ +// +// basic_socket_acceptor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SOCKET_ACCEPTOR_HPP +#define BOOST_ASIO_BASIC_SOCKET_ACCEPTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/basic_io_object.hpp> +#include <boost/asio/basic_socket.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/socket_acceptor_service.hpp> +#include <boost/asio/socket_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides the ability to accept new connections. +/** + * The basic_socket_acceptor class template is used for accepting new socket + * connections. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Example + * Opening a socket acceptor with the SO_REUSEADDR option enabled: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), port); + * acceptor.open(endpoint.protocol()); + * acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + * acceptor.bind(endpoint); + * acceptor.listen(); + * @endcode + */ +template <typename Protocol, + typename SocketAcceptorService = socket_acceptor_service<Protocol> > +class basic_socket_acceptor + : public basic_io_object<SocketAcceptorService>, + public socket_base +{ +public: + /// The native representation of an acceptor. + typedef typename SocketAcceptorService::native_type native_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct an acceptor without opening it. + /** + * This constructor creates an acceptor without opening it to listen for new + * connections. The open() function must be called before the acceptor can + * accept new socket connections. + * + * @param io_service The io_service object that the acceptor will use to + * dispatch handlers for any asynchronous operations performed on the + * acceptor. + */ + explicit basic_socket_acceptor(boost::asio::io_service& io_service) + : basic_io_object<SocketAcceptorService>(io_service) + { + } + + /// Construct an open acceptor. + /** + * This constructor creates an acceptor and automatically opens it. + * + * @param io_service The io_service object that the acceptor will use to + * dispatch handlers for any asynchronous operations performed on the + * acceptor. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_socket_acceptor(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_io_object<SocketAcceptorService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, protocol, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct an acceptor opened on the given endpoint. + /** + * This constructor creates an acceptor and automatically opens it to listen + * for new connections on the specified endpoint. + * + * @param io_service The io_service object that the acceptor will use to + * dispatch handlers for any asynchronous operations performed on the + * acceptor. + * + * @param endpoint An endpoint on the local machine on which the acceptor + * will listen for new connections. + * + * @param reuse_addr Whether the constructor should set the socket option + * socket_base::reuse_address. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note This constructor is equivalent to the following code: + * @code + * basic_socket_acceptor<Protocol> acceptor(io_service); + * acceptor.open(endpoint.protocol()); + * if (reuse_addr) + * acceptor.set_option(socket_base::reuse_address(true)); + * acceptor.bind(endpoint); + * acceptor.listen(listen_backlog); + * @endcode + */ + basic_socket_acceptor(boost::asio::io_service& io_service, + const endpoint_type& endpoint, bool reuse_addr = true) + : basic_io_object<SocketAcceptorService>(io_service) + { + boost::system::error_code ec; + this->service.open(this->implementation, endpoint.protocol(), ec); + boost::asio::detail::throw_error(ec); + if (reuse_addr) + { + this->service.set_option(this->implementation, + socket_base::reuse_address(true), ec); + boost::asio::detail::throw_error(ec); + } + this->service.bind(this->implementation, endpoint, ec); + boost::asio::detail::throw_error(ec); + this->service.listen(this->implementation, + socket_base::max_connections, ec); + boost::asio::detail::throw_error(ec); + } + + /// Construct a basic_socket_acceptor on an existing native acceptor. + /** + * This constructor creates an acceptor object to hold an existing native + * acceptor. + * + * @param io_service The io_service object that the acceptor will use to + * dispatch handlers for any asynchronous operations performed on the + * acceptor. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_acceptor A native acceptor. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_socket_acceptor(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_type& native_acceptor) + : basic_io_object<SocketAcceptorService>(io_service) + { + boost::system::error_code ec; + this->service.assign(this->implementation, protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec); + } + + /// Open the acceptor using the specified protocol. + /** + * This function opens the socket acceptor so that it will use the specified + * protocol. + * + * @param protocol An object specifying which protocol is to be used. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * acceptor.open(boost::asio::ip::tcp::v4()); + * @endcode + */ + void open(const protocol_type& protocol = protocol_type()) + { + boost::system::error_code ec; + this->service.open(this->implementation, protocol, ec); + boost::asio::detail::throw_error(ec); + } + + /// Open the acceptor using the specified protocol. + /** + * This function opens the socket acceptor so that it will use the specified + * protocol. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * boost::system::error_code ec; + * acceptor.open(boost::asio::ip::tcp::v4(), ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code open(const protocol_type& protocol, + boost::system::error_code& ec) + { + return this->service.open(this->implementation, protocol, ec); + } + + /// Assigns an existing native acceptor to the acceptor. + /* + * This function opens the acceptor to hold an existing native acceptor. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param native_acceptor A native acceptor. + * + * @throws boost::system::system_error Thrown on failure. + */ + void assign(const protocol_type& protocol, const native_type& native_acceptor) + { + boost::system::error_code ec; + this->service.assign(this->implementation, protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec); + } + + /// Assigns an existing native acceptor to the acceptor. + /* + * This function opens the acceptor to hold an existing native acceptor. + * + * @param protocol An object specifying which protocol is to be used. + * + * @param native_acceptor A native acceptor. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code assign(const protocol_type& protocol, + const native_type& native_acceptor, boost::system::error_code& ec) + { + return this->service.assign(this->implementation, + protocol, native_acceptor, ec); + } + + /// Determine whether the acceptor is open. + bool is_open() const + { + return this->service.is_open(this->implementation); + } + + /// Bind the acceptor to the given local endpoint. + /** + * This function binds the socket acceptor to the specified endpoint on the + * local machine. + * + * @param endpoint An endpoint on the local machine to which the socket + * acceptor will be bound. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * acceptor.open(boost::asio::ip::tcp::v4()); + * acceptor.bind(boost::asio::ip::tcp::endpoint(12345)); + * @endcode + */ + void bind(const endpoint_type& endpoint) + { + boost::system::error_code ec; + this->service.bind(this->implementation, endpoint, ec); + boost::asio::detail::throw_error(ec); + } + + /// Bind the acceptor to the given local endpoint. + /** + * This function binds the socket acceptor to the specified endpoint on the + * local machine. + * + * @param endpoint An endpoint on the local machine to which the socket + * acceptor will be bound. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * acceptor.open(boost::asio::ip::tcp::v4()); + * boost::system::error_code ec; + * acceptor.bind(boost::asio::ip::tcp::endpoint(12345), ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code bind(const endpoint_type& endpoint, + boost::system::error_code& ec) + { + return this->service.bind(this->implementation, endpoint, ec); + } + + /// Place the acceptor into the state where it will listen for new + /// connections. + /** + * This function puts the socket acceptor into the state where it may accept + * new connections. + * + * @param backlog The maximum length of the queue of pending connections. + * + * @throws boost::system::system_error Thrown on failure. + */ + void listen(int backlog = socket_base::max_connections) + { + boost::system::error_code ec; + this->service.listen(this->implementation, backlog, ec); + boost::asio::detail::throw_error(ec); + } + + /// Place the acceptor into the state where it will listen for new + /// connections. + /** + * This function puts the socket acceptor into the state where it may accept + * new connections. + * + * @param backlog The maximum length of the queue of pending connections. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::system::error_code ec; + * acceptor.listen(boost::asio::socket_base::max_connections, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code listen(int backlog, boost::system::error_code& ec) + { + return this->service.listen(this->implementation, backlog, ec); + } + + /// Close the acceptor. + /** + * This function is used to close the acceptor. Any asynchronous accept + * operations will be cancelled immediately. + * + * A subsequent call to open() is required before the acceptor can again be + * used to again perform socket accept operations. + * + * @throws boost::system::system_error Thrown on failure. + */ + void close() + { + boost::system::error_code ec; + this->service.close(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Close the acceptor. + /** + * This function is used to close the acceptor. Any asynchronous accept + * operations will be cancelled immediately. + * + * A subsequent call to open() is required before the acceptor can again be + * used to again perform socket accept operations. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::system::error_code ec; + * acceptor.close(ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + boost::system::error_code close(boost::system::error_code& ec) + { + return this->service.close(this->implementation, ec); + } + + /// Get the native acceptor representation. + /** + * This function may be used to obtain the underlying representation of the + * acceptor. This is intended to allow access to native acceptor functionality + * that is not otherwise provided. + */ + native_type native() + { + return this->service.native(this->implementation); + } + + /// Cancel all asynchronous operations associated with the acceptor. + /** + * This function causes all outstanding asynchronous connect, send and receive + * operations to finish immediately, and the handlers for cancelled operations + * will be passed the boost::asio::error::operation_aborted error. + * + * @throws boost::system::system_error Thrown on failure. + */ + void cancel() + { + boost::system::error_code ec; + this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec); + } + + /// Cancel all asynchronous operations associated with the acceptor. + /** + * This function causes all outstanding asynchronous connect, send and receive + * operations to finish immediately, and the handlers for cancelled operations + * will be passed the boost::asio::error::operation_aborted error. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Set an option on the acceptor. + /** + * This function is used to set an option on the acceptor. + * + * @param option The new option value to be set on the acceptor. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa SettableSocketOption @n + * boost::asio::socket_base::reuse_address + * boost::asio::socket_base::enable_connection_aborted + * + * @par Example + * Setting the SOL_SOCKET/SO_REUSEADDR option: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::reuse_address option(true); + * acceptor.set_option(option); + * @endcode + */ + template <typename SettableSocketOption> + void set_option(const SettableSocketOption& option) + { + boost::system::error_code ec; + this->service.set_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Set an option on the acceptor. + /** + * This function is used to set an option on the acceptor. + * + * @param option The new option value to be set on the acceptor. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa SettableSocketOption @n + * boost::asio::socket_base::reuse_address + * boost::asio::socket_base::enable_connection_aborted + * + * @par Example + * Setting the SOL_SOCKET/SO_REUSEADDR option: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::reuse_address option(true); + * boost::system::error_code ec; + * acceptor.set_option(option, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template <typename SettableSocketOption> + boost::system::error_code set_option(const SettableSocketOption& option, + boost::system::error_code& ec) + { + return this->service.set_option(this->implementation, option, ec); + } + + /// Get an option from the acceptor. + /** + * This function is used to get the current value of an option on the + * acceptor. + * + * @param option The option value to be obtained from the acceptor. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa GettableSocketOption @n + * boost::asio::socket_base::reuse_address + * + * @par Example + * Getting the value of the SOL_SOCKET/SO_REUSEADDR option: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::reuse_address option; + * acceptor.get_option(option); + * bool is_set = option.get(); + * @endcode + */ + template <typename GettableSocketOption> + void get_option(GettableSocketOption& option) + { + boost::system::error_code ec; + this->service.get_option(this->implementation, option, ec); + boost::asio::detail::throw_error(ec); + } + + /// Get an option from the acceptor. + /** + * This function is used to get the current value of an option on the + * acceptor. + * + * @param option The option value to be obtained from the acceptor. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa GettableSocketOption @n + * boost::asio::socket_base::reuse_address + * + * @par Example + * Getting the value of the SOL_SOCKET/SO_REUSEADDR option: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::reuse_address option; + * boost::system::error_code ec; + * acceptor.get_option(option, ec); + * if (ec) + * { + * // An error occurred. + * } + * bool is_set = option.get(); + * @endcode + */ + template <typename GettableSocketOption> + boost::system::error_code get_option(GettableSocketOption& option, + boost::system::error_code& ec) + { + return this->service.get_option(this->implementation, option, ec); + } + + /// Get the local endpoint of the acceptor. + /** + * This function is used to obtain the locally bound endpoint of the acceptor. + * + * @returns An object that represents the local endpoint of the acceptor. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint(); + * @endcode + */ + endpoint_type local_endpoint() const + { + boost::system::error_code ec; + endpoint_type ep = this->service.local_endpoint(this->implementation, ec); + boost::asio::detail::throw_error(ec); + return ep; + } + + /// Get the local endpoint of the acceptor. + /** + * This function is used to obtain the locally bound endpoint of the acceptor. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns An object that represents the local endpoint of the acceptor. + * Returns a default-constructed endpoint object if an error occurred and the + * error handler did not throw an exception. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::system::error_code ec; + * boost::asio::ip::tcp::endpoint endpoint = acceptor.local_endpoint(ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + endpoint_type local_endpoint(boost::system::error_code& ec) const + { + return this->service.local_endpoint(this->implementation, ec); + } + + /// Accept a new connection. + /** + * This function is used to accept a new connection from a peer into the + * given socket. The function call will block until a new connection has been + * accepted successfully or an error occurs. + * + * @param peer The socket into which the new connection will be accepted. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::socket socket(io_service); + * acceptor.accept(socket); + * @endcode + */ + template <typename SocketService> + void accept(basic_socket<protocol_type, SocketService>& peer) + { + boost::system::error_code ec; + this->service.accept(this->implementation, peer, 0, ec); + boost::asio::detail::throw_error(ec); + } + + /// Accept a new connection. + /** + * This function is used to accept a new connection from a peer into the + * given socket. The function call will block until a new connection has been + * accepted successfully or an error occurs. + * + * @param peer The socket into which the new connection will be accepted. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::soocket socket(io_service); + * boost::system::error_code ec; + * acceptor.accept(socket, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template <typename SocketService> + boost::system::error_code accept( + basic_socket<protocol_type, SocketService>& peer, + boost::system::error_code& ec) + { + return this->service.accept(this->implementation, peer, 0, ec); + } + + /// Start an asynchronous accept. + /** + * This function is used to asynchronously accept a new connection into a + * socket. The function call always returns immediately. + * + * @param peer The socket into which the new connection will be accepted. + * Ownership of the peer object is retained by the caller, which must + * guarantee that it is valid until the handler is called. + * + * @param handler The handler to be called when the accept operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error // Result of operation. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * @code + * void accept_handler(const boost::system::error_code& error) + * { + * if (!error) + * { + * // Accept succeeded. + * } + * } + * + * ... + * + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::socket socket(io_service); + * acceptor.async_accept(socket, accept_handler); + * @endcode + */ + template <typename SocketService, typename AcceptHandler> + void async_accept(basic_socket<protocol_type, SocketService>& peer, + AcceptHandler handler) + { + this->service.async_accept(this->implementation, peer, 0, handler); + } + + /// Accept a new connection and obtain the endpoint of the peer + /** + * This function is used to accept a new connection from a peer into the + * given socket, and additionally provide the endpoint of the remote peer. + * The function call will block until a new connection has been accepted + * successfully or an error occurs. + * + * @param peer The socket into which the new connection will be accepted. + * + * @param peer_endpoint An endpoint object which will receive the endpoint of + * the remote peer. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::socket socket(io_service); + * boost::asio::ip::tcp::endpoint endpoint; + * acceptor.accept(socket, endpoint); + * @endcode + */ + template <typename SocketService> + void accept(basic_socket<protocol_type, SocketService>& peer, + endpoint_type& peer_endpoint) + { + boost::system::error_code ec; + this->service.accept(this->implementation, peer, &peer_endpoint, ec); + boost::asio::detail::throw_error(ec); + } + + /// Accept a new connection and obtain the endpoint of the peer + /** + * This function is used to accept a new connection from a peer into the + * given socket, and additionally provide the endpoint of the remote peer. + * The function call will block until a new connection has been accepted + * successfully or an error occurs. + * + * @param peer The socket into which the new connection will be accepted. + * + * @param peer_endpoint An endpoint object which will receive the endpoint of + * the remote peer. + * + * @param ec Set to indicate what error occurred, if any. + * + * @par Example + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::socket socket(io_service); + * boost::asio::ip::tcp::endpoint endpoint; + * boost::system::error_code ec; + * acceptor.accept(socket, endpoint, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template <typename SocketService> + boost::system::error_code accept( + basic_socket<protocol_type, SocketService>& peer, + endpoint_type& peer_endpoint, boost::system::error_code& ec) + { + return this->service.accept(this->implementation, peer, &peer_endpoint, ec); + } + + /// Start an asynchronous accept. + /** + * This function is used to asynchronously accept a new connection into a + * socket, and additionally obtain the endpoint of the remote peer. The + * function call always returns immediately. + * + * @param peer The socket into which the new connection will be accepted. + * Ownership of the peer object is retained by the caller, which must + * guarantee that it is valid until the handler is called. + * + * @param peer_endpoint An endpoint object into which the endpoint of the + * remote peer will be written. Ownership of the peer_endpoint object is + * retained by the caller, which must guarantee that it is valid until the + * handler is called. + * + * @param handler The handler to be called when the accept operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error // Result of operation. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template <typename SocketService, typename AcceptHandler> + void async_accept(basic_socket<protocol_type, SocketService>& peer, + endpoint_type& peer_endpoint, AcceptHandler handler) + { + this->service.async_accept(this->implementation, + peer, &peer_endpoint, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_SOCKET_ACCEPTOR_HPP
diff --git a/boost_1_45_0/boost/asio/basic_socket_iostream.hpp b/boost_1_45_0/boost/asio/basic_socket_iostream.hpp new file mode 100644 index 0000000..a8cea4f --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_socket_iostream.hpp
@@ -0,0 +1,153 @@ +// +// basic_socket_iostream.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP +#define BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_NO_IOSTREAM) + +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/utility/base_from_member.hpp> +#include <boost/asio/basic_socket_streambuf.hpp> +#include <boost/asio/stream_socket_service.hpp> + +#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) +#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5 +#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) + +// A macro that should expand to: +// template <typename T1, ..., typename Tn> +// explicit basic_socket_iostream(T1 x1, ..., Tn xn) +// : basic_iostream<char>(&this->boost::base_from_member< +// basic_socket_streambuf<Protocol, StreamSocketService> >::member) +// { +// if (rdbuf()->connect(x1, ..., xn) == 0) +// this->setstate(std::ios_base::failbit); +// } +// This macro should only persist within this file. + +#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \ + template <BOOST_PP_ENUM_PARAMS(n, typename T)> \ + explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ + : std::basic_iostream<char>(&this->boost::base_from_member< \ + basic_socket_streambuf<Protocol, StreamSocketService> >::member) \ + { \ + tie(this); \ + if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \ + this->setstate(std::ios_base::failbit); \ + } \ + /**/ + +// A macro that should expand to: +// template <typename T1, ..., typename Tn> +// void connect(T1 x1, ..., Tn xn) +// { +// if (rdbuf()->connect(x1, ..., xn) == 0) +// this->setstate(std::ios_base::failbit); +// } +// This macro should only persist within this file. + +#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \ + template <BOOST_PP_ENUM_PARAMS(n, typename T)> \ + void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ + { \ + if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \ + this->setstate(std::ios_base::failbit); \ + } \ + /**/ + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Iostream interface for a socket. +template <typename Protocol, + typename StreamSocketService = stream_socket_service<Protocol> > +class basic_socket_iostream + : public boost::base_from_member< + basic_socket_streambuf<Protocol, StreamSocketService> >, + public std::basic_iostream<char> +{ +public: + /// Construct a basic_socket_iostream without establishing a connection. + basic_socket_iostream() + : std::basic_iostream<char>(&this->boost::base_from_member< + basic_socket_streambuf<Protocol, StreamSocketService> >::member) + { + tie(this); + } + +#if defined(GENERATING_DOCUMENTATION) + /// Establish a connection to an endpoint corresponding to a resolver query. + /** + * This constructor automatically establishes a connection based on the + * supplied resolver query parameters. The arguments are used to construct + * a resolver query object. + */ + template <typename T1, ..., typename TN> + explicit basic_socket_iostream(T1 t1, ..., TN tn); +#else + BOOST_PP_REPEAT_FROM_TO( + 1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY), + BOOST_ASIO_PRIVATE_CTR_DEF, _ ) +#endif + +#if defined(GENERATING_DOCUMENTATION) + /// Establish a connection to an endpoint corresponding to a resolver query. + /** + * This function automatically establishes a connection based on the supplied + * resolver query parameters. The arguments are used to construct a resolver + * query object. + */ + template <typename T1, ..., typename TN> + void connect(T1 t1, ..., TN tn); +#else + BOOST_PP_REPEAT_FROM_TO( + 1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY), + BOOST_ASIO_PRIVATE_CONNECT_DEF, _ ) +#endif + + /// Close the connection. + void close() + { + if (rdbuf()->close() == 0) + this->setstate(std::ios_base::failbit); + } + + /// Return a pointer to the underlying streambuf. + basic_socket_streambuf<Protocol, StreamSocketService>* rdbuf() const + { + return const_cast<basic_socket_streambuf<Protocol, StreamSocketService>*>( + &this->boost::base_from_member< + basic_socket_streambuf<Protocol, StreamSocketService> >::member); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#undef BOOST_ASIO_PRIVATE_CTR_DEF +#undef BOOST_ASIO_PRIVATE_CONNECT_DEF + +#endif // defined(BOOST_NO_IOSTREAM) + +#endif // BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
diff --git a/boost_1_45_0/boost/asio/basic_socket_streambuf.hpp b/boost_1_45_0/boost/asio/basic_socket_streambuf.hpp new file mode 100644 index 0000000..35e96d0 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_socket_streambuf.hpp
@@ -0,0 +1,292 @@ +// +// basic_socket_streambuf.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP +#define BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_NO_IOSTREAM) + +#include <streambuf> +#include <boost/array.hpp> +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/utility/base_from_member.hpp> +#include <boost/asio/basic_socket.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/stream_socket_service.hpp> + +#if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY) +#define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5 +#endif // !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY) + +// A macro that should expand to: +// template <typename T1, ..., typename Tn> +// basic_socket_streambuf<Protocol, StreamSocketService>* connect( +// T1 x1, ..., Tn xn) +// { +// init_buffers(); +// boost::system::error_code ec; +// this->basic_socket<Protocol, StreamSocketService>::close(ec); +// typedef typename Protocol::resolver resolver_type; +// typedef typename resolver_type::query resolver_query; +// resolver_query query(x1, ..., xn); +// resolve_and_connect(query, ec); +// return !ec ? this : 0; +// } +// This macro should only persist within this file. + +#define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \ + template <BOOST_PP_ENUM_PARAMS(n, typename T)> \ + basic_socket_streambuf<Protocol, StreamSocketService>* connect( \ + BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ + { \ + init_buffers(); \ + boost::system::error_code ec; \ + this->basic_socket<Protocol, StreamSocketService>::close(ec); \ + typedef typename Protocol::resolver resolver_type; \ + typedef typename resolver_type::query resolver_query; \ + resolver_query query(BOOST_PP_ENUM_PARAMS(n, x)); \ + resolve_and_connect(query, ec); \ + return !ec ? this : 0; \ + } \ + /**/ + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Iostream streambuf for a socket. +template <typename Protocol, + typename StreamSocketService = stream_socket_service<Protocol> > +class basic_socket_streambuf + : public std::streambuf, + private boost::base_from_member<io_service>, + public basic_socket<Protocol, StreamSocketService> +{ +public: + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_socket_streambuf without establishing a connection. + basic_socket_streambuf() + : basic_socket<Protocol, StreamSocketService>( + boost::base_from_member<boost::asio::io_service>::member), + unbuffered_(false) + { + init_buffers(); + } + + /// Destructor flushes buffered data. + virtual ~basic_socket_streambuf() + { + if (pptr() != pbase()) + overflow(traits_type::eof()); + } + + /// Establish a connection. + /** + * This function establishes a connection to the specified endpoint. + * + * @return \c this if a connection was successfully established, a null + * pointer otherwise. + */ + basic_socket_streambuf<Protocol, StreamSocketService>* connect( + const endpoint_type& endpoint) + { + init_buffers(); + boost::system::error_code ec; + this->basic_socket<Protocol, StreamSocketService>::close(ec); + this->basic_socket<Protocol, StreamSocketService>::connect(endpoint, ec); + return !ec ? this : 0; + } + +#if defined(GENERATING_DOCUMENTATION) + /// Establish a connection. + /** + * This function automatically establishes a connection based on the supplied + * resolver query parameters. The arguments are used to construct a resolver + * query object. + * + * @return \c this if a connection was successfully established, a null + * pointer otherwise. + */ + template <typename T1, ..., typename TN> + basic_socket_streambuf<Protocol, StreamSocketService>* connect( + T1 t1, ..., TN tn); +#else + BOOST_PP_REPEAT_FROM_TO( + 1, BOOST_PP_INC(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY), + BOOST_ASIO_PRIVATE_CONNECT_DEF, _ ) +#endif + + /// Close the connection. + /** + * @return \c this if a connection was successfully established, a null + * pointer otherwise. + */ + basic_socket_streambuf<Protocol, StreamSocketService>* close() + { + boost::system::error_code ec; + sync(); + this->basic_socket<Protocol, StreamSocketService>::close(ec); + if (!ec) + init_buffers(); + return !ec ? this : 0; + } + +protected: + int_type underflow() + { + if (gptr() == egptr()) + { + boost::system::error_code ec; + std::size_t bytes_transferred = this->service.receive( + this->implementation, + boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max), + 0, ec); + if (ec) + return traits_type::eof(); + setg(get_buffer_.begin(), get_buffer_.begin() + putback_max, + get_buffer_.begin() + putback_max + bytes_transferred); + return traits_type::to_int_type(*gptr()); + } + else + { + return traits_type::eof(); + } + } + + int_type overflow(int_type c) + { + if (unbuffered_) + { + if (traits_type::eq_int_type(c, traits_type::eof())) + { + // Nothing to do. + return traits_type::not_eof(c); + } + else + { + // Send the single character immediately. + boost::system::error_code ec; + char_type ch = traits_type::to_char_type(c); + this->service.send(this->implementation, + boost::asio::buffer(&ch, sizeof(char_type)), 0, ec); + if (ec) + return traits_type::eof(); + return c; + } + } + else + { + // Send all data in the output buffer. + boost::asio::const_buffer buffer = + boost::asio::buffer(pbase(), pptr() - pbase()); + while (boost::asio::buffer_size(buffer) > 0) + { + boost::system::error_code ec; + std::size_t bytes_transferred = this->service.send( + this->implementation, boost::asio::buffer(buffer), + 0, ec); + if (ec) + return traits_type::eof(); + buffer = buffer + bytes_transferred; + } + setp(put_buffer_.begin(), put_buffer_.end()); + + // If the new character is eof then our work here is done. + if (traits_type::eq_int_type(c, traits_type::eof())) + return traits_type::not_eof(c); + + // Add the new character to the output buffer. + *pptr() = traits_type::to_char_type(c); + pbump(1); + return c; + } + } + + int sync() + { + return overflow(traits_type::eof()); + } + + std::streambuf* setbuf(char_type* s, std::streamsize n) + { + if (pptr() == pbase() && s == 0 && n == 0) + { + unbuffered_ = true; + setp(0, 0); + return this; + } + + return 0; + } + +private: + void init_buffers() + { + setg(get_buffer_.begin(), + get_buffer_.begin() + putback_max, + get_buffer_.begin() + putback_max); + if (unbuffered_) + setp(0, 0); + else + setp(put_buffer_.begin(), put_buffer_.end()); + } + + template <typename ResolverQuery> + void resolve_and_connect(const ResolverQuery& query, + boost::system::error_code& ec) + { + typedef typename Protocol::resolver resolver_type; + typedef typename resolver_type::iterator iterator_type; + resolver_type resolver( + boost::base_from_member<boost::asio::io_service>::member); + iterator_type i = resolver.resolve(query, ec); + if (!ec) + { + iterator_type end; + ec = boost::asio::error::host_not_found; + while (ec && i != end) + { + this->basic_socket<Protocol, StreamSocketService>::close(); + this->basic_socket<Protocol, StreamSocketService>::connect(*i, ec); + ++i; + } + } + } + + enum { putback_max = 8 }; + enum { buffer_size = 512 }; + boost::array<char, buffer_size> get_buffer_; + boost::array<char, buffer_size> put_buffer_; + bool unbuffered_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#undef BOOST_ASIO_PRIVATE_CONNECT_DEF + +#endif // !defined(BOOST_NO_IOSTREAM) + +#endif // BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
diff --git a/boost_1_45_0/boost/asio/basic_stream_socket.hpp b/boost_1_45_0/boost/asio/basic_stream_socket.hpp new file mode 100644 index 0000000..956d623 --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_stream_socket.hpp
@@ -0,0 +1,717 @@ +// +// basic_stream_socket.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_STREAM_SOCKET_HPP +#define BOOST_ASIO_BASIC_STREAM_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/basic_socket.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/stream_socket_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Provides stream-oriented socket functionality. +/** + * The basic_stream_socket class template provides asynchronous and blocking + * stream-oriented socket functionality. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Concepts: + * AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream. + */ +template <typename Protocol, + typename StreamSocketService = stream_socket_service<Protocol> > +class basic_stream_socket + : public basic_socket<Protocol, StreamSocketService> +{ +public: + /// The native representation of a socket. + typedef typename StreamSocketService::native_type native_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_stream_socket without opening it. + /** + * This constructor creates a stream socket without opening it. The socket + * needs to be opened and then connected or accepted before data can be sent + * or received on it. + * + * @param io_service The io_service object that the stream socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + */ + explicit basic_stream_socket(boost::asio::io_service& io_service) + : basic_socket<Protocol, StreamSocketService>(io_service) + { + } + + /// Construct and open a basic_stream_socket. + /** + * This constructor creates and opens a stream socket. The socket needs to be + * connected or accepted before data can be sent or received on it. + * + * @param io_service The io_service object that the stream socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_stream_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_socket<Protocol, StreamSocketService>(io_service, protocol) + { + } + + /// Construct a basic_stream_socket, opening it and binding it to the given + /// local endpoint. + /** + * This constructor creates a stream socket and automatically opens it bound + * to the specified endpoint on the local machine. The protocol used is the + * protocol associated with the given endpoint. + * + * @param io_service The io_service object that the stream socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param endpoint An endpoint on the local machine to which the stream + * socket will be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_stream_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_socket<Protocol, StreamSocketService>(io_service, endpoint) + { + } + + /// Construct a basic_stream_socket on an existing native socket. + /** + * This constructor creates a stream socket object to hold an existing native + * socket. + * + * @param io_service The io_service object that the stream socket will use to + * dispatch handlers for any asynchronous operations performed on the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket The new underlying socket implementation. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_stream_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_type& native_socket) + : basic_socket<Protocol, StreamSocketService>( + io_service, protocol, native_socket) + { + } + + /// Send some data on the socket. + /** + * This function is used to send data on the stream socket. The function + * call will block until one or more bytes of the data has been sent + * successfully, or an until error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref write function if you need to ensure that all data + * is written before the blocking operation completes. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.send(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.send( + this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on the socket. + /** + * This function is used to send data on the stream socket. The function + * call will block until one or more bytes of the data has been sent + * successfully, or an until error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref write function if you need to ensure that all data + * is written before the blocking operation completes. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.send(boost::asio::buffer(data, size), 0); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.send( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Send some data on the socket. + /** + * This function is used to send data on the stream socket. The function + * call will block until one or more bytes of the data has been sent + * successfully, or an until error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. Returns 0 if an error occurred. + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref write function if you need to ensure that all data + * is written before the blocking operation completes. + */ + template <typename ConstBufferSequence> + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.send(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send data on the stream socket. + * The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref async_write function if you need to ensure that all + * data is written before the asynchronous operation completes. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send data on the stream socket. + * The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref async_write function if you need to ensure that all + * data is written before the asynchronous operation completes. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), 0, handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, flags, handler); + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the stream socket. The function + * call will block until one or more bytes of data has been received + * successfully, or until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.receive(this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the stream socket. The function + * call will block until one or more bytes of data has been received + * successfully, or until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size), 0); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->service.receive( + this->implementation, buffers, flags, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the stream socket. The function + * call will block until one or more bytes of data has been received + * successfully, or until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. Returns 0 if an error occurred. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + */ + template <typename MutableBufferSequence> + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->service.receive(this->implementation, buffers, flags, ec); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the stream + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref async_read function if you need to ensure + * that the requested amount of data is received before the asynchronous + * operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, 0, handler); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the stream + * socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param flags Flags specifying how the receive call is to be made. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref async_read function if you need to ensure + * that the requested amount of data is received before the asynchronous + * operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), 0, handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags flags, ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, flags, handler); + } + + /// Write some data to the socket. + /** + * This function is used to write data to the stream socket. The function call + * will block until one or more bytes of the data has been written + * successfully, or until an error occurs. + * + * @param buffers One or more data buffers to be written to the socket. + * + * @returns The number of bytes written. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The write_some operation may not transmit all of the data to the + * peer. Consider using the @ref write function if you need to ensure that + * all data is written before the blocking operation completes. + * + * @par Example + * To write a single data buffer use the @ref buffer function as follows: + * @code + * socket.write_some(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on writing multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.send(this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Write some data to the socket. + /** + * This function is used to write data to the stream socket. The function call + * will block until one or more bytes of the data has been written + * successfully, or until an error occurs. + * + * @param buffers One or more data buffers to be written to the socket. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes written. Returns 0 if an error occurred. + * + * @note The write_some operation may not transmit all of the data to the + * peer. Consider using the @ref write function if you need to ensure that + * all data is written before the blocking operation completes. + */ + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers, + boost::system::error_code& ec) + { + return this->service.send(this->implementation, buffers, 0, ec); + } + + /// Start an asynchronous write. + /** + * This function is used to asynchronously write data to the stream socket. + * The function call always returns immediately. + * + * @param buffers One or more data buffers to be written to the socket. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the write operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes written. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The write operation may not transmit all of the data to the peer. + * Consider using the @ref async_write function if you need to ensure that all + * data is written before the asynchronous operation completes. + * + * @par Example + * To write a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_write_some(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on writing multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename ConstBufferSequence, typename WriteHandler> + void async_write_some(const ConstBufferSequence& buffers, + WriteHandler handler) + { + this->service.async_send(this->implementation, buffers, 0, handler); + } + + /// Read some data from the socket. + /** + * This function is used to read data from the stream socket. The function + * call will block until one or more bytes of data has been read successfully, + * or until an error occurs. + * + * @param buffers One or more buffers into which the data will be read. + * + * @returns The number of bytes read. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The read_some operation may not read all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that + * the requested amount of data is read before the blocking operation + * completes. + * + * @par Example + * To read into a single data buffer use the @ref buffer function as follows: + * @code + * socket.read_some(boost::asio::buffer(data, size)); + * @endcode + * See the @ref buffer documentation for information on reading into multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers) + { + boost::system::error_code ec; + std::size_t s = this->service.receive(this->implementation, buffers, 0, ec); + boost::asio::detail::throw_error(ec); + return s; + } + + /// Read some data from the socket. + /** + * This function is used to read data from the stream socket. The function + * call will block until one or more bytes of data has been read successfully, + * or until an error occurs. + * + * @param buffers One or more buffers into which the data will be read. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes read. Returns 0 if an error occurred. + * + * @note The read_some operation may not read all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that + * the requested amount of data is read before the blocking operation + * completes. + */ + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return this->service.receive(this->implementation, buffers, 0, ec); + } + + /// Start an asynchronous read. + /** + * This function is used to asynchronously read data from the stream socket. + * The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be read. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param handler The handler to be called when the read operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes read. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @note The read operation may not read all of the requested number of bytes. + * Consider using the @ref async_read function if you need to ensure that the + * requested amount of data is read before the asynchronous operation + * completes. + * + * @par Example + * To read into a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_read_some(boost::asio::buffer(data, size), handler); + * @endcode + * See the @ref buffer documentation for information on reading into multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template <typename MutableBufferSequence, typename ReadHandler> + void async_read_some(const MutableBufferSequence& buffers, + ReadHandler handler) + { + this->service.async_receive(this->implementation, buffers, 0, handler); + } +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BASIC_STREAM_SOCKET_HPP
diff --git a/boost_1_45_0/boost/asio/basic_streambuf.hpp b/boost_1_45_0/boost/asio/basic_streambuf.hpp new file mode 100644 index 0000000..546a4ac --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_streambuf.hpp
@@ -0,0 +1,368 @@ +// +// basic_streambuf.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_STREAMBUF_HPP +#define BOOST_ASIO_BASIC_STREAMBUF_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_NO_IOSTREAM) + +#include <algorithm> +#include <cstring> +#include <stdexcept> +#include <streambuf> +#include <vector> +#include <boost/limits.hpp> +#include <boost/throw_exception.hpp> +#include <boost/asio/basic_streambuf_fwd.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Automatically resizable buffer class based on std::streambuf. +/** + * The @c basic_streambuf class is derived from @c std::streambuf to associate + * the streambuf's input and output sequences with one or more character + * arrays. These character arrays are internal to the @c basic_streambuf + * object, but direct access to the array elements is provided to permit them + * to be used efficiently with I/O operations. Characters written to the output + * sequence of a @c basic_streambuf object are appended to the input sequence + * of the same object. + * + * The @c basic_streambuf class's public interface is intended to permit the + * following implementation strategies: + * + * @li A single contiguous character array, which is reallocated as necessary + * to accommodate changes in the size of the character sequence. This is the + * implementation approach currently used in Asio. + * + * @li A sequence of one or more character arrays, where each array is of the + * same size. Additional character array objects are appended to the sequence + * to accommodate changes in the size of the character sequence. + * + * @li A sequence of one or more character arrays of varying sizes. Additional + * character array objects are appended to the sequence to accommodate changes + * in the size of the character sequence. + * + * The constructor for basic_streambuf accepts a @c size_t argument specifying + * the maximum of the sum of the sizes of the input sequence and output + * sequence. During the lifetime of the @c basic_streambuf object, the following + * invariant holds: + * @code size() <= max_size()@endcode + * Any member function that would, if successful, cause the invariant to be + * violated shall throw an exception of class @c std::length_error. + * + * The constructor for @c basic_streambuf takes an Allocator argument. A copy + * of this argument is used for any memory allocation performed, by the + * constructor and by all member functions, during the lifetime of each @c + * basic_streambuf object. + * + * @par Examples + * Writing directly from an streambuf to a socket: + * @code + * boost::asio::streambuf b; + * std::ostream os(&b); + * os << "Hello, World!\n"; + * + * // try sending some data in input sequence + * size_t n = sock.send(b.data()); + * + * b.consume(n); // sent data is removed from input sequence + * @endcode + * + * Reading from a socket directly into a streambuf: + * @code + * boost::asio::streambuf b; + * + * // reserve 512 bytes in output sequence + * boost::asio::streambuf::mutable_buffers_type bufs = b.prepare(512); + * + * size_t n = sock.receive(bufs); + * + * // received data is "committed" from output sequence to input sequence + * b.commit(n); + * + * std::istream is(&b); + * std::string s; + * is >> s; + * @endcode + */ +#if defined(GENERATING_DOCUMENTATION) +template <typename Allocator = std::allocator<char> > +#else +template <typename Allocator> +#endif +class basic_streambuf + : public std::streambuf, + private noncopyable +{ +public: +#if defined(GENERATING_DOCUMENTATION) + /// The type used to represent the input sequence as a list of buffers. + typedef implementation_defined const_buffers_type; + + /// The type used to represent the output sequence as a list of buffers. + typedef implementation_defined mutable_buffers_type; +#else + typedef boost::asio::const_buffers_1 const_buffers_type; + typedef boost::asio::mutable_buffers_1 mutable_buffers_type; +#endif + + /// Construct a basic_streambuf object. + /** + * Constructs a streambuf with the specified maximum size. The initial size + * of the streambuf's input sequence is 0. + */ + explicit basic_streambuf( + std::size_t max_size = (std::numeric_limits<std::size_t>::max)(), + const Allocator& allocator = Allocator()) + : max_size_(max_size), + buffer_(allocator) + { + std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta); + buffer_.resize((std::max<std::size_t>)(pend, 1)); + setg(&buffer_[0], &buffer_[0], &buffer_[0]); + setp(&buffer_[0], &buffer_[0] + pend); + } + + /// Get the size of the input sequence. + /** + * @returns The size of the input sequence. The value is equal to that + * calculated for @c s in the following code: + * @code + * size_t s = 0; + * const_buffers_type bufs = data(); + * const_buffers_type::const_iterator i = bufs.begin(); + * while (i != bufs.end()) + * { + * const_buffer buf(*i++); + * s += buffer_size(buf); + * } + * @endcode + */ + std::size_t size() const + { + return pptr() - gptr(); + } + + /// Get the maximum size of the basic_streambuf. + /** + * @returns The allowed maximum of the sum of the sizes of the input sequence + * and output sequence. + */ + std::size_t max_size() const + { + return max_size_; + } + + /// Get a list of buffers that represents the input sequence. + /** + * @returns An object of type @c const_buffers_type that satisfies + * ConstBufferSequence requirements, representing all character arrays in the + * input sequence. + * + * @note The returned object is invalidated by any @c basic_streambuf member + * function that modifies the input sequence or output sequence. + */ + const_buffers_type data() const + { + return boost::asio::buffer(boost::asio::const_buffer(gptr(), + (pptr() - gptr()) * sizeof(char_type))); + } + + /// Get a list of buffers that represents the output sequence, with the given + /// size. + /** + * Ensures that the output sequence can accommodate @c n characters, + * reallocating character array objects as necessary. + * + * @returns An object of type @c mutable_buffers_type that satisfies + * MutableBufferSequence requirements, representing character array objects + * at the start of the output sequence such that the sum of the buffer sizes + * is @c n. + * + * @throws std::length_error If <tt>size() + n > max_size()</tt>. + * + * @note The returned object is invalidated by any @c basic_streambuf member + * function that modifies the input sequence or output sequence. + */ + mutable_buffers_type prepare(std::size_t n) + { + reserve(n); + return boost::asio::buffer(boost::asio::mutable_buffer( + pptr(), n * sizeof(char_type))); + } + + /// Move characters from the output sequence to the input sequence. + /** + * Appends @c n characters from the start of the output sequence to the input + * sequence. The beginning of the output sequence is advanced by @c n + * characters. + * + * Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and + * no intervening operations that modify the input or output sequence. + * + * @throws std::length_error If @c n is greater than the size of the output + * sequence. + */ + void commit(std::size_t n) + { + if (pptr() + n > epptr()) + n = epptr() - pptr(); + pbump(static_cast<int>(n)); + setg(eback(), gptr(), pptr()); + } + + /// Remove characters from the input sequence. + /** + * Removes @c n characters from the beginning of the input sequence. + * + * @throws std::length_error If <tt>n > size()</tt>. + */ + void consume(std::size_t n) + { + if (gptr() + n > pptr()) + n = pptr() - gptr(); + gbump(static_cast<int>(n)); + } + +protected: + enum { buffer_delta = 128 }; + + /// Override std::streambuf behaviour. + /** + * Behaves according to the specification of @c std::streambuf::underflow(). + */ + int_type underflow() + { + if (gptr() < pptr()) + { + setg(&buffer_[0], gptr(), pptr()); + return traits_type::to_int_type(*gptr()); + } + else + { + return traits_type::eof(); + } + } + + /// Override std::streambuf behaviour. + /** + * Behaves according to the specification of @c std::streambuf::overflow(), + * with the specialisation that @c std::length_error is thrown if appending + * the character to the input sequence would require the condition + * <tt>size() > max_size()</tt> to be true. + */ + int_type overflow(int_type c) + { + if (!traits_type::eq_int_type(c, traits_type::eof())) + { + if (pptr() == epptr()) + { + std::size_t buffer_size = pptr() - gptr(); + if (buffer_size < max_size_ && max_size_ - buffer_size < buffer_delta) + { + reserve(max_size_ - buffer_size); + } + else + { + reserve(buffer_delta); + } + } + + *pptr() = traits_type::to_char_type(c); + pbump(1); + return c; + } + + return traits_type::not_eof(c); + } + + void reserve(std::size_t n) + { + // Get current stream positions as offsets. + std::size_t gnext = gptr() - &buffer_[0]; + std::size_t pnext = pptr() - &buffer_[0]; + std::size_t pend = epptr() - &buffer_[0]; + + // Check if there is already enough space in the put area. + if (n <= pend - pnext) + { + return; + } + + // Shift existing contents of get area to start of buffer. + if (gnext > 0) + { + pnext -= gnext; + std::memmove(&buffer_[0], &buffer_[0] + gnext, pnext); + } + + // Ensure buffer is large enough to hold at least the specified size. + if (n > pend - pnext) + { + if (n <= max_size_ && pnext <= max_size_ - n) + { + pend = pnext + n; + buffer_.resize((std::max<std::size_t>)(pend, 1)); + } + else + { + std::length_error ex("boost::asio::streambuf too long"); + boost::throw_exception(ex); + } + } + + // Update stream positions. + setg(&buffer_[0], &buffer_[0], &buffer_[0] + pnext); + setp(&buffer_[0] + pnext, &buffer_[0] + pend); + } + +private: + std::size_t max_size_; + std::vector<char_type, Allocator> buffer_; + + // Helper function to get the preferred size for reading data. + friend std::size_t read_size_helper( + basic_streambuf& sb, std::size_t max_size) + { + return std::min<std::size_t>( + std::max<std::size_t>(512, sb.buffer_.capacity() - sb.size()), + std::min<std::size_t>(max_size, sb.max_size() - sb.size())); + } +}; + +// Helper function to get the preferred size for reading data. Used for any +// user-provided specialisations of basic_streambuf. +template <typename Allocator> +inline std::size_t read_size_helper( + basic_streambuf<Allocator>& sb, std::size_t max_size) +{ + return std::min<std::size_t>(512, + std::min<std::size_t>(max_size, sb.max_size() - sb.size())); +} + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_NO_IOSTREAM) + +#endif // BOOST_ASIO_BASIC_STREAMBUF_HPP
diff --git a/boost_1_45_0/boost/asio/basic_streambuf_fwd.hpp b/boost_1_45_0/boost/asio/basic_streambuf_fwd.hpp new file mode 100644 index 0000000..215937e --- /dev/null +++ b/boost_1_45_0/boost/asio/basic_streambuf_fwd.hpp
@@ -0,0 +1,35 @@ +// +// basic_streambuf_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BASIC_STREAMBUF_FWD_HPP +#define BOOST_ASIO_BASIC_STREAMBUF_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_NO_IOSTREAM) + +#include <memory> + +namespace boost { +namespace asio { + +template <typename Allocator = std::allocator<char> > +class basic_streambuf; + +} // namespace asio +} // namespace boost + +#endif // !defined(BOOST_NO_IOSTREAM) + +#endif // BOOST_ASIO_BASIC_STREAMBUF_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/buffer.hpp b/boost_1_45_0/boost/asio/buffer.hpp new file mode 100644 index 0000000..f925361 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffer.hpp
@@ -0,0 +1,1044 @@ +// +// buffer.hpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFER_HPP +#define BOOST_ASIO_BUFFER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <string> +#include <vector> +#include <boost/detail/workaround.hpp> +#include <boost/asio/detail/array_fwd.hpp> + +#if defined(BOOST_MSVC) +# if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0) +# if !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING) +# define BOOST_ASIO_ENABLE_BUFFER_DEBUGGING +# endif // !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING) +# endif // defined(_HAS_ITERATOR_DEBUGGING) +#endif // defined(BOOST_MSVC) + +#if defined(__GNUC__) +# if defined(_GLIBCXX_DEBUG) +# if !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING) +# define BOOST_ASIO_ENABLE_BUFFER_DEBUGGING +# endif // !defined(BOOST_ASIO_DISABLE_BUFFER_DEBUGGING) +# endif // defined(_GLIBCXX_DEBUG) +#endif // defined(__GNUC__) + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) +# include <boost/function.hpp> +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \ + || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) +# include <boost/type_traits/is_const.hpp> +#endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + // || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +class mutable_buffer; +class const_buffer; + +namespace detail { +void* buffer_cast_helper(const mutable_buffer&); +const void* buffer_cast_helper(const const_buffer&); +std::size_t buffer_size_helper(const mutable_buffer&); +std::size_t buffer_size_helper(const const_buffer&); +} // namespace detail + +/// Holds a buffer that can be modified. +/** + * The mutable_buffer class provides a safe representation of a buffer that can + * be modified. It does not own the underlying data, and so is cheap to copy or + * assign. + */ +class mutable_buffer +{ +public: + /// Construct an empty buffer. + mutable_buffer() + : data_(0), + size_(0) + { + } + + /// Construct a buffer to represent a given memory range. + mutable_buffer(void* data, std::size_t size) + : data_(data), + size_(size) + { + } + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + mutable_buffer(void* data, std::size_t size, + boost::function<void()> debug_check) + : data_(data), + size_(size), + debug_check_(debug_check) + { + } + + const boost::function<void()>& get_debug_check() const + { + return debug_check_; + } +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + +private: + friend void* boost::asio::detail::buffer_cast_helper( + const mutable_buffer& b); + friend std::size_t boost::asio::detail::buffer_size_helper( + const mutable_buffer& b); + + void* data_; + std::size_t size_; + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + boost::function<void()> debug_check_; +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING +}; + +namespace detail { + +inline void* buffer_cast_helper(const mutable_buffer& b) +{ +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + if (b.size_ && b.debug_check_) + b.debug_check_(); +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + return b.data_; +} + +inline std::size_t buffer_size_helper(const mutable_buffer& b) +{ + return b.size_; +} + +} // namespace detail + +/// Cast a non-modifiable buffer to a specified pointer to POD type. +/** + * @relates mutable_buffer + */ +template <typename PointerToPodType> +inline PointerToPodType buffer_cast(const mutable_buffer& b) +{ + return static_cast<PointerToPodType>(detail::buffer_cast_helper(b)); +} + +/// Get the number of bytes in a non-modifiable buffer. +/** + * @relates mutable_buffer + */ +inline std::size_t buffer_size(const mutable_buffer& b) +{ + return detail::buffer_size_helper(b); +} + +/// Create a new modifiable buffer that is offset from the start of another. +/** + * @relates mutable_buffer + */ +inline mutable_buffer operator+(const mutable_buffer& b, std::size_t start) +{ + if (start > buffer_size(b)) + return mutable_buffer(); + char* new_data = buffer_cast<char*>(b) + start; + std::size_t new_size = buffer_size(b) - start; + return mutable_buffer(new_data, new_size +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + ); +} + +/// Create a new modifiable buffer that is offset from the start of another. +/** + * @relates mutable_buffer + */ +inline mutable_buffer operator+(std::size_t start, const mutable_buffer& b) +{ + if (start > buffer_size(b)) + return mutable_buffer(); + char* new_data = buffer_cast<char*>(b) + start; + std::size_t new_size = buffer_size(b) - start; + return mutable_buffer(new_data, new_size +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + ); +} + +/// Adapts a single modifiable buffer so that it meets the requirements of the +/// MutableBufferSequence concept. +class mutable_buffers_1 + : public mutable_buffer +{ +public: + /// The type for each element in the list of buffers. + typedef mutable_buffer value_type; + + /// A random-access iterator type that may be used to read elements. + typedef const mutable_buffer* const_iterator; + + /// Construct to represent a given memory range. + mutable_buffers_1(void* data, std::size_t size) + : mutable_buffer(data, size) + { + } + + /// Construct to represent a single modifiable buffer. + explicit mutable_buffers_1(const mutable_buffer& b) + : mutable_buffer(b) + { + } + + /// Get a random-access iterator to the first element. + const_iterator begin() const + { + return this; + } + + /// Get a random-access iterator for one past the last element. + const_iterator end() const + { + return begin() + 1; + } +}; + +/// Holds a buffer that cannot be modified. +/** + * The const_buffer class provides a safe representation of a buffer that cannot + * be modified. It does not own the underlying data, and so is cheap to copy or + * assign. + */ +class const_buffer +{ +public: + /// Construct an empty buffer. + const_buffer() + : data_(0), + size_(0) + { + } + + /// Construct a buffer to represent a given memory range. + const_buffer(const void* data, std::size_t size) + : data_(data), + size_(size) + { + } + + /// Construct a non-modifiable buffer from a modifiable one. + const_buffer(const mutable_buffer& b) + : data_(boost::asio::detail::buffer_cast_helper(b)), + size_(boost::asio::detail::buffer_size_helper(b)) +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , debug_check_(b.get_debug_check()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + { + } + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + const_buffer(const void* data, std::size_t size, + boost::function<void()> debug_check) + : data_(data), + size_(size), + debug_check_(debug_check) + { + } + + const boost::function<void()>& get_debug_check() const + { + return debug_check_; + } +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + +private: + friend const void* boost::asio::detail::buffer_cast_helper( + const const_buffer& b); + friend std::size_t boost::asio::detail::buffer_size_helper( + const const_buffer& b); + + const void* data_; + std::size_t size_; + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + boost::function<void()> debug_check_; +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING +}; + +namespace detail { + +inline const void* buffer_cast_helper(const const_buffer& b) +{ +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + if (b.size_ && b.debug_check_) + b.debug_check_(); +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + return b.data_; +} + +inline std::size_t buffer_size_helper(const const_buffer& b) +{ + return b.size_; +} + +} // namespace detail + +/// Cast a non-modifiable buffer to a specified pointer to POD type. +/** + * @relates const_buffer + */ +template <typename PointerToPodType> +inline PointerToPodType buffer_cast(const const_buffer& b) +{ + return static_cast<PointerToPodType>(detail::buffer_cast_helper(b)); +} + +/// Get the number of bytes in a non-modifiable buffer. +/** + * @relates const_buffer + */ +inline std::size_t buffer_size(const const_buffer& b) +{ + return detail::buffer_size_helper(b); +} + +/// Create a new non-modifiable buffer that is offset from the start of another. +/** + * @relates const_buffer + */ +inline const_buffer operator+(const const_buffer& b, std::size_t start) +{ + if (start > buffer_size(b)) + return const_buffer(); + const char* new_data = buffer_cast<const char*>(b) + start; + std::size_t new_size = buffer_size(b) - start; + return const_buffer(new_data, new_size +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + ); +} + +/// Create a new non-modifiable buffer that is offset from the start of another. +/** + * @relates const_buffer + */ +inline const_buffer operator+(std::size_t start, const const_buffer& b) +{ + if (start > buffer_size(b)) + return const_buffer(); + const char* new_data = buffer_cast<const char*>(b) + start; + std::size_t new_size = buffer_size(b) - start; + return const_buffer(new_data, new_size +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + ); +} + +/// Adapts a single non-modifiable buffer so that it meets the requirements of +/// the ConstBufferSequence concept. +class const_buffers_1 + : public const_buffer +{ +public: + /// The type for each element in the list of buffers. + typedef const_buffer value_type; + + /// A random-access iterator type that may be used to read elements. + typedef const const_buffer* const_iterator; + + /// Construct to represent a given memory range. + const_buffers_1(const void* data, std::size_t size) + : const_buffer(data, size) + { + } + + /// Construct to represent a single non-modifiable buffer. + explicit const_buffers_1(const const_buffer& b) + : const_buffer(b) + { + } + + /// Get a random-access iterator to the first element. + const_iterator begin() const + { + return this; + } + + /// Get a random-access iterator for one past the last element. + const_iterator end() const + { + return begin() + 1; + } +}; + +/// An implementation of both the ConstBufferSequence and MutableBufferSequence +/// concepts to represent a null buffer sequence. +class null_buffers +{ +public: + /// The type for each element in the list of buffers. + typedef mutable_buffer value_type; + + /// A random-access iterator type that may be used to read elements. + typedef const mutable_buffer* const_iterator; + + /// Get a random-access iterator to the first element. + const_iterator begin() const + { + return &buf_; + } + + /// Get a random-access iterator for one past the last element. + const_iterator end() const + { + return &buf_; + } + +private: + mutable_buffer buf_; +}; + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) +namespace detail { + +template <typename Iterator> +class buffer_debug_check +{ +public: + buffer_debug_check(Iterator iter) + : iter_(iter) + { + } + + ~buffer_debug_check() + { +#if BOOST_WORKAROUND(BOOST_MSVC, == 1400) + // MSVC 8's string iterator checking may crash in a std::string::iterator + // object's destructor when the iterator points to an already-destroyed + // std::string object, unless the iterator is cleared first. + iter_ = Iterator(); +#endif // BOOST_WORKAROUND(BOOST_MSVC, == 1400) + } + + void operator()() + { + *iter_; + } + +private: + Iterator iter_; +}; + +} // namespace detail +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + +/** @defgroup buffer boost::asio::buffer + * + * @brief The boost::asio::buffer function is used to create a buffer object to + * represent raw memory, an array of POD elements, a vector of POD elements, + * or a std::string. + * + * A buffer object represents a contiguous region of memory as a 2-tuple + * consisting of a pointer and size in bytes. A tuple of the form <tt>{void*, + * size_t}</tt> specifies a mutable (modifiable) region of memory. Similarly, a + * tuple of the form <tt>{const void*, size_t}</tt> specifies a const + * (non-modifiable) region of memory. These two forms correspond to the classes + * mutable_buffer and const_buffer, respectively. To mirror C++'s conversion + * rules, a mutable_buffer is implicitly convertible to a const_buffer, and the + * opposite conversion is not permitted. + * + * The simplest use case involves reading or writing a single buffer of a + * specified size: + * + * @code sock.send(boost::asio::buffer(data, size)); @endcode + * + * In the above example, the return value of boost::asio::buffer meets the + * requirements of the ConstBufferSequence concept so that it may be directly + * passed to the socket's write function. A buffer created for modifiable + * memory also meets the requirements of the MutableBufferSequence concept. + * + * An individual buffer may be created from a builtin array, std::vector or + * boost::array of POD elements. This helps prevent buffer overruns by + * automatically determining the size of the buffer: + * + * @code char d1[128]; + * size_t bytes_transferred = sock.receive(boost::asio::buffer(d1)); + * + * std::vector<char> d2(128); + * bytes_transferred = sock.receive(boost::asio::buffer(d2)); + * + * boost::array<char, 128> d3; + * bytes_transferred = sock.receive(boost::asio::buffer(d3)); @endcode + * + * In all three cases above, the buffers created are exactly 128 bytes long. + * Note that a vector is @e never automatically resized when creating or using + * a buffer. The buffer size is determined using the vector's <tt>size()</tt> + * member function, and not its capacity. + * + * @par Accessing Buffer Contents + * + * The contents of a buffer may be accessed using the boost::asio::buffer_size + * and boost::asio::buffer_cast functions: + * + * @code boost::asio::mutable_buffer b1 = ...; + * std::size_t s1 = boost::asio::buffer_size(b1); + * unsigned char* p1 = boost::asio::buffer_cast<unsigned char*>(b1); + * + * boost::asio::const_buffer b2 = ...; + * std::size_t s2 = boost::asio::buffer_size(b2); + * const void* p2 = boost::asio::buffer_cast<const void*>(b2); @endcode + * + * The boost::asio::buffer_cast function permits violations of type safety, so + * uses of it in application code should be carefully considered. + * + * @par Buffer Invalidation + * + * A buffer object does not have any ownership of the memory it refers to. It + * is the responsibility of the application to ensure the memory region remains + * valid until it is no longer required for an I/O operation. When the memory + * is no longer available, the buffer is said to have been invalidated. + * + * For the boost::asio::buffer overloads that accept an argument of type + * std::vector, the buffer objects returned are invalidated by any vector + * operation that also invalidates all references, pointers and iterators + * referring to the elements in the sequence (C++ Std, 23.2.4) + * + * For the boost::asio::buffer overloads that accept an argument of type + * std::string, the buffer objects returned are invalidated according to the + * rules defined for invalidation of references, pointers and iterators + * referring to elements of the sequence (C++ Std, 21.3). + * + * @par Buffer Arithmetic + * + * Buffer objects may be manipulated using simple arithmetic in a safe way + * which helps prevent buffer overruns. Consider an array initialised as + * follows: + * + * @code boost::array<char, 6> a = { 'a', 'b', 'c', 'd', 'e' }; @endcode + * + * A buffer object @c b1 created using: + * + * @code b1 = boost::asio::buffer(a); @endcode + * + * represents the entire array, <tt>{ 'a', 'b', 'c', 'd', 'e' }</tt>. An + * optional second argument to the boost::asio::buffer function may be used to + * limit the size, in bytes, of the buffer: + * + * @code b2 = boost::asio::buffer(a, 3); @endcode + * + * such that @c b2 represents the data <tt>{ 'a', 'b', 'c' }</tt>. Even if the + * size argument exceeds the actual size of the array, the size of the buffer + * object created will be limited to the array size. + * + * An offset may be applied to an existing buffer to create a new one: + * + * @code b3 = b1 + 2; @endcode + * + * where @c b3 will set to represent <tt>{ 'c', 'd', 'e' }</tt>. If the offset + * exceeds the size of the existing buffer, the newly created buffer will be + * empty. + * + * Both an offset and size may be specified to create a buffer that corresponds + * to a specific range of bytes within an existing buffer: + * + * @code b4 = boost::asio::buffer(b1 + 1, 3); @endcode + * + * so that @c b4 will refer to the bytes <tt>{ 'b', 'c', 'd' }</tt>. + * + * @par Buffers and Scatter-Gather I/O + * + * To read or write using multiple buffers (i.e. scatter-gather I/O), multiple + * buffer objects may be assigned into a container that supports the + * MutableBufferSequence (for read) or ConstBufferSequence (for write) concepts: + * + * @code + * char d1[128]; + * std::vector<char> d2(128); + * boost::array<char, 128> d3; + * + * boost::array<mutable_buffer, 3> bufs1 = { + * boost::asio::buffer(d1), + * boost::asio::buffer(d2), + * boost::asio::buffer(d3) }; + * bytes_transferred = sock.receive(bufs1); + * + * std::vector<const_buffer> bufs2; + * bufs2.push_back(boost::asio::buffer(d1)); + * bufs2.push_back(boost::asio::buffer(d2)); + * bufs2.push_back(boost::asio::buffer(d3)); + * bytes_transferred = sock.send(bufs2); @endcode + */ +/*@{*/ + +/// Create a new modifiable buffer from an existing buffer. +/** + * @returns <tt>mutable_buffers_1(b)</tt>. + */ +inline mutable_buffers_1 buffer(const mutable_buffer& b) +{ + return mutable_buffers_1(b); +} + +/// Create a new modifiable buffer from an existing buffer. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * buffer_cast<void*>(b), + * min(buffer_size(b), max_size_in_bytes)); @endcode + */ +inline mutable_buffers_1 buffer(const mutable_buffer& b, + std::size_t max_size_in_bytes) +{ + return mutable_buffers_1( + mutable_buffer(buffer_cast<void*>(b), + buffer_size(b) < max_size_in_bytes + ? buffer_size(b) : max_size_in_bytes +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new non-modifiable buffer from an existing buffer. +/** + * @returns <tt>const_buffers_1(b)</tt>. + */ +inline const_buffers_1 buffer(const const_buffer& b) +{ + return const_buffers_1(b); +} + +/// Create a new non-modifiable buffer from an existing buffer. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * buffer_cast<const void*>(b), + * min(buffer_size(b), max_size_in_bytes)); @endcode + */ +inline const_buffers_1 buffer(const const_buffer& b, + std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(buffer_cast<const void*>(b), + buffer_size(b) < max_size_in_bytes + ? buffer_size(b) : max_size_in_bytes +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , b.get_debug_check() +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new modifiable buffer that represents the given memory range. +/** + * @returns <tt>mutable_buffers_1(data, size_in_bytes)</tt>. + */ +inline mutable_buffers_1 buffer(void* data, std::size_t size_in_bytes) +{ + return mutable_buffers_1(mutable_buffer(data, size_in_bytes)); +} + +/// Create a new non-modifiable buffer that represents the given memory range. +/** + * @returns <tt>const_buffers_1(data, size_in_bytes)</tt>. + */ +inline const_buffers_1 buffer(const void* data, + std::size_t size_in_bytes) +{ + return const_buffers_1(const_buffer(data, size_in_bytes)); +} + +/// Create a new modifiable buffer that represents the given POD array. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * static_cast<void*>(data), + * N * sizeof(PodType)); @endcode + */ +template <typename PodType, std::size_t N> +inline mutable_buffers_1 buffer(PodType (&data)[N]) +{ + return mutable_buffers_1(mutable_buffer(data, N * sizeof(PodType))); +} + +/// Create a new modifiable buffer that represents the given POD array. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * static_cast<void*>(data), + * min(N * sizeof(PodType), max_size_in_bytes)); @endcode + */ +template <typename PodType, std::size_t N> +inline mutable_buffers_1 buffer(PodType (&data)[N], + std::size_t max_size_in_bytes) +{ + return mutable_buffers_1( + mutable_buffer(data, + N * sizeof(PodType) < max_size_in_bytes + ? N * sizeof(PodType) : max_size_in_bytes)); +} + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * static_cast<const void*>(data), + * N * sizeof(PodType)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(const PodType (&data)[N]) +{ + return const_buffers_1(const_buffer(data, N * sizeof(PodType))); +} + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * static_cast<const void*>(data), + * min(N * sizeof(PodType), max_size_in_bytes)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(const PodType (&data)[N], + std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(data, + N * sizeof(PodType) < max_size_in_bytes + ? N * sizeof(PodType) : max_size_in_bytes)); +} + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \ + || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) + +// Borland C++ and Sun Studio think the overloads: +// +// unspecified buffer(boost::array<PodType, N>& array ...); +// +// and +// +// unspecified buffer(boost::array<const PodType, N>& array ...); +// +// are ambiguous. This will be worked around by using a buffer_types traits +// class that contains typedefs for the appropriate buffer and container +// classes, based on whether PodType is const or non-const. + +namespace detail { + +template <bool IsConst> +struct buffer_types_base; + +template <> +struct buffer_types_base<false> +{ + typedef mutable_buffer buffer_type; + typedef mutable_buffers_1 container_type; +}; + +template <> +struct buffer_types_base<true> +{ + typedef const_buffer buffer_type; + typedef const_buffers_1 container_type; +}; + +template <typename PodType> +struct buffer_types + : public buffer_types_base<boost::is_const<PodType>::value> +{ +}; + +} // namespace detail + +template <typename PodType, std::size_t N> +inline typename detail::buffer_types<PodType>::container_type +buffer(boost::array<PodType, N>& data) +{ + typedef typename boost::asio::detail::buffer_types<PodType>::buffer_type + buffer_type; + typedef typename boost::asio::detail::buffer_types<PodType>::container_type + container_type; + return container_type( + buffer_type(data.c_array(), data.size() * sizeof(PodType))); +} + +template <typename PodType, std::size_t N> +inline typename detail::buffer_types<PodType>::container_type +buffer(boost::array<PodType, N>& data, std::size_t max_size_in_bytes) +{ + typedef typename boost::asio::detail::buffer_types<PodType>::buffer_type + buffer_type; + typedef typename boost::asio::detail::buffer_types<PodType>::container_type + container_type; + return container_type( + buffer_type(data.c_array(), + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes)); +} + +#else // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + // || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) + +/// Create a new modifiable buffer that represents the given POD array. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * data.data(), + * data.size() * sizeof(PodType)); @endcode + */ +template <typename PodType, std::size_t N> +inline mutable_buffers_1 buffer(boost::array<PodType, N>& data) +{ + return mutable_buffers_1( + mutable_buffer(data.c_array(), data.size() * sizeof(PodType))); +} + +/// Create a new modifiable buffer that represents the given POD array. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * data.data(), + * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode + */ +template <typename PodType, std::size_t N> +inline mutable_buffers_1 buffer(boost::array<PodType, N>& data, + std::size_t max_size_in_bytes) +{ + return mutable_buffers_1( + mutable_buffer(data.c_array(), + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes)); +} + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.data(), + * data.size() * sizeof(PodType)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(boost::array<const PodType, N>& data) +{ + return const_buffers_1( + const_buffer(data.data(), data.size() * sizeof(PodType))); +} + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.data(), + * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(boost::array<const PodType, N>& data, + std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(data.data(), + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes)); +} + +#endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + // || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590)) + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.data(), + * data.size() * sizeof(PodType)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(const boost::array<PodType, N>& data) +{ + return const_buffers_1( + const_buffer(data.data(), data.size() * sizeof(PodType))); +} + +/// Create a new non-modifiable buffer that represents the given POD array. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.data(), + * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode + */ +template <typename PodType, std::size_t N> +inline const_buffers_1 buffer(const boost::array<PodType, N>& data, + std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(data.data(), + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes)); +} + +/// Create a new modifiable buffer that represents the given POD vector. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * data.size() ? &data[0] : 0, + * data.size() * sizeof(PodType)); @endcode + * + * @note The buffer is invalidated by any vector operation that would also + * invalidate iterators. + */ +template <typename PodType, typename Allocator> +inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data) +{ + return mutable_buffers_1( + mutable_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check< + typename std::vector<PodType, Allocator>::iterator + >(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new modifiable buffer that represents the given POD vector. +/** + * @returns A mutable_buffers_1 value equivalent to: + * @code mutable_buffers_1( + * data.size() ? &data[0] : 0, + * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode + * + * @note The buffer is invalidated by any vector operation that would also + * invalidate iterators. + */ +template <typename PodType, typename Allocator> +inline mutable_buffers_1 buffer(std::vector<PodType, Allocator>& data, + std::size_t max_size_in_bytes) +{ + return mutable_buffers_1( + mutable_buffer(data.size() ? &data[0] : 0, + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check< + typename std::vector<PodType, Allocator>::iterator + >(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new non-modifiable buffer that represents the given POD vector. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.size() ? &data[0] : 0, + * data.size() * sizeof(PodType)); @endcode + * + * @note The buffer is invalidated by any vector operation that would also + * invalidate iterators. + */ +template <typename PodType, typename Allocator> +inline const_buffers_1 buffer( + const std::vector<PodType, Allocator>& data) +{ + return const_buffers_1( + const_buffer(data.size() ? &data[0] : 0, data.size() * sizeof(PodType) +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check< + typename std::vector<PodType, Allocator>::const_iterator + >(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new non-modifiable buffer that represents the given POD vector. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.size() ? &data[0] : 0, + * min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode + * + * @note The buffer is invalidated by any vector operation that would also + * invalidate iterators. + */ +template <typename PodType, typename Allocator> +inline const_buffers_1 buffer( + const std::vector<PodType, Allocator>& data, std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(data.size() ? &data[0] : 0, + data.size() * sizeof(PodType) < max_size_in_bytes + ? data.size() * sizeof(PodType) : max_size_in_bytes +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check< + typename std::vector<PodType, Allocator>::const_iterator + >(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new non-modifiable buffer that represents the given string. +/** + * @returns <tt>const_buffers_1(data.data(), data.size())</tt>. + * + * @note The buffer is invalidated by any non-const operation called on the + * given string object. + */ +inline const_buffers_1 buffer(const std::string& data) +{ + return const_buffers_1(const_buffer(data.data(), data.size() +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check<std::string::const_iterator>(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/// Create a new non-modifiable buffer that represents the given string. +/** + * @returns A const_buffers_1 value equivalent to: + * @code const_buffers_1( + * data.data(), + * min(data.size(), max_size_in_bytes)); @endcode + * + * @note The buffer is invalidated by any non-const operation called on the + * given string object. + */ +inline const_buffers_1 buffer(const std::string& data, + std::size_t max_size_in_bytes) +{ + return const_buffers_1( + const_buffer(data.data(), + data.size() < max_size_in_bytes + ? data.size() : max_size_in_bytes +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + , detail::buffer_debug_check<std::string::const_iterator>(data.begin()) +#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING + )); +} + +/*@}*/ + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BUFFER_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_read_stream.hpp b/boost_1_45_0/boost/asio/buffered_read_stream.hpp new file mode 100644 index 0000000..935f5b9 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_read_stream.hpp
@@ -0,0 +1,460 @@ +// +// buffered_read_stream.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_READ_STREAM_HPP +#define BOOST_ASIO_BUFFERED_READ_STREAM_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <cstring> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/asio/buffered_read_stream_fwd.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_resize_guard.hpp> +#include <boost/asio/detail/buffered_stream_storage.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Adds buffering to the read-related operations of a stream. +/** + * The buffered_read_stream class template can be used to add buffering to the + * synchronous and asynchronous read operations of a stream. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Concepts: + * AsyncReadStream, AsyncWriteStream, Stream, Sync_Read_Stream, SyncWriteStream. + */ +template <typename Stream> +class buffered_read_stream + : private noncopyable +{ +public: + /// The type of the next layer. + typedef typename boost::remove_reference<Stream>::type next_layer_type; + + /// The type of the lowest layer. + typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + +#if defined(GENERATING_DOCUMENTATION) + /// The default buffer size. + static const std::size_t default_buffer_size = implementation_defined; +#else + BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024); +#endif + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + explicit buffered_read_stream(Arg& a) + : next_layer_(a), + storage_(default_buffer_size) + { + } + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + buffered_read_stream(Arg& a, std::size_t buffer_size) + : next_layer_(a), + storage_(buffer_size) + { + } + + /// Get a reference to the next layer. + next_layer_type& next_layer() + { + return next_layer_; + } + + /// Get a reference to the lowest layer. + lowest_layer_type& lowest_layer() + { + return next_layer_.lowest_layer(); + } + + /// Get a const reference to the lowest layer. + const lowest_layer_type& lowest_layer() const + { + return next_layer_.lowest_layer(); + } + + /// (Deprecated: use get_io_service().) Get the io_service associated with + /// the object. + boost::asio::io_service& io_service() + { + return next_layer_.get_io_service(); + } + + /// Get the io_service associated with the object. + boost::asio::io_service& get_io_service() + { + return next_layer_.get_io_service(); + } + + /// Close the stream. + void close() + { + next_layer_.close(); + } + + /// Close the stream. + boost::system::error_code close(boost::system::error_code& ec) + { + return next_layer_.close(ec); + } + + /// Write the given data to the stream. Returns the number of bytes written. + /// Throws an exception on failure. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers) + { + return next_layer_.write_some(buffers); + } + + /// Write the given data to the stream. Returns the number of bytes written, + /// or 0 if an error occurred. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers, + boost::system::error_code& ec) + { + return next_layer_.write_some(buffers, ec); + } + + /// Start an asynchronous write. The data being written must be valid for the + /// lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename WriteHandler> + void async_write_some(const ConstBufferSequence& buffers, + WriteHandler handler) + { + next_layer_.async_write_some(buffers, handler); + } + + /// Fill the buffer with some data. Returns the number of bytes placed in the + /// buffer as a result of the operation. Throws an exception on failure. + std::size_t fill() + { + detail::buffer_resize_guard<detail::buffered_stream_storage> + resize_guard(storage_); + std::size_t previous_size = storage_.size(); + storage_.resize(storage_.capacity()); + storage_.resize(previous_size + next_layer_.read_some(buffer( + storage_.data() + previous_size, + storage_.size() - previous_size))); + resize_guard.commit(); + return storage_.size() - previous_size; + } + + /// Fill the buffer with some data. Returns the number of bytes placed in the + /// buffer as a result of the operation, or 0 if an error occurred. + std::size_t fill(boost::system::error_code& ec) + { + detail::buffer_resize_guard<detail::buffered_stream_storage> + resize_guard(storage_); + std::size_t previous_size = storage_.size(); + storage_.resize(storage_.capacity()); + storage_.resize(previous_size + next_layer_.read_some(buffer( + storage_.data() + previous_size, + storage_.size() - previous_size), + ec)); + resize_guard.commit(); + return storage_.size() - previous_size; + } + + template <typename ReadHandler> + class fill_handler + { + public: + fill_handler(boost::asio::io_service& io_service, + detail::buffered_stream_storage& storage, + std::size_t previous_size, ReadHandler handler) + : io_service_(io_service), + storage_(storage), + previous_size_(previous_size), + handler_(handler) + { + } + + void operator()(const boost::system::error_code& ec, + std::size_t bytes_transferred) + { + storage_.resize(previous_size_ + bytes_transferred); + io_service_.dispatch(detail::bind_handler( + handler_, ec, bytes_transferred)); + } + + private: + boost::asio::io_service& io_service_; + detail::buffered_stream_storage& storage_; + std::size_t previous_size_; + ReadHandler handler_; + }; + + /// Start an asynchronous fill. + template <typename ReadHandler> + void async_fill(ReadHandler handler) + { + std::size_t previous_size = storage_.size(); + storage_.resize(storage_.capacity()); + next_layer_.async_read_some( + buffer( + storage_.data() + previous_size, + storage_.size() - previous_size), + fill_handler<ReadHandler>(get_io_service(), + storage_, previous_size, handler)); + } + + /// Read some data from the stream. Returns the number of bytes read. Throws + /// an exception on failure. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers) + { + typename MutableBufferSequence::const_iterator iter = buffers.begin(); + typename MutableBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::mutable_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + return 0; + + if (storage_.empty()) + fill(); + + return copy(buffers); + } + + /// Read some data from the stream. Returns the number of bytes read or 0 if + /// an error occurred. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + ec = boost::system::error_code(); + + typename MutableBufferSequence::const_iterator iter = buffers.begin(); + typename MutableBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::mutable_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + return 0; + + if (storage_.empty() && !fill(ec)) + return 0; + + return copy(buffers); + } + + template <typename MutableBufferSequence, typename ReadHandler> + class read_some_handler + { + public: + read_some_handler(boost::asio::io_service& io_service, + detail::buffered_stream_storage& storage, + const MutableBufferSequence& buffers, ReadHandler handler) + : io_service_(io_service), + storage_(storage), + buffers_(buffers), + handler_(handler) + { + } + + void operator()(const boost::system::error_code& ec, std::size_t) + { + if (ec || storage_.empty()) + { + std::size_t length = 0; + io_service_.dispatch(detail::bind_handler(handler_, ec, length)); + } + else + { + using namespace std; // For memcpy. + + std::size_t bytes_avail = storage_.size(); + std::size_t bytes_copied = 0; + + typename MutableBufferSequence::const_iterator iter = buffers_.begin(); + typename MutableBufferSequence::const_iterator end = buffers_.end(); + for (; iter != end && bytes_avail > 0; ++iter) + { + std::size_t max_length = buffer_size(*iter); + std::size_t length = (max_length < bytes_avail) + ? max_length : bytes_avail; + memcpy(buffer_cast<void*>(*iter), + storage_.data() + bytes_copied, length); + bytes_copied += length; + bytes_avail -= length; + } + + storage_.consume(bytes_copied); + io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied)); + } + } + + private: + boost::asio::io_service& io_service_; + detail::buffered_stream_storage& storage_; + MutableBufferSequence buffers_; + ReadHandler handler_; + }; + + /// Start an asynchronous read. The buffer into which the data will be read + /// must be valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename ReadHandler> + void async_read_some(const MutableBufferSequence& buffers, + ReadHandler handler) + { + typename MutableBufferSequence::const_iterator iter = buffers.begin(); + typename MutableBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::mutable_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + { + get_io_service().post(detail::bind_handler( + handler, boost::system::error_code(), 0)); + } + else if (storage_.empty()) + { + async_fill(read_some_handler<MutableBufferSequence, ReadHandler>( + get_io_service(), storage_, buffers, handler)); + } + else + { + std::size_t length = copy(buffers); + get_io_service().post(detail::bind_handler( + handler, boost::system::error_code(), length)); + } + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read. + /// Throws an exception on failure. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers) + { + if (storage_.empty()) + fill(); + return peek_copy(buffers); + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read, + /// or 0 if an error occurred. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + ec = boost::system::error_code(); + if (storage_.empty() && !fill(ec)) + return 0; + return peek_copy(buffers); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail() + { + return storage_.size(); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail(boost::system::error_code& ec) + { + ec = boost::system::error_code(); + return storage_.size(); + } + +private: + /// Copy data out of the internal buffer to the specified target buffer. + /// Returns the number of bytes copied. + template <typename MutableBufferSequence> + std::size_t copy(const MutableBufferSequence& buffers) + { + using namespace std; // For memcpy. + + std::size_t bytes_avail = storage_.size(); + std::size_t bytes_copied = 0; + + typename MutableBufferSequence::const_iterator iter = buffers.begin(); + typename MutableBufferSequence::const_iterator end = buffers.end(); + for (; iter != end && bytes_avail > 0; ++iter) + { + std::size_t max_length = buffer_size(*iter); + std::size_t length = (max_length < bytes_avail) + ? max_length : bytes_avail; + memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length); + bytes_copied += length; + bytes_avail -= length; + } + + storage_.consume(bytes_copied); + return bytes_copied; + } + + /// Copy data from the internal buffer to the specified target buffer, without + /// removing the data from the internal buffer. Returns the number of bytes + /// copied. + template <typename MutableBufferSequence> + std::size_t peek_copy(const MutableBufferSequence& buffers) + { + using namespace std; // For memcpy. + + std::size_t bytes_avail = storage_.size(); + std::size_t bytes_copied = 0; + + typename MutableBufferSequence::const_iterator iter = buffers.begin(); + typename MutableBufferSequence::const_iterator end = buffers.end(); + for (; iter != end && bytes_avail > 0; ++iter) + { + std::size_t max_length = buffer_size(*iter); + std::size_t length = (max_length < bytes_avail) + ? max_length : bytes_avail; + memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length); + bytes_copied += length; + bytes_avail -= length; + } + + return bytes_copied; + } + + /// The next layer. + Stream next_layer_; + + // The data in the buffer. + detail::buffered_stream_storage storage_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BUFFERED_READ_STREAM_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_read_stream_fwd.hpp b/boost_1_45_0/boost/asio/buffered_read_stream_fwd.hpp new file mode 100644 index 0000000..87f27d9 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_read_stream_fwd.hpp
@@ -0,0 +1,27 @@ +// +// buffered_read_stream_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP +#define BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { + +template <typename Stream> +class buffered_read_stream; + +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_stream.hpp b/boost_1_45_0/boost/asio/buffered_stream.hpp new file mode 100644 index 0000000..ceeb6f2 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_stream.hpp
@@ -0,0 +1,255 @@ +// +// buffered_stream.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_STREAM_HPP +#define BOOST_ASIO_BUFFERED_STREAM_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/buffered_read_stream.hpp> +#include <boost/asio/buffered_write_stream.hpp> +#include <boost/asio/buffered_stream_fwd.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Adds buffering to the read- and write-related operations of a stream. +/** + * The buffered_stream class template can be used to add buffering to the + * synchronous and asynchronous read and write operations of a stream. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Concepts: + * AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream. + */ +template <typename Stream> +class buffered_stream + : private noncopyable +{ +public: + /// The type of the next layer. + typedef typename boost::remove_reference<Stream>::type next_layer_type; + + /// The type of the lowest layer. + typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + explicit buffered_stream(Arg& a) + : inner_stream_impl_(a), + stream_impl_(inner_stream_impl_) + { + } + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + explicit buffered_stream(Arg& a, std::size_t read_buffer_size, + std::size_t write_buffer_size) + : inner_stream_impl_(a, write_buffer_size), + stream_impl_(inner_stream_impl_, read_buffer_size) + { + } + + /// Get a reference to the next layer. + next_layer_type& next_layer() + { + return stream_impl_.next_layer().next_layer(); + } + + /// Get a reference to the lowest layer. + lowest_layer_type& lowest_layer() + { + return stream_impl_.lowest_layer(); + } + + /// Get a const reference to the lowest layer. + const lowest_layer_type& lowest_layer() const + { + return stream_impl_.lowest_layer(); + } + + /// (Deprecated: use get_io_service().) Get the io_service associated with + /// the object. + boost::asio::io_service& io_service() + { + return stream_impl_.get_io_service(); + } + + /// Get the io_service associated with the object. + boost::asio::io_service& get_io_service() + { + return stream_impl_.get_io_service(); + } + + /// Close the stream. + void close() + { + stream_impl_.close(); + } + + /// Close the stream. + boost::system::error_code close(boost::system::error_code& ec) + { + return stream_impl_.close(ec); + } + + /// Flush all data from the buffer to the next layer. Returns the number of + /// bytes written to the next layer on the last write operation. Throws an + /// exception on failure. + std::size_t flush() + { + return stream_impl_.next_layer().flush(); + } + + /// Flush all data from the buffer to the next layer. Returns the number of + /// bytes written to the next layer on the last write operation, or 0 if an + /// error occurred. + std::size_t flush(boost::system::error_code& ec) + { + return stream_impl_.next_layer().flush(ec); + } + + /// Start an asynchronous flush. + template <typename WriteHandler> + void async_flush(WriteHandler handler) + { + return stream_impl_.next_layer().async_flush(handler); + } + + /// Write the given data to the stream. Returns the number of bytes written. + /// Throws an exception on failure. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers) + { + return stream_impl_.write_some(buffers); + } + + /// Write the given data to the stream. Returns the number of bytes written, + /// or 0 if an error occurred. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers, + boost::system::error_code& ec) + { + return stream_impl_.write_some(buffers, ec); + } + + /// Start an asynchronous write. The data being written must be valid for the + /// lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename WriteHandler> + void async_write_some(const ConstBufferSequence& buffers, + WriteHandler handler) + { + stream_impl_.async_write_some(buffers, handler); + } + + /// Fill the buffer with some data. Returns the number of bytes placed in the + /// buffer as a result of the operation. Throws an exception on failure. + std::size_t fill() + { + return stream_impl_.fill(); + } + + /// Fill the buffer with some data. Returns the number of bytes placed in the + /// buffer as a result of the operation, or 0 if an error occurred. + std::size_t fill(boost::system::error_code& ec) + { + return stream_impl_.fill(ec); + } + + /// Start an asynchronous fill. + template <typename ReadHandler> + void async_fill(ReadHandler handler) + { + stream_impl_.async_fill(handler); + } + + /// Read some data from the stream. Returns the number of bytes read. Throws + /// an exception on failure. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers) + { + return stream_impl_.read_some(buffers); + } + + /// Read some data from the stream. Returns the number of bytes read or 0 if + /// an error occurred. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return stream_impl_.read_some(buffers, ec); + } + + /// Start an asynchronous read. The buffer into which the data will be read + /// must be valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename ReadHandler> + void async_read_some(const MutableBufferSequence& buffers, + ReadHandler handler) + { + stream_impl_.async_read_some(buffers, handler); + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read. + /// Throws an exception on failure. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers) + { + return stream_impl_.peek(buffers); + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read, + /// or 0 if an error occurred. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return stream_impl_.peek(buffers, ec); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail() + { + return stream_impl_.in_avail(); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail(boost::system::error_code& ec) + { + return stream_impl_.in_avail(ec); + } + +private: + // The buffered write stream. + typedef buffered_write_stream<Stream> write_stream_type; + write_stream_type inner_stream_impl_; + + // The buffered read stream. + typedef buffered_read_stream<write_stream_type&> read_stream_type; + read_stream_type stream_impl_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BUFFERED_STREAM_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_stream_fwd.hpp b/boost_1_45_0/boost/asio/buffered_stream_fwd.hpp new file mode 100644 index 0000000..d23bc26 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_stream_fwd.hpp
@@ -0,0 +1,27 @@ +// +// buffered_stream_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_STREAM_FWD_HPP +#define BOOST_ASIO_BUFFERED_STREAM_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { + +template <typename Stream> +class buffered_stream; + +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_write_stream.hpp b/boost_1_45_0/boost/asio/buffered_write_stream.hpp new file mode 100644 index 0000000..c918a0a --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_write_stream.hpp
@@ -0,0 +1,414 @@ +// +// buffered_write_stream.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP +#define BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <cstring> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/asio/buffered_write_stream_fwd.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/completion_condition.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffered_stream_storage.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/write.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Adds buffering to the write-related operations of a stream. +/** + * The buffered_write_stream class template can be used to add buffering to the + * synchronous and asynchronous write operations of a stream. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Concepts: + * AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream. + */ +template <typename Stream> +class buffered_write_stream + : private noncopyable +{ +public: + /// The type of the next layer. + typedef typename boost::remove_reference<Stream>::type next_layer_type; + + /// The type of the lowest layer. + typedef typename next_layer_type::lowest_layer_type lowest_layer_type; + +#if defined(GENERATING_DOCUMENTATION) + /// The default buffer size. + static const std::size_t default_buffer_size = implementation_defined; +#else + BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024); +#endif + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + explicit buffered_write_stream(Arg& a) + : next_layer_(a), + storage_(default_buffer_size) + { + } + + /// Construct, passing the specified argument to initialise the next layer. + template <typename Arg> + buffered_write_stream(Arg& a, std::size_t buffer_size) + : next_layer_(a), + storage_(buffer_size) + { + } + + /// Get a reference to the next layer. + next_layer_type& next_layer() + { + return next_layer_; + } + + /// Get a reference to the lowest layer. + lowest_layer_type& lowest_layer() + { + return next_layer_.lowest_layer(); + } + + /// Get a const reference to the lowest layer. + const lowest_layer_type& lowest_layer() const + { + return next_layer_.lowest_layer(); + } + + /// (Deprecated: use get_io_service().) Get the io_service associated with + /// the object. + boost::asio::io_service& io_service() + { + return next_layer_.get_io_service(); + } + + /// Get the io_service associated with the object. + boost::asio::io_service& get_io_service() + { + return next_layer_.get_io_service(); + } + + /// Close the stream. + void close() + { + next_layer_.close(); + } + + /// Close the stream. + boost::system::error_code close(boost::system::error_code& ec) + { + return next_layer_.close(ec); + } + + /// Flush all data from the buffer to the next layer. Returns the number of + /// bytes written to the next layer on the last write operation. Throws an + /// exception on failure. + std::size_t flush() + { + std::size_t bytes_written = write(next_layer_, + buffer(storage_.data(), storage_.size())); + storage_.consume(bytes_written); + return bytes_written; + } + + /// Flush all data from the buffer to the next layer. Returns the number of + /// bytes written to the next layer on the last write operation, or 0 if an + /// error occurred. + std::size_t flush(boost::system::error_code& ec) + { + std::size_t bytes_written = write(next_layer_, + buffer(storage_.data(), storage_.size()), + transfer_all(), ec); + storage_.consume(bytes_written); + return bytes_written; + } + + template <typename WriteHandler> + class flush_handler + { + public: + flush_handler(boost::asio::io_service& io_service, + detail::buffered_stream_storage& storage, WriteHandler handler) + : io_service_(io_service), + storage_(storage), + handler_(handler) + { + } + + void operator()(const boost::system::error_code& ec, + std::size_t bytes_written) + { + storage_.consume(bytes_written); + io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_written)); + } + + private: + boost::asio::io_service& io_service_; + detail::buffered_stream_storage& storage_; + WriteHandler handler_; + }; + + /// Start an asynchronous flush. + template <typename WriteHandler> + void async_flush(WriteHandler handler) + { + async_write(next_layer_, buffer(storage_.data(), storage_.size()), + flush_handler<WriteHandler>(get_io_service(), storage_, handler)); + } + + /// Write the given data to the stream. Returns the number of bytes written. + /// Throws an exception on failure. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers) + { + typename ConstBufferSequence::const_iterator iter = buffers.begin(); + typename ConstBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::const_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + return 0; + + if (storage_.size() == storage_.capacity()) + flush(); + + return copy(buffers); + } + + /// Write the given data to the stream. Returns the number of bytes written, + /// or 0 if an error occurred and the error handler did not throw. + template <typename ConstBufferSequence> + std::size_t write_some(const ConstBufferSequence& buffers, + boost::system::error_code& ec) + { + ec = boost::system::error_code(); + + typename ConstBufferSequence::const_iterator iter = buffers.begin(); + typename ConstBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::const_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + return 0; + + if (storage_.size() == storage_.capacity() && !flush(ec)) + return 0; + + return copy(buffers); + } + + template <typename ConstBufferSequence, typename WriteHandler> + class write_some_handler + { + public: + write_some_handler(boost::asio::io_service& io_service, + detail::buffered_stream_storage& storage, + const ConstBufferSequence& buffers, WriteHandler handler) + : io_service_(io_service), + storage_(storage), + buffers_(buffers), + handler_(handler) + { + } + + void operator()(const boost::system::error_code& ec, std::size_t) + { + if (ec) + { + std::size_t length = 0; + io_service_.dispatch(detail::bind_handler(handler_, ec, length)); + } + else + { + using namespace std; // For memcpy. + + std::size_t orig_size = storage_.size(); + std::size_t space_avail = storage_.capacity() - orig_size; + std::size_t bytes_copied = 0; + + typename ConstBufferSequence::const_iterator iter = buffers_.begin(); + typename ConstBufferSequence::const_iterator end = buffers_.end(); + for (; iter != end && space_avail > 0; ++iter) + { + std::size_t bytes_avail = buffer_size(*iter); + std::size_t length = (bytes_avail < space_avail) + ? bytes_avail : space_avail; + storage_.resize(orig_size + bytes_copied + length); + memcpy(storage_.data() + orig_size + bytes_copied, + buffer_cast<const void*>(*iter), length); + bytes_copied += length; + space_avail -= length; + } + + io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied)); + } + } + + private: + boost::asio::io_service& io_service_; + detail::buffered_stream_storage& storage_; + ConstBufferSequence buffers_; + WriteHandler handler_; + }; + + /// Start an asynchronous write. The data being written must be valid for the + /// lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename WriteHandler> + void async_write_some(const ConstBufferSequence& buffers, + WriteHandler handler) + { + typename ConstBufferSequence::const_iterator iter = buffers.begin(); + typename ConstBufferSequence::const_iterator end = buffers.end(); + size_t total_buffer_size = 0; + for (; iter != end; ++iter) + { + boost::asio::const_buffer buffer(*iter); + total_buffer_size += boost::asio::buffer_size(buffer); + } + + if (total_buffer_size == 0) + { + get_io_service().post(detail::bind_handler( + handler, boost::system::error_code(), 0)); + } + else if (storage_.size() == storage_.capacity()) + { + async_flush(write_some_handler<ConstBufferSequence, WriteHandler>( + get_io_service(), storage_, buffers, handler)); + } + else + { + std::size_t bytes_copied = copy(buffers); + get_io_service().post(detail::bind_handler( + handler, boost::system::error_code(), bytes_copied)); + } + } + + /// Read some data from the stream. Returns the number of bytes read. Throws + /// an exception on failure. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers) + { + return next_layer_.read_some(buffers); + } + + /// Read some data from the stream. Returns the number of bytes read or 0 if + /// an error occurred. + template <typename MutableBufferSequence> + std::size_t read_some(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return next_layer_.read_some(buffers, ec); + } + + /// Start an asynchronous read. The buffer into which the data will be read + /// must be valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename ReadHandler> + void async_read_some(const MutableBufferSequence& buffers, + ReadHandler handler) + { + next_layer_.async_read_some(buffers, handler); + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read. + /// Throws an exception on failure. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers) + { + return next_layer_.peek(buffers); + } + + /// Peek at the incoming data on the stream. Returns the number of bytes read, + /// or 0 if an error occurred. + template <typename MutableBufferSequence> + std::size_t peek(const MutableBufferSequence& buffers, + boost::system::error_code& ec) + { + return next_layer_.peek(buffers, ec); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail() + { + return next_layer_.in_avail(); + } + + /// Determine the amount of data that may be read without blocking. + std::size_t in_avail(boost::system::error_code& ec) + { + return next_layer_.in_avail(ec); + } + +private: + /// Copy data into the internal buffer from the specified source buffer. + /// Returns the number of bytes copied. + template <typename ConstBufferSequence> + std::size_t copy(const ConstBufferSequence& buffers) + { + using namespace std; // For memcpy. + + std::size_t orig_size = storage_.size(); + std::size_t space_avail = storage_.capacity() - orig_size; + std::size_t bytes_copied = 0; + + typename ConstBufferSequence::const_iterator iter = buffers.begin(); + typename ConstBufferSequence::const_iterator end = buffers.end(); + for (; iter != end && space_avail > 0; ++iter) + { + std::size_t bytes_avail = buffer_size(*iter); + std::size_t length = (bytes_avail < space_avail) + ? bytes_avail : space_avail; + storage_.resize(orig_size + bytes_copied + length); + memcpy(storage_.data() + orig_size + bytes_copied, + buffer_cast<const void*>(*iter), length); + bytes_copied += length; + space_avail -= length; + } + + return bytes_copied; + } + + /// The next layer. + Stream next_layer_; + + // The data in the buffer. + detail::buffered_stream_storage storage_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP
diff --git a/boost_1_45_0/boost/asio/buffered_write_stream_fwd.hpp b/boost_1_45_0/boost/asio/buffered_write_stream_fwd.hpp new file mode 100644 index 0000000..8f0f409 --- /dev/null +++ b/boost_1_45_0/boost/asio/buffered_write_stream_fwd.hpp
@@ -0,0 +1,27 @@ +// +// buffered_write_stream_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERED_WRITE_STREAM_FWD_HPP +#define BOOST_ASIO_BUFFERED_WRITE_STREAM_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { + +template <typename Stream> +class buffered_write_stream; + +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_BUFFERED_WRITE_STREAM_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/buffers_iterator.hpp b/boost_1_45_0/boost/asio/buffers_iterator.hpp new file mode 100644 index 0000000..1ffd02d --- /dev/null +++ b/boost_1_45_0/boost/asio/buffers_iterator.hpp
@@ -0,0 +1,455 @@ +// +// buffers_iterator.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_BUFFERS_ITERATOR_HPP +#define BOOST_ASIO_BUFFERS_ITERATOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/assert.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/iterator.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/asio/buffer.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +namespace detail +{ + template <bool IsMutable> + struct buffers_iterator_types_helper; + + template <> + struct buffers_iterator_types_helper<false> + { + typedef const_buffer buffer_type; + template <typename ByteType> + struct byte_type + { + typedef typename boost::add_const<ByteType>::type type; + }; + }; + + template <> + struct buffers_iterator_types_helper<true> + { + typedef mutable_buffer buffer_type; + template <typename ByteType> + struct byte_type + { + typedef ByteType type; + }; + }; + + template <typename BufferSequence, typename ByteType> + struct buffers_iterator_types + { + enum + { + is_mutable = boost::is_convertible< + typename BufferSequence::value_type, mutable_buffer>::value + }; + typedef buffers_iterator_types_helper<is_mutable> helper; + typedef typename helper::buffer_type buffer_type; + typedef typename helper::template byte_type<ByteType>::type byte_type; + }; +} + +/// A random access iterator over the bytes in a buffer sequence. +template <typename BufferSequence, typename ByteType = char> +class buffers_iterator + : public boost::iterator< + std::random_access_iterator_tag, + typename detail::buffers_iterator_types< + BufferSequence, ByteType>::byte_type> +{ +private: + typedef typename detail::buffers_iterator_types< + BufferSequence, ByteType>::buffer_type buffer_type; + typedef typename detail::buffers_iterator_types< + BufferSequence, ByteType>::byte_type byte_type; + +public: + /// Default constructor. Creates an iterator in an undefined state. + buffers_iterator() + : current_buffer_(), + current_buffer_position_(0), + begin_(), + current_(), + end_(), + position_(0) + { + } + + /// Construct an iterator representing the beginning of the buffers' data. + static buffers_iterator begin(const BufferSequence& buffers) +#if BOOST_WORKAROUND(__GNUC__, == 4) && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) + __attribute__ ((noinline)) +#endif + { + buffers_iterator new_iter; + new_iter.begin_ = buffers.begin(); + new_iter.current_ = buffers.begin(); + new_iter.end_ = buffers.end(); + while (new_iter.current_ != new_iter.end_) + { + new_iter.current_buffer_ = *new_iter.current_; + if (boost::asio::buffer_size(new_iter.current_buffer_) > 0) + break; + ++new_iter.current_; + } + return new_iter; + } + + /// Construct an iterator representing the end of the buffers' data. + static buffers_iterator end(const BufferSequence& buffers) +#if BOOST_WORKAROUND(__GNUC__, == 4) && BOOST_WORKAROUND(__GNUC_MINOR__, == 3) + __attribute__ ((noinline)) +#endif + { + buffers_iterator new_iter; + new_iter.begin_ = buffers.begin(); + new_iter.current_ = buffers.begin(); + new_iter.end_ = buffers.end(); + while (new_iter.current_ != new_iter.end_) + { + buffer_type buffer = *new_iter.current_; + new_iter.position_ += boost::asio::buffer_size(buffer); + ++new_iter.current_; + } + return new_iter; + } + + /// Dereference an iterator. + byte_type& operator*() const + { + return dereference(); + } + + /// Dereference an iterator. + byte_type* operator->() const + { + return &dereference(); + } + + /// Access an individual element. + byte_type& operator[](std::ptrdiff_t difference) const + { + buffers_iterator tmp(*this); + tmp.advance(difference); + return *tmp; + } + + /// Increment operator (prefix). + buffers_iterator& operator++() + { + increment(); + return *this; + } + + /// Increment operator (postfix). + buffers_iterator operator++(int) + { + buffers_iterator tmp(*this); + ++*this; + return tmp; + } + + /// Decrement operator (prefix). + buffers_iterator& operator--() + { + decrement(); + return *this; + } + + /// Decrement operator (postfix). + buffers_iterator operator--(int) + { + buffers_iterator tmp(*this); + --*this; + return tmp; + } + + /// Addition operator. + buffers_iterator& operator+=(std::ptrdiff_t difference) + { + advance(difference); + return *this; + } + + /// Subtraction operator. + buffers_iterator& operator-=(std::ptrdiff_t difference) + { + advance(-difference); + return *this; + } + + /// Addition operator. + friend buffers_iterator operator+(const buffers_iterator& iter, + std::ptrdiff_t difference) + { + buffers_iterator tmp(iter); + tmp.advance(difference); + return tmp; + } + + /// Addition operator. + friend buffers_iterator operator+(std::ptrdiff_t difference, + const buffers_iterator& iter) + { + buffers_iterator tmp(iter); + tmp.advance(difference); + return tmp; + } + + /// Subtraction operator. + friend buffers_iterator operator-(const buffers_iterator& iter, + std::ptrdiff_t difference) + { + buffers_iterator tmp(iter); + tmp.advance(-difference); + return tmp; + } + + /// Subtraction operator. + friend std::ptrdiff_t operator-(const buffers_iterator& a, + const buffers_iterator& b) + { + return b.distance_to(a); + } + + /// Test two iterators for equality. + friend bool operator==(const buffers_iterator& a, const buffers_iterator& b) + { + return a.equal(b); + } + + /// Test two iterators for inequality. + friend bool operator!=(const buffers_iterator& a, const buffers_iterator& b) + { + return !a.equal(b); + } + + /// Compare two iterators. + friend bool operator<(const buffers_iterator& a, const buffers_iterator& b) + { + return a.distance_to(b) > 0; + } + + /// Compare two iterators. + friend bool operator<=(const buffers_iterator& a, const buffers_iterator& b) + { + return !(b < a); + } + + /// Compare two iterators. + friend bool operator>(const buffers_iterator& a, const buffers_iterator& b) + { + return b < a; + } + + /// Compare two iterators. + friend bool operator>=(const buffers_iterator& a, const buffers_iterator& b) + { + return !(a < b); + } + +private: + // Dereference the iterator. + byte_type& dereference() const + { + return buffer_cast<byte_type*>(current_buffer_)[current_buffer_position_]; + } + + // Compare two iterators for equality. + bool equal(const buffers_iterator& other) const + { + return position_ == other.position_; + } + + // Increment the iterator. + void increment() + { + BOOST_ASSERT(current_ != end_ && "iterator out of bounds"); + ++position_; + + // Check if the increment can be satisfied by the current buffer. + ++current_buffer_position_; + if (current_buffer_position_ != boost::asio::buffer_size(current_buffer_)) + return; + + // Find the next non-empty buffer. + ++current_; + current_buffer_position_ = 0; + while (current_ != end_) + { + current_buffer_ = *current_; + if (boost::asio::buffer_size(current_buffer_) > 0) + return; + ++current_; + } + } + + // Decrement the iterator. + void decrement() + { + BOOST_ASSERT(position_ > 0 && "iterator out of bounds"); + --position_; + + // Check if the decrement can be satisfied by the current buffer. + if (current_buffer_position_ != 0) + { + --current_buffer_position_; + return; + } + + // Find the previous non-empty buffer. + typename BufferSequence::const_iterator iter = current_; + while (iter != begin_) + { + --iter; + buffer_type buffer = *iter; + std::size_t buffer_size = boost::asio::buffer_size(buffer); + if (buffer_size > 0) + { + current_ = iter; + current_buffer_ = buffer; + current_buffer_position_ = buffer_size - 1; + return; + } + } + } + + // Advance the iterator by the specified distance. + void advance(std::ptrdiff_t n) + { + if (n > 0) + { + BOOST_ASSERT(current_ != end_ && "iterator out of bounds"); + for (;;) + { + std::ptrdiff_t current_buffer_balance + = boost::asio::buffer_size(current_buffer_) + - current_buffer_position_; + + // Check if the advance can be satisfied by the current buffer. + if (current_buffer_balance > n) + { + position_ += n; + current_buffer_position_ += n; + return; + } + + // Update position. + n -= current_buffer_balance; + position_ += current_buffer_balance; + + // Move to next buffer. If it is empty then it will be skipped on the + // next iteration of this loop. + if (++current_ == end_) + { + BOOST_ASSERT(n == 0 && "iterator out of bounds"); + current_buffer_ = buffer_type(); + current_buffer_position_ = 0; + return; + } + current_buffer_ = *current_; + current_buffer_position_ = 0; + } + } + else if (n < 0) + { + std::size_t abs_n = -n; + BOOST_ASSERT(position_ >= abs_n && "iterator out of bounds"); + for (;;) + { + // Check if the advance can be satisfied by the current buffer. + if (current_buffer_position_ >= abs_n) + { + position_ -= abs_n; + current_buffer_position_ -= abs_n; + return; + } + + // Update position. + abs_n -= current_buffer_position_; + position_ -= current_buffer_position_; + + // Check if we've reached the beginning of the buffers. + if (current_ == begin_) + { + BOOST_ASSERT(abs_n == 0 && "iterator out of bounds"); + current_buffer_position_ = 0; + return; + } + + // Find the previous non-empty buffer. + typename BufferSequence::const_iterator iter = current_; + while (iter != begin_) + { + --iter; + buffer_type buffer = *iter; + std::size_t buffer_size = boost::asio::buffer_size(buffer); + if (buffer_size > 0) + { + current_ = iter; + current_buffer_ = buffer; + current_buffer_position_ = buffer_size; + break; + } + } + } + } + } + + // Determine the distance between two iterators. + std::ptrdiff_t distance_to(const buffers_iterator& other) const + { + return other.position_ - position_; + } + + buffer_type current_buffer_; + std::size_t current_buffer_position_; + typename BufferSequence::const_iterator begin_; + typename BufferSequence::const_iterator current_; + typename BufferSequence::const_iterator end_; + std::size_t position_; +}; + +/// Construct an iterator representing the beginning of the buffers' data. +template <typename BufferSequence> +inline buffers_iterator<BufferSequence> buffers_begin( + const BufferSequence& buffers) +{ + return buffers_iterator<BufferSequence>::begin(buffers); +} + +/// Construct an iterator representing the end of the buffers' data. +template <typename BufferSequence> +inline buffers_iterator<BufferSequence> buffers_end( + const BufferSequence& buffers) +{ + return buffers_iterator<BufferSequence>::end(buffers); +} + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_BUFFERS_ITERATOR_HPP
diff --git a/boost_1_45_0/boost/asio/completion_condition.hpp b/boost_1_45_0/boost/asio/completion_condition.hpp new file mode 100644 index 0000000..dfb48ed --- /dev/null +++ b/boost_1_45_0/boost/asio/completion_condition.hpp
@@ -0,0 +1,164 @@ +// +// completion_condition.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_COMPLETION_CONDITION_HPP +#define BOOST_ASIO_COMPLETION_CONDITION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +namespace detail { + +// The default maximum number of bytes to transfer in a single operation. +enum { default_max_transfer_size = 65536 }; + +// Adapt result of old-style completion conditions (which had a bool result +// where true indicated that the operation was complete). +inline std::size_t adapt_completion_condition_result(bool result) +{ + return result ? 0 : default_max_transfer_size; +} + +// Adapt result of current completion conditions (which have a size_t result +// where 0 means the operation is complete, and otherwise the result is the +// maximum number of bytes to transfer on the next underlying operation). +inline std::size_t adapt_completion_condition_result(std::size_t result) +{ + return result; +} + +class transfer_all_t +{ +public: + typedef std::size_t result_type; + + template <typename Error> + std::size_t operator()(const Error& err, std::size_t) + { + return !!err ? 0 : default_max_transfer_size; + } +}; + +class transfer_at_least_t +{ +public: + typedef std::size_t result_type; + + explicit transfer_at_least_t(std::size_t minimum) + : minimum_(minimum) + { + } + + template <typename Error> + std::size_t operator()(const Error& err, std::size_t bytes_transferred) + { + return (!!err || bytes_transferred >= minimum_) + ? 0 : default_max_transfer_size; + } + +private: + std::size_t minimum_; +}; + +} // namespace detail + +/** + * @defgroup completion_condition Completion Condition Function Objects + * + * Function objects used for determining when a read or write operation should + * complete. + */ +/*@{*/ + +/// Return a completion condition function object that indicates that a read or +/// write operation should continue until all of the data has been transferred, +/// or until an error occurs. +/** + * This function is used to create an object, of unspecified type, that meets + * CompletionCondition requirements. + * + * @par Example + * Reading until a buffer is full: + * @code + * boost::array<char, 128> buf; + * boost::system::error_code ec; + * std::size_t n = boost::asio::read( + * sock, boost::asio::buffer(buf), + * boost::asio::transfer_all(), ec); + * if (ec) + * { + * // An error occurred. + * } + * else + * { + * // n == 128 + * } + * @endcode + */ +#if defined(GENERATING_DOCUMENTATION) +unspecified transfer_all(); +#else +inline detail::transfer_all_t transfer_all() +{ + return detail::transfer_all_t(); +} +#endif + +/// Return a completion condition function object that indicates that a read or +/// write operation should continue until a minimum number of bytes has been +/// transferred, or until an error occurs. +/** + * This function is used to create an object, of unspecified type, that meets + * CompletionCondition requirements. + * + * @par Example + * Reading until a buffer is full or contains at least 64 bytes: + * @code + * boost::array<char, 128> buf; + * boost::system::error_code ec; + * std::size_t n = boost::asio::read( + * sock, boost::asio::buffer(buf), + * boost::asio::transfer_at_least(64), ec); + * if (ec) + * { + * // An error occurred. + * } + * else + * { + * // n >= 64 && n <= 128 + * } + * @endcode + */ +#if defined(GENERATING_DOCUMENTATION) +unspecified transfer_at_least(std::size_t minimum); +#else +inline detail::transfer_at_least_t transfer_at_least(std::size_t minimum) +{ + return detail::transfer_at_least_t(minimum); +} +#endif + +/*@}*/ + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_COMPLETION_CONDITION_HPP
diff --git a/boost_1_45_0/boost/asio/datagram_socket_service.hpp b/boost_1_45_0/boost/asio/datagram_socket_service.hpp new file mode 100644 index 0000000..4d324e2 --- /dev/null +++ b/boost_1_45_0/boost/asio/datagram_socket_service.hpp
@@ -0,0 +1,313 @@ +// +// datagram_socket_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DATAGRAM_SOCKET_SERVICE_HPP +#define BOOST_ASIO_DATAGRAM_SOCKET_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/win_iocp_socket_service.hpp> +#else +# include <boost/asio/detail/reactive_socket_service.hpp> +#endif + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Default service implementation for a datagram socket. +template <typename Protocol> +class datagram_socket_service +#if defined(GENERATING_DOCUMENTATION) + : public boost::asio::io_service::service +#else + : public boost::asio::detail::service_base<datagram_socket_service<Protocol> > +#endif +{ +public: +#if defined(GENERATING_DOCUMENTATION) + /// The unique service identifier. + static boost::asio::io_service::id id; +#endif + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + +private: + // The type of the platform-specific implementation. +#if defined(BOOST_ASIO_HAS_IOCP) + typedef detail::win_iocp_socket_service<Protocol> service_impl_type; +#else + typedef detail::reactive_socket_service<Protocol> service_impl_type; +#endif + +public: + /// The type of a datagram socket. +#if defined(GENERATING_DOCUMENTATION) + typedef implementation_defined implementation_type; +#else + typedef typename service_impl_type::implementation_type implementation_type; +#endif + + /// The native socket type. +#if defined(GENERATING_DOCUMENTATION) + typedef implementation_defined native_type; +#else + typedef typename service_impl_type::native_type native_type; +#endif + + /// Construct a new datagram socket service for the specified io_service. + explicit datagram_socket_service(boost::asio::io_service& io_service) + : boost::asio::detail::service_base< + datagram_socket_service<Protocol> >(io_service), + service_impl_(io_service) + { + } + + /// Destroy all user-defined handler objects owned by the service. + void shutdown_service() + { + service_impl_.shutdown_service(); + } + + /// Construct a new datagram socket implementation. + void construct(implementation_type& impl) + { + service_impl_.construct(impl); + } + + /// Destroy a datagram socket implementation. + void destroy(implementation_type& impl) + { + service_impl_.destroy(impl); + } + + // Open a new datagram socket implementation. + boost::system::error_code open(implementation_type& impl, + const protocol_type& protocol, boost::system::error_code& ec) + { + if (protocol.type() == SOCK_DGRAM) + service_impl_.open(impl, protocol, ec); + else + ec = boost::asio::error::invalid_argument; + return ec; + } + + /// Assign an existing native socket to a datagram socket. + boost::system::error_code assign(implementation_type& impl, + const protocol_type& protocol, const native_type& native_socket, + boost::system::error_code& ec) + { + return service_impl_.assign(impl, protocol, native_socket, ec); + } + + /// Determine whether the socket is open. + bool is_open(const implementation_type& impl) const + { + return service_impl_.is_open(impl); + } + + /// Close a datagram socket implementation. + boost::system::error_code close(implementation_type& impl, + boost::system::error_code& ec) + { + return service_impl_.close(impl, ec); + } + + /// Get the native socket implementation. + native_type native(implementation_type& impl) + { + return service_impl_.native(impl); + } + + /// Cancel all asynchronous operations associated with the socket. + boost::system::error_code cancel(implementation_type& impl, + boost::system::error_code& ec) + { + return service_impl_.cancel(impl, ec); + } + + /// Determine whether the socket is at the out-of-band data mark. + bool at_mark(const implementation_type& impl, + boost::system::error_code& ec) const + { + return service_impl_.at_mark(impl, ec); + } + + /// Determine the number of bytes available for reading. + std::size_t available(const implementation_type& impl, + boost::system::error_code& ec) const + { + return service_impl_.available(impl, ec); + } + + // Bind the datagram socket to the specified local endpoint. + boost::system::error_code bind(implementation_type& impl, + const endpoint_type& endpoint, boost::system::error_code& ec) + { + return service_impl_.bind(impl, endpoint, ec); + } + + /// Connect the datagram socket to the specified endpoint. + boost::system::error_code connect(implementation_type& impl, + const endpoint_type& peer_endpoint, boost::system::error_code& ec) + { + return service_impl_.connect(impl, peer_endpoint, ec); + } + + /// Start an asynchronous connect. + template <typename ConnectHandler> + void async_connect(implementation_type& impl, + const endpoint_type& peer_endpoint, ConnectHandler handler) + { + service_impl_.async_connect(impl, peer_endpoint, handler); + } + + /// Set a socket option. + template <typename SettableSocketOption> + boost::system::error_code set_option(implementation_type& impl, + const SettableSocketOption& option, boost::system::error_code& ec) + { + return service_impl_.set_option(impl, option, ec); + } + + /// Get a socket option. + template <typename GettableSocketOption> + boost::system::error_code get_option(const implementation_type& impl, + GettableSocketOption& option, boost::system::error_code& ec) const + { + return service_impl_.get_option(impl, option, ec); + } + + /// Perform an IO control command on the socket. + template <typename IoControlCommand> + boost::system::error_code io_control(implementation_type& impl, + IoControlCommand& command, boost::system::error_code& ec) + { + return service_impl_.io_control(impl, command, ec); + } + + /// Get the local endpoint. + endpoint_type local_endpoint(const implementation_type& impl, + boost::system::error_code& ec) const + { + return service_impl_.local_endpoint(impl, ec); + } + + /// Get the remote endpoint. + endpoint_type remote_endpoint(const implementation_type& impl, + boost::system::error_code& ec) const + { + return service_impl_.remote_endpoint(impl, ec); + } + + /// Disable sends or receives on the socket. + boost::system::error_code shutdown(implementation_type& impl, + socket_base::shutdown_type what, boost::system::error_code& ec) + { + return service_impl_.shutdown(impl, what, ec); + } + + /// Send the given data to the peer. + template <typename ConstBufferSequence> + std::size_t send(implementation_type& impl, + const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return service_impl_.send(impl, buffers, flags, ec); + } + + /// Start an asynchronous send. + template <typename ConstBufferSequence, typename WriteHandler> + void async_send(implementation_type& impl, const ConstBufferSequence& buffers, + socket_base::message_flags flags, WriteHandler handler) + { + service_impl_.async_send(impl, buffers, flags, handler); + } + + /// Send a datagram to the specified endpoint. + template <typename ConstBufferSequence> + std::size_t send_to(implementation_type& impl, + const ConstBufferSequence& buffers, const endpoint_type& destination, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return service_impl_.send_to(impl, buffers, destination, flags, ec); + } + + /// Start an asynchronous send. + template <typename ConstBufferSequence, typename WriteHandler> + void async_send_to(implementation_type& impl, + const ConstBufferSequence& buffers, const endpoint_type& destination, + socket_base::message_flags flags, WriteHandler handler) + { + service_impl_.async_send_to(impl, buffers, destination, flags, handler); + } + + /// Receive some data from the peer. + template <typename MutableBufferSequence> + std::size_t receive(implementation_type& impl, + const MutableBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return service_impl_.receive(impl, buffers, flags, ec); + } + + /// Start an asynchronous receive. + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive(implementation_type& impl, + const MutableBufferSequence& buffers, + socket_base::message_flags flags, ReadHandler handler) + { + service_impl_.async_receive(impl, buffers, flags, handler); + } + + /// Receive a datagram with the endpoint of the sender. + template <typename MutableBufferSequence> + std::size_t receive_from(implementation_type& impl, + const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return service_impl_.receive_from(impl, buffers, sender_endpoint, flags, + ec); + } + + /// Start an asynchronous receive that will get the endpoint of the sender. + template <typename MutableBufferSequence, typename ReadHandler> + void async_receive_from(implementation_type& impl, + const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, + socket_base::message_flags flags, ReadHandler handler) + { + service_impl_.async_receive_from(impl, buffers, sender_endpoint, flags, + handler); + } + +private: + // The platform-specific implementation. + service_impl_type service_impl_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DATAGRAM_SOCKET_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/deadline_timer.hpp b/boost_1_45_0/boost/asio/deadline_timer.hpp new file mode 100644 index 0000000..3ed7b67 --- /dev/null +++ b/boost_1_45_0/boost/asio/deadline_timer.hpp
@@ -0,0 +1,35 @@ +// +// deadline_timer.hpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DEADLINE_TIMER_HPP +#define BOOST_ASIO_DEADLINE_TIMER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/socket_types.hpp> // Must come before posix_time. +#include <boost/asio/basic_deadline_timer.hpp> + +#include <boost/asio/detail/push_options.hpp> +#include <boost/date_time/posix_time/posix_time_types.hpp> +#include <boost/asio/detail/pop_options.hpp> + +namespace boost { +namespace asio { + +/// Typedef for the typical usage of timer. Uses a UTC clock. +typedef basic_deadline_timer<boost::posix_time::ptime> deadline_timer; + +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DEADLINE_TIMER_HPP
diff --git a/boost_1_45_0/boost/asio/deadline_timer_service.hpp b/boost_1_45_0/boost/asio/deadline_timer_service.hpp new file mode 100644 index 0000000..77060c4 --- /dev/null +++ b/boost_1_45_0/boost/asio/deadline_timer_service.hpp
@@ -0,0 +1,148 @@ +// +// deadline_timer_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DEADLINE_TIMER_SERVICE_HPP +#define BOOST_ASIO_DEADLINE_TIMER_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/detail/deadline_timer_service.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/time_traits.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { + +/// Default service implementation for a timer. +template <typename TimeType, + typename TimeTraits = boost::asio::time_traits<TimeType> > +class deadline_timer_service +#if defined(GENERATING_DOCUMENTATION) + : public boost::asio::io_service::service +#else + : public boost::asio::detail::service_base< + deadline_timer_service<TimeType, TimeTraits> > +#endif +{ +public: +#if defined(GENERATING_DOCUMENTATION) + /// The unique service identifier. + static boost::asio::io_service::id id; +#endif + + /// The time traits type. + typedef TimeTraits traits_type; + + /// The time type. + typedef typename traits_type::time_type time_type; + + /// The duration type. + typedef typename traits_type::duration_type duration_type; + +private: + // The type of the platform-specific implementation. + typedef detail::deadline_timer_service<traits_type> service_impl_type; + +public: + /// The implementation type of the deadline timer. +#if defined(GENERATING_DOCUMENTATION) + typedef implementation_defined implementation_type; +#else + typedef typename service_impl_type::implementation_type implementation_type; +#endif + + /// Construct a new timer service for the specified io_service. + explicit deadline_timer_service(boost::asio::io_service& io_service) + : boost::asio::detail::service_base< + deadline_timer_service<TimeType, TimeTraits> >(io_service), + service_impl_(io_service) + { + } + + /// Destroy all user-defined handler objects owned by the service. + void shutdown_service() + { + service_impl_.shutdown_service(); + } + + /// Construct a new timer implementation. + void construct(implementation_type& impl) + { + service_impl_.construct(impl); + } + + /// Destroy a timer implementation. + void destroy(implementation_type& impl) + { + service_impl_.destroy(impl); + } + + /// Cancel any asynchronous wait operations associated with the timer. + std::size_t cancel(implementation_type& impl, boost::system::error_code& ec) + { + return service_impl_.cancel(impl, ec); + } + + /// Get the expiry time for the timer as an absolute time. + time_type expires_at(const implementation_type& impl) const + { + return service_impl_.expires_at(impl); + } + + /// Set the expiry time for the timer as an absolute time. + std::size_t expires_at(implementation_type& impl, + const time_type& expiry_time, boost::system::error_code& ec) + { + return service_impl_.expires_at(impl, expiry_time, ec); + } + + /// Get the expiry time for the timer relative to now. + duration_type expires_from_now(const implementation_type& impl) const + { + return service_impl_.expires_from_now(impl); + } + + /// Set the expiry time for the timer relative to now. + std::size_t expires_from_now(implementation_type& impl, + const duration_type& expiry_time, boost::system::error_code& ec) + { + return service_impl_.expires_from_now(impl, expiry_time, ec); + } + + // Perform a blocking wait on the timer. + void wait(implementation_type& impl, boost::system::error_code& ec) + { + service_impl_.wait(impl, ec); + } + + // Start an asynchronous wait on the timer. + template <typename WaitHandler> + void async_wait(implementation_type& impl, WaitHandler handler) + { + service_impl_.async_wait(impl, handler); + } + +private: + // The platform-specific implementation. + service_impl_type service_impl_; +}; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DEADLINE_TIMER_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/array_fwd.hpp b/boost_1_45_0/boost/asio/detail/array_fwd.hpp new file mode 100644 index 0000000..3d47a9a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/array_fwd.hpp
@@ -0,0 +1,25 @@ +// +// detail/array_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_ARRAY_FWD_HPP +#define BOOST_ASIO_DETAIL_ARRAY_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { + +template<class T, std::size_t N> +class array; + +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_ARRAY_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/base_from_completion_cond.hpp b/boost_1_45_0/boost/asio/detail/base_from_completion_cond.hpp new file mode 100644 index 0000000..797e3ce --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/base_from_completion_cond.hpp
@@ -0,0 +1,70 @@ +// +// detail/base_from_completion_cond.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP +#define BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/completion_condition.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename CompletionCondition> +class base_from_completion_cond +{ +protected: + explicit base_from_completion_cond(CompletionCondition completion_condition) + : completion_condition_(completion_condition) + { + } + + std::size_t check_for_completion( + const boost::system::error_code& ec, + std::size_t total_transferred) + { + return detail::adapt_completion_condition_result( + completion_condition_(ec, total_transferred)); + } + +private: + CompletionCondition completion_condition_; +}; + +template <> +class base_from_completion_cond<transfer_all_t> +{ +protected: + explicit base_from_completion_cond(transfer_all_t) + { + } + + static std::size_t check_for_completion( + const boost::system::error_code& ec, + std::size_t total_transferred) + { + return transfer_all_t()(ec, total_transferred); + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
diff --git a/boost_1_45_0/boost/asio/detail/bind_handler.hpp b/boost_1_45_0/boost/asio/detail/bind_handler.hpp new file mode 100644 index 0000000..6b515db --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/bind_handler.hpp
@@ -0,0 +1,362 @@ +// +// detail/bind_handler.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_BIND_HANDLER_HPP +#define BOOST_ASIO_DETAIL_BIND_HANDLER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler, typename Arg1> +class binder1 +{ +public: + binder1(const Handler& handler, const Arg1& arg1) + : handler_(handler), + arg1_(arg1) + { + } + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_)); + } + + void operator()() const + { + handler_(arg1_); + } + +//private: + Handler handler_; + Arg1 arg1_; +}; + +template <typename Handler, typename Arg1> +inline void* asio_handler_allocate(std::size_t size, + binder1<Handler, Arg1>* this_handler) +{ + return boost_asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder1<Handler, Arg1>* this_handler) +{ + boost_asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1> +inline void asio_handler_invoke(const Function& function, + binder1<Handler, Arg1>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1> +inline binder1<Handler, Arg1> bind_handler(const Handler& handler, + const Arg1& arg1) +{ + return binder1<Handler, Arg1>(handler, arg1); +} + +template <typename Handler, typename Arg1, typename Arg2> +class binder2 +{ +public: + binder2(const Handler& handler, const Arg1& arg1, const Arg2& arg2) + : handler_(handler), + arg1_(arg1), + arg2_(arg2) + { + } + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_)); + } + + void operator()() const + { + handler_(arg1_, arg2_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; +}; + +template <typename Handler, typename Arg1, typename Arg2> +inline void* asio_handler_allocate(std::size_t size, + binder2<Handler, Arg1, Arg2>* this_handler) +{ + return boost_asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder2<Handler, Arg1, Arg2>* this_handler) +{ + boost_asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, typename Arg2> +inline void asio_handler_invoke(const Function& function, + binder2<Handler, Arg1, Arg2>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2> +inline binder2<Handler, Arg1, Arg2> bind_handler(const Handler& handler, + const Arg1& arg1, const Arg2& arg2) +{ + return binder2<Handler, Arg1, Arg2>(handler, arg1, arg2); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +class binder3 +{ +public: + binder3(const Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3) + : handler_(handler), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3) + { + } + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), + static_cast<const Arg3&>(arg3_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; +}; + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline void* asio_handler_allocate(std::size_t size, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + return boost_asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + boost_asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, typename Arg2, + typename Arg3> +inline void asio_handler_invoke(const Function& function, + binder3<Handler, Arg1, Arg2, Arg3>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3> +inline binder3<Handler, Arg1, Arg2, Arg3> bind_handler(const Handler& handler, + const Arg1& arg1, const Arg2& arg2, const Arg3& arg3) +{ + return binder3<Handler, Arg1, Arg2, Arg3>(handler, arg1, arg2, arg3); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4> +class binder4 +{ +public: + binder4(const Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4) + : handler_(handler), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4) + { + } + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), + static_cast<const Arg3&>(arg3_), + static_cast<const Arg4&>(arg4_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_, arg4_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; + Arg4 arg4_; +}; + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4> +inline void* asio_handler_allocate(std::size_t size, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + return boost_asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + boost_asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4> +inline void asio_handler_invoke(const Function& function, + binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4> +inline binder4<Handler, Arg1, Arg2, Arg3, Arg4> bind_handler( + const Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4) +{ + return binder4<Handler, Arg1, Arg2, Arg3, Arg4>(handler, arg1, arg2, arg3, + arg4); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4, typename Arg5> +class binder5 +{ +public: + binder5(const Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) + : handler_(handler), + arg1_(arg1), + arg2_(arg2), + arg3_(arg3), + arg4_(arg4), + arg5_(arg5) + { + } + + void operator()() + { + handler_(static_cast<const Arg1&>(arg1_), + static_cast<const Arg2&>(arg2_), + static_cast<const Arg3&>(arg3_), + static_cast<const Arg4&>(arg4_), + static_cast<const Arg5&>(arg5_)); + } + + void operator()() const + { + handler_(arg1_, arg2_, arg3_, arg4_, arg5_); + } + +//private: + Handler handler_; + Arg1 arg1_; + Arg2 arg2_; + Arg3 arg3_; + Arg4 arg4_; + Arg5 arg5_; +}; + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4, typename Arg5> +inline void* asio_handler_allocate(std::size_t size, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + return boost_asio_handler_alloc_helpers::allocate( + size, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4, typename Arg5> +inline void asio_handler_deallocate(void* pointer, std::size_t size, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + boost_asio_handler_alloc_helpers::deallocate( + pointer, size, this_handler->handler_); +} + +template <typename Function, typename Handler, typename Arg1, typename Arg2, + typename Arg3, typename Arg4, typename Arg5> +inline void asio_handler_invoke(const Function& function, + binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler) +{ + boost_asio_handler_invoke_helpers::invoke( + function, this_handler->handler_); +} + +template <typename Handler, typename Arg1, typename Arg2, typename Arg3, + typename Arg4, typename Arg5> +inline binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5> bind_handler( + const Handler& handler, const Arg1& arg1, const Arg2& arg2, + const Arg3& arg3, const Arg4& arg4, const Arg5& arg5) +{ + return binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>(handler, arg1, arg2, + arg3, arg4, arg5); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_BIND_HANDLER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/buffer_resize_guard.hpp b/boost_1_45_0/boost/asio/detail/buffer_resize_guard.hpp new file mode 100644 index 0000000..bcffc1a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/buffer_resize_guard.hpp
@@ -0,0 +1,70 @@ +// +// detail/buffer_resize_guard.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP +#define BOOST_ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/limits.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Helper class to manage buffer resizing in an exception safe way. +template <typename Buffer> +class buffer_resize_guard +{ +public: + // Constructor. + buffer_resize_guard(Buffer& buffer) + : buffer_(buffer), + old_size_(buffer.size()) + { + } + + // Destructor rolls back the buffer resize unless commit was called. + ~buffer_resize_guard() + { + if (old_size_ + != std::numeric_limits<size_t>::max BOOST_PREVENT_MACRO_SUBSTITUTION()) + { + buffer_.resize(old_size_); + } + } + + // Commit the resize transaction. + void commit() + { + old_size_ + = std::numeric_limits<size_t>::max BOOST_PREVENT_MACRO_SUBSTITUTION(); + } + +private: + // The buffer being managed. + Buffer& buffer_; + + // The size of the buffer at the time the guard was constructed. + size_t old_size_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/buffer_sequence_adapter.hpp b/boost_1_45_0/boost/asio/detail/buffer_sequence_adapter.hpp new file mode 100644 index 0000000..214cd41 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/buffer_sequence_adapter.hpp
@@ -0,0 +1,256 @@ +// +// detail/buffer_sequence_adapter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_BUFFER_SEQUENCE_ADAPTER_HPP +#define BOOST_ASIO_DETAIL_BUFFER_SEQUENCE_ADAPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class buffer_sequence_adapter_base +{ +protected: +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + typedef WSABUF native_buffer_type; + + static void init_native_buffer(WSABUF& buf, + const boost::asio::mutable_buffer& buffer) + { + buf.buf = boost::asio::buffer_cast<char*>(buffer); + buf.len = static_cast<ULONG>(boost::asio::buffer_size(buffer)); + } + + static void init_native_buffer(WSABUF& buf, + const boost::asio::const_buffer& buffer) + { + buf.buf = const_cast<char*>(boost::asio::buffer_cast<const char*>(buffer)); + buf.len = static_cast<ULONG>(boost::asio::buffer_size(buffer)); + } +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + typedef iovec native_buffer_type; + + static void init_iov_base(void*& base, void* addr) + { + base = addr; + } + + template <typename T> + static void init_iov_base(T& base, void* addr) + { + base = static_cast<T>(addr); + } + + static void init_native_buffer(iovec& iov, + const boost::asio::mutable_buffer& buffer) + { + init_iov_base(iov.iov_base, boost::asio::buffer_cast<void*>(buffer)); + iov.iov_len = boost::asio::buffer_size(buffer); + } + + static void init_native_buffer(iovec& iov, + const boost::asio::const_buffer& buffer) + { + init_iov_base(iov.iov_base, const_cast<void*>( + boost::asio::buffer_cast<const void*>(buffer))); + iov.iov_len = boost::asio::buffer_size(buffer); + } +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +}; + +// Helper class to translate buffers into the native buffer representation. +template <typename Buffer, typename Buffers> +class buffer_sequence_adapter + : buffer_sequence_adapter_base +{ +public: + explicit buffer_sequence_adapter(const Buffers& buffers) + : count_(0), total_buffer_size_(0) + { + typename Buffers::const_iterator iter = buffers.begin(); + typename Buffers::const_iterator end = buffers.end(); + for (; iter != end && count_ < max_buffers; ++iter, ++count_) + { + Buffer buffer(*iter); + init_native_buffer(buffers_[count_], buffer); + total_buffer_size_ += boost::asio::buffer_size(buffer); + } + } + + native_buffer_type* buffers() + { + return buffers_; + } + + std::size_t count() const + { + return count_; + } + + bool all_empty() const + { + return total_buffer_size_ == 0; + } + + static bool all_empty(const Buffers& buffers) + { + typename Buffers::const_iterator iter = buffers.begin(); + typename Buffers::const_iterator end = buffers.end(); + std::size_t i = 0; + for (; iter != end && i < max_buffers; ++iter, ++i) + if (boost::asio::buffer_size(Buffer(*iter)) > 0) + return false; + return true; + } + + static void validate(const Buffers& buffers) + { + typename Buffers::const_iterator iter = buffers.begin(); + typename Buffers::const_iterator end = buffers.end(); + for (; iter != end; ++iter) + { + Buffer buffer(*iter); + boost::asio::buffer_cast<const void*>(buffer); + } + } + + static Buffer first(const Buffers& buffers) + { + typename Buffers::const_iterator iter = buffers.begin(); + typename Buffers::const_iterator end = buffers.end(); + for (; iter != end; ++iter) + { + Buffer buffer(*iter); + if (boost::asio::buffer_size(buffer) != 0) + return buffer; + } + return Buffer(); + } + +private: + // The maximum number of buffers to support in a single operation. + enum { max_buffers = 64 < max_iov_len ? 64 : max_iov_len }; + + native_buffer_type buffers_[max_buffers]; + std::size_t count_; + std::size_t total_buffer_size_; +}; + +template <typename Buffer> +class buffer_sequence_adapter<Buffer, boost::asio::mutable_buffers_1> + : buffer_sequence_adapter_base +{ +public: + explicit buffer_sequence_adapter( + const boost::asio::mutable_buffers_1& buffers) + { + init_native_buffer(buffer_, Buffer(buffers)); + total_buffer_size_ = boost::asio::buffer_size(buffers); + } + + native_buffer_type* buffers() + { + return &buffer_; + } + + std::size_t count() const + { + return 1; + } + + bool all_empty() const + { + return total_buffer_size_ == 0; + } + + static bool all_empty(const boost::asio::mutable_buffers_1& buffers) + { + return boost::asio::buffer_size(buffers) == 0; + } + + static void validate(const boost::asio::mutable_buffers_1& buffers) + { + boost::asio::buffer_cast<const void*>(buffers); + } + + static Buffer first(const boost::asio::mutable_buffers_1& buffers) + { + return Buffer(buffers); + } + +private: + native_buffer_type buffer_; + std::size_t total_buffer_size_; +}; + +template <typename Buffer> +class buffer_sequence_adapter<Buffer, boost::asio::const_buffers_1> + : buffer_sequence_adapter_base +{ +public: + explicit buffer_sequence_adapter( + const boost::asio::const_buffers_1& buffers) + { + init_native_buffer(buffer_, Buffer(buffers)); + total_buffer_size_ = boost::asio::buffer_size(buffers); + } + + native_buffer_type* buffers() + { + return &buffer_; + } + + std::size_t count() const + { + return 1; + } + + bool all_empty() const + { + return total_buffer_size_ == 0; + } + + static bool all_empty(const boost::asio::const_buffers_1& buffers) + { + return boost::asio::buffer_size(buffers) == 0; + } + + static void validate(const boost::asio::const_buffers_1& buffers) + { + boost::asio::buffer_cast<const void*>(buffers); + } + + static Buffer first(const boost::asio::const_buffers_1& buffers) + { + return Buffer(buffers); + } + +private: + native_buffer_type buffer_; + std::size_t total_buffer_size_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_BUFFER_SEQUENCE_ADAPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/buffered_stream_storage.hpp b/boost_1_45_0/boost/asio/detail/buffered_stream_storage.hpp new file mode 100644 index 0000000..9a2929e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/buffered_stream_storage.hpp
@@ -0,0 +1,127 @@ +// +// detail/buffered_stream_storage.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_BUFFERED_STREAM_STORAGE_HPP +#define BOOST_ASIO_DETAIL_BUFFERED_STREAM_STORAGE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cassert> +#include <cstddef> +#include <cstring> +#include <vector> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class buffered_stream_storage +{ +public: + // The type of the bytes stored in the buffer. + typedef unsigned char byte_type; + + // The type used for offsets into the buffer. + typedef std::size_t size_type; + + // Constructor. + explicit buffered_stream_storage(std::size_t capacity) + : begin_offset_(0), + end_offset_(0), + buffer_(capacity) + { + } + + /// Clear the buffer. + void clear() + { + begin_offset_ = 0; + end_offset_ = 0; + } + + // Return a pointer to the beginning of the unread data. + byte_type* data() + { + return &buffer_[0] + begin_offset_; + } + + // Return a pointer to the beginning of the unread data. + const byte_type* data() const + { + return &buffer_[0] + begin_offset_; + } + + // Is there no unread data in the buffer. + bool empty() const + { + return begin_offset_ == end_offset_; + } + + // Return the amount of unread data the is in the buffer. + size_type size() const + { + return end_offset_ - begin_offset_; + } + + // Resize the buffer to the specified length. + void resize(size_type length) + { + assert(length <= capacity()); + if (begin_offset_ + length <= capacity()) + { + end_offset_ = begin_offset_ + length; + } + else + { + using namespace std; // For memmove. + memmove(&buffer_[0], &buffer_[0] + begin_offset_, size()); + end_offset_ = length; + begin_offset_ = 0; + } + } + + // Return the maximum size for data in the buffer. + size_type capacity() const + { + return buffer_.size(); + } + + // Consume multiple bytes from the beginning of the buffer. + void consume(size_type count) + { + assert(begin_offset_ + count <= end_offset_); + begin_offset_ += count; + if (empty()) + clear(); + } + +private: + // The offset to the beginning of the unread data. + size_type begin_offset_; + + // The offset to the end of the unread data. + size_type end_offset_; + + // The data in the buffer. + std::vector<byte_type> buffer_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_BUFFERED_STREAM_STORAGE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/call_stack.hpp b/boost_1_45_0/boost/asio/detail/call_stack.hpp new file mode 100644 index 0000000..561a826 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/call_stack.hpp
@@ -0,0 +1,93 @@ +// +// detail/call_stack.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_CALL_STACK_HPP +#define BOOST_ASIO_DETAIL_CALL_STACK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/tss_ptr.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Helper class to determine whether or not the current thread is inside an +// invocation of io_service::run() for a specified io_service object. +template <typename Owner> +class call_stack +{ +public: + // Context class automatically pushes an owner on to the stack. + class context + : private noncopyable + { + public: + // Push the owner on to the stack. + explicit context(Owner* d) + : owner_(d), + next_(call_stack<Owner>::top_) + { + call_stack<Owner>::top_ = this; + } + + // Pop the owner from the stack. + ~context() + { + call_stack<Owner>::top_ = next_; + } + + private: + friend class call_stack<Owner>; + + // The owner associated with the context. + Owner* owner_; + + // The next element in the stack. + context* next_; + }; + + friend class context; + + // Determine whether the specified owner is on the stack. + static bool contains(Owner* d) + { + context* elem = top_; + while (elem) + { + if (elem->owner_ == d) + return true; + elem = elem->next_; + } + return false; + } + +private: + // The top of the stack of calls for the current thread. + static tss_ptr<context> top_; +}; + +template <typename Owner> +tss_ptr<typename call_stack<Owner>::context> +call_stack<Owner>::top_; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_CALL_STACK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/completion_handler.hpp b/boost_1_45_0/boost/asio/detail/completion_handler.hpp new file mode 100644 index 0000000..6701fb3 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/completion_handler.hpp
@@ -0,0 +1,77 @@ +// +// detail/completion_handler.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_COMPLETION_HANDLER_HPP +#define BOOST_ASIO_DETAIL_COMPLETION_HANDLER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +class completion_handler : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(completion_handler); + + completion_handler(Handler h) + : operation(&completion_handler::do_complete), + handler_(h) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + completion_handler* h(static_cast<completion_handler*>(base)); + ptr p = { boost::addressof(h->handler_), h, h }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + Handler handler(h->handler_); + p.h = boost::addressof(handler); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_COMPLETION_HANDLER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/config.hpp b/boost_1_45_0/boost/asio/detail/config.hpp new file mode 100644 index 0000000..abd2044 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/config.hpp
@@ -0,0 +1,205 @@ +// +// detail/config.hpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_CONFIG_HPP +#define BOOST_ASIO_DETAIL_CONFIG_HPP + +#include <boost/config.hpp> + +// Default to a header-only implementation. The user must specifically request +// separate compilation by defining either BOOST_ASIO_SEPARATE_COMPILATION or +// BOOST_ASIO_DYN_LINK (as a DLL/shared library implies separate compilation). +#if !defined(BOOST_ASIO_HEADER_ONLY) +# if !defined(BOOST_ASIO_SEPARATE_COMPILATION) +# if !defined(BOOST_ASIO_DYN_LINK) +# define BOOST_ASIO_HEADER_ONLY +# endif // !defined(BOOST_ASIO_DYN_LINK) +# endif // !defined(BOOST_ASIO_SEPARATE_COMPILATION) +#endif // !defined(BOOST_ASIO_HEADER_ONLY) + +#if defined(BOOST_ASIO_HEADER_ONLY) +# define BOOST_ASIO_DECL inline +#else // defined(BOOST_ASIO_HEADER_ONLY) +# if defined(BOOST_HAS_DECLSPEC) +// We need to import/export our code only if the user has specifically asked +// for it by defining BOOST_ASIO_DYN_LINK. +# if defined(BOOST_ASIO_DYN_LINK) +// Export if this is our own source, otherwise import. +# if defined(BOOST_ASIO_SOURCE) +# define BOOST_ASIO_DECL __declspec(dllexport) +# else // defined(BOOST_ASIO_SOURCE) +# define BOOST_ASIO_DECL __declspec(dllimport) +# endif // defined(BOOST_ASIO_SOURCE) +# endif // defined(BOOST_ASIO_DYN_LINK) +# endif // defined(BOOST_HAS_DECLSPEC) +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +// If BOOST_ASIO_DECL isn't defined yet define it now. +#if !defined(BOOST_ASIO_DECL) +# define BOOST_ASIO_DECL +#endif // !defined(BOOST_ASIO_DECL) + +// Windows: target OS version. +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS) +# if defined(_MSC_VER) || defined(__BORLANDC__) +# pragma message( \ + "Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:\n"\ + "- add -D_WIN32_WINNT=0x0501 to the compiler command line; or\n"\ + "- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions.\n"\ + "Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target).") +# else // defined(_MSC_VER) || defined(__BORLANDC__) +# warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. +# warning For example, add -D_WIN32_WINNT=0x0501 to the compiler command line. +# warning Assuming _WIN32_WINNT=0x0501 (i.e. Windows XP target). +# endif // defined(_MSC_VER) || defined(__BORLANDC__) +# define _WIN32_WINNT 0x0501 +# endif // !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS) +# if defined(_MSC_VER) +# if defined(_WIN32) && !defined(WIN32) +# if !defined(_WINSOCK2API_) +# define WIN32 // Needed for correct types in winsock2.h +# else // !defined(_WINSOCK2API_) +# error Please define the macro WIN32 in your compiler options +# endif // !defined(_WINSOCK2API_) +# endif // defined(_WIN32) && !defined(WIN32) +# endif // defined(_MSC_VER) +# if defined(__BORLANDC__) +# if defined(__WIN32__) && !defined(WIN32) +# if !defined(_WINSOCK2API_) +# define WIN32 // Needed for correct types in winsock2.h +# else // !defined(_WINSOCK2API_) +# error Please define the macro WIN32 in your compiler options +# endif // !defined(_WINSOCK2API_) +# endif // defined(__WIN32__) && !defined(WIN32) +# endif // defined(__BORLANDC__) +# if defined(__CYGWIN__) +# if !defined(__USE_W32_SOCKETS) +# error You must add -D__USE_W32_SOCKETS to your compiler options. +# endif // !defined(__USE_W32_SOCKETS) +# endif // defined(__CYGWIN__) +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Windows: minimise header inclusion. +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) +# if !defined(WIN32_LEAN_AND_MEAN) +# define WIN32_LEAN_AND_MEAN +# endif // !defined(WIN32_LEAN_AND_MEAN) +# endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Windows: suppress definition of "min" and "max" macros. +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if !defined(BOOST_ASIO_NO_NOMINMAX) +# if !defined(NOMINMAX) +# define NOMINMAX 1 +# endif // !defined(NOMINMAX) +# endif // !defined(BOOST_ASIO_NO_NOMINMAX) +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Windows: IO Completion Ports. +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) +# if !defined(UNDER_CE) +# if !defined(BOOST_ASIO_DISABLE_IOCP) +# define BOOST_ASIO_HAS_IOCP 1 +# endif // !defined(BOOST_ASIO_DISABLE_IOCP) +# endif // !defined(UNDER_CE) +# endif // defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0400) +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Linux: epoll, eventfd and timerfd. +#if defined(__linux__) +# include <linux/version.h> +# if !defined(BOOST_ASIO_DISABLE_EPOLL) +# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45) +# define BOOST_ASIO_HAS_EPOLL 1 +# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45) +# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD) +# if !defined(BOOST_ASIO_DISABLE_EVENTFD) +# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) +# define BOOST_ASIO_HAS_EVENTFD 1 +# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) +# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD) +# if defined(BOOST_ASIO_HAS_EPOLL) +# if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8) +# define BOOST_ASIO_HAS_TIMERFD 1 +# endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8) +# endif // defined(BOOST_ASIO_HAS_EPOLL) +#endif // defined(__linux__) + +// Mac OS X, FreeBSD, NetBSD, OpenBSD: kqueue. +#if (defined(__MACH__) && defined(__APPLE__)) \ + || defined(__FreeBSD__) \ + || defined(__NetBSD__) \ + || defined(__OpenBSD__) +# if !defined(BOOST_ASIO_DISABLE_KQUEUE) +# define BOOST_ASIO_HAS_KQUEUE 1 +# endif // !defined(BOOST_ASIO_DISABLE_KQUEUE) +#endif // (defined(__MACH__) && defined(__APPLE__)) + // || defined(__FreeBSD__) + // || defined(__NetBSD__) + // || defined(__OpenBSD__) + +// Solaris: /dev/poll. +#if defined(__sun) +# if !defined(BOOST_ASIO_DISABLE_DEV_POLL) +# define BOOST_ASIO_HAS_DEV_POLL 1 +# endif // !defined(BOOST_ASIO_DISABLE_DEV_POLL) +#endif // defined(__sun) + +// Serial ports. +#if defined(BOOST_ASIO_HAS_IOCP) \ + || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +# if !defined(__SYMBIAN32__) +# if !defined(BOOST_ASIO_DISABLE_SERIAL_PORT) +# define BOOST_ASIO_HAS_SERIAL_PORT 1 +# endif // !defined(BOOST_ASIO_DISABLE_SERIAL_PORT) +# endif // !defined(__SYMBIAN32__) +#endif // defined(BOOST_ASIO_HAS_IOCP) + // || !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +// Windows: stream handles. +#if !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE) +# if defined(BOOST_ASIO_HAS_IOCP) +# define BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE 1 +# endif // defined(BOOST_ASIO_HAS_IOCP) +#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_STREAM_HANDLE) + +// Windows: random access handles. +#if !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE) +# if defined(BOOST_ASIO_HAS_IOCP) +# define BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE 1 +# endif // defined(BOOST_ASIO_HAS_IOCP) +#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE) + +// Windows: OVERLAPPED wrapper. +#if !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR) +# if defined(BOOST_ASIO_HAS_IOCP) +# define BOOST_ASIO_HAS_WINDOWS_OVERLAPPED_PTR 1 +# endif // defined(BOOST_ASIO_HAS_IOCP) +#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR) + +// POSIX: stream-oriented file descriptors. +#if !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR) +# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +# define BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR 1 +# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#endif // !defined(BOOST_ASIO_DISABLE_POSIX_STREAM_DESCRIPTOR) + +// UNIX domain sockets. +#if !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS) +# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +# define BOOST_ASIO_HAS_LOCAL_SOCKETS 1 +# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#endif // !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS) + +#endif // BOOST_ASIO_DETAIL_CONFIG_HPP
diff --git a/boost_1_45_0/boost/asio/detail/consuming_buffers.hpp b/boost_1_45_0/boost/asio/detail/consuming_buffers.hpp new file mode 100644 index 0000000..23114a0 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/consuming_buffers.hpp
@@ -0,0 +1,280 @@ +// +// detail/consuming_buffers.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_CONSUMING_BUFFERS_HPP +#define BOOST_ASIO_DETAIL_CONSUMING_BUFFERS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/iterator.hpp> +#include <boost/limits.hpp> +#include <boost/asio/buffer.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// A proxy iterator for a sub-range in a list of buffers. +template <typename Buffer, typename Buffer_Iterator> +class consuming_buffers_iterator + : public boost::iterator<std::forward_iterator_tag, const Buffer> +{ +public: + // Default constructor creates an end iterator. + consuming_buffers_iterator() + : at_end_(true) + { + } + + // Construct with a buffer for the first entry and an iterator + // range for the remaining entries. + consuming_buffers_iterator(bool at_end, const Buffer& first, + Buffer_Iterator begin_remainder, Buffer_Iterator end_remainder, + std::size_t max_size) + : at_end_(max_size > 0 ? at_end : true), + first_(buffer(first, max_size)), + begin_remainder_(begin_remainder), + end_remainder_(end_remainder), + offset_(0), + max_size_(max_size) + { + } + + // Dereference an iterator. + const Buffer& operator*() const + { + return dereference(); + } + + // Dereference an iterator. + const Buffer* operator->() const + { + return &dereference(); + } + + // Increment operator (prefix). + consuming_buffers_iterator& operator++() + { + increment(); + return *this; + } + + // Increment operator (postfix). + consuming_buffers_iterator operator++(int) + { + consuming_buffers_iterator tmp(*this); + ++*this; + return tmp; + } + + // Test two iterators for equality. + friend bool operator==(const consuming_buffers_iterator& a, + const consuming_buffers_iterator& b) + { + return a.equal(b); + } + + // Test two iterators for inequality. + friend bool operator!=(const consuming_buffers_iterator& a, + const consuming_buffers_iterator& b) + { + return !a.equal(b); + } + +private: + void increment() + { + if (!at_end_) + { + if (begin_remainder_ == end_remainder_ + || offset_ + buffer_size(first_) >= max_size_) + { + at_end_ = true; + } + else + { + offset_ += buffer_size(first_); + first_ = buffer(*begin_remainder_++, max_size_ - offset_); + } + } + } + + bool equal(const consuming_buffers_iterator& other) const + { + if (at_end_ && other.at_end_) + return true; + return !at_end_ && !other.at_end_ + && buffer_cast<const void*>(first_) + == buffer_cast<const void*>(other.first_) + && buffer_size(first_) == buffer_size(other.first_) + && begin_remainder_ == other.begin_remainder_ + && end_remainder_ == other.end_remainder_; + } + + const Buffer& dereference() const + { + return first_; + } + + bool at_end_; + Buffer first_; + Buffer_Iterator begin_remainder_; + Buffer_Iterator end_remainder_; + std::size_t offset_; + std::size_t max_size_; +}; + +// A proxy for a sub-range in a list of buffers. +template <typename Buffer, typename Buffers> +class consuming_buffers +{ +public: + // The type for each element in the list of buffers. + typedef Buffer value_type; + + // A forward-only iterator type that may be used to read elements. + typedef consuming_buffers_iterator<Buffer, typename Buffers::const_iterator> + const_iterator; + + // Construct to represent the entire list of buffers. + consuming_buffers(const Buffers& buffers) + : buffers_(buffers), + at_end_(buffers_.begin() == buffers_.end()), + begin_remainder_(buffers_.begin()), + max_size_((std::numeric_limits<std::size_t>::max)()) + { + if (!at_end_) + { + first_ = *buffers_.begin(); + ++begin_remainder_; + } + } + + // Copy constructor. + consuming_buffers(const consuming_buffers& other) + : buffers_(other.buffers_), + at_end_(other.at_end_), + first_(other.first_), + begin_remainder_(buffers_.begin()), + max_size_(other.max_size_) + { + typename Buffers::const_iterator first = other.buffers_.begin(); + typename Buffers::const_iterator second = other.begin_remainder_; + std::advance(begin_remainder_, std::distance(first, second)); + } + + // Assignment operator. + consuming_buffers& operator=(const consuming_buffers& other) + { + buffers_ = other.buffers_; + at_end_ = other.at_end_; + first_ = other.first_; + begin_remainder_ = buffers_.begin(); + typename Buffers::const_iterator first = other.buffers_.begin(); + typename Buffers::const_iterator second = other.begin_remainder_; + std::advance(begin_remainder_, std::distance(first, second)); + max_size_ = other.max_size_; + return *this; + } + + // Get a forward-only iterator to the first element. + const_iterator begin() const + { + return const_iterator(at_end_, first_, + begin_remainder_, buffers_.end(), max_size_); + } + + // Get a forward-only iterator for one past the last element. + const_iterator end() const + { + return const_iterator(); + } + + // Set the maximum size for a single transfer. + void prepare(std::size_t max_size) + { + max_size_ = max_size; + } + + // Consume the specified number of bytes from the buffers. + void consume(std::size_t size) + { + // Remove buffers from the start until the specified size is reached. + while (size > 0 && !at_end_) + { + if (buffer_size(first_) <= size) + { + size -= buffer_size(first_); + if (begin_remainder_ == buffers_.end()) + at_end_ = true; + else + first_ = *begin_remainder_++; + } + else + { + first_ = first_ + size; + size = 0; + } + } + + // Remove any more empty buffers at the start. + while (!at_end_ && buffer_size(first_) == 0) + { + if (begin_remainder_ == buffers_.end()) + at_end_ = true; + else + first_ = *begin_remainder_++; + } + } + +private: + Buffers buffers_; + bool at_end_; + Buffer first_; + typename Buffers::const_iterator begin_remainder_; + std::size_t max_size_; +}; + +// Specialisation for null_buffers to ensure that the null_buffers type is +// always passed through to the underlying read or write operation. +template <typename Buffer> +class consuming_buffers<Buffer, boost::asio::null_buffers> + : public boost::asio::null_buffers +{ +public: + consuming_buffers(const boost::asio::null_buffers&) + { + // No-op. + } + + void prepare(std::size_t) + { + // No-op. + } + + void consume(std::size_t) + { + // No-op. + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_CONSUMING_BUFFERS_HPP
diff --git a/boost_1_45_0/boost/asio/detail/deadline_timer_service.hpp b/boost_1_45_0/boost/asio/detail/deadline_timer_service.hpp new file mode 100644 index 0000000..c391824 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/deadline_timer_service.hpp
@@ -0,0 +1,188 @@ +// +// detail/deadline_timer_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP +#define BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue.hpp> +#include <boost/asio/detail/timer_scheduler.hpp> +#include <boost/asio/detail/wait_handler.hpp> + +#include <boost/asio/detail/push_options.hpp> +#include <boost/date_time/posix_time/posix_time_types.hpp> +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +class deadline_timer_service +{ +public: + // The time type. + typedef typename Time_Traits::time_type time_type; + + // The duration type. + typedef typename Time_Traits::duration_type duration_type; + + // The implementation type of the timer. This type is dependent on the + // underlying implementation of the timer service. + struct implementation_type + : private boost::asio::detail::noncopyable + { + time_type expiry; + bool might_have_pending_waits; + typename timer_queue<Time_Traits>::per_timer_data timer_data; + }; + + // Constructor. + deadline_timer_service(boost::asio::io_service& io_service) + : scheduler_(boost::asio::use_service<timer_scheduler>(io_service)) + { + scheduler_.init_task(); + scheduler_.add_timer_queue(timer_queue_); + } + + // Destructor. + ~deadline_timer_service() + { + scheduler_.remove_timer_queue(timer_queue_); + } + + // Destroy all user-defined handler objects owned by the service. + void shutdown_service() + { + } + + // Construct a new timer implementation. + void construct(implementation_type& impl) + { + impl.expiry = time_type(); + impl.might_have_pending_waits = false; + } + + // Destroy a timer implementation. + void destroy(implementation_type& impl) + { + boost::system::error_code ec; + cancel(impl, ec); + } + + // Cancel any asynchronous wait operations associated with the timer. + std::size_t cancel(implementation_type& impl, boost::system::error_code& ec) + { + if (!impl.might_have_pending_waits) + { + ec = boost::system::error_code(); + return 0; + } + std::size_t count = scheduler_.cancel_timer(timer_queue_, impl.timer_data); + impl.might_have_pending_waits = false; + ec = boost::system::error_code(); + return count; + } + + // Get the expiry time for the timer as an absolute time. + time_type expires_at(const implementation_type& impl) const + { + return impl.expiry; + } + + // Set the expiry time for the timer as an absolute time. + std::size_t expires_at(implementation_type& impl, + const time_type& expiry_time, boost::system::error_code& ec) + { + std::size_t count = cancel(impl, ec); + impl.expiry = expiry_time; + ec = boost::system::error_code(); + return count; + } + + // Get the expiry time for the timer relative to now. + duration_type expires_from_now(const implementation_type& impl) const + { + return Time_Traits::subtract(expires_at(impl), Time_Traits::now()); + } + + // Set the expiry time for the timer relative to now. + std::size_t expires_from_now(implementation_type& impl, + const duration_type& expiry_time, boost::system::error_code& ec) + { + return expires_at(impl, + Time_Traits::add(Time_Traits::now(), expiry_time), ec); + } + + // Perform a blocking wait on the timer. + void wait(implementation_type& impl, boost::system::error_code& ec) + { + time_type now = Time_Traits::now(); + while (Time_Traits::less_than(now, impl.expiry)) + { + boost::posix_time::time_duration timeout = + Time_Traits::to_posix_duration(Time_Traits::subtract(impl.expiry, now)); + ::timeval tv; + tv.tv_sec = timeout.total_seconds(); + tv.tv_usec = timeout.total_microseconds() % 1000000; + boost::system::error_code ec; + socket_ops::select(0, 0, 0, 0, &tv, ec); + now = Time_Traits::now(); + } + ec = boost::system::error_code(); + } + + // Start an asynchronous wait on the timer. + template <typename Handler> + void async_wait(implementation_type& impl, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef wait_handler<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + impl.might_have_pending_waits = true; + + scheduler_.schedule_timer(timer_queue_, impl.expiry, impl.timer_data, p.p); + p.v = p.p = 0; + } + +private: + // The queue of timers. + timer_queue<Time_Traits> timer_queue_; + + // The object that schedules and executes timers. Usually a reactor. + timer_scheduler& scheduler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/descriptor_ops.hpp b/boost_1_45_0/boost/asio/detail/descriptor_ops.hpp new file mode 100644 index 0000000..4f82cd6 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/descriptor_ops.hpp
@@ -0,0 +1,107 @@ +// +// detail/descriptor_ops.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP +#define BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <cstddef> +#include <boost/system/error_code.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace descriptor_ops { + +// Descriptor state bits. +enum +{ + // The user wants a non-blocking descriptor. + user_set_non_blocking = 1, + + // The descriptor has been set non-blocking. + internal_non_blocking = 2, + + // Helper "state" used to determine whether the descriptor is non-blocking. + non_blocking = user_set_non_blocking | internal_non_blocking +}; + +typedef unsigned char state_type; + +template <typename ReturnType> +inline ReturnType error_wrapper(ReturnType return_value, + boost::system::error_code& ec) +{ + ec = boost::system::error_code(errno, + boost::asio::error::get_system_category()); + return return_value; +} + +BOOST_ASIO_DECL int open(const char* path, int flags, + boost::system::error_code& ec); + +BOOST_ASIO_DECL int close(int d, state_type& state, + boost::system::error_code& ec); + +BOOST_ASIO_DECL bool set_internal_non_blocking(int d, + state_type& state, boost::system::error_code& ec); + +typedef iovec buf; + +BOOST_ASIO_DECL std::size_t sync_read(int d, state_type state, buf* bufs, + std::size_t count, bool all_empty, boost::system::error_code& ec); + +BOOST_ASIO_DECL bool non_blocking_read(int d, buf* bufs, std::size_t count, + boost::system::error_code& ec, std::size_t& bytes_transferred); + +BOOST_ASIO_DECL std::size_t sync_write(int d, state_type state, + const buf* bufs, std::size_t count, bool all_empty, + boost::system::error_code& ec); + +BOOST_ASIO_DECL bool non_blocking_write(int d, + const buf* bufs, std::size_t count, + boost::system::error_code& ec, std::size_t& bytes_transferred); + +BOOST_ASIO_DECL int ioctl(int d, state_type& state, long cmd, + ioctl_arg_type* arg, boost::system::error_code& ec); + +BOOST_ASIO_DECL int fcntl(int d, long cmd, boost::system::error_code& ec); + +BOOST_ASIO_DECL int fcntl(int d, long cmd, + long arg, boost::system::error_code& ec); + +BOOST_ASIO_DECL int poll_read(int d, boost::system::error_code& ec); + +BOOST_ASIO_DECL int poll_write(int d, boost::system::error_code& ec); + +} // namespace descriptor_ops +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/descriptor_ops.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_DESCRIPTOR_OPS_HPP
diff --git a/boost_1_45_0/boost/asio/detail/descriptor_read_op.hpp b/boost_1_45_0/boost/asio/detail/descriptor_read_op.hpp new file mode 100644 index 0000000..c068108 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/descriptor_read_op.hpp
@@ -0,0 +1,116 @@ +// +// detail/descriptor_read_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_READ_OP_HPP +#define BOOST_ASIO_DETAIL_DESCRIPTOR_READ_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/descriptor_ops.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename MutableBufferSequence> +class descriptor_read_op_base : public reactor_op +{ +public: + descriptor_read_op_base(int descriptor, + const MutableBufferSequence& buffers, func_type complete_func) + : reactor_op(&descriptor_read_op_base::do_perform, complete_func), + descriptor_(descriptor), + buffers_(buffers) + { + } + + static bool do_perform(reactor_op* base) + { + descriptor_read_op_base* o(static_cast<descriptor_read_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(o->buffers_); + + return descriptor_ops::non_blocking_read(o->descriptor_, + bufs.buffers(), bufs.count(), o->ec_, o->bytes_transferred_); + } + +private: + int descriptor_; + MutableBufferSequence buffers_; +}; + +template <typename MutableBufferSequence, typename Handler> +class descriptor_read_op + : public descriptor_read_op_base<MutableBufferSequence> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(descriptor_read_op); + + descriptor_read_op(int descriptor, + const MutableBufferSequence& buffers, Handler handler) + : descriptor_read_op_base<MutableBufferSequence>( + descriptor, buffers, &descriptor_read_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + descriptor_read_op* o(static_cast<descriptor_read_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_DESCRIPTOR_READ_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/descriptor_write_op.hpp b/boost_1_45_0/boost/asio/detail/descriptor_write_op.hpp new file mode 100644 index 0000000..0983854 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/descriptor_write_op.hpp
@@ -0,0 +1,116 @@ +// +// detail/descriptor_write_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DESCRIPTOR_WRITE_OP_HPP +#define BOOST_ASIO_DETAIL_DESCRIPTOR_WRITE_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/descriptor_ops.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename ConstBufferSequence> +class descriptor_write_op_base : public reactor_op +{ +public: + descriptor_write_op_base(int descriptor, + const ConstBufferSequence& buffers, func_type complete_func) + : reactor_op(&descriptor_write_op_base::do_perform, complete_func), + descriptor_(descriptor), + buffers_(buffers) + { + } + + static bool do_perform(reactor_op* base) + { + descriptor_write_op_base* o(static_cast<descriptor_write_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(o->buffers_); + + return descriptor_ops::non_blocking_write(o->descriptor_, + bufs.buffers(), bufs.count(), o->ec_, o->bytes_transferred_); + } + +private: + int descriptor_; + ConstBufferSequence buffers_; +}; + +template <typename ConstBufferSequence, typename Handler> +class descriptor_write_op + : public descriptor_write_op_base<ConstBufferSequence> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(descriptor_write_op); + + descriptor_write_op(int descriptor, + const ConstBufferSequence& buffers, Handler handler) + : descriptor_write_op_base<ConstBufferSequence>( + descriptor, buffers, &descriptor_write_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + descriptor_write_op* o(static_cast<descriptor_write_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_DESCRIPTOR_WRITE_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/dev_poll_reactor.hpp b/boost_1_45_0/boost/asio/detail/dev_poll_reactor.hpp new file mode 100644 index 0000000..ef2b0dc --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/dev_poll_reactor.hpp
@@ -0,0 +1,187 @@ +// +// detail/dev_poll_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_HPP +#define BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_DEV_POLL) + +#include <cstddef> +#include <vector> +#include <sys/devpoll.h> +#include <boost/asio/detail/dev_poll_reactor_fwd.hpp> +#include <boost/asio/detail/hash_map.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/reactor_op_queue.hpp> +#include <boost/asio/detail/select_interrupter.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/detail/timer_queue_fwd.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> +#include <boost/asio/io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class dev_poll_reactor + : public boost::asio::detail::service_base<dev_poll_reactor> +{ +public: + enum { read_op = 0, write_op = 1, + connect_op = 1, except_op = 2, max_ops = 3 }; + + // Per-descriptor data. + struct per_descriptor_data + { + }; + + // Constructor. + BOOST_ASIO_DECL dev_poll_reactor(boost::asio::io_service& io_service); + + // Destructor. + BOOST_ASIO_DECL ~dev_poll_reactor(); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task. + BOOST_ASIO_DECL void init_task(); + + // Register a socket with the reactor. Returns 0 on success, system error + // code on failure. + BOOST_ASIO_DECL int register_descriptor(socket_type, per_descriptor_data&); + + // Post a reactor operation for immediate completion. + void post_immediate_completion(reactor_op* op) + { + io_service_.post_immediate_completion(op); + } + + // Start a new operation. The reactor operation will be performed when the + // given descriptor is flagged as ready, or an error has occurred. + BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor, + per_descriptor_data&, reactor_op* op, bool allow_speculative); + + // Cancel all operations associated with the given descriptor. The + // handlers associated with the descriptor will be invoked with the + // operation_aborted error. + BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, per_descriptor_data&); + + // Cancel any operations that are running against the descriptor and remove + // its registration from the reactor. + BOOST_ASIO_DECL void close_descriptor( + socket_type descriptor, per_descriptor_data&); + + // Add a new timer queue to the reactor. + template <typename Time_Traits> + void add_timer_queue(timer_queue<Time_Traits>& queue); + + // Remove a timer queue from the reactor. + template <typename Time_Traits> + void remove_timer_queue(timer_queue<Time_Traits>& queue); + + // Schedule a new operation in the given timer queue to expire at the + // specified absolute time. + template <typename Time_Traits> + void schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op); + + // Cancel the timer operations associated with the given token. Returns the + // number of operations that have been posted or dispatched. + template <typename Time_Traits> + std::size_t cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer); + + // Run /dev/poll once until interrupted or events are ready to be dispatched. + BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops); + + // Interrupt the select loop. + BOOST_ASIO_DECL void interrupt(); + +private: + // Create the /dev/poll file descriptor. Throws an exception if the descriptor + // cannot be created. + BOOST_ASIO_DECL static int do_dev_poll_create(); + + // Helper function to add a new timer queue. + BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); + + // Helper function to remove a timer queue. + BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); + + // Get the timeout value for the /dev/poll DP_POLL operation. The timeout + // value is returned as a number of milliseconds. A return value of -1 + // indicates that the poll should block indefinitely. + BOOST_ASIO_DECL int get_timeout(); + + // Cancel all operations associated with the given descriptor. The do_cancel + // function of the handler objects will be invoked. This function does not + // acquire the dev_poll_reactor's mutex. + BOOST_ASIO_DECL void cancel_ops_unlocked(socket_type descriptor, + const boost::system::error_code& ec); + + // Add a pending event entry for the given descriptor. + BOOST_ASIO_DECL ::pollfd& add_pending_event_change(int descriptor); + + // The io_service implementation used to post completions. + io_service_impl& io_service_; + + // Mutex to protect access to internal data. + boost::asio::detail::mutex mutex_; + + // The /dev/poll file descriptor. + int dev_poll_fd_; + + // Vector of /dev/poll events waiting to be written to the descriptor. + std::vector< ::pollfd> pending_event_changes_; + + // Hash map to associate a descriptor with a pending event change index. + hash_map<int, std::size_t> pending_event_change_index_; + + // The interrupter is used to break a blocking DP_POLL operation. + select_interrupter interrupter_; + + // The queues of read, write and except operations. + reactor_op_queue<socket_type> op_queue_[max_ops]; + + // The timer queues. + timer_queue_set timer_queues_; + + // Whether the service has been shut down. + bool shutdown_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/dev_poll_reactor.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/dev_poll_reactor.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_DEV_POLL) + +#endif // BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/dev_poll_reactor_fwd.hpp b/boost_1_45_0/boost/asio/detail/dev_poll_reactor_fwd.hpp new file mode 100644 index 0000000..7e8defc --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/dev_poll_reactor_fwd.hpp
@@ -0,0 +1,34 @@ +// +// detail/dev_poll_reactor_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_FWD_HPP +#define BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_DEV_POLL) + +namespace boost { +namespace asio { +namespace detail { + +class dev_poll_reactor; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // defined(BOOST_ASIO_HAS_DEV_POLL) + +#endif // BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/epoll_reactor.hpp b/boost_1_45_0/boost/asio/detail/epoll_reactor.hpp new file mode 100644 index 0000000..18d87ee --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/epoll_reactor.hpp
@@ -0,0 +1,199 @@ +// +// detail/epoll_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_EPOLL_REACTOR_HPP +#define BOOST_ASIO_DETAIL_EPOLL_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_EPOLL) + +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/epoll_reactor_fwd.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/object_pool.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/select_interrupter.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/detail/timer_queue_fwd.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class epoll_reactor + : public boost::asio::detail::service_base<epoll_reactor> +{ +public: + enum { read_op = 0, write_op = 1, + connect_op = 1, except_op = 2, max_ops = 3 }; + + // Per-descriptor queues. + class descriptor_state + { + friend class epoll_reactor; + friend class object_pool_access; + mutex mutex_; + op_queue<reactor_op> op_queue_[max_ops]; + bool shutdown_; + descriptor_state* next_; + descriptor_state* prev_; + }; + + // Per-descriptor data. + typedef descriptor_state* per_descriptor_data; + + // Constructor. + BOOST_ASIO_DECL epoll_reactor(boost::asio::io_service& io_service); + + // Destructor. + BOOST_ASIO_DECL ~epoll_reactor(); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task. + BOOST_ASIO_DECL void init_task(); + + // Register a socket with the reactor. Returns 0 on success, system error + // code on failure. + BOOST_ASIO_DECL int register_descriptor(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Post a reactor operation for immediate completion. + void post_immediate_completion(reactor_op* op) + { + io_service_.post_immediate_completion(op); + } + + // Start a new operation. The reactor operation will be performed when the + // given descriptor is flagged as ready, or an error has occurred. + BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor, + per_descriptor_data& descriptor_data, + reactor_op* op, bool allow_speculative); + + // Cancel all operations associated with the given descriptor. The + // handlers associated with the descriptor will be invoked with the + // operation_aborted error. + BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Cancel any operations that are running against the descriptor and remove + // its registration from the reactor. + BOOST_ASIO_DECL void close_descriptor(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Add a new timer queue to the reactor. + template <typename Time_Traits> + void add_timer_queue(timer_queue<Time_Traits>& timer_queue); + + // Remove a timer queue from the reactor. + template <typename Time_Traits> + void remove_timer_queue(timer_queue<Time_Traits>& timer_queue); + + // Schedule a new operation in the given timer queue to expire at the + // specified absolute time. + template <typename Time_Traits> + void schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op); + + // Cancel the timer operations associated with the given token. Returns the + // number of operations that have been posted or dispatched. + template <typename Time_Traits> + std::size_t cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer); + + // Run epoll once until interrupted or events are ready to be dispatched. + BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops); + + // Interrupt the select loop. + BOOST_ASIO_DECL void interrupt(); + +private: + // The hint to pass to epoll_create to size its data structures. + enum { epoll_size = 20000 }; + + // Create the epoll file descriptor. Throws an exception if the descriptor + // cannot be created. + BOOST_ASIO_DECL static int do_epoll_create(); + + // Helper function to add a new timer queue. + BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); + + // Helper function to remove a timer queue. + BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); + + // Called to recalculate and update the timeout. + BOOST_ASIO_DECL void update_timeout(); + + // Get the timeout value for the epoll_wait call. The timeout value is + // returned as a number of milliseconds. A return value of -1 indicates + // that epoll_wait should block indefinitely. + BOOST_ASIO_DECL int get_timeout(); + +#if defined(BOOST_ASIO_HAS_TIMERFD) + // Get the timeout value for the timer descriptor. The return value is the + // flag argument to be used when calling timerfd_settime. + BOOST_ASIO_DECL int get_timeout(itimerspec& ts); +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + + // The io_service implementation used to post completions. + io_service_impl& io_service_; + + // Mutex to protect access to internal data. + mutex mutex_; + + // The epoll file descriptor. + int epoll_fd_; + + // The timer file descriptor. + int timer_fd_; + + // The interrupter is used to break a blocking epoll_wait call. + select_interrupter interrupter_; + + // The timer queues. + timer_queue_set timer_queues_; + + // Whether the service has been shut down. + bool shutdown_; + + // Mutex to protect access to the registered descriptors. + mutex registered_descriptors_mutex_; + + // Keep track of all registered descriptors. + object_pool<descriptor_state> registered_descriptors_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/epoll_reactor.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/epoll_reactor.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_EPOLL) + +#endif // BOOST_ASIO_DETAIL_EPOLL_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/epoll_reactor_fwd.hpp b/boost_1_45_0/boost/asio/detail/epoll_reactor_fwd.hpp new file mode 100644 index 0000000..dc0e92d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/epoll_reactor_fwd.hpp
@@ -0,0 +1,34 @@ +// +// detail/epoll_reactor_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_EPOLL_REACTOR_FWD_HPP +#define BOOST_ASIO_DETAIL_EPOLL_REACTOR_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_EPOLL) + +namespace boost { +namespace asio { +namespace detail { + +class epoll_reactor; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // defined(BOOST_ASIO_HAS_EPOLL) + +#endif // BOOST_ASIO_DETAIL_EPOLL_REACTOR_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/event.hpp b/boost_1_45_0/boost/asio/detail/event.hpp new file mode 100644 index 0000000..c33b65a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/event.hpp
@@ -0,0 +1,46 @@ +// +// detail/event.hpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_EVENT_HPP +#define BOOST_ASIO_DETAIL_EVENT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +# include <boost/asio/detail/null_event.hpp> +#elif defined(BOOST_WINDOWS) +# include <boost/asio/detail/win_event.hpp> +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/asio/detail/posix_event.hpp> +#else +# error Only Windows and POSIX are supported! +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +typedef null_event event; +#elif defined(BOOST_WINDOWS) +typedef win_event event; +#elif defined(BOOST_HAS_PTHREADS) +typedef posix_event event; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_EVENT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/eventfd_select_interrupter.hpp b/boost_1_45_0/boost/asio/detail/eventfd_select_interrupter.hpp new file mode 100644 index 0000000..b2cb68b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/eventfd_select_interrupter.hpp
@@ -0,0 +1,76 @@ +// +// detail/eventfd_select_interrupter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Roelof Naude (roelof.naude at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP +#define BOOST_ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_EVENTFD) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class eventfd_select_interrupter +{ +public: + // Constructor. + BOOST_ASIO_DECL eventfd_select_interrupter(); + + // Destructor. + BOOST_ASIO_DECL ~eventfd_select_interrupter(); + + // Interrupt the select call. + BOOST_ASIO_DECL void interrupt(); + + // Reset the select interrupt. Returns true if the call was interrupted. + BOOST_ASIO_DECL bool reset(); + + // Get the read descriptor to be passed to select. + int read_descriptor() const + { + return read_descriptor_; + } + +private: + // The read end of a connection used to interrupt the select call. This file + // descriptor is passed to select such that when it is time to stop, a single + // 64bit value will be written on the other end of the connection and this + // descriptor will become readable. + int read_descriptor_; + + // The write end of a connection used to interrupt the select call. A single + // 64bit non-zero value may be written to this to wake up the select which is + // waiting for the other end to become readable. This descriptor will only + // differ from the read descriptor when a pipe is used. + int write_descriptor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/eventfd_select_interrupter.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_EVENTFD) + +#endif // BOOST_ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/fd_set_adapter.hpp b/boost_1_45_0/boost/asio/detail/fd_set_adapter.hpp new file mode 100644 index 0000000..138264f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/fd_set_adapter.hpp
@@ -0,0 +1,36 @@ +// +// detail/fd_set_adapter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_FD_SET_ADAPTER_HPP +#define BOOST_ASIO_DETAIL_FD_SET_ADAPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/posix_fd_set_adapter.hpp> +#include <boost/asio/detail/win_fd_set_adapter.hpp> + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef win_fd_set_adapter fd_set_adapter; +#else +typedef posix_fd_set_adapter fd_set_adapter; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_FD_SET_ADAPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/fenced_block.hpp b/boost_1_45_0/boost/asio/detail/fenced_block.hpp new file mode 100644 index 0000000..443f487 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/fenced_block.hpp
@@ -0,0 +1,78 @@ +// +// detail/fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) \ + || defined(BOOST_ASIO_DISABLE_THREADS) \ + || defined(BOOST_ASIO_DISABLE_FENCED_BLOCK) +# include <boost/asio/detail/null_fenced_block.hpp> +#elif defined(__MACH__) && defined(__APPLE__) +# include <boost/asio/detail/macos_fenced_block.hpp> +#elif defined(__sun) +# include <boost/asio/detail/solaris_fenced_block.hpp> +#elif defined(__GNUC__) && defined(__arm__) +# include <boost/asio/detail/gcc_arm_fenced_block.hpp> +#elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__)) +# include <boost/asio/detail/gcc_hppa_fenced_block.hpp> +#elif defined(__GNUC__) \ + && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \ + && !defined(__INTEL_COMPILER) && !defined(__ICL) \ + && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) +# include <boost/asio/detail/gcc_sync_fenced_block.hpp> +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +# include <boost/asio/detail/gcc_x86_fenced_block.hpp> +#elif defined(BOOST_WINDOWS) && !defined(UNDER_CE) +# include <boost/asio/detail/win_fenced_block.hpp> +#else +# include <boost/asio/detail/null_fenced_block.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if !defined(BOOST_HAS_THREADS) \ + || defined(BOOST_ASIO_DISABLE_THREADS) \ + || defined(BOOST_ASIO_DISABLE_FENCED_BLOCK) +typedef null_fenced_block fenced_block; +#elif defined(__MACH__) && defined(__APPLE__) +typedef macos_fenced_block fenced_block; +#elif defined(__sun) +typedef solaris_fenced_block fenced_block; +#elif defined(__GNUC__) && defined(__arm__) +typedef gcc_arm_fenced_block fenced_block; +#elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__)) +typedef gcc_hppa_fenced_block fenced_block; +#elif defined(__GNUC__) \ + && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \ + && !defined(__INTEL_COMPILER) && !defined(__ICL) \ + && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) +typedef gcc_sync_fenced_block fenced_block; +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +typedef gcc_x86_fenced_block fenced_block; +#elif defined(BOOST_WINDOWS) && !defined(UNDER_CE) +typedef win_fenced_block fenced_block; +#else +typedef null_fenced_block fenced_block; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/gcc_arm_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/gcc_arm_fenced_block.hpp new file mode 100644 index 0000000..1350f09 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/gcc_arm_fenced_block.hpp
@@ -0,0 +1,78 @@ +// +// detail/gcc_arm_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__GNUC__) && defined(__arm__) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class gcc_arm_fenced_block + : private noncopyable +{ +public: + // Constructor. + gcc_arm_fenced_block() + { + barrier(); + } + + // Destructor. + ~gcc_arm_fenced_block() + { + barrier(); + } + +private: + static void barrier() + { +#if defined(__ARM_ARCH_4__) \ + || defined(__ARM_ARCH_4T__) \ + || defined(__ARM_ARCH_5__) \ + || defined(__ARM_ARCH_5E__) \ + || defined(__ARM_ARCH_5T__) \ + || defined(__ARM_ARCH_5TE__) \ + || defined(__ARM_ARCH_5TEJ__) \ + || defined(__ARM_ARCH_6__) \ + || defined(__ARM_ARCH_6J__) \ + || defined(__ARM_ARCH_6K__) \ + || defined(__ARM_ARCH_6Z__) \ + || defined(__ARM_ARCH_6ZK__) \ + || defined(__ARM_ARCH_6T2__) + int a = 0, b = 0; + __asm__ __volatile__ ("swp %0, %1, [%2]" + : "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc"); +#else + // ARMv7 and later. + __asm__ __volatile__ ("dmb" : : : "memory"); +#endif + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__GNUC__) && defined(__arm__) + +#endif // BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/gcc_hppa_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/gcc_hppa_fenced_block.hpp new file mode 100644 index 0000000..ef5c093 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/gcc_hppa_fenced_block.hpp
@@ -0,0 +1,60 @@ +// +// detail/gcc_hppa_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__GNUC__) && (defined(__hppa) || defined(__hppa__)) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class gcc_hppa_fenced_block + : private noncopyable +{ +public: + // Constructor. + gcc_hppa_fenced_block() + { + barrier(); + } + + // Destructor. + ~gcc_hppa_fenced_block() + { + barrier(); + } + +private: + static void barrier() + { + // This is just a placeholder and almost certainly not sufficient. + __asm__ __volatile__ ("" : : : "memory"); + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__GNUC__) && (defined(__hppa) || defined(__hppa__)) + +#endif // BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/gcc_sync_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/gcc_sync_fenced_block.hpp new file mode 100644 index 0000000..83341d5 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/gcc_sync_fenced_block.hpp
@@ -0,0 +1,63 @@ +// +// detail/gcc_sync_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__GNUC__) \ + && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \ + && !defined(__INTEL_COMPILER) && !defined(__ICL) \ + && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class gcc_sync_fenced_block + : private noncopyable +{ +public: + // Constructor. + gcc_sync_fenced_block() + : value_(0) + { + __sync_lock_test_and_set(&value_, 1); + } + + // Destructor. + ~gcc_sync_fenced_block() + { + __sync_lock_release(&value_); + } + +private: + int value_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__GNUC__) + // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) + // && !defined(__INTEL_COMPILER) && !defined(__ICL) + // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__) + +#endif // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/gcc_x86_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/gcc_x86_fenced_block.hpp new file mode 100644 index 0000000..5353f87 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/gcc_x86_fenced_block.hpp
@@ -0,0 +1,61 @@ +// +// detail/gcc_x86_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class gcc_x86_fenced_block + : private noncopyable +{ +public: + // Constructor. + gcc_x86_fenced_block() + { + barrier(); + } + + // Destructor. + ~gcc_x86_fenced_block() + { + barrier(); + } + +private: + static int barrier() + { + int r = 0; + __asm__ __volatile__ ("xchgl %%eax, %0" : "=m" (r) : : "memory", "cc"); + return r; + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + +#endif // BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/handler_alloc_helpers.hpp b/boost_1_45_0/boost/asio/detail/handler_alloc_helpers.hpp new file mode 100644 index 0000000..00d4c02 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/handler_alloc_helpers.hpp
@@ -0,0 +1,85 @@ +// +// detail/handler_alloc_helpers.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_HANDLER_ALLOC_HELPERS_HPP +#define BOOST_ASIO_DETAIL_HANDLER_ALLOC_HELPERS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/handler_alloc_hook.hpp> + +#include <boost/asio/detail/push_options.hpp> + +// Calls to asio_handler_allocate and asio_handler_deallocate must be made from +// a namespace that does not contain any overloads of these functions. The +// boost_asio_handler_alloc_helpers namespace is defined here for that purpose. +namespace boost_asio_handler_alloc_helpers { + +template <typename Handler> +inline void* allocate(std::size_t s, Handler& h) +{ +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \ + || BOOST_WORKAROUND(__GNUC__, < 3) + return ::operator new(s); +#else + using namespace boost::asio; + return asio_handler_allocate(s, boost::addressof(h)); +#endif +} + +template <typename Handler> +inline void deallocate(void* p, std::size_t s, Handler& h) +{ +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \ + || BOOST_WORKAROUND(__GNUC__, < 3) + ::operator delete(p); +#else + using namespace boost::asio; + asio_handler_deallocate(p, s, boost::addressof(h)); +#endif +} + +} // namespace boost_asio_handler_alloc_helpers + +#define BOOST_ASIO_DEFINE_HANDLER_PTR(op) \ + struct ptr \ + { \ + Handler* h; \ + void* v; \ + op* p; \ + ~ptr() \ + { \ + reset(); \ + } \ + void reset() \ + { \ + if (p) \ + { \ + p->~op(); \ + p = 0; \ + } \ + if (v) \ + { \ + boost_asio_handler_alloc_helpers::deallocate(v, sizeof(op), *h); \ + v = 0; \ + } \ + } \ + } \ + /**/ + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_HANDLER_ALLOC_HELPERS_HPP
diff --git a/boost_1_45_0/boost/asio/detail/handler_invoke_helpers.hpp b/boost_1_45_0/boost/asio/detail/handler_invoke_helpers.hpp new file mode 100644 index 0000000..996bde9 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/handler_invoke_helpers.hpp
@@ -0,0 +1,47 @@ +// +// detail/handler_invoke_helpers.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP +#define BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/handler_invoke_hook.hpp> + +#include <boost/asio/detail/push_options.hpp> + +// Calls to asio_handler_invoke must be made from a namespace that does not +// contain overloads of this function. The boost_asio_handler_invoke_helpers +// namespace is defined here for that purpose. +namespace boost_asio_handler_invoke_helpers { + +template <typename Function, typename Context> +inline void invoke(const Function& function, Context& context) +{ +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \ + || BOOST_WORKAROUND(__GNUC__, < 3) + Function tmp(function); + tmp(); +#else + using namespace boost::asio; + asio_handler_invoke(function, boost::addressof(context)); +#endif +} + +} // namespace boost_asio_handler_invoke_helpers + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
diff --git a/boost_1_45_0/boost/asio/detail/hash_map.hpp b/boost_1_45_0/boost/asio/detail/hash_map.hpp new file mode 100644 index 0000000..c58096b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/hash_map.hpp
@@ -0,0 +1,331 @@ +// +// detail/hash_map.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_HASH_MAP_HPP +#define BOOST_ASIO_DETAIL_HASH_MAP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cassert> +#include <list> +#include <utility> +#include <boost/asio/detail/noncopyable.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# include <boost/asio/detail/socket_types.hpp> +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +inline std::size_t calculate_hash_value(int i) +{ + return static_cast<std::size_t>(i); +} + +inline std::size_t calculate_hash_value(void* p) +{ + return reinterpret_cast<std::size_t>(p) + + (reinterpret_cast<std::size_t>(p) >> 3); +} + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +inline std::size_t calculate_hash_value(SOCKET s) +{ + return static_cast<std::size_t>(s); +} +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Note: assumes K and V are POD types. +template <typename K, typename V> +class hash_map + : private noncopyable +{ +public: + // The type of a value in the map. + typedef std::pair<K, V> value_type; + + // The type of a non-const iterator over the hash map. + typedef typename std::list<value_type>::iterator iterator; + + // The type of a const iterator over the hash map. + typedef typename std::list<value_type>::const_iterator const_iterator; + + // Constructor. + hash_map() + : size_(0), + buckets_(0), + num_buckets_(0) + { + } + + // Destructor. + ~hash_map() + { + delete[] buckets_; + } + + // Get an iterator for the beginning of the map. + iterator begin() + { + return values_.begin(); + } + + // Get an iterator for the beginning of the map. + const_iterator begin() const + { + return values_.begin(); + } + + // Get an iterator for the end of the map. + iterator end() + { + return values_.end(); + } + + // Get an iterator for the end of the map. + const_iterator end() const + { + return values_.end(); + } + + // Check whether the map is empty. + bool empty() const + { + return values_.empty(); + } + + // Find an entry in the map. + iterator find(const K& k) + { + if (num_buckets_) + { + size_t bucket = calculate_hash_value(k) % num_buckets_; + iterator it = buckets_[bucket].first; + if (it == values_.end()) + return values_.end(); + iterator end = buckets_[bucket].last; + ++end; + while (it != end) + { + if (it->first == k) + return it; + ++it; + } + } + return values_.end(); + } + + // Find an entry in the map. + const_iterator find(const K& k) const + { + if (num_buckets_) + { + size_t bucket = calculate_hash_value(k) % num_buckets_; + const_iterator it = buckets_[bucket].first; + if (it == values_.end()) + return it; + const_iterator end = buckets_[bucket].last; + ++end; + while (it != end) + { + if (it->first == k) + return it; + ++it; + } + } + return values_.end(); + } + + // Insert a new entry into the map. + std::pair<iterator, bool> insert(const value_type& v) + { + if (size_ + 1 >= num_buckets_) + rehash(hash_size(size_ + 1)); + size_t bucket = calculate_hash_value(v.first) % num_buckets_; + iterator it = buckets_[bucket].first; + if (it == values_.end()) + { + buckets_[bucket].first = buckets_[bucket].last = + values_insert(values_.end(), v); + ++size_; + return std::pair<iterator, bool>(buckets_[bucket].last, true); + } + iterator end = buckets_[bucket].last; + ++end; + while (it != end) + { + if (it->first == v.first) + return std::pair<iterator, bool>(it, false); + ++it; + } + buckets_[bucket].last = values_insert(end, v); + ++size_; + return std::pair<iterator, bool>(buckets_[bucket].last, true); + } + + // Erase an entry from the map. + void erase(iterator it) + { + assert(it != values_.end()); + + size_t bucket = calculate_hash_value(it->first) % num_buckets_; + bool is_first = (it == buckets_[bucket].first); + bool is_last = (it == buckets_[bucket].last); + if (is_first && is_last) + buckets_[bucket].first = buckets_[bucket].last = values_.end(); + else if (is_first) + ++buckets_[bucket].first; + else if (is_last) + --buckets_[bucket].last; + + values_erase(it); + --size_; + } + + // Erase a key from the map. + void erase(const K& k) + { + iterator it = find(k); + if (it != values_.end()) + erase(it); + } + + // Remove all entries from the map. + void clear() + { + // Clear the values. + values_.clear(); + size_ = 0; + + // Initialise all buckets to empty. + iterator end = values_.end(); + for (size_t i = 0; i < num_buckets_; ++i) + buckets_[i].first = buckets_[i].last = end; + } + +private: + // Calculate the hash size for the specified number of elements. + static std::size_t hash_size(std::size_t num_elems) + { + static std::size_t sizes[] = + { +#if defined(BOOST_ASIO_HASH_MAP_BUCKETS) + BOOST_ASIO_HASH_MAP_BUCKETS +#else // BOOST_ASIO_HASH_MAP_BUCKETS + 3, 13, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, + 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, + 12582917, 25165843 +#endif // BOOST_ASIO_HASH_MAP_BUCKETS + }; + const std::size_t nth_size = sizeof(sizes) / sizeof(std::size_t) - 1; + for (std::size_t i = 0; i < nth_size; ++i) + if (num_elems < sizes[i]) + return sizes[i]; + return sizes[nth_size]; + } + + // Re-initialise the hash from the values already contained in the list. + void rehash(std::size_t num_buckets) + { + if (num_buckets == num_buckets_) + return; + num_buckets_ = num_buckets; + + iterator end = values_.end(); + + // Update number of buckets and initialise all buckets to empty. + bucket_type* tmp = new bucket_type[num_buckets_]; + delete[] buckets_; + buckets_ = tmp; + for (std::size_t i = 0; i < num_buckets_; ++i) + buckets_[i].first = buckets_[i].last = end; + + // Put all values back into the hash. + iterator iter = values_.begin(); + while (iter != end) + { + std::size_t bucket = calculate_hash_value(iter->first) % num_buckets_; + if (buckets_[bucket].last == end) + { + buckets_[bucket].first = buckets_[bucket].last = iter++; + } + else if (++buckets_[bucket].last == iter) + { + ++iter; + } + else + { + values_.splice(buckets_[bucket].last, values_, iter++); + --buckets_[bucket].last; + } + } + } + + // Insert an element into the values list by splicing from the spares list, + // if a spare is available, and otherwise by inserting a new element. + iterator values_insert(iterator it, const value_type& v) + { + if (spares_.empty()) + { + return values_.insert(it, v); + } + else + { + spares_.front() = v; + values_.splice(it, spares_, spares_.begin()); + return --it; + } + } + + // Erase an element from the values list by splicing it to the spares list. + void values_erase(iterator it) + { + *it = value_type(); + spares_.splice(spares_.begin(), values_, it); + } + + // The number of elements in the hash. + std::size_t size_; + + // The list of all values in the hash map. + std::list<value_type> values_; + + // The list of spare nodes waiting to be recycled. Assumes that POD types only + // are stored in the hash map. + std::list<value_type> spares_; + + // The type for a bucket in the hash table. + struct bucket_type + { + iterator first; + iterator last; + }; + + // The buckets in the hash. + bucket_type* buckets_; + + // The number of buckets in the hash. + std::size_t num_buckets_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_HASH_MAP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/descriptor_ops.ipp b/boost_1_45_0/boost/asio/detail/impl/descriptor_ops.ipp new file mode 100644 index 0000000..74a8e6f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/descriptor_ops.ipp
@@ -0,0 +1,372 @@ +// +// detail/impl/descriptor_ops.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_DESCRIPTOR_OPS_IPP +#define BOOST_ASIO_DETAIL_IMPL_DESCRIPTOR_OPS_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cerrno> +#include <boost/asio/detail/descriptor_ops.hpp> +#include <boost/asio/error.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace descriptor_ops { + +int open(const char* path, int flags, boost::system::error_code& ec) +{ + errno = 0; + int result = error_wrapper(::open(path, flags), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +} + +int close(int d, state_type& state, boost::system::error_code& ec) +{ + int result = 0; + if (d != -1) + { + if (state & internal_non_blocking) + { +#if defined(__SYMBIAN32__) + int flags = ::fcntl(d, F_GETFL, 0); + if (flags >= 0) + ::fcntl(d, F_SETFL, flags & ~O_NONBLOCK); +#else // defined(__SYMBIAN32__) + ioctl_arg_type arg = 0; + ::ioctl(d, FIONBIO, &arg); +#endif // defined(__SYMBIAN32__) + state &= ~internal_non_blocking; + } + + errno = 0; + result = error_wrapper(::close(d), ec); + } + + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +bool set_internal_non_blocking(int d, + state_type& state, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return false; + } + + errno = 0; +#if defined(__SYMBIAN32__) + int result = error_wrapper(::fcntl(d, F_GETFL, 0), ec); + if (result >= 0) + { + errno = 0; + result = error_wrapper(::fcntl(d, F_SETFL, result | O_NONBLOCK), ec); + } +#else // defined(__SYMBIAN32__) + ioctl_arg_type arg = 1; + int result = error_wrapper(::ioctl(d, FIONBIO, &arg), ec); +#endif // defined(__SYMBIAN32__) + + if (result >= 0) + { + ec = boost::system::error_code(); + state |= internal_non_blocking; + return true; + } + + return false; +} + +std::size_t sync_read(int d, state_type state, buf* bufs, + std::size_t count, bool all_empty, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to read 0 bytes on a stream is a no-op. + if (all_empty) + { + ec = boost::system::error_code(); + return 0; + } + + // Read some data. + for (;;) + { + // Try to complete the operation without blocking. + errno = 0; + int bytes = error_wrapper(::readv(d, bufs, static_cast<int>(count)), ec); + + // Check if operation succeeded. + if (bytes > 0) + return bytes; + + // Check for EOF. + if (bytes == 0) + { + ec = boost::asio::error::eof; + return 0; + } + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for descriptor to become ready. + if (descriptor_ops::poll_read(d, ec) < 0) + return 0; + } +} + +bool non_blocking_read(int d, buf* bufs, std::size_t count, + boost::system::error_code& ec, std::size_t& bytes_transferred) +{ + for (;;) + { + // Read some data. + errno = 0; + int bytes = error_wrapper(::readv(d, bufs, static_cast<int>(count)), ec); + + // Check for end of stream. + if (bytes == 0) + { + ec = boost::asio::error::eof; + return true; + } + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes > 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +std::size_t sync_write(int d, state_type state, const buf* bufs, + std::size_t count, bool all_empty, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to write 0 bytes on a stream is a no-op. + if (all_empty) + { + ec = boost::system::error_code(); + return 0; + } + + // Write some data. + for (;;) + { + // Try to complete the operation without blocking. + errno = 0; + int bytes = error_wrapper(::writev(d, bufs, static_cast<int>(count)), ec); + + // Check if operation succeeded. + if (bytes > 0) + return bytes; + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for descriptor to become ready. + if (descriptor_ops::poll_write(d, ec) < 0) + return 0; + } +} + +bool non_blocking_write(int d, const buf* bufs, std::size_t count, + boost::system::error_code& ec, std::size_t& bytes_transferred) +{ + for (;;) + { + // Write some data. + errno = 0; + int bytes = error_wrapper(::writev(d, bufs, static_cast<int>(count)), ec); + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes >= 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +int ioctl(int d, state_type& state, long cmd, + ioctl_arg_type* arg, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return -1; + } + + errno = 0; + int result = error_wrapper(::ioctl(d, cmd, arg), ec); + + if (result >= 0) + { + ec = boost::system::error_code(); + + // When updating the non-blocking mode we always perform the ioctl syscall, + // even if the flags would otherwise indicate that the descriptor is + // already in the correct state. This ensures that the underlying + // descriptor is put into the state that has been requested by the user. If + // the ioctl syscall was successful then we need to update the flags to + // match. + if (cmd == static_cast<long>(FIONBIO)) + { + if (*arg) + { + state |= user_set_non_blocking; + } + else + { + // Clearing the non-blocking mode always overrides any internally-set + // non-blocking flag. Any subsequent asynchronous operations will need + // to re-enable non-blocking I/O. + state &= ~(user_set_non_blocking | internal_non_blocking); + } + } + } + + return result; +} + +int fcntl(int d, long cmd, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return -1; + } + + errno = 0; + int result = error_wrapper(::fcntl(d, cmd), ec); + if (result != -1) + ec = boost::system::error_code(); + return result; +} + +int fcntl(int d, long cmd, long arg, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return -1; + } + + errno = 0; + int result = error_wrapper(::fcntl(d, cmd, arg), ec); + if (result != -1) + ec = boost::system::error_code(); + return result; +} + +int poll_read(int d, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return -1; + } + + pollfd fds; + fds.fd = d; + fds.events = POLLIN; + fds.revents = 0; + errno = 0; + int result = error_wrapper(::poll(&fds, 1, -1), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +} + +int poll_write(int d, boost::system::error_code& ec) +{ + if (d == -1) + { + ec = boost::asio::error::bad_descriptor; + return -1; + } + + pollfd fds; + fds.fd = d; + fds.events = POLLOUT; + fds.revents = 0; + errno = 0; + int result = error_wrapper(::poll(&fds, 1, -1), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +} + +} // namespace descriptor_ops +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_IMPL_DESCRIPTOR_OPS_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.hpp b/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.hpp new file mode 100644 index 0000000..2aed0a8 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.hpp
@@ -0,0 +1,79 @@ +// +// detail/impl/dev_poll_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_HPP +#define BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_DEV_POLL) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +void dev_poll_reactor::add_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_add_timer_queue(queue); +} + +template <typename Time_Traits> +void dev_poll_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_remove_timer_queue(queue); +} + +template <typename Time_Traits> +void dev_poll_reactor::schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + io_service_.post_immediate_completion(op); + return; + } + + bool earliest = queue.enqueue_timer(time, timer, op); + io_service_.work_started(); + if (earliest) + interrupter_.interrupt(); +} + +template <typename Time_Traits> +std::size_t dev_poll_reactor::cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + op_queue<operation> ops; + std::size_t n = queue.cancel_timer(timer, ops); + lock.unlock(); + io_service_.post_deferred_completions(ops); + return n; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_DEV_POLL) + +#endif // BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.ipp b/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.ipp new file mode 100644 index 0000000..67f6d50 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/dev_poll_reactor.ipp
@@ -0,0 +1,340 @@ +// +// detail/impl/dev_poll_reactor.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_IPP +#define BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_DEV_POLL) + +#include <boost/asio/detail/dev_poll_reactor.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +dev_poll_reactor::dev_poll_reactor(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<dev_poll_reactor>(io_service), + io_service_(use_service<io_service_impl>(io_service)), + mutex_(), + dev_poll_fd_(do_dev_poll_create()), + interrupter_(), + shutdown_(false) +{ + // Add the interrupter's descriptor to /dev/poll. + ::pollfd ev = { 0 }; + ev.fd = interrupter_.read_descriptor(); + ev.events = POLLIN | POLLERR; + ev.revents = 0; + ::write(dev_poll_fd_, &ev, sizeof(ev)); +} + +dev_poll_reactor::~dev_poll_reactor() +{ + shutdown_service(); + ::close(dev_poll_fd_); +} + +void dev_poll_reactor::shutdown_service() +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + shutdown_ = true; + lock.unlock(); + + op_queue<operation> ops; + + for (int i = 0; i < max_ops; ++i) + op_queue_[i].get_all_operations(ops); + + timer_queues_.get_all_timers(ops); +} + +void dev_poll_reactor::init_task() +{ + io_service_.init_task(); +} + +int dev_poll_reactor::register_descriptor(socket_type, per_descriptor_data&) +{ + return 0; +} + +void dev_poll_reactor::start_op(int op_type, socket_type descriptor, + dev_poll_reactor::per_descriptor_data&, + reactor_op* op, bool allow_speculative) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + post_immediate_completion(op); + return; + } + + if (allow_speculative) + { + if (op_type != read_op || !op_queue_[except_op].has_operation(descriptor)) + { + if (!op_queue_[op_type].has_operation(descriptor)) + { + if (op->perform()) + { + lock.unlock(); + io_service_.post_immediate_completion(op); + return; + } + } + } + } + + bool first = op_queue_[op_type].enqueue_operation(descriptor, op); + io_service_.work_started(); + if (first) + { + ::pollfd& ev = add_pending_event_change(descriptor); + ev.events = POLLERR | POLLHUP; + if (op_type == read_op + || op_queue_[read_op].has_operation(descriptor)) + ev.events |= POLLIN; + if (op_type == write_op + || op_queue_[write_op].has_operation(descriptor)) + ev.events |= POLLOUT; + if (op_type == except_op + || op_queue_[except_op].has_operation(descriptor)) + ev.events |= POLLPRI; + interrupter_.interrupt(); + } +} + +void dev_poll_reactor::cancel_ops(socket_type descriptor, + dev_poll_reactor::per_descriptor_data&) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted); +} + +void dev_poll_reactor::close_descriptor(socket_type descriptor, + dev_poll_reactor::per_descriptor_data&) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + // Remove the descriptor from /dev/poll. + ::pollfd& ev = add_pending_event_change(descriptor); + ev.events = POLLREMOVE; + interrupter_.interrupt(); + + // Cancel any outstanding operations associated with the descriptor. + cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted); +} + +void dev_poll_reactor::run(bool block, op_queue<operation>& ops) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + // We can return immediately if there's no work to do and the reactor is + // not supposed to block. + if (!block && op_queue_[read_op].empty() && op_queue_[write_op].empty() + && op_queue_[except_op].empty() && timer_queues_.all_empty()) + return; + + // Write the pending event registration changes to the /dev/poll descriptor. + std::size_t events_size = sizeof(::pollfd) * pending_event_changes_.size(); + if (events_size > 0) + { + errno = 0; + int result = ::write(dev_poll_fd_, + &pending_event_changes_[0], events_size); + if (result != static_cast<int>(events_size)) + { + boost::system::error_code ec = boost::system::error_code( + errno, boost::asio::error::get_system_category()); + for (std::size_t i = 0; i < pending_event_changes_.size(); ++i) + { + int descriptor = pending_event_changes_[i].fd; + for (int j = 0; j < max_ops; ++j) + op_queue_[j].cancel_operations(descriptor, ops, ec); + } + } + pending_event_changes_.clear(); + pending_event_change_index_.clear(); + } + + int timeout = block ? get_timeout() : 0; + lock.unlock(); + + // Block on the /dev/poll descriptor. + ::pollfd events[128] = { { 0 } }; + ::dvpoll dp = { 0 }; + dp.dp_fds = events; + dp.dp_nfds = 128; + dp.dp_timeout = timeout; + int num_events = ::ioctl(dev_poll_fd_, DP_POLL, &dp); + + lock.lock(); + + // Dispatch the waiting events. + for (int i = 0; i < num_events; ++i) + { + int descriptor = events[i].fd; + if (descriptor == interrupter_.read_descriptor()) + { + interrupter_.reset(); + } + else + { + bool more_reads = false; + bool more_writes = false; + bool more_except = false; + + // Exception operations must be processed first to ensure that any + // out-of-band data is read before normal data. + if (events[i].events & (POLLPRI | POLLERR | POLLHUP)) + more_except = + op_queue_[except_op].perform_operations(descriptor, ops); + else + more_except = op_queue_[except_op].has_operation(descriptor); + + if (events[i].events & (POLLIN | POLLERR | POLLHUP)) + more_reads = op_queue_[read_op].perform_operations(descriptor, ops); + else + more_reads = op_queue_[read_op].has_operation(descriptor); + + if (events[i].events & (POLLOUT | POLLERR | POLLHUP)) + more_writes = op_queue_[write_op].perform_operations(descriptor, ops); + else + more_writes = op_queue_[write_op].has_operation(descriptor); + + if ((events[i].events & (POLLERR | POLLHUP)) != 0 + && !more_except && !more_reads && !more_writes) + { + // If we have an event and no operations associated with the + // descriptor then we need to delete the descriptor from /dev/poll. + // The poll operation can produce POLLHUP or POLLERR events when there + // is no operation pending, so if we do not remove the descriptor we + // can end up in a tight polling loop. + ::pollfd ev = { 0 }; + ev.fd = descriptor; + ev.events = POLLREMOVE; + ev.revents = 0; + ::write(dev_poll_fd_, &ev, sizeof(ev)); + } + else + { + ::pollfd ev = { 0 }; + ev.fd = descriptor; + ev.events = POLLERR | POLLHUP; + if (more_reads) + ev.events |= POLLIN; + if (more_writes) + ev.events |= POLLOUT; + if (more_except) + ev.events |= POLLPRI; + ev.revents = 0; + int result = ::write(dev_poll_fd_, &ev, sizeof(ev)); + if (result != sizeof(ev)) + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + for (int j = 0; j < max_ops; ++j) + op_queue_[j].cancel_operations(descriptor, ops, ec); + } + } + } + } + timer_queues_.get_ready_timers(ops); +} + +void dev_poll_reactor::interrupt() +{ + interrupter_.interrupt(); +} + +int dev_poll_reactor::do_dev_poll_create() +{ + int fd = ::open("/dev/poll", O_RDWR); + if (fd == -1) + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "/dev/poll"); + } + return fd; +} + +void dev_poll_reactor::do_add_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.insert(&queue); +} + +void dev_poll_reactor::do_remove_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.erase(&queue); +} + +int dev_poll_reactor::get_timeout() +{ + // By default we will wait no longer than 5 minutes. This will ensure that + // any changes to the system clock are detected after no longer than this. + return timer_queues_.wait_duration_msec(5 * 60 * 1000); +} + +void dev_poll_reactor::cancel_ops_unlocked(socket_type descriptor, + const boost::system::error_code& ec) +{ + bool need_interrupt = false; + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + need_interrupt = op_queue_[i].cancel_operations( + descriptor, ops, ec) || need_interrupt; + io_service_.post_deferred_completions(ops); + if (need_interrupt) + interrupter_.interrupt(); +} + +::pollfd& dev_poll_reactor::add_pending_event_change(int descriptor) +{ + hash_map<int, std::size_t>::iterator iter + = pending_event_change_index_.find(descriptor); + if (iter == pending_event_change_index_.end()) + { + std::size_t index = pending_event_changes_.size(); + pending_event_changes_.reserve(pending_event_changes_.size() + 1); + pending_event_change_index_.insert(std::make_pair(descriptor, index)); + pending_event_changes_.push_back(::pollfd()); + pending_event_changes_[index].fd = descriptor; + pending_event_changes_[index].revents = 0; + return pending_event_changes_[index]; + } + else + { + return pending_event_changes_[iter->second]; + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_DEV_POLL) + +#endif // BOOST_ASIO_DETAIL_IMPL_DEV_POLL_REACTOR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.hpp b/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.hpp new file mode 100644 index 0000000..49f0d50 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.hpp
@@ -0,0 +1,77 @@ +// +// detail/impl/epoll_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP +#define BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#if defined(BOOST_ASIO_HAS_EPOLL) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +void epoll_reactor::add_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_add_timer_queue(queue); +} + +template <typename Time_Traits> +void epoll_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_remove_timer_queue(queue); +} + +template <typename Time_Traits> +void epoll_reactor::schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op) +{ + mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + io_service_.post_immediate_completion(op); + return; + } + + bool earliest = queue.enqueue_timer(time, timer, op); + io_service_.work_started(); + if (earliest) + update_timeout(); +} + +template <typename Time_Traits> +std::size_t epoll_reactor::cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer) +{ + mutex::scoped_lock lock(mutex_); + op_queue<operation> ops; + std::size_t n = queue.cancel_timer(timer, ops); + lock.unlock(); + io_service_.post_deferred_completions(ops); + return n; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_EPOLL) + +#endif // BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.ipp b/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.ipp new file mode 100644 index 0000000..a4c2491 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/epoll_reactor.ipp
@@ -0,0 +1,392 @@ +// +// detail/impl/epoll_reactor.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP +#define BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_EPOLL) + +#include <cstddef> +#include <sys/epoll.h> +#include <boost/asio/detail/epoll_reactor.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#if defined(BOOST_ASIO_HAS_TIMERFD) +# include <sys/timerfd.h> +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +epoll_reactor::epoll_reactor(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<epoll_reactor>(io_service), + io_service_(use_service<io_service_impl>(io_service)), + mutex_(), + epoll_fd_(do_epoll_create()), +#if defined(BOOST_ASIO_HAS_TIMERFD) + timer_fd_(timerfd_create(CLOCK_MONOTONIC, 0)), +#else // defined(BOOST_ASIO_HAS_TIMERFD) + timer_fd_(-1), +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + interrupter_(), + shutdown_(false) +{ + // Add the interrupter's descriptor to epoll. + epoll_event ev = { 0, { 0 } }; + ev.events = EPOLLIN | EPOLLERR | EPOLLET; + ev.data.ptr = &interrupter_; + epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupter_.read_descriptor(), &ev); + interrupter_.interrupt(); + + // Add the timer descriptor to epoll. + if (timer_fd_ != -1) + { + ev.events = EPOLLIN | EPOLLERR; + ev.data.ptr = &timer_fd_; + epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, timer_fd_, &ev); + } +} + +epoll_reactor::~epoll_reactor() +{ + close(epoll_fd_); + if (timer_fd_ != -1) + close(timer_fd_); +} + +void epoll_reactor::shutdown_service() +{ + mutex::scoped_lock lock(mutex_); + shutdown_ = true; + lock.unlock(); + + op_queue<operation> ops; + + while (descriptor_state* state = registered_descriptors_.first()) + { + for (int i = 0; i < max_ops; ++i) + ops.push(state->op_queue_[i]); + state->shutdown_ = true; + registered_descriptors_.free(state); + } + + timer_queues_.get_all_timers(ops); +} + +void epoll_reactor::init_task() +{ + io_service_.init_task(); +} + +int epoll_reactor::register_descriptor(socket_type descriptor, + epoll_reactor::per_descriptor_data& descriptor_data) +{ + mutex::scoped_lock lock(registered_descriptors_mutex_); + + descriptor_data = registered_descriptors_.alloc(); + descriptor_data->shutdown_ = false; + + lock.unlock(); + + epoll_event ev = { 0, { 0 } }; + ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLOUT | EPOLLPRI | EPOLLET; + ev.data.ptr = descriptor_data; + int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, descriptor, &ev); + if (result != 0) + return errno; + + return 0; +} + +void epoll_reactor::start_op(int op_type, socket_type descriptor, + epoll_reactor::per_descriptor_data& descriptor_data, + reactor_op* op, bool allow_speculative) +{ + if (!descriptor_data) + { + op->ec_ = boost::asio::error::bad_descriptor; + post_immediate_completion(op); + return; + } + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + if (descriptor_data->shutdown_) + { + post_immediate_completion(op); + return; + } + + if (descriptor_data->op_queue_[op_type].empty()) + { + if (allow_speculative + && (op_type != read_op + || descriptor_data->op_queue_[except_op].empty())) + { + if (op->perform()) + { + descriptor_lock.unlock(); + io_service_.post_immediate_completion(op); + return; + } + } + else + { + epoll_event ev = { 0, { 0 } }; + ev.events = EPOLLIN | EPOLLERR | EPOLLHUP + | EPOLLOUT | EPOLLPRI | EPOLLET; + ev.data.ptr = descriptor_data; + epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev); + } + } + + descriptor_data->op_queue_[op_type].push(op); + io_service_.work_started(); +} + +void epoll_reactor::cancel_ops(socket_type, + epoll_reactor::per_descriptor_data& descriptor_data) +{ + if (!descriptor_data) + return; + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + { + while (reactor_op* op = descriptor_data->op_queue_[i].front()) + { + op->ec_ = boost::asio::error::operation_aborted; + descriptor_data->op_queue_[i].pop(); + ops.push(op); + } + } + + descriptor_lock.unlock(); + + io_service_.post_deferred_completions(ops); +} + +void epoll_reactor::close_descriptor(socket_type, + epoll_reactor::per_descriptor_data& descriptor_data) +{ + if (!descriptor_data) + return; + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_); + + if (!descriptor_data->shutdown_) + { + // Remove the descriptor from the set of known descriptors. The descriptor + // will be automatically removed from the epoll set when it is closed. + + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + { + while (reactor_op* op = descriptor_data->op_queue_[i].front()) + { + op->ec_ = boost::asio::error::operation_aborted; + descriptor_data->op_queue_[i].pop(); + ops.push(op); + } + } + + descriptor_data->shutdown_ = true; + + descriptor_lock.unlock(); + + registered_descriptors_.free(descriptor_data); + descriptor_data = 0; + + descriptors_lock.unlock(); + + io_service_.post_deferred_completions(ops); + } +} + +void epoll_reactor::run(bool block, op_queue<operation>& ops) +{ + // Calculate a timeout only if timerfd is not used. + int timeout; + if (timer_fd_ != -1) + timeout = block ? -1 : 0; + else + { + mutex::scoped_lock lock(mutex_); + timeout = block ? get_timeout() : 0; + } + + // Block on the epoll descriptor. + epoll_event events[128]; + int num_events = epoll_wait(epoll_fd_, events, 128, timeout); + +#if defined(BOOST_ASIO_HAS_TIMERFD) + bool check_timers = (timer_fd_ == -1); +#else // defined(BOOST_ASIO_HAS_TIMERFD) + bool check_timers = true; +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + + // Dispatch the waiting events. + for (int i = 0; i < num_events; ++i) + { + void* ptr = events[i].data.ptr; + if (ptr == &interrupter_) + { + // No need to reset the interrupter since we're leaving the descriptor + // in a ready-to-read state and relying on edge-triggered notifications + // to make it so that we only get woken up when the descriptor's epoll + // registration is updated. + +#if defined(BOOST_ASIO_HAS_TIMERFD) + if (timer_fd_ == -1) + check_timers = true; +#else // defined(BOOST_ASIO_HAS_TIMERFD) + check_timers = true; +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + } +#if defined(BOOST_ASIO_HAS_TIMERFD) + else if (ptr == &timer_fd_) + { + check_timers = true; + } +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + else + { + descriptor_state* descriptor_data = static_cast<descriptor_state*>(ptr); + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + // Exception operations must be processed first to ensure that any + // out-of-band data is read before normal data. + static const int flag[max_ops] = { EPOLLIN, EPOLLOUT, EPOLLPRI }; + for (int j = max_ops - 1; j >= 0; --j) + { + if (events[i].events & (flag[j] | EPOLLERR | EPOLLHUP)) + { + while (reactor_op* op = descriptor_data->op_queue_[j].front()) + { + if (op->perform()) + { + descriptor_data->op_queue_[j].pop(); + ops.push(op); + } + else + break; + } + } + } + } + } + + if (check_timers) + { + mutex::scoped_lock common_lock(mutex_); + timer_queues_.get_ready_timers(ops); + +#if defined(BOOST_ASIO_HAS_TIMERFD) + if (timer_fd_ != -1) + { + itimerspec new_timeout; + itimerspec old_timeout; + int flags = get_timeout(new_timeout); + timerfd_settime(timer_fd_, flags, &new_timeout, &old_timeout); + } +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + } +} + +void epoll_reactor::interrupt() +{ + epoll_event ev = { 0, { 0 } }; + ev.events = EPOLLIN | EPOLLERR | EPOLLET; + ev.data.ptr = &interrupter_; + epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, interrupter_.read_descriptor(), &ev); +} + +int epoll_reactor::do_epoll_create() +{ + int fd = epoll_create(epoll_size); + if (fd == -1) + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "epoll"); + } + return fd; +} + +void epoll_reactor::do_add_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.insert(&queue); +} + +void epoll_reactor::do_remove_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.erase(&queue); +} + +void epoll_reactor::update_timeout() +{ +#if defined(BOOST_ASIO_HAS_TIMERFD) + if (timer_fd_ != -1) + { + itimerspec new_timeout; + itimerspec old_timeout; + int flags = get_timeout(new_timeout); + timerfd_settime(timer_fd_, flags, &new_timeout, &old_timeout); + return; + } +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + interrupter_.interrupt(); +} + +int epoll_reactor::get_timeout() +{ + // By default we will wait no longer than 5 minutes. This will ensure that + // any changes to the system clock are detected after no longer than this. + return timer_queues_.wait_duration_msec(5 * 60 * 1000); +} + +#if defined(BOOST_ASIO_HAS_TIMERFD) +int epoll_reactor::get_timeout(itimerspec& ts) +{ + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 0; + + long usec = timer_queues_.wait_duration_usec(5 * 60 * 1000 * 1000); + ts.it_value.tv_sec = usec / 1000000; + ts.it_value.tv_nsec = usec ? (usec % 1000000) * 1000 : 1; + + return usec ? 0 : TFD_TIMER_ABSTIME; +} +#endif // defined(BOOST_ASIO_HAS_TIMERFD) + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_EPOLL) + +#endif // BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp b/boost_1_45_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp new file mode 100644 index 0000000..5bcc55b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp
@@ -0,0 +1,127 @@ +// +// detail/impl/eventfd_select_interrupter.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Roelof Naude (roelof.naude at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_EVENTFD_SELECT_INTERRUPTER_IPP +#define BOOST_ASIO_DETAIL_IMPL_EVENTFD_SELECT_INTERRUPTER_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_EVENTFD) + +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 +# include <asm/unistd.h> +#else // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 +# include <sys/eventfd.h> +#endif // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 +#include <boost/asio/detail/eventfd_select_interrupter.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +eventfd_select_interrupter::eventfd_select_interrupter() +{ +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 + write_descriptor_ = read_descriptor_ = syscall(__NR_eventfd, 0); +#else // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 + write_descriptor_ = read_descriptor_ = ::eventfd(0, 0); +#endif // __GLIBC__ == 2 && __GLIBC_MINOR__ < 8 + if (read_descriptor_ != -1) + { + ::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK); + } + else + { + int pipe_fds[2]; + if (pipe(pipe_fds) == 0) + { + read_descriptor_ = pipe_fds[0]; + ::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK); + write_descriptor_ = pipe_fds[1]; + ::fcntl(write_descriptor_, F_SETFL, O_NONBLOCK); + } + else + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "eventfd_select_interrupter"); + } + } +} + +eventfd_select_interrupter::~eventfd_select_interrupter() +{ + if (write_descriptor_ != -1 && write_descriptor_ != read_descriptor_) + ::close(write_descriptor_); + if (read_descriptor_ != -1) + ::close(read_descriptor_); +} + +void eventfd_select_interrupter::interrupt() +{ + uint64_t counter(1UL); + int result = ::write(write_descriptor_, &counter, sizeof(uint64_t)); + (void)result; +} + +bool eventfd_select_interrupter::reset() +{ + if (write_descriptor_ == read_descriptor_) + { + for (;;) + { + // Only perform one read. The kernel maintains an atomic counter. + uint64_t counter(0); + errno = 0; + int bytes_read = ::read(read_descriptor_, &counter, sizeof(uint64_t)); + if (bytes_read < 0 && errno == EINTR) + continue; + bool was_interrupted = (bytes_read > 0); + return was_interrupted; + } + } + else + { + for (;;) + { + // Clear all data from the pipe. + char data[1024]; + int bytes_read = ::read(read_descriptor_, data, sizeof(data)); + if (bytes_read < 0 && errno == EINTR) + continue; + bool was_interrupted = (bytes_read > 0); + while (bytes_read == sizeof(data)) + bytes_read = ::read(read_descriptor_, data, sizeof(data)); + return was_interrupted; + } + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_EVENTFD) + +#endif // BOOST_ASIO_DETAIL_IMPL_EVENTFD_SELECT_INTERRUPTER_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.hpp b/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.hpp new file mode 100644 index 0000000..7bb0269 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.hpp
@@ -0,0 +1,81 @@ +// +// detail/impl/kqueue_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP +#define BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_KQUEUE) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +void kqueue_reactor::add_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_add_timer_queue(queue); +} + +// Remove a timer queue from the reactor. +template <typename Time_Traits> +void kqueue_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_remove_timer_queue(queue); +} + +template <typename Time_Traits> +void kqueue_reactor::schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + io_service_.post_immediate_completion(op); + return; + } + + bool earliest = queue.enqueue_timer(time, timer, op); + io_service_.work_started(); + if (earliest) + interrupt(); +} + +template <typename Time_Traits> +std::size_t kqueue_reactor::cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + op_queue<operation> ops; + std::size_t n = queue.cancel_timer(timer, ops); + lock.unlock(); + io_service_.post_deferred_completions(ops); + return n; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_KQUEUE) + +#endif // BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.ipp b/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.ipp new file mode 100644 index 0000000..08209bd --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/kqueue_reactor.ipp
@@ -0,0 +1,387 @@ +// +// detail/impl/kqueue_reactor.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_IPP +#define BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_KQUEUE) + +#include <boost/asio/detail/kqueue_reactor.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +#if defined(__NetBSD__) +# define BOOST_ASIO_KQUEUE_EV_SET(ev, ident, filt, flags, fflags, data, udata) \ + EV_SET(ev, ident, filt, flags, fflags, \ + data, reinterpret_cast<intptr_t>(udata)) +#else +# define BOOST_ASIO_KQUEUE_EV_SET(ev, ident, filt, flags, fflags, data, udata) \ + EV_SET(ev, ident, filt, flags, fflags, data, udata) +#endif + +namespace boost { +namespace asio { +namespace detail { + +kqueue_reactor::kqueue_reactor(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<kqueue_reactor>(io_service), + io_service_(use_service<io_service_impl>(io_service)), + mutex_(), + kqueue_fd_(do_kqueue_create()), + interrupter_(), + shutdown_(false) +{ + // The interrupter is put into a permanently readable state. Whenever we + // want to interrupt the blocked kevent call we register a one-shot read + // operation against the descriptor. + interrupter_.interrupt(); +} + +kqueue_reactor::~kqueue_reactor() +{ + close(kqueue_fd_); +} + +void kqueue_reactor::shutdown_service() +{ + mutex::scoped_lock lock(mutex_); + shutdown_ = true; + lock.unlock(); + + op_queue<operation> ops; + + while (descriptor_state* state = registered_descriptors_.first()) + { + for (int i = 0; i < max_ops; ++i) + ops.push(state->op_queue_[i]); + state->shutdown_ = true; + registered_descriptors_.free(state); + } + + timer_queues_.get_all_timers(ops); +} + +void kqueue_reactor::init_task() +{ + io_service_.init_task(); +} + +int kqueue_reactor::register_descriptor(socket_type, + kqueue_reactor::per_descriptor_data& descriptor_data) +{ + mutex::scoped_lock lock(registered_descriptors_mutex_); + + descriptor_data = registered_descriptors_.alloc(); + descriptor_data->shutdown_ = false; + + return 0; +} + +void kqueue_reactor::start_op(int op_type, socket_type descriptor, + kqueue_reactor::per_descriptor_data& descriptor_data, + reactor_op* op, bool allow_speculative) +{ + if (!descriptor_data) + { + op->ec_ = boost::asio::error::bad_descriptor; + post_immediate_completion(op); + return; + } + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + if (descriptor_data->shutdown_) + { + post_immediate_completion(op); + return; + } + + bool first = descriptor_data->op_queue_[op_type].empty(); + if (first) + { + if (allow_speculative) + { + if (op_type != read_op || descriptor_data->op_queue_[except_op].empty()) + { + if (op->perform()) + { + descriptor_lock.unlock(); + io_service_.post_immediate_completion(op); + return; + } + } + } + } + + descriptor_data->op_queue_[op_type].push(op); + io_service_.work_started(); + + if (first) + { + struct kevent event; + switch (op_type) + { + case read_op: + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ, + EV_ADD | EV_ONESHOT, 0, 0, descriptor_data); + break; + case write_op: + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_WRITE, + EV_ADD | EV_ONESHOT, 0, 0, descriptor_data); + break; + case except_op: + if (!descriptor_data->op_queue_[read_op].empty()) + return; // Already registered for read events. + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ, + EV_ADD | EV_ONESHOT, EV_OOBAND, 0, descriptor_data); + break; + } + + if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1) + { + op->ec_ = boost::system::error_code(errno, + boost::asio::error::get_system_category()); + descriptor_data->op_queue_[op_type].pop(); + io_service_.post_deferred_completion(op); + } + } +} + +void kqueue_reactor::cancel_ops(socket_type, + kqueue_reactor::per_descriptor_data& descriptor_data) +{ + if (!descriptor_data) + return; + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + { + while (reactor_op* op = descriptor_data->op_queue_[i].front()) + { + op->ec_ = boost::asio::error::operation_aborted; + descriptor_data->op_queue_[i].pop(); + ops.push(op); + } + } + + descriptor_lock.unlock(); + + io_service_.post_deferred_completions(ops); +} + +void kqueue_reactor::close_descriptor(socket_type, + kqueue_reactor::per_descriptor_data& descriptor_data) +{ + if (!descriptor_data) + return; + + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + mutex::scoped_lock descriptors_lock(registered_descriptors_mutex_); + + if (!descriptor_data->shutdown_) + { + // Remove the descriptor from the set of known descriptors. The descriptor + // will be automatically removed from the kqueue set when it is closed. + + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + { + while (reactor_op* op = descriptor_data->op_queue_[i].front()) + { + op->ec_ = boost::asio::error::operation_aborted; + descriptor_data->op_queue_[i].pop(); + ops.push(op); + } + } + + descriptor_data->shutdown_ = true; + + descriptor_lock.unlock(); + + registered_descriptors_.free(descriptor_data); + descriptor_data = 0; + + descriptors_lock.unlock(); + + io_service_.post_deferred_completions(ops); + } +} + +void kqueue_reactor::run(bool block, op_queue<operation>& ops) +{ + mutex::scoped_lock lock(mutex_); + + // Determine how long to block while waiting for events. + timespec timeout_buf = { 0, 0 }; + timespec* timeout = block ? get_timeout(timeout_buf) : &timeout_buf; + + lock.unlock(); + + // Block on the kqueue descriptor. + struct kevent events[128]; + int num_events = kevent(kqueue_fd_, 0, 0, events, 128, timeout); + + // Dispatch the waiting events. + for (int i = 0; i < num_events; ++i) + { + int descriptor = events[i].ident; + void* ptr = reinterpret_cast<void*>(events[i].udata); + if (ptr == &interrupter_) + { + // No need to reset the interrupter since we're leaving the descriptor + // in a ready-to-read state and relying on one-shot notifications. + } + else + { + descriptor_state* descriptor_data = static_cast<descriptor_state*>(ptr); + mutex::scoped_lock descriptor_lock(descriptor_data->mutex_); + + // Exception operations must be processed first to ensure that any + // out-of-band data is read before normal data. +#if defined(__NetBSD__) + static const unsigned int filter[max_ops] = +#else + static const int filter[max_ops] = +#endif + { EVFILT_READ, EVFILT_WRITE, EVFILT_READ }; + for (int j = max_ops - 1; j >= 0; --j) + { + if (events[i].filter == filter[j]) + { + if (j != except_op || events[i].flags & EV_OOBAND) + { + while (reactor_op* op = descriptor_data->op_queue_[j].front()) + { + if (events[i].flags & EV_ERROR) + { + op->ec_ = boost::system::error_code(events[i].data, + boost::asio::error::get_system_category()); + descriptor_data->op_queue_[j].pop(); + ops.push(op); + } + if (op->perform()) + { + descriptor_data->op_queue_[j].pop(); + ops.push(op); + } + else + break; + } + } + } + } + + // Renew registration for event notifications. + struct kevent event; + switch (events[i].filter) + { + case EVFILT_READ: + if (!descriptor_data->op_queue_[read_op].empty()) + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ, + EV_ADD | EV_ONESHOT, 0, 0, descriptor_data); + else if (!descriptor_data->op_queue_[except_op].empty()) + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_READ, + EV_ADD | EV_ONESHOT, EV_OOBAND, 0, descriptor_data); + else + continue; + case EVFILT_WRITE: + if (!descriptor_data->op_queue_[write_op].empty()) + BOOST_ASIO_KQUEUE_EV_SET(&event, descriptor, EVFILT_WRITE, + EV_ADD | EV_ONESHOT, 0, 0, descriptor_data); + else + continue; + default: + break; + } + if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1) + { + boost::system::error_code error(errno, + boost::asio::error::get_system_category()); + for (int j = 0; j < max_ops; ++j) + { + while (reactor_op* op = descriptor_data->op_queue_[j].front()) + { + op->ec_ = error; + descriptor_data->op_queue_[j].pop(); + ops.push(op); + } + } + } + } + } + + lock.lock(); + timer_queues_.get_ready_timers(ops); +} + +void kqueue_reactor::interrupt() +{ + struct kevent event; + BOOST_ASIO_KQUEUE_EV_SET(&event, interrupter_.read_descriptor(), + EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, &interrupter_); + ::kevent(kqueue_fd_, &event, 1, 0, 0, 0); +} + +int kqueue_reactor::do_kqueue_create() +{ + int fd = ::kqueue(); + if (fd == -1) + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "kqueue"); + } + return fd; +} + +void kqueue_reactor::do_add_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.insert(&queue); +} + +void kqueue_reactor::do_remove_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.erase(&queue); +} + +timespec* kqueue_reactor::get_timeout(timespec& ts) +{ + // By default we will wait no longer than 5 minutes. This will ensure that + // any changes to the system clock are detected after no longer than this. + long usec = timer_queues_.wait_duration_usec(5 * 60 * 1000 * 1000); + ts.tv_sec = usec / 1000000; + ts.tv_nsec = (usec % 1000000) * 1000; + return &ts; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#undef BOOST_ASIO_KQUEUE_EV_SET + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_KQUEUE) + +#endif // BOOST_ASIO_DETAIL_IMPL_KQUEUE_REACTOR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/pipe_select_interrupter.ipp b/boost_1_45_0/boost/asio/detail/impl/pipe_select_interrupter.ipp new file mode 100644 index 0000000..f2a7291 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/pipe_select_interrupter.ipp
@@ -0,0 +1,98 @@ +// +// detail/impl/pipe_select_interrupter.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_PIPE_SELECT_INTERRUPTER_IPP +#define BOOST_ASIO_DETAIL_IMPL_PIPE_SELECT_INTERRUPTER_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) +#if !defined(__CYGWIN__) +#if !defined(__SYMBIAN32__) +#if !defined(BOOST_ASIO_HAS_EVENTFD) + +#include <fcntl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <boost/asio/detail/pipe_select_interrupter.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +pipe_select_interrupter::pipe_select_interrupter() +{ + int pipe_fds[2]; + if (pipe(pipe_fds) == 0) + { + read_descriptor_ = pipe_fds[0]; + ::fcntl(read_descriptor_, F_SETFL, O_NONBLOCK); + write_descriptor_ = pipe_fds[1]; + ::fcntl(write_descriptor_, F_SETFL, O_NONBLOCK); + } + else + { + boost::system::error_code ec(errno, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "pipe_select_interrupter"); + } +} + +pipe_select_interrupter::~pipe_select_interrupter() +{ + if (read_descriptor_ != -1) + ::close(read_descriptor_); + if (write_descriptor_ != -1) + ::close(write_descriptor_); +} + +void pipe_select_interrupter::interrupt() +{ + char byte = 0; + int result = ::write(write_descriptor_, &byte, 1); + (void)result; +} + +bool pipe_select_interrupter::reset() +{ + for (;;) + { + char data[1024]; + int bytes_read = ::read(read_descriptor_, data, sizeof(data)); + if (bytes_read < 0 && errno == EINTR) + continue; + bool was_interrupted = (bytes_read > 0); + while (bytes_read == sizeof(data)) + bytes_read = ::read(read_descriptor_, data, sizeof(data)); + return was_interrupted; + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_ASIO_HAS_EVENTFD) +#endif // !defined(__SYMBIAN32__) +#endif // !defined(__CYGWIN__) +#endif // !defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_IMPL_PIPE_SELECT_INTERRUPTER_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/posix_event.ipp b/boost_1_45_0/boost/asio/detail/impl/posix_event.ipp new file mode 100644 index 0000000..7e89b6c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/posix_event.ipp
@@ -0,0 +1,48 @@ +// +// detail/impl/posix_event.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_POSIX_EVENT_IPP +#define BOOST_ASIO_DETAIL_IMPL_POSIX_EVENT_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/posix_event.hpp> +#include <boost/asio/detail/throw_error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +posix_event::posix_event() + : signalled_(false) +{ + int error = ::pthread_cond_init(&cond_, 0); + boost::system::error_code ec(error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "event"); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_IMPL_POSIX_EVENT_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/posix_mutex.ipp b/boost_1_45_0/boost/asio/detail/impl/posix_mutex.ipp new file mode 100644 index 0000000..a4f81bb --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/posix_mutex.ipp
@@ -0,0 +1,48 @@ +// +// detail/impl/posix_mutex.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP +#define BOOST_ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/posix_mutex.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +posix_mutex::posix_mutex() +{ + int error = ::pthread_mutex_init(&mutex_, 0); + boost::system::error_code ec(error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "mutex"); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/posix_thread.ipp b/boost_1_45_0/boost/asio/detail/impl/posix_thread.ipp new file mode 100644 index 0000000..5dc41fa --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/posix_thread.ipp
@@ -0,0 +1,76 @@ +// +// detail/impl/posix_thread.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_POSIX_THREAD_IPP +#define BOOST_ASIO_DETAIL_IMPL_POSIX_THREAD_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/posix_thread.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +posix_thread::~posix_thread() +{ + if (!joined_) + ::pthread_detach(thread_); +} + +void posix_thread::join() +{ + if (!joined_) + { + ::pthread_join(thread_, 0); + joined_ = true; + } +} + +void posix_thread::start_thread(func_base* arg) +{ + int error = ::pthread_create(&thread_, 0, + boost_asio_detail_posix_thread_function, arg); + if (error != 0) + { + delete arg; + boost::system::error_code ec(error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "thread"); + } +} + +void* boost_asio_detail_posix_thread_function(void* arg) +{ + posix_thread::auto_func_base_ptr func = { + static_cast<posix_thread::func_base*>(arg) }; + func.ptr->run(); + return 0; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_IMPL_POSIX_THREAD_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/posix_tss_ptr.ipp b/boost_1_45_0/boost/asio/detail/impl/posix_tss_ptr.ipp new file mode 100644 index 0000000..1c626e5 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/posix_tss_ptr.ipp
@@ -0,0 +1,48 @@ +// +// detail/impl/posix_tss_ptr.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP +#define BOOST_ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/posix_tss_ptr.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +void posix_tss_ptr_create(pthread_key_t& key) +{ + int error = ::pthread_key_create(&key, 0); + boost::system::error_code ec(error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "tss"); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/reactive_descriptor_service.ipp b/boost_1_45_0/boost/asio/detail/impl/reactive_descriptor_service.ipp new file mode 100644 index 0000000..6f0dc5a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/reactive_descriptor_service.ipp
@@ -0,0 +1,138 @@ +// +// detail/impl/reactive_descriptor_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_REACTIVE_DESCRIPTOR_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_REACTIVE_DESCRIPTOR_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <boost/asio/error.hpp> +#include <boost/asio/detail/reactive_descriptor_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +reactive_descriptor_service::reactive_descriptor_service( + boost::asio::io_service& io_service) + : reactor_(boost::asio::use_service<reactor>(io_service)) +{ + reactor_.init_task(); +} + +void reactive_descriptor_service::shutdown_service() +{ +} + +void reactive_descriptor_service::construct( + reactive_descriptor_service::implementation_type& impl) +{ + impl.descriptor_ = -1; + impl.state_ = 0; +} + +void reactive_descriptor_service::destroy( + reactive_descriptor_service::implementation_type& impl) +{ + if (is_open(impl)) + reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_); + + boost::system::error_code ignored_ec; + descriptor_ops::close(impl.descriptor_, impl.state_, ignored_ec); +} + +boost::system::error_code reactive_descriptor_service::assign( + reactive_descriptor_service::implementation_type& impl, + const native_type& native_descriptor, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + if (int err = reactor_.register_descriptor( + native_descriptor, impl.reactor_data_)) + { + ec = boost::system::error_code(err, + boost::asio::error::get_system_category()); + return ec; + } + + impl.descriptor_ = native_descriptor; + impl.state_ = 0; + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code reactive_descriptor_service::close( + reactive_descriptor_service::implementation_type& impl, + boost::system::error_code& ec) +{ + if (is_open(impl)) + reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_); + + if (descriptor_ops::close(impl.descriptor_, impl.state_, ec) == 0) + construct(impl); + + return ec; +} + +boost::system::error_code reactive_descriptor_service::cancel( + reactive_descriptor_service::implementation_type& impl, + boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + return ec; + } + + reactor_.cancel_ops(impl.descriptor_, impl.reactor_data_); + ec = boost::system::error_code(); + return ec; +} + +void reactive_descriptor_service::start_op( + reactive_descriptor_service::implementation_type& impl, + int op_type, reactor_op* op, bool non_blocking, bool noop) +{ + if (!noop) + { + if ((impl.state_ & descriptor_ops::non_blocking) || + descriptor_ops::set_internal_non_blocking( + impl.descriptor_, impl.state_, op->ec_)) + { + reactor_.start_op(op_type, impl.descriptor_, + impl.reactor_data_, op, non_blocking); + return; + } + } + + reactor_.post_immediate_completion(op); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_IMPL_REACTIVE_DESCRIPTOR_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/reactive_serial_port_service.ipp b/boost_1_45_0/boost/asio/detail/impl/reactive_serial_port_service.ipp new file mode 100644 index 0000000..b467209 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/reactive_serial_port_service.ipp
@@ -0,0 +1,153 @@ +// +// detail/impl/reactive_serial_port_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_REACTIVE_SERIAL_PORT_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_REACTIVE_SERIAL_PORT_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_SERIAL_PORT) +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <cstring> +#include <boost/asio/detail/reactive_serial_port_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +reactive_serial_port_service::reactive_serial_port_service( + boost::asio::io_service& io_service) + : descriptor_service_(io_service) +{ +} + +void reactive_serial_port_service::shutdown_service() +{ + descriptor_service_.shutdown_service(); +} + +boost::system::error_code reactive_serial_port_service::open( + reactive_serial_port_service::implementation_type& impl, + const std::string& device, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + descriptor_ops::state_type state = 0; + int fd = descriptor_ops::open(device.c_str(), + O_RDWR | O_NONBLOCK | O_NOCTTY, ec); + if (fd < 0) + return ec; + + int s = descriptor_ops::fcntl(fd, F_GETFL, ec); + if (s >= 0) + s = descriptor_ops::fcntl(fd, F_SETFL, s | O_NONBLOCK, ec); + if (s < 0) + { + boost::system::error_code ignored_ec; + descriptor_ops::close(fd, state, ignored_ec); + return ec; + } + + // Set up default serial port options. + termios ios; + errno = 0; + s = descriptor_ops::error_wrapper(::tcgetattr(fd, &ios), ec); + if (s >= 0) + { +#if defined(_BSD_SOURCE) + ::cfmakeraw(&ios); +#else + ios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK + | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + ios.c_oflag &= ~OPOST; + ios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + ios.c_cflag &= ~(CSIZE | PARENB); + ios.c_cflag |= CS8; +#endif + ios.c_iflag |= IGNPAR; + ios.c_cflag |= CREAD | CLOCAL; + errno = 0; + s = descriptor_ops::error_wrapper(::tcsetattr(fd, TCSANOW, &ios), ec); + } + if (s < 0) + { + boost::system::error_code ignored_ec; + descriptor_ops::close(fd, state, ignored_ec); + return ec; + } + + // We're done. Take ownership of the serial port descriptor. + if (descriptor_service_.assign(impl, fd, ec)) + { + boost::system::error_code ignored_ec; + descriptor_ops::close(fd, state, ignored_ec); + } + + return ec; +} + +boost::system::error_code reactive_serial_port_service::do_set_option( + reactive_serial_port_service::implementation_type& impl, + reactive_serial_port_service::store_function_type store, + const void* option, boost::system::error_code& ec) +{ + termios ios; + errno = 0; + descriptor_ops::error_wrapper(::tcgetattr( + descriptor_service_.native(impl), &ios), ec); + if (ec) + return ec; + + if (store(option, ios, ec)) + return ec; + + errno = 0; + descriptor_ops::error_wrapper(::tcsetattr( + descriptor_service_.native(impl), TCSANOW, &ios), ec); + return ec; +} + +boost::system::error_code reactive_serial_port_service::do_get_option( + const reactive_serial_port_service::implementation_type& impl, + reactive_serial_port_service::load_function_type load, + void* option, boost::system::error_code& ec) const +{ + termios ios; + errno = 0; + descriptor_ops::error_wrapper(::tcgetattr( + descriptor_service_.native(impl), &ios), ec); + if (ec) + return ec; + + return load(option, ios, ec); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT) + +#endif // BOOST_ASIO_DETAIL_IMPL_REACTIVE_SERIAL_PORT_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/reactive_socket_service_base.ipp b/boost_1_45_0/boost/asio/detail/impl/reactive_socket_service_base.ipp new file mode 100644 index 0000000..cecbe73 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/reactive_socket_service_base.ipp
@@ -0,0 +1,214 @@ +// +// detail/reactive_socket_service_base.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_REACTIVE_SOCKET_SERVICE_BASE_IPP +#define BOOST_ASIO_DETAIL_IMPL_REACTIVE_SOCKET_SERVICE_BASE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/reactive_socket_service_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +reactive_socket_service_base::reactive_socket_service_base( + boost::asio::io_service& io_service) + : reactor_(use_service<reactor>(io_service)) +{ + reactor_.init_task(); +} + +void reactive_socket_service_base::shutdown_service() +{ +} + +void reactive_socket_service_base::construct( + reactive_socket_service_base::base_implementation_type& impl) +{ + impl.socket_ = invalid_socket; + impl.state_ = 0; +} + +void reactive_socket_service_base::destroy( + reactive_socket_service_base::base_implementation_type& impl) +{ + if (impl.socket_ != invalid_socket) + { + reactor_.close_descriptor(impl.socket_, impl.reactor_data_); + + boost::system::error_code ignored_ec; + socket_ops::close(impl.socket_, impl.state_, true, ignored_ec); + } +} + +boost::system::error_code reactive_socket_service_base::close( + reactive_socket_service_base::base_implementation_type& impl, + boost::system::error_code& ec) +{ + if (is_open(impl)) + reactor_.close_descriptor(impl.socket_, impl.reactor_data_); + + if (socket_ops::close(impl.socket_, impl.state_, true, ec) == 0) + construct(impl); + + return ec; +} + +boost::system::error_code reactive_socket_service_base::cancel( + reactive_socket_service_base::base_implementation_type& impl, + boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + return ec; + } + + reactor_.cancel_ops(impl.socket_, impl.reactor_data_); + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code reactive_socket_service_base::do_open( + reactive_socket_service_base::base_implementation_type& impl, + int af, int type, int protocol, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + socket_holder sock(socket_ops::socket(af, type, protocol, ec)); + if (sock.get() == invalid_socket) + return ec; + + if (int err = reactor_.register_descriptor(sock.get(), impl.reactor_data_)) + { + ec = boost::system::error_code(err, + boost::asio::error::get_system_category()); + return ec; + } + + impl.socket_ = sock.release(); + switch (type) + { + case SOCK_STREAM: impl.state_ = socket_ops::stream_oriented; break; + case SOCK_DGRAM: impl.state_ = socket_ops::datagram_oriented; break; + default: impl.state_ = 0; break; + } + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code reactive_socket_service_base::do_assign( + reactive_socket_service_base::base_implementation_type& impl, int type, + const reactive_socket_service_base::native_type& native_socket, + boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + if (int err = reactor_.register_descriptor( + native_socket, impl.reactor_data_)) + { + ec = boost::system::error_code(err, + boost::asio::error::get_system_category()); + return ec; + } + + impl.socket_ = native_socket; + switch (type) + { + case SOCK_STREAM: impl.state_ = socket_ops::stream_oriented; break; + case SOCK_DGRAM: impl.state_ = socket_ops::datagram_oriented; break; + default: impl.state_ = 0; break; + } + ec = boost::system::error_code(); + return ec; +} + +void reactive_socket_service_base::start_op( + reactive_socket_service_base::base_implementation_type& impl, + int op_type, reactor_op* op, bool non_blocking, bool noop) +{ + if (!noop) + { + if ((impl.state_ & socket_ops::non_blocking) + || socket_ops::set_internal_non_blocking( + impl.socket_, impl.state_, op->ec_)) + { + reactor_.start_op(op_type, impl.socket_, + impl.reactor_data_, op, non_blocking); + return; + } + } + + reactor_.post_immediate_completion(op); +} + +void reactive_socket_service_base::start_accept_op( + reactive_socket_service_base::base_implementation_type& impl, + reactor_op* op, bool peer_is_open) +{ + if (!peer_is_open) + start_op(impl, reactor::read_op, op, true, false); + else + { + op->ec_ = boost::asio::error::already_open; + reactor_.post_immediate_completion(op); + } +} + +void reactive_socket_service_base::start_connect_op( + reactive_socket_service_base::base_implementation_type& impl, + reactor_op* op, const socket_addr_type* addr, size_t addrlen) +{ + if ((impl.state_ & socket_ops::non_blocking) + || socket_ops::set_internal_non_blocking( + impl.socket_, impl.state_, op->ec_)) + { + if (socket_ops::connect(impl.socket_, addr, addrlen, op->ec_) != 0) + { + if (op->ec_ == boost::asio::error::in_progress + || op->ec_ == boost::asio::error::would_block) + { + op->ec_ = boost::system::error_code(); + reactor_.start_op(reactor::connect_op, + impl.socket_, impl.reactor_data_, op, false); + return; + } + } + } + + reactor_.post_immediate_completion(op); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_REACTIVE_SOCKET_SERVICE_BASE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/resolver_service_base.ipp b/boost_1_45_0/boost/asio/detail/impl/resolver_service_base.ipp new file mode 100644 index 0000000..d1af0be --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/resolver_service_base.ipp
@@ -0,0 +1,108 @@ +// +// detail/impl/resolver_service_base.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP +#define BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/resolver_service_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class resolver_service_base::work_io_service_runner +{ +public: + work_io_service_runner(boost::asio::io_service& io_service) + : io_service_(io_service) {} + void operator()() { io_service_.run(); } +private: + boost::asio::io_service& io_service_; +}; + +resolver_service_base::resolver_service_base( + boost::asio::io_service& io_service) + : io_service_impl_(boost::asio::use_service<io_service_impl>(io_service)), + work_io_service_(new boost::asio::io_service), + work_io_service_impl_(boost::asio::use_service< + io_service_impl>(*work_io_service_)), + work_(new boost::asio::io_service::work(*work_io_service_)), + work_thread_(0) +{ +} + +resolver_service_base::~resolver_service_base() +{ + shutdown_service(); +} + +void resolver_service_base::shutdown_service() +{ + work_.reset(); + if (work_io_service_) + { + work_io_service_->stop(); + if (work_thread_) + { + work_thread_->join(); + work_thread_.reset(); + } + work_io_service_.reset(); + } +} + +void resolver_service_base::construct( + resolver_service_base::implementation_type& impl) +{ + impl.reset(static_cast<void*>(0), socket_ops::noop_deleter()); +} + +void resolver_service_base::destroy( + resolver_service_base::implementation_type&) +{ +} + +void resolver_service_base::cancel( + resolver_service_base::implementation_type& impl) +{ + impl.reset(static_cast<void*>(0), socket_ops::noop_deleter()); +} + +void resolver_service_base::start_resolve_op(operation* op) +{ + start_work_thread(); + io_service_impl_.work_started(); + work_io_service_impl_.post_immediate_completion(op); +} + +void resolver_service_base::start_work_thread() +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + if (!work_thread_) + { + work_thread_.reset(new boost::asio::detail::thread( + work_io_service_runner(*work_io_service_))); + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_RESOLVER_SERVICE_BASE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/select_reactor.hpp b/boost_1_45_0/boost/asio/detail/impl/select_reactor.hpp new file mode 100644 index 0000000..55e064e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/select_reactor.hpp
@@ -0,0 +1,86 @@ +// +// detail/impl/select_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP +#define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) \ + || (!defined(BOOST_ASIO_HAS_DEV_POLL) \ + && !defined(BOOST_ASIO_HAS_EPOLL) \ + && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +void select_reactor::add_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_add_timer_queue(queue); +} + +// Remove a timer queue from the reactor. +template <typename Time_Traits> +void select_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue) +{ + do_remove_timer_queue(queue); +} + +template <typename Time_Traits> +void select_reactor::schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + io_service_.post_immediate_completion(op); + return; + } + + bool earliest = queue.enqueue_timer(time, timer, op); + io_service_.work_started(); + if (earliest) + interrupter_.interrupt(); +} + +template <typename Time_Traits> +std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + op_queue<operation> ops; + std::size_t n = queue.cancel_timer(timer, ops); + lock.unlock(); + io_service_.post_deferred_completions(ops); + return n; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + // || (!defined(BOOST_ASIO_HAS_DEV_POLL) + // && !defined(BOOST_ASIO_HAS_EPOLL) + // && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/select_reactor.ipp b/boost_1_45_0/boost/asio/detail/impl/select_reactor.ipp new file mode 100644 index 0000000..af6e6c1 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/select_reactor.ipp
@@ -0,0 +1,275 @@ +// +// detail/impl/select_reactor.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_IPP +#define BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) \ + || (!defined(BOOST_ASIO_HAS_DEV_POLL) \ + && !defined(BOOST_ASIO_HAS_EPOLL) \ + && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/fd_set_adapter.hpp> +#include <boost/asio/detail/select_reactor.hpp> +#include <boost/asio/detail/signal_blocker.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +select_reactor::select_reactor(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<select_reactor>(io_service), + io_service_(use_service<io_service_impl>(io_service)), + mutex_(), + interrupter_(), +#if defined(BOOST_ASIO_HAS_IOCP) + stop_thread_(false), + thread_(0), +#endif // defined(BOOST_ASIO_HAS_IOCP) + shutdown_(false) +{ +#if defined(BOOST_ASIO_HAS_IOCP) + boost::asio::detail::signal_blocker sb; + thread_ = new boost::asio::detail::thread( + bind_handler(&select_reactor::call_run_thread, this)); +#endif // defined(BOOST_ASIO_HAS_IOCP) +} + +select_reactor::~select_reactor() +{ + shutdown_service(); +} + +void select_reactor::shutdown_service() +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + shutdown_ = true; +#if defined(BOOST_ASIO_HAS_IOCP) + stop_thread_ = true; +#endif // defined(BOOST_ASIO_HAS_IOCP) + lock.unlock(); + +#if defined(BOOST_ASIO_HAS_IOCP) + if (thread_) + { + interrupter_.interrupt(); + thread_->join(); + delete thread_; + thread_ = 0; + } +#endif // defined(BOOST_ASIO_HAS_IOCP) + + op_queue<operation> ops; + + for (int i = 0; i < max_ops; ++i) + op_queue_[i].get_all_operations(ops); + + timer_queues_.get_all_timers(ops); +} + +void select_reactor::init_task() +{ + io_service_.init_task(); +} + +int select_reactor::register_descriptor(socket_type, + select_reactor::per_descriptor_data&) +{ + return 0; +} + +void select_reactor::start_op(int op_type, socket_type descriptor, + select_reactor::per_descriptor_data&, reactor_op* op, bool) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (shutdown_) + { + post_immediate_completion(op); + return; + } + + bool first = op_queue_[op_type].enqueue_operation(descriptor, op); + io_service_.work_started(); + if (first) + interrupter_.interrupt(); +} + +void select_reactor::cancel_ops(socket_type descriptor, + select_reactor::per_descriptor_data&) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted); +} + +void select_reactor::close_descriptor(socket_type descriptor, + select_reactor::per_descriptor_data&) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted); +} + +void select_reactor::run(bool block, op_queue<operation>& ops) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + +#if defined(BOOST_ASIO_HAS_IOCP) + // Check if the thread is supposed to stop. + if (stop_thread_) + return; +#endif // defined(BOOST_ASIO_HAS_IOCP) + + // Set up the descriptor sets. + fd_set_adapter fds[max_select_ops]; + fds[read_op].set(interrupter_.read_descriptor()); + socket_type max_fd = 0; + bool have_work_to_do = !timer_queues_.all_empty(); + for (int i = 0; i < max_select_ops; ++i) + { + have_work_to_do = have_work_to_do || !op_queue_[i].empty(); + op_queue_[i].get_descriptors(fds[i], ops); + if (fds[i].max_descriptor() > max_fd) + max_fd = fds[i].max_descriptor(); + } + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Connection operations on Windows use both except and write fd_sets. + have_work_to_do = have_work_to_do || !op_queue_[connect_op].empty(); + op_queue_[connect_op].get_descriptors(fds[write_op], ops); + if (fds[write_op].max_descriptor() > max_fd) + max_fd = fds[write_op].max_descriptor(); + op_queue_[connect_op].get_descriptors(fds[except_op], ops); + if (fds[except_op].max_descriptor() > max_fd) + max_fd = fds[except_op].max_descriptor(); +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + + // We can return immediately if there's no work to do and the reactor is + // not supposed to block. + if (!block && !have_work_to_do) + return; + + // Determine how long to block while waiting for events. + timeval tv_buf = { 0, 0 }; + timeval* tv = block ? get_timeout(tv_buf) : &tv_buf; + + lock.unlock(); + + // Block on the select call until descriptors become ready. + boost::system::error_code ec; + int retval = socket_ops::select(static_cast<int>(max_fd + 1), + fds[read_op], fds[write_op], fds[except_op], tv, ec); + + // Reset the interrupter. + if (retval > 0 && fds[read_op].is_set(interrupter_.read_descriptor())) + interrupter_.reset(); + + lock.lock(); + + // Dispatch all ready operations. + if (retval > 0) + { +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Connection operations on Windows use both except and write fd_sets. + op_queue_[connect_op].perform_operations_for_descriptors( + fds[except_op], ops); + op_queue_[connect_op].perform_operations_for_descriptors( + fds[write_op], ops); +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + + // Exception operations must be processed first to ensure that any + // out-of-band data is read before normal data. + for (int i = max_select_ops - 1; i >= 0; --i) + op_queue_[i].perform_operations_for_descriptors(fds[i], ops); + } + timer_queues_.get_ready_timers(ops); +} + +void select_reactor::interrupt() +{ + interrupter_.interrupt(); +} + +#if defined(BOOST_ASIO_HAS_IOCP) +void select_reactor::run_thread() +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + while (!stop_thread_) + { + lock.unlock(); + op_queue<operation> ops; + run(true, ops); + io_service_.post_deferred_completions(ops); + lock.lock(); + } +} + +void select_reactor::call_run_thread(select_reactor* reactor) +{ + reactor->run_thread(); +} +#endif // defined(BOOST_ASIO_HAS_IOCP) + +void select_reactor::do_add_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.insert(&queue); +} + +void select_reactor::do_remove_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(mutex_); + timer_queues_.erase(&queue); +} + +timeval* select_reactor::get_timeout(timeval& tv) +{ + // By default we will wait no longer than 5 minutes. This will ensure that + // any changes to the system clock are detected after no longer than this. + long usec = timer_queues_.wait_duration_usec(5 * 60 * 1000 * 1000); + tv.tv_sec = usec / 1000000; + tv.tv_usec = usec % 1000000; + return &tv; +} + +void select_reactor::cancel_ops_unlocked(socket_type descriptor, + const boost::system::error_code& ec) +{ + bool need_interrupt = false; + op_queue<operation> ops; + for (int i = 0; i < max_ops; ++i) + need_interrupt = op_queue_[i].cancel_operations( + descriptor, ops, ec) || need_interrupt; + io_service_.post_deferred_completions(ops); + if (need_interrupt) + interrupter_.interrupt(); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + // || (!defined(BOOST_ASIO_HAS_DEV_POLL) + // && !defined(BOOST_ASIO_HAS_EPOLL) + // && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#endif // BOOST_ASIO_DETAIL_IMPL_SELECT_REACTOR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/service_registry.hpp b/boost_1_45_0/boost/asio/detail/impl/service_registry.hpp new file mode 100644 index 0000000..59eb3f7 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/service_registry.hpp
@@ -0,0 +1,72 @@ +// +// detail/impl/service_registry.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_HPP +#define BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Service> +Service& service_registry::use_service() +{ + boost::asio::io_service::service::key key; + init_key(key, Service::id); + factory_type factory = &service_registry::create<Service>; + return *static_cast<Service*>(do_use_service(key, factory)); +} + +template <typename Service> +void service_registry::add_service(Service* new_service) +{ + boost::asio::io_service::service::key key; + init_key(key, Service::id); + return do_add_service(key, new_service); +} + +template <typename Service> +bool service_registry::has_service() const +{ + boost::asio::io_service::service::key key; + init_key(key, Service::id); + return do_has_service(key); +} + +#if !defined(BOOST_ASIO_NO_TYPEID) +template <typename Service> +void service_registry::init_key(boost::asio::io_service::service::key& key, + const boost::asio::detail::service_id<Service>& /*id*/) +{ + key.type_info_ = &typeid(typeid_wrapper<Service>); + key.id_ = 0; +} +#endif // !defined(BOOST_ASIO_NO_TYPEID) + +template <typename Service> +boost::asio::io_service::service* service_registry::create( + boost::asio::io_service& owner) +{ + return new Service(owner); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/service_registry.ipp b/boost_1_45_0/boost/asio/detail/impl/service_registry.ipp new file mode 100644 index 0000000..9f7381e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/service_registry.ipp
@@ -0,0 +1,166 @@ +// +// detail/impl/service_registry.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_IPP +#define BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/throw_exception.hpp> +#include <boost/asio/detail/service_registry.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +service_registry::service_registry(boost::asio::io_service& o) + : owner_(o), + first_service_(0) +{ +} + +service_registry::~service_registry() +{ + // Shutdown all services. This must be done in a separate loop before the + // services are destroyed since the destructors of user-defined handler + // objects may try to access other service objects. + boost::asio::io_service::service* service = first_service_; + while (service) + { + service->shutdown_service(); + service = service->next_; + } + + // Destroy all services. + while (first_service_) + { + boost::asio::io_service::service* next_service = first_service_->next_; + destroy(first_service_); + first_service_ = next_service; + } +} + +void service_registry::init_key(boost::asio::io_service::service::key& key, + const boost::asio::io_service::id& id) +{ + key.type_info_ = 0; + key.id_ = &id; +} + +bool service_registry::keys_match( + const boost::asio::io_service::service::key& key1, + const boost::asio::io_service::service::key& key2) +{ + if (key1.id_ && key2.id_) + if (key1.id_ == key2.id_) + return true; + if (key1.type_info_ && key2.type_info_) + if (*key1.type_info_ == *key2.type_info_) + return true; + return false; +} + +void service_registry::destroy(boost::asio::io_service::service* service) +{ + delete service; +} + +boost::asio::io_service::service* service_registry::do_use_service( + const boost::asio::io_service::service::key& key, + factory_type factory) +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + // First see if there is an existing service object with the given key. + boost::asio::io_service::service* service = first_service_; + while (service) + { + if (keys_match(service->key_, key)) + return service; + service = service->next_; + } + + // Create a new service object. The service registry's mutex is not locked + // at this time to allow for nested calls into this function from the new + // service's constructor. + lock.unlock(); + auto_service_ptr new_service = { factory(owner_) }; + new_service.ptr_->key_ = key; + lock.lock(); + + // Check that nobody else created another service object of the same type + // while the lock was released. + service = first_service_; + while (service) + { + if (keys_match(service->key_, key)) + return service; + service = service->next_; + } + + // Service was successfully initialised, pass ownership to registry. + new_service.ptr_->next_ = first_service_; + first_service_ = new_service.ptr_; + new_service.ptr_ = 0; + return first_service_; +} + +void service_registry::do_add_service( + const boost::asio::io_service::service::key& key, + boost::asio::io_service::service* new_service) +{ + if (&owner_ != &new_service->io_service()) + boost::throw_exception(invalid_service_owner()); + + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + // Check if there is an existing service object with the given key. + boost::asio::io_service::service* service = first_service_; + while (service) + { + if (keys_match(service->key_, key)) + boost::throw_exception(service_already_exists()); + service = service->next_; + } + + // Take ownership of the service object. + new_service->key_ = key; + new_service->next_ = first_service_; + first_service_ = new_service; +} + +bool service_registry::do_has_service( + const boost::asio::io_service::service::key& key) const +{ + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + boost::asio::io_service::service* service = first_service_; + while (service) + { + if (keys_match(service->key_, key)) + return true; + service = service->next_; + } + + return false; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_SERVICE_REGISTRY_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/socket_ops.ipp b/boost_1_45_0/boost/asio/detail/impl/socket_ops.ipp new file mode 100644 index 0000000..5ac052a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/socket_ops.ipp
@@ -0,0 +1,2865 @@ +// +// detail/impl/socket_ops.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_OPS_IPP +#define BOOST_ASIO_DETAIL_SOCKET_OPS_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/assert.hpp> +#include <boost/detail/workaround.hpp> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <cerrno> +#include <new> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace socket_ops { + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +struct msghdr { int msg_namelen; }; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#if defined(__hpux) +// HP-UX doesn't declare these functions extern "C", so they are declared again +// here to avoid linker errors about undefined symbols. +extern "C" char* if_indextoname(unsigned int, char*); +extern "C" unsigned int if_nametoindex(const char*); +#endif // defined(__hpux) + +inline void clear_last_error() +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + WSASetLastError(0); +#else + errno = 0; +#endif +} + +template <typename ReturnType> +inline ReturnType error_wrapper(ReturnType return_value, + boost::system::error_code& ec) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + ec = boost::system::error_code(WSAGetLastError(), + boost::asio::error::get_system_category()); +#else + ec = boost::system::error_code(errno, + boost::asio::error::get_system_category()); +#endif + return return_value; +} + +template <typename SockLenType> +inline socket_type call_accept(SockLenType msghdr::*, + socket_type s, socket_addr_type* addr, std::size_t* addrlen) +{ + SockLenType tmp_addrlen = addrlen ? (SockLenType)*addrlen : 0; + socket_type result = ::accept(s, addr, addrlen ? &tmp_addrlen : 0); + if (addrlen) + *addrlen = (std::size_t)tmp_addrlen; + return result; +} + +socket_type accept(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return invalid_socket; + } + + clear_last_error(); + + socket_type new_s = error_wrapper(call_accept( + &msghdr::msg_namelen, s, addr, addrlen), ec); + if (new_s == invalid_socket) + return new_s; + +#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__) + int optval = 1; + int result = error_wrapper(::setsockopt(new_s, + SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval)), ec); + if (result != 0) + { + ::close(new_s); + return invalid_socket; + } +#endif + + ec = boost::system::error_code(); + return new_s; +} + +socket_type sync_accept(socket_type s, state_type state, + socket_addr_type* addr, std::size_t* addrlen, boost::system::error_code& ec) +{ + // Accept a socket. + for (;;) + { + // Try to complete the operation without blocking. + socket_type new_socket = socket_ops::accept(s, addr, addrlen, ec); + + // Check if operation succeeded. + if (new_socket != invalid_socket) + return new_socket; + + // Operation failed. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + { + if (state & user_set_non_blocking) + return invalid_socket; + // Fall through to retry operation. + } + else if (ec == boost::asio::error::connection_aborted) + { + if (state & enable_connection_aborted) + return invalid_socket; + // Fall through to retry operation. + } +#if defined(EPROTO) + else if (ec.value() == EPROTO) + { + if (state & enable_connection_aborted) + return invalid_socket; + // Fall through to retry operation. + } +#endif // defined(EPROTO) + else + return invalid_socket; + + // Wait for socket to become ready. + if (socket_ops::poll_read(s, ec) < 0) + return invalid_socket; + } +} + +#if defined(BOOST_ASIO_HAS_IOCP) + +void complete_iocp_accept(socket_type s, + void* output_buffer, DWORD address_length, + socket_addr_type* addr, std::size_t* addrlen, + socket_type new_socket, boost::system::error_code& ec) +{ + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_NETNAME_DELETED) + ec = boost::asio::error::connection_aborted; + + if (!ec) + { + // Get the address of the peer. + if (addr && addrlen) + { + LPSOCKADDR local_addr = 0; + int local_addr_length = 0; + LPSOCKADDR remote_addr = 0; + int remote_addr_length = 0; + GetAcceptExSockaddrs(output_buffer, 0, address_length, + address_length, &local_addr, &local_addr_length, + &remote_addr, &remote_addr_length); + if (static_cast<std::size_t>(remote_addr_length) > *addrlen) + { + ec = boost::asio::error::invalid_argument; + } + else + { + using namespace std; // For memcpy. + memcpy(addr, remote_addr, remote_addr_length); + *addrlen = static_cast<std::size_t>(remote_addr_length); + } + } + + // Need to set the SO_UPDATE_ACCEPT_CONTEXT option so that getsockname + // and getpeername will work on the accepted socket. + SOCKET update_ctx_param = s; + socket_ops::state_type state = 0; + socket_ops::setsockopt(new_socket, state, + SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, + &update_ctx_param, sizeof(SOCKET), ec); + } +} + +#else // defined(BOOST_ASIO_HAS_IOCP) + +bool non_blocking_accept(socket_type s, + state_type state, socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec, socket_type& new_socket) +{ + for (;;) + { + // Accept the waiting connection. + new_socket = socket_ops::accept(s, addr, addrlen, ec); + + // Check if operation succeeded. + if (new_socket != invalid_socket) + return true; + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Operation failed. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + { + if (state & user_set_non_blocking) + return true; + // Fall through to retry operation. + } + else if (ec == boost::asio::error::connection_aborted) + { + if (state & enable_connection_aborted) + return true; + // Fall through to retry operation. + } +#if defined(EPROTO) + else if (ec.value() == EPROTO) + { + if (state & enable_connection_aborted) + return true; + // Fall through to retry operation. + } +#endif // defined(EPROTO) + else + return true; + + return false; + } +} + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +template <typename SockLenType> +inline int call_bind(SockLenType msghdr::*, + socket_type s, const socket_addr_type* addr, std::size_t addrlen) +{ + return ::bind(s, addr, (SockLenType)addrlen); +} + +int bind(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); + int result = error_wrapper(call_bind( + &msghdr::msg_namelen, s, addr, addrlen), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +int close(socket_type s, state_type& state, + bool destruction, boost::system::error_code& ec) +{ + int result = 0; + if (s != invalid_socket) + { +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if ((state & non_blocking) && (state & user_set_linger)) + { + ioctl_arg_type arg = 0; + ::ioctlsocket(s, FIONBIO, &arg); + state &= ~non_blocking; + } +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if (state & non_blocking) + { +#if defined(__SYMBIAN32__) + int flags = ::fcntl(s, F_GETFL, 0); + if (flags >= 0) + ::fcntl(s, F_SETFL, flags & ~O_NONBLOCK); +#else // defined(__SYMBIAN32__) + ioctl_arg_type arg = 0; + ::ioctl(s, FIONBIO, &arg); +#endif // defined(__SYMBIAN32__) + state &= ~non_blocking; + } +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + + if (destruction && (state & user_set_linger)) + { + ::linger opt; + opt.l_onoff = 0; + opt.l_linger = 0; + boost::system::error_code ignored_ec; + socket_ops::setsockopt(s, state, SOL_SOCKET, + SO_LINGER, &opt, sizeof(opt), ignored_ec); + } + + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + result = error_wrapper(::closesocket(s), ec); +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + result = error_wrapper(::close(s), ec); +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + } + + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +bool set_internal_non_blocking(socket_type s, + state_type& state, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return false; + } + + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + ioctl_arg_type arg = 1; + int result = error_wrapper(::ioctlsocket(s, FIONBIO, &arg), ec); +#elif defined(__SYMBIAN32__) + int result = error_wrapper(::fcntl(s, F_GETFL, 0), ec); + if (result >= 0) + { + clear_last_error(); + result = error_wrapper(::fcntl(s, F_SETFL, result | O_NONBLOCK), ec); + } +#else + ioctl_arg_type arg = 1; + int result = error_wrapper(::ioctl(s, FIONBIO, &arg), ec); +#endif + + if (result >= 0) + { + ec = boost::system::error_code(); + state |= internal_non_blocking; + return true; + } + + return false; +} + +int shutdown(socket_type s, int what, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); + int result = error_wrapper(::shutdown(s, what), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +template <typename SockLenType> +inline int call_connect(SockLenType msghdr::*, + socket_type s, const socket_addr_type* addr, std::size_t addrlen) +{ + return ::connect(s, addr, (SockLenType)addrlen); +} + +int connect(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); + int result = error_wrapper(call_connect( + &msghdr::msg_namelen, s, addr, addrlen), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +void sync_connect(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec) +{ + // Perform the connect operation. + socket_ops::connect(s, addr, addrlen, ec); + if (ec != boost::asio::error::in_progress + && ec != boost::asio::error::would_block) + { + // The connect operation finished immediately. + return; + } + + // Wait for socket to become ready. + if (socket_ops::poll_connect(s, ec) < 0) + return; + + // Get the error code from the connect operation. + int connect_error = 0; + size_t connect_error_len = sizeof(connect_error); + if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_ERROR, + &connect_error, &connect_error_len, ec) == socket_error_retval) + return; + + // Return the result of the connect operation. + ec = boost::system::error_code(connect_error, + boost::asio::error::get_system_category()); +} + +bool non_blocking_connect(socket_type s, boost::system::error_code& ec) +{ + // Get the error code from the connect operation. + int connect_error = 0; + size_t connect_error_len = sizeof(connect_error); + if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_ERROR, + &connect_error, &connect_error_len, ec) == 0) + { + if (connect_error) + { + ec = boost::system::error_code(connect_error, + boost::asio::error::get_system_category()); + } + else + ec = boost::system::error_code(); + } + + return true; +} + +int socketpair(int af, int type, int protocol, + socket_type sv[2], boost::system::error_code& ec) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + (void)(af); + (void)(type); + (void)(protocol); + (void)(sv); + ec = boost::asio::error::operation_not_supported; + return socket_error_retval; +#else + clear_last_error(); + int result = error_wrapper(::socketpair(af, type, protocol, sv), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +#endif +} + +bool sockatmark(socket_type s, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return false; + } + +#if defined(SIOCATMARK) + ioctl_arg_type value = 0; +# if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::ioctlsocket(s, SIOCATMARK, &value), ec); +# else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::ioctl(s, SIOCATMARK, &value), ec); +# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if (result == 0) + ec = boost::system::error_code(); +# if defined(ENOTTY) + if (ec.value() == ENOTTY) + ec = boost::asio::error::not_socket; +# endif // defined(ENOTTY) +#else // defined(SIOCATMARK) + int value = error_wrapper(::sockatmark(s), ec); + if (value != -1) + ec = boost::system::error_code(); +#endif // defined(SIOCATMARK) + + return ec ? false : value != 0; +} + +size_t available(socket_type s, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + ioctl_arg_type value = 0; +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::ioctlsocket(s, FIONREAD, &value), ec); +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::ioctl(s, FIONREAD, &value), ec); +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if (result == 0) + ec = boost::system::error_code(); +#if defined(ENOTTY) + if (ec.value() == ENOTTY) + ec = boost::asio::error::not_socket; +#endif // defined(ENOTTY) + + return ec ? static_cast<size_t>(0) : static_cast<size_t>(value); +} + +int listen(socket_type s, int backlog, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); + int result = error_wrapper(::listen(s, backlog), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +inline void init_buf_iov_base(void*& base, void* addr) +{ + base = addr; +} + +template <typename T> +inline void init_buf_iov_base(T& base, void* addr) +{ + base = static_cast<T>(addr); +} + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef WSABUF buf; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef iovec buf; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +void init_buf(buf& b, void* data, size_t size) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + b.buf = static_cast<char*>(data); + b.len = static_cast<u_long>(size); +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + init_buf_iov_base(b.iov_base, data); + b.iov_len = size; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +void init_buf(buf& b, const void* data, size_t size) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + b.buf = static_cast<char*>(const_cast<void*>(data)); + b.len = static_cast<u_long>(size); +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + init_buf_iov_base(b.iov_base, const_cast<void*>(data)); + b.iov_len = size; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +inline void init_msghdr_msg_name(void*& name, socket_addr_type* addr) +{ + name = addr; +} + +inline void init_msghdr_msg_name(void*& name, const socket_addr_type* addr) +{ + name = const_cast<socket_addr_type*>(addr); +} + +template <typename T> +inline void init_msghdr_msg_name(T& name, socket_addr_type* addr) +{ + name = reinterpret_cast<T>(addr); +} + +template <typename T> +inline void init_msghdr_msg_name(T& name, const socket_addr_type* addr) +{ + name = reinterpret_cast<T>(const_cast<socket_addr_type*>(addr)); +} + +int recv(socket_type s, buf* bufs, size_t count, int flags, + boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Receive some data. + DWORD recv_buf_count = static_cast<DWORD>(count); + DWORD bytes_transferred = 0; + DWORD recv_flags = flags; + int result = error_wrapper(::WSARecv(s, bufs, + recv_buf_count, &bytes_transferred, &recv_flags, 0, 0), ec); + if (ec.value() == ERROR_NETNAME_DELETED) + ec = boost::asio::error::connection_reset; + else if (ec.value() == ERROR_PORT_UNREACHABLE) + ec = boost::asio::error::connection_refused; + if (result != 0) + return socket_error_retval; + ec = boost::system::error_code(); + return bytes_transferred; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + msghdr msg = msghdr(); + msg.msg_iov = bufs; + msg.msg_iovlen = count; + int result = error_wrapper(::recvmsg(s, &msg, flags), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +size_t sync_recv(socket_type s, state_type state, buf* bufs, + size_t count, int flags, bool all_empty, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to read 0 bytes on a stream is a no-op. + if (all_empty && (state & stream_oriented)) + { + ec = boost::system::error_code(); + return 0; + } + + // Read some data. + for (;;) + { + // Try to complete the operation without blocking. + int bytes = socket_ops::recv(s, bufs, count, flags, ec); + + // Check if operation succeeded. + if (bytes > 0) + return bytes; + + // Check for EOF. + if ((state & stream_oriented) && bytes == 0) + { + ec = boost::asio::error::eof; + return 0; + } + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for socket to become ready. + if (socket_ops::poll_read(s, ec) < 0) + return 0; + } +} + +#if defined(BOOST_ASIO_HAS_IOCP) + +void complete_iocp_recv(state_type state, + const weak_cancel_token_type& cancel_token, bool all_empty, + boost::system::error_code& ec, size_t bytes_transferred) +{ + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_NETNAME_DELETED) + { + if (cancel_token.expired()) + ec = boost::asio::error::operation_aborted; + else + ec = boost::asio::error::connection_reset; + } + else if (ec.value() == ERROR_PORT_UNREACHABLE) + { + ec = boost::asio::error::connection_refused; + } + + // Check for connection closed. + else if (!ec && bytes_transferred == 0 + && (state & stream_oriented) != 0 + && !all_empty) + { + ec = boost::asio::error::eof; + } +} + +#else // defined(BOOST_ASIO_HAS_IOCP) + +bool non_blocking_recv(socket_type s, + buf* bufs, size_t count, int flags, bool is_stream, + boost::system::error_code& ec, size_t& bytes_transferred) +{ + for (;;) + { + // Read some data. + int bytes = socket_ops::recv(s, bufs, count, flags, ec); + + // Check for end of stream. + if (is_stream && bytes == 0) + { + ec = boost::asio::error::eof; + return true; + } + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes >= 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +int recvfrom(socket_type s, buf* bufs, size_t count, int flags, + socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Receive some data. + DWORD recv_buf_count = static_cast<DWORD>(count); + DWORD bytes_transferred = 0; + DWORD recv_flags = flags; + int tmp_addrlen = (int)*addrlen; + int result = error_wrapper(::WSARecvFrom(s, bufs, recv_buf_count, + &bytes_transferred, &recv_flags, addr, &tmp_addrlen, 0, 0), ec); + *addrlen = (std::size_t)tmp_addrlen; + if (ec.value() == ERROR_NETNAME_DELETED) + ec = boost::asio::error::connection_reset; + else if (ec.value() == ERROR_PORT_UNREACHABLE) + ec = boost::asio::error::connection_refused; + if (result != 0) + return socket_error_retval; + ec = boost::system::error_code(); + return bytes_transferred; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + msghdr msg = msghdr(); + init_msghdr_msg_name(msg.msg_name, addr); + msg.msg_namelen = *addrlen; + msg.msg_iov = bufs; + msg.msg_iovlen = count; + int result = error_wrapper(::recvmsg(s, &msg, flags), ec); + *addrlen = msg.msg_namelen; + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +size_t sync_recvfrom(socket_type s, state_type state, buf* bufs, + size_t count, int flags, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // Read some data. + for (;;) + { + // Try to complete the operation without blocking. + int bytes = socket_ops::recvfrom(s, bufs, count, flags, addr, addrlen, ec); + + // Check if operation succeeded. + if (bytes >= 0) + return bytes; + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for socket to become ready. + if (socket_ops::poll_read(s, ec) < 0) + return 0; + } +} + +#if defined(BOOST_ASIO_HAS_IOCP) + +void complete_iocp_recvfrom( + const weak_cancel_token_type& cancel_token, + boost::system::error_code& ec) +{ + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_NETNAME_DELETED) + { + if (cancel_token.expired()) + ec = boost::asio::error::operation_aborted; + else + ec = boost::asio::error::connection_reset; + } + else if (ec.value() == ERROR_PORT_UNREACHABLE) + { + ec = boost::asio::error::connection_refused; + } +} + +#else // defined(BOOST_ASIO_HAS_IOCP) + +bool non_blocking_recvfrom(socket_type s, + buf* bufs, size_t count, int flags, + socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec, size_t& bytes_transferred) +{ + for (;;) + { + // Read some data. + int bytes = socket_ops::recvfrom(s, bufs, count, flags, addr, addrlen, ec); + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes >= 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +int send(socket_type s, const buf* bufs, size_t count, int flags, + boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Send the data. + DWORD send_buf_count = static_cast<DWORD>(count); + DWORD bytes_transferred = 0; + DWORD send_flags = flags; + int result = error_wrapper(::WSASend(s, const_cast<buf*>(bufs), + send_buf_count, &bytes_transferred, send_flags, 0, 0), ec); + if (ec.value() == ERROR_NETNAME_DELETED) + ec = boost::asio::error::connection_reset; + else if (ec.value() == ERROR_PORT_UNREACHABLE) + ec = boost::asio::error::connection_refused; + if (result != 0) + return socket_error_retval; + ec = boost::system::error_code(); + return bytes_transferred; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + msghdr msg = msghdr(); + msg.msg_iov = const_cast<buf*>(bufs); + msg.msg_iovlen = count; +#if defined(__linux__) + flags |= MSG_NOSIGNAL; +#endif // defined(__linux__) + int result = error_wrapper(::sendmsg(s, &msg, flags), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +size_t sync_send(socket_type s, state_type state, const buf* bufs, + size_t count, int flags, bool all_empty, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to write 0 bytes to a stream is a no-op. + if (all_empty && (state & stream_oriented)) + { + ec = boost::system::error_code(); + return 0; + } + + // Read some data. + for (;;) + { + // Try to complete the operation without blocking. + int bytes = socket_ops::send(s, bufs, count, flags, ec); + + // Check if operation succeeded. + if (bytes >= 0) + return bytes; + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for socket to become ready. + if (socket_ops::poll_write(s, ec) < 0) + return 0; + } +} + +#if defined(BOOST_ASIO_HAS_IOCP) + +void complete_iocp_send( + const weak_cancel_token_type& cancel_token, + boost::system::error_code& ec) +{ + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_NETNAME_DELETED) + { + if (cancel_token.expired()) + ec = boost::asio::error::operation_aborted; + else + ec = boost::asio::error::connection_reset; + } + else if (ec.value() == ERROR_PORT_UNREACHABLE) + { + ec = boost::asio::error::connection_refused; + } +} + +#else // defined(BOOST_ASIO_HAS_IOCP) + +bool non_blocking_send(socket_type s, + const buf* bufs, size_t count, int flags, + boost::system::error_code& ec, size_t& bytes_transferred) +{ + for (;;) + { + // Write some data. + int bytes = socket_ops::send(s, bufs, count, flags, ec); + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes >= 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +int sendto(socket_type s, const buf* bufs, size_t count, int flags, + const socket_addr_type* addr, std::size_t addrlen, + boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // Send the data. + DWORD send_buf_count = static_cast<DWORD>(count); + DWORD bytes_transferred = 0; + int result = error_wrapper(::WSASendTo(s, const_cast<buf*>(bufs), + send_buf_count, &bytes_transferred, flags, addr, + static_cast<int>(addrlen), 0, 0), ec); + if (ec.value() == ERROR_NETNAME_DELETED) + ec = boost::asio::error::connection_reset; + else if (ec.value() == ERROR_PORT_UNREACHABLE) + ec = boost::asio::error::connection_refused; + if (result != 0) + return socket_error_retval; + ec = boost::system::error_code(); + return bytes_transferred; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + msghdr msg = msghdr(); + init_msghdr_msg_name(msg.msg_name, addr); + msg.msg_namelen = addrlen; + msg.msg_iov = const_cast<buf*>(bufs); + msg.msg_iovlen = count; +#if defined(__linux__) + flags |= MSG_NOSIGNAL; +#endif // defined(__linux__) + int result = error_wrapper(::sendmsg(s, &msg, flags), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +size_t sync_sendto(socket_type s, state_type state, const buf* bufs, + size_t count, int flags, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // Write some data. + for (;;) + { + // Try to complete the operation without blocking. + int bytes = socket_ops::sendto(s, bufs, count, flags, addr, addrlen, ec); + + // Check if operation succeeded. + if (bytes >= 0) + return bytes; + + // Operation failed. + if ((state & user_set_non_blocking) + || (ec != boost::asio::error::would_block + && ec != boost::asio::error::try_again)) + return 0; + + // Wait for socket to become ready. + if (socket_ops::poll_write(s, ec) < 0) + return 0; + } +} + +#if !defined(BOOST_ASIO_HAS_IOCP) + +bool non_blocking_sendto(socket_type s, + const buf* bufs, size_t count, int flags, + const socket_addr_type* addr, std::size_t addrlen, + boost::system::error_code& ec, size_t& bytes_transferred) +{ + for (;;) + { + // Write some data. + int bytes = socket_ops::sendto(s, bufs, count, flags, addr, addrlen, ec); + + // Retry operation if interrupted by signal. + if (ec == boost::asio::error::interrupted) + continue; + + // Check if we need to run the operation again. + if (ec == boost::asio::error::would_block + || ec == boost::asio::error::try_again) + return false; + + // Operation is complete. + if (bytes >= 0) + { + ec = boost::system::error_code(); + bytes_transferred = bytes; + } + else + bytes_transferred = 0; + + return true; + } +} + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +socket_type socket(int af, int type, int protocol, + boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + socket_type s = error_wrapper(::WSASocket(af, type, protocol, 0, 0, + WSA_FLAG_OVERLAPPED), ec); + if (s == invalid_socket) + return s; + + if (af == AF_INET6) + { + // Try to enable the POSIX default behaviour of having IPV6_V6ONLY set to + // false. This will only succeed on Windows Vista and later versions of + // Windows, where a dual-stack IPv4/v6 implementation is available. + DWORD optval = 0; + ::setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + reinterpret_cast<const char*>(&optval), sizeof(optval)); + } + + ec = boost::system::error_code(); + + return s; +#elif defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__) + socket_type s = error_wrapper(::socket(af, type, protocol), ec); + if (s == invalid_socket) + return s; + + int optval = 1; + int result = error_wrapper(::setsockopt(s, + SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval)), ec); + if (result != 0) + { + ::close(s); + return invalid_socket; + } + + return s; +#else + int s = error_wrapper(::socket(af, type, protocol), ec); + if (s >= 0) + ec = boost::system::error_code(); + return s; +#endif +} + +template <typename SockLenType> +inline int call_setsockopt(SockLenType msghdr::*, + socket_type s, int level, int optname, + const void* optval, std::size_t optlen) +{ + return ::setsockopt(s, level, optname, + (const char*)optval, (SockLenType)optlen); +} + +int setsockopt(socket_type s, state_type& state, int level, int optname, + const void* optval, std::size_t optlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + if (level == custom_socket_option_level && optname == always_fail_option) + { + ec = boost::asio::error::invalid_argument; + return socket_error_retval; + } + + if (level == custom_socket_option_level + && optname == enable_connection_aborted_option) + { + if (optlen != sizeof(int)) + { + ec = boost::asio::error::invalid_argument; + return socket_error_retval; + } + + if (*static_cast<const int*>(optval)) + state |= enable_connection_aborted; + else + state &= ~enable_connection_aborted; + ec = boost::system::error_code(); + return 0; + } + + if (level == SOL_SOCKET && optname == SO_LINGER) + state |= user_set_linger; + +#if defined(__BORLANDC__) + // Mysteriously, using the getsockopt and setsockopt functions directly with + // Borland C++ results in incorrect values being set and read. The bug can be + // worked around by using function addresses resolved with GetProcAddress. + if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32")) + { + typedef int (WSAAPI *sso_t)(SOCKET, int, int, const char*, int); + if (sso_t sso = (sso_t)::GetProcAddress(winsock_module, "setsockopt")) + { + clear_last_error(); + return error_wrapper(sso(s, level, optname, + reinterpret_cast<const char*>(optval), + static_cast<int>(optlen)), ec); + } + } + ec = boost::asio::error::fault; + return socket_error_retval; +#else // defined(__BORLANDC__) + clear_last_error(); + int result = error_wrapper(call_setsockopt(&msghdr::msg_namelen, + s, level, optname, optval, optlen), ec); + if (result == 0) + { + ec = boost::system::error_code(); + +#if defined(__MACH__) && defined(__APPLE__) \ + || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) + // To implement portable behaviour for SO_REUSEADDR with UDP sockets we + // need to also set SO_REUSEPORT on BSD-based platforms. + if ((state & datagram_oriented) + && level == SOL_SOCKET && optname == SO_REUSEADDR) + { + call_setsockopt(&msghdr::msg_namelen, s, + SOL_SOCKET, SO_REUSEPORT, optval, optlen); + } +#endif + } + + return result; +#endif // defined(__BORLANDC__) +} + +template <typename SockLenType> +inline int call_getsockopt(SockLenType msghdr::*, + socket_type s, int level, int optname, + void* optval, std::size_t* optlen) +{ + SockLenType tmp_optlen = (SockLenType)*optlen; + int result = ::getsockopt(s, level, optname, (char*)optval, &tmp_optlen); + *optlen = (std::size_t)tmp_optlen; + return result; +} + +int getsockopt(socket_type s, state_type state, int level, int optname, + void* optval, size_t* optlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + if (level == custom_socket_option_level && optname == always_fail_option) + { + ec = boost::asio::error::invalid_argument; + return socket_error_retval; + } + + if (level == custom_socket_option_level + && optname == enable_connection_aborted_option) + { + if (*optlen != sizeof(int)) + { + ec = boost::asio::error::invalid_argument; + return socket_error_retval; + } + + *static_cast<int*>(optval) = (state & enable_connection_aborted) ? 1 : 0; + ec = boost::system::error_code(); + return 0; + } + +#if defined(__BORLANDC__) + // Mysteriously, using the getsockopt and setsockopt functions directly with + // Borland C++ results in incorrect values being set and read. The bug can be + // worked around by using function addresses resolved with GetProcAddress. + if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32")) + { + typedef int (WSAAPI *gso_t)(SOCKET, int, int, char*, int*); + if (gso_t gso = (gso_t)::GetProcAddress(winsock_module, "getsockopt")) + { + clear_last_error(); + int tmp_optlen = static_cast<int>(*optlen); + int result = error_wrapper(gso(s, level, optname, + reinterpret_cast<char*>(optval), &tmp_optlen), ec); + *optlen = static_cast<size_t>(tmp_optlen); + if (result != 0 && level == IPPROTO_IPV6 && optname == IPV6_V6ONLY + && ec.value() == WSAENOPROTOOPT && *optlen == sizeof(DWORD)) + { + // Dual-stack IPv4/v6 sockets, and the IPV6_V6ONLY socket option, are + // only supported on Windows Vista and later. To simplify program logic + // we will fake success of getting this option and specify that the + // value is non-zero (i.e. true). This corresponds to the behavior of + // IPv6 sockets on Windows platforms pre-Vista. + *static_cast<DWORD*>(optval) = 1; + ec = boost::system::error_code(); + } + return result; + } + } + ec = boost::asio::error::fault; + return socket_error_retval; +#elif defined(BOOST_WINDOWS) || defined(__CYGWIN__) + clear_last_error(); + int result = error_wrapper(call_getsockopt(&msghdr::msg_namelen, + s, level, optname, optval, optlen), ec); + if (result != 0 && level == IPPROTO_IPV6 && optname == IPV6_V6ONLY + && ec.value() == WSAENOPROTOOPT && *optlen == sizeof(DWORD)) + { + // Dual-stack IPv4/v6 sockets, and the IPV6_V6ONLY socket option, are only + // supported on Windows Vista and later. To simplify program logic we will + // fake success of getting this option and specify that the value is + // non-zero (i.e. true). This corresponds to the behavior of IPv6 sockets + // on Windows platforms pre-Vista. + *static_cast<DWORD*>(optval) = 1; + ec = boost::system::error_code(); + } + if (result == 0) + ec = boost::system::error_code(); + return result; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + clear_last_error(); + int result = error_wrapper(call_getsockopt(&msghdr::msg_namelen, + s, level, optname, optval, optlen), ec); +#if defined(__linux__) + if (result == 0 && level == SOL_SOCKET && *optlen == sizeof(int) + && (optname == SO_SNDBUF || optname == SO_RCVBUF)) + { + // On Linux, setting SO_SNDBUF or SO_RCVBUF to N actually causes the kernel + // to set the buffer size to N*2. Linux puts additional stuff into the + // buffers so that only about half is actually available to the application. + // The retrieved value is divided by 2 here to make it appear as though the + // correct value has been set. + *static_cast<int*>(optval) /= 2; + } +#endif // defined(__linux__) + if (result == 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +template <typename SockLenType> +inline int call_getpeername(SockLenType msghdr::*, + socket_type s, socket_addr_type* addr, std::size_t* addrlen) +{ + SockLenType tmp_addrlen = (SockLenType)*addrlen; + int result = ::getpeername(s, addr, &tmp_addrlen); + *addrlen = (std::size_t)tmp_addrlen; + return result; +} + +int getpeername(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, bool cached, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if (cached) + { + // Check if socket is still connected. + DWORD connect_time = 0; + size_t connect_time_len = sizeof(connect_time); + if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_CONNECT_TIME, + &connect_time, &connect_time_len, ec) == socket_error_retval) + { + return socket_error_retval; + } + if (connect_time == 0xFFFFFFFF) + { + ec = boost::asio::error::not_connected; + return socket_error_retval; + } + + // The cached value is still valid. + ec = boost::system::error_code(); + return 0; + } +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + (void)cached; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + + clear_last_error(); + int result = error_wrapper(call_getpeername( + &msghdr::msg_namelen, s, addr, addrlen), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +template <typename SockLenType> +inline int call_getsockname(SockLenType msghdr::*, + socket_type s, socket_addr_type* addr, std::size_t* addrlen) +{ + SockLenType tmp_addrlen = (SockLenType)*addrlen; + int result = ::getsockname(s, addr, &tmp_addrlen); + *addrlen = (std::size_t)tmp_addrlen; + return result; +} + +int getsockname(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); + int result = error_wrapper(call_getsockname( + &msghdr::msg_namelen, s, addr, addrlen), ec); + if (result == 0) + ec = boost::system::error_code(); + return result; +} + +int ioctl(socket_type s, state_type& state, int cmd, + ioctl_arg_type* arg, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::ioctlsocket(s, cmd, arg), ec); +#elif defined(__MACH__) && defined(__APPLE__) \ + || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) + int result = error_wrapper(::ioctl(s, + static_cast<unsigned int>(cmd), arg), ec); +#else + int result = error_wrapper(::ioctl(s, cmd, arg), ec); +#endif + if (result >= 0) + { + ec = boost::system::error_code(); + + // When updating the non-blocking mode we always perform the ioctl syscall, + // even if the flags would otherwise indicate that the socket is already in + // the correct state. This ensures that the underlying socket is put into + // the state that has been requested by the user. If the ioctl syscall was + // successful then we need to update the flags to match. + if (cmd == static_cast<int>(FIONBIO)) + { + if (*arg) + { + state |= user_set_non_blocking; + } + else + { + // Clearing the non-blocking mode always overrides any internally-set + // non-blocking flag. Any subsequent asynchronous operations will need + // to re-enable non-blocking I/O. + state &= ~(user_set_non_blocking | internal_non_blocking); + } + } + } + + return result; +} + +int select(int nfds, fd_set* readfds, fd_set* writefds, + fd_set* exceptfds, timeval* timeout, boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + if (!readfds && !writefds && !exceptfds && timeout) + { + DWORD milliseconds = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; + if (milliseconds == 0) + milliseconds = 1; // Force context switch. + ::Sleep(milliseconds); + ec = boost::system::error_code(); + return 0; + } + + // The select() call allows timeout values measured in microseconds, but the + // system clock (as wrapped by boost::posix_time::microsec_clock) typically + // has a resolution of 10 milliseconds. This can lead to a spinning select + // reactor, meaning increased CPU usage, when waiting for the earliest + // scheduled timeout if it's less than 10 milliseconds away. To avoid a tight + // spin we'll use a minimum timeout of 1 millisecond. + if (timeout && timeout->tv_sec == 0 + && timeout->tv_usec > 0 && timeout->tv_usec < 1000) + timeout->tv_usec = 1000; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#if defined(__hpux) && defined(__SELECT) + timespec ts; + ts.tv_sec = timeout ? timeout->tv_sec : 0; + ts.tv_nsec = timeout ? timeout->tv_usec * 1000 : 0; + return error_wrapper(::pselect(nfds, readfds, + writefds, exceptfds, timeout ? &ts : 0, 0), ec); +#else + int result = error_wrapper(::select(nfds, readfds, + writefds, exceptfds, timeout), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif +} + +int poll_read(socket_type s, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + +#if defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + fd_set fds; + FD_ZERO(&fds); + FD_SET(s, &fds); + clear_last_error(); + int result = error_wrapper(::select(s, &fds, 0, 0, 0), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#else // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + pollfd fds; + fds.fd = s; + fds.events = POLLIN; + fds.revents = 0; + clear_last_error(); + int result = error_wrapper(::poll(&fds, 1, -1), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) +} + +int poll_write(socket_type s, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + +#if defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + fd_set fds; + FD_ZERO(&fds); + FD_SET(s, &fds); + clear_last_error(); + int result = error_wrapper(::select(s, 0, &fds, 0, 0), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#else // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + pollfd fds; + fds.fd = s; + fds.events = POLLOUT; + fds.revents = 0; + clear_last_error(); + int result = error_wrapper(::poll(&fds, 1, -1), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) +} + +int poll_connect(socket_type s, boost::system::error_code& ec) +{ + if (s == invalid_socket) + { + ec = boost::asio::error::bad_descriptor; + return socket_error_retval; + } + +#if defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + fd_set write_fds; + FD_ZERO(&write_fds); + FD_SET(s, &write_fds); + fd_set except_fds; + FD_ZERO(&except_fds); + FD_SET(s, &except_fds); + clear_last_error(); + int result = error_wrapper(::select(s, 0, &write_fds, &except_fds, 0), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#else // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + pollfd fds; + fds.fd = s; + fds.events = POLLOUT; + fds.revents = 0; + clear_last_error(); + int result = error_wrapper(::poll(&fds, 1, -1), ec); + if (result >= 0) + ec = boost::system::error_code(); + return result; +#endif // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) +} + +const char* inet_ntop(int af, const void* src, char* dest, size_t length, + unsigned long scope_id, boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + using namespace std; // For memcpy. + + if (af != AF_INET && af != AF_INET6) + { + ec = boost::asio::error::address_family_not_supported; + return 0; + } + + union + { + socket_addr_type base; + sockaddr_storage_type storage; + sockaddr_in4_type v4; + sockaddr_in6_type v6; + } address; + DWORD address_length; + if (af == AF_INET) + { + address_length = sizeof(sockaddr_in4_type); + address.v4.sin_family = AF_INET; + address.v4.sin_port = 0; + memcpy(&address.v4.sin_addr, src, sizeof(in4_addr_type)); + } + else // AF_INET6 + { + address_length = sizeof(sockaddr_in6_type); + address.v6.sin6_family = AF_INET6; + address.v6.sin6_port = 0; + address.v6.sin6_flowinfo = 0; + address.v6.sin6_scope_id = scope_id; + memcpy(&address.v6.sin6_addr, src, sizeof(in6_addr_type)); + } + + DWORD string_length = static_cast<DWORD>(length); +#if defined(BOOST_NO_ANSI_APIS) + LPWSTR string_buffer = (LPWSTR)_alloca(length * sizeof(WCHAR)); + int result = error_wrapper(::WSAAddressToStringW(&address.base, + address_length, 0, string_buffer, &string_length), ec); + ::WideCharToMultiByte(CP_ACP, 0, string_buffer, -1, dest, length, 0, 0); +#else + int result = error_wrapper(::WSAAddressToStringA( + &address.base, address_length, 0, dest, &string_length), ec); +#endif + + // Windows may set error code on success. + if (result != socket_error_retval) + ec = boost::system::error_code(); + + // Windows may not set an error code on failure. + else if (result == socket_error_retval && !ec) + ec = boost::asio::error::invalid_argument; + + return result == socket_error_retval ? 0 : dest; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + const char* result = error_wrapper(::inet_ntop(af, src, dest, length), ec); + if (result == 0 && !ec) + ec = boost::asio::error::invalid_argument; + if (result != 0 && af == AF_INET6 && scope_id != 0) + { + using namespace std; // For strcat and sprintf. + char if_name[IF_NAMESIZE + 1] = "%"; + const in6_addr_type* ipv6_address = static_cast<const in6_addr_type*>(src); + bool is_link_local = IN6_IS_ADDR_LINKLOCAL(ipv6_address); + if (!is_link_local || if_indextoname(scope_id, if_name + 1) == 0) + sprintf(if_name + 1, "%lu", scope_id); + strcat(dest, if_name); + } + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +int inet_pton(int af, const char* src, void* dest, + unsigned long* scope_id, boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + using namespace std; // For memcpy and strcmp. + + if (af != AF_INET && af != AF_INET6) + { + ec = boost::asio::error::address_family_not_supported; + return -1; + } + + union + { + socket_addr_type base; + sockaddr_storage_type storage; + sockaddr_in4_type v4; + sockaddr_in6_type v6; + } address; + int address_length = sizeof(sockaddr_storage_type); +#if defined(BOOST_NO_ANSI_APIS) + int num_wide_chars = strlen(src) + 1; + LPWSTR wide_buffer = (LPWSTR)_alloca(num_wide_chars * sizeof(WCHAR)); + ::MultiByteToWideChar(CP_ACP, 0, src, -1, wide_buffer, num_wide_chars); + int result = error_wrapper(::WSAStringToAddressW( + wide_buffer, af, 0, &address.base, &address_length), ec); +#else + int result = error_wrapper(::WSAStringToAddressA( + const_cast<char*>(src), af, 0, &address.base, &address_length), ec); +#endif + + if (af == AF_INET) + { + if (result != socket_error_retval) + { + memcpy(dest, &address.v4.sin_addr, sizeof(in4_addr_type)); + ec = boost::system::error_code(); + } + else if (strcmp(src, "255.255.255.255") == 0) + { + static_cast<in4_addr_type*>(dest)->s_addr = INADDR_NONE; + ec = boost::system::error_code(); + } + } + else // AF_INET6 + { + if (result != socket_error_retval) + { + memcpy(dest, &address.v6.sin6_addr, sizeof(in6_addr_type)); + if (scope_id) + *scope_id = address.v6.sin6_scope_id; + ec = boost::system::error_code(); + } + } + + // Windows may not set an error code on failure. + if (result == socket_error_retval && !ec) + ec = boost::asio::error::invalid_argument; + + if (result != socket_error_retval) + ec = boost::system::error_code(); + + return result == socket_error_retval ? -1 : 1; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + int result = error_wrapper(::inet_pton(af, src, dest), ec); + if (result <= 0 && !ec) + ec = boost::asio::error::invalid_argument; + if (result > 0 && af == AF_INET6 && scope_id) + { + using namespace std; // For strchr and atoi. + *scope_id = 0; + if (const char* if_name = strchr(src, '%')) + { + in6_addr_type* ipv6_address = static_cast<in6_addr_type*>(dest); + bool is_link_local = IN6_IS_ADDR_LINKLOCAL(ipv6_address); + if (is_link_local) + *scope_id = if_nametoindex(if_name + 1); + if (*scope_id == 0) + *scope_id = atoi(if_name + 1); + } + } + return result; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +} + +int gethostname(char* name, int namelen, boost::system::error_code& ec) +{ + clear_last_error(); + int result = error_wrapper(::gethostname(name, namelen), ec); +#if defined(BOOST_WINDOWS) + if (result == 0) + ec = boost::system::error_code(); +#endif + return result; +} + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) \ + || defined(__MACH__) && defined(__APPLE__) + +// The following functions are only needed for emulation of getaddrinfo and +// getnameinfo. + +inline boost::system::error_code translate_netdb_error(int error) +{ + switch (error) + { + case 0: + return boost::system::error_code(); + case HOST_NOT_FOUND: + return boost::asio::error::host_not_found; + case TRY_AGAIN: + return boost::asio::error::host_not_found_try_again; + case NO_RECOVERY: + return boost::asio::error::no_recovery; + case NO_DATA: + return boost::asio::error::no_data; + default: + BOOST_ASSERT(false); + return boost::asio::error::invalid_argument; + } +} + +inline hostent* gethostbyaddr(const char* addr, int length, int af, + hostent* result, char* buffer, int buflength, boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + (void)(buffer); + (void)(buflength); + hostent* retval = error_wrapper(::gethostbyaddr(addr, length, af), ec); + if (!retval) + return 0; + ec = boost::system::error_code(); + *result = *retval; + return retval; +#elif defined(__sun) || defined(__QNX__) + int error = 0; + hostent* retval = error_wrapper(::gethostbyaddr_r(addr, length, af, result, + buffer, buflength, &error), ec); + if (error) + ec = translate_netdb_error(error); + return retval; +#elif defined(__MACH__) && defined(__APPLE__) + (void)(buffer); + (void)(buflength); + int error = 0; + hostent* retval = error_wrapper(::getipnodebyaddr( + addr, length, af, &error), ec); + if (error) + ec = translate_netdb_error(error); + if (!retval) + return 0; + *result = *retval; + return retval; +#else + hostent* retval = 0; + int error = 0; + error_wrapper(::gethostbyaddr_r(addr, length, af, result, buffer, + buflength, &retval, &error), ec); + if (error) + ec = translate_netdb_error(error); + return retval; +#endif +} + +inline hostent* gethostbyname(const char* name, int af, struct hostent* result, + char* buffer, int buflength, int ai_flags, boost::system::error_code& ec) +{ + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + (void)(buffer); + (void)(buflength); + (void)(ai_flags); + if (af != AF_INET) + { + ec = boost::asio::error::address_family_not_supported; + return 0; + } + hostent* retval = error_wrapper(::gethostbyname(name), ec); + if (!retval) + return 0; + ec = boost::system::error_code(); + *result = *retval; + return result; +#elif defined(__sun) || defined(__QNX__) + (void)(ai_flags); + if (af != AF_INET) + { + ec = boost::asio::error::address_family_not_supported; + return 0; + } + int error = 0; + hostent* retval = error_wrapper(::gethostbyname_r(name, result, buffer, + buflength, &error), ec); + if (error) + ec = translate_netdb_error(error); + return retval; +#elif defined(__MACH__) && defined(__APPLE__) + (void)(buffer); + (void)(buflength); + int error = 0; + hostent* retval = error_wrapper(::getipnodebyname( + name, af, ai_flags, &error), ec); + if (error) + ec = translate_netdb_error(error); + if (!retval) + return 0; + *result = *retval; + return retval; +#else + (void)(ai_flags); + if (af != AF_INET) + { + ec = boost::asio::error::address_family_not_supported; + return 0; + } + hostent* retval = 0; + int error = 0; + error_wrapper(::gethostbyname_r(name, result, + buffer, buflength, &retval, &error), ec); + if (error) + ec = translate_netdb_error(error); + return retval; +#endif +} + +inline void freehostent(hostent* h) +{ +#if defined(__MACH__) && defined(__APPLE__) + if (h) + ::freehostent(h); +#else + (void)(h); +#endif +} + +// Emulation of getaddrinfo based on implementation in: +// Stevens, W. R., UNIX Network Programming Vol. 1, 2nd Ed., Prentice-Hall 1998. + +struct gai_search +{ + const char* host; + int family; +}; + +inline int gai_nsearch(const char* host, + const addrinfo_type* hints, gai_search (&search)[2]) +{ + int search_count = 0; + if (host == 0 || host[0] == '\0') + { + if (hints->ai_flags & AI_PASSIVE) + { + // No host and AI_PASSIVE implies wildcard bind. + switch (hints->ai_family) + { + case AF_INET: + search[search_count].host = "0.0.0.0"; + search[search_count].family = AF_INET; + ++search_count; + break; + case AF_INET6: + search[search_count].host = "0::0"; + search[search_count].family = AF_INET6; + ++search_count; + break; + case AF_UNSPEC: + search[search_count].host = "0::0"; + search[search_count].family = AF_INET6; + ++search_count; + search[search_count].host = "0.0.0.0"; + search[search_count].family = AF_INET; + ++search_count; + break; + default: + break; + } + } + else + { + // No host and not AI_PASSIVE means connect to local host. + switch (hints->ai_family) + { + case AF_INET: + search[search_count].host = "localhost"; + search[search_count].family = AF_INET; + ++search_count; + break; + case AF_INET6: + search[search_count].host = "localhost"; + search[search_count].family = AF_INET6; + ++search_count; + break; + case AF_UNSPEC: + search[search_count].host = "localhost"; + search[search_count].family = AF_INET6; + ++search_count; + search[search_count].host = "localhost"; + search[search_count].family = AF_INET; + ++search_count; + break; + default: + break; + } + } + } + else + { + // Host is specified. + switch (hints->ai_family) + { + case AF_INET: + search[search_count].host = host; + search[search_count].family = AF_INET; + ++search_count; + break; + case AF_INET6: + search[search_count].host = host; + search[search_count].family = AF_INET6; + ++search_count; + break; + case AF_UNSPEC: + search[search_count].host = host; + search[search_count].family = AF_INET6; + ++search_count; + search[search_count].host = host; + search[search_count].family = AF_INET; + ++search_count; + break; + default: + break; + } + } + return search_count; +} + +template <typename T> +inline T* gai_alloc(std::size_t size = sizeof(T)) +{ + using namespace std; + T* p = static_cast<T*>(::operator new(size, std::nothrow)); + if (p) + memset(p, 0, size); + return p; +} + +inline void gai_free(void* p) +{ + ::operator delete(p); +} + +inline void gai_strcpy(char* target, const char* source, std::size_t max_size) +{ + using namespace std; +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE) + strcpy_s(target, max_size, source); +#else + *target = 0; + strncat(target, source, max_size); +#endif +} + +enum { gai_clone_flag = 1 << 30 }; + +inline int gai_aistruct(addrinfo_type*** next, const addrinfo_type* hints, + const void* addr, int family) +{ + using namespace std; + + addrinfo_type* ai = gai_alloc<addrinfo_type>(); + if (ai == 0) + return EAI_MEMORY; + + ai->ai_next = 0; + **next = ai; + *next = &ai->ai_next; + + ai->ai_canonname = 0; + ai->ai_socktype = hints->ai_socktype; + if (ai->ai_socktype == 0) + ai->ai_flags |= gai_clone_flag; + ai->ai_protocol = hints->ai_protocol; + ai->ai_family = family; + + switch (ai->ai_family) + { + case AF_INET: + { + sockaddr_in4_type* sinptr = gai_alloc<sockaddr_in4_type>(); + if (sinptr == 0) + return EAI_MEMORY; + sinptr->sin_family = AF_INET; + memcpy(&sinptr->sin_addr, addr, sizeof(in4_addr_type)); + ai->ai_addr = reinterpret_cast<sockaddr*>(sinptr); + ai->ai_addrlen = sizeof(sockaddr_in4_type); + break; + } + case AF_INET6: + { + sockaddr_in6_type* sin6ptr = gai_alloc<sockaddr_in6_type>(); + if (sin6ptr == 0) + return EAI_MEMORY; + sin6ptr->sin6_family = AF_INET6; + memcpy(&sin6ptr->sin6_addr, addr, sizeof(in6_addr_type)); + ai->ai_addr = reinterpret_cast<sockaddr*>(sin6ptr); + ai->ai_addrlen = sizeof(sockaddr_in6_type); + break; + } + default: + break; + } + + return 0; +} + +inline addrinfo_type* gai_clone(addrinfo_type* ai) +{ + using namespace std; + + addrinfo_type* new_ai = gai_alloc<addrinfo_type>(); + if (new_ai == 0) + return new_ai; + + new_ai->ai_next = ai->ai_next; + ai->ai_next = new_ai; + + new_ai->ai_flags = 0; + new_ai->ai_family = ai->ai_family; + new_ai->ai_socktype = ai->ai_socktype; + new_ai->ai_protocol = ai->ai_protocol; + new_ai->ai_canonname = 0; + new_ai->ai_addrlen = ai->ai_addrlen; + new_ai->ai_addr = gai_alloc<sockaddr>(ai->ai_addrlen); + memcpy(new_ai->ai_addr, ai->ai_addr, ai->ai_addrlen); + + return new_ai; +} + +inline int gai_port(addrinfo_type* aihead, int port, int socktype) +{ + int num_found = 0; + + for (addrinfo_type* ai = aihead; ai; ai = ai->ai_next) + { + if (ai->ai_flags & gai_clone_flag) + { + if (ai->ai_socktype != 0) + { + ai = gai_clone(ai); + if (ai == 0) + return -1; + // ai now points to newly cloned entry. + } + } + else if (ai->ai_socktype != socktype) + { + // Ignore if mismatch on socket type. + continue; + } + + ai->ai_socktype = socktype; + + switch (ai->ai_family) + { + case AF_INET: + { + sockaddr_in4_type* sinptr = + reinterpret_cast<sockaddr_in4_type*>(ai->ai_addr); + sinptr->sin_port = port; + ++num_found; + break; + } + case AF_INET6: + { + sockaddr_in6_type* sin6ptr = + reinterpret_cast<sockaddr_in6_type*>(ai->ai_addr); + sin6ptr->sin6_port = port; + ++num_found; + break; + } + default: + break; + } + } + + return num_found; +} + +inline int gai_serv(addrinfo_type* aihead, + const addrinfo_type* hints, const char* serv) +{ + using namespace std; + + int num_found = 0; + + if ( +#if defined(AI_NUMERICSERV) + (hints->ai_flags & AI_NUMERICSERV) || +#endif + isdigit(static_cast<unsigned char>(serv[0]))) + { + int port = htons(atoi(serv)); + if (hints->ai_socktype) + { + // Caller specifies socket type. + int rc = gai_port(aihead, port, hints->ai_socktype); + if (rc < 0) + return EAI_MEMORY; + num_found += rc; + } + else + { + // Caller does not specify socket type. + int rc = gai_port(aihead, port, SOCK_STREAM); + if (rc < 0) + return EAI_MEMORY; + num_found += rc; + rc = gai_port(aihead, port, SOCK_DGRAM); + if (rc < 0) + return EAI_MEMORY; + num_found += rc; + } + } + else + { + // Try service name with TCP first, then UDP. + if (hints->ai_socktype == 0 || hints->ai_socktype == SOCK_STREAM) + { + servent* sptr = getservbyname(serv, "tcp"); + if (sptr != 0) + { + int rc = gai_port(aihead, sptr->s_port, SOCK_STREAM); + if (rc < 0) + return EAI_MEMORY; + num_found += rc; + } + } + if (hints->ai_socktype == 0 || hints->ai_socktype == SOCK_DGRAM) + { + servent* sptr = getservbyname(serv, "udp"); + if (sptr != 0) + { + int rc = gai_port(aihead, sptr->s_port, SOCK_DGRAM); + if (rc < 0) + return EAI_MEMORY; + num_found += rc; + } + } + } + + if (num_found == 0) + { + if (hints->ai_socktype == 0) + { + // All calls to getservbyname() failed. + return EAI_NONAME; + } + else + { + // Service not supported for socket type. + return EAI_SERVICE; + } + } + + return 0; +} + +inline int gai_echeck(const char* host, const char* service, + int flags, int family, int socktype, int protocol) +{ + (void)(flags); + (void)(protocol); + + // Host or service must be specified. + if (host == 0 || host[0] == '\0') + if (service == 0 || service[0] == '\0') + return EAI_NONAME; + + // Check combination of family and socket type. + switch (family) + { + case AF_UNSPEC: + break; + case AF_INET: + case AF_INET6: + if (service != 0 && service[0] != '\0') + if (socktype != 0 && socktype != SOCK_STREAM && socktype != SOCK_DGRAM) + return EAI_SOCKTYPE; + break; + default: + return EAI_FAMILY; + } + + return 0; +} + +inline void freeaddrinfo_emulation(addrinfo_type* aihead) +{ + addrinfo_type* ai = aihead; + while (ai) + { + gai_free(ai->ai_addr); + gai_free(ai->ai_canonname); + addrinfo_type* ainext = ai->ai_next; + gai_free(ai); + ai = ainext; + } +} + +inline int getaddrinfo_emulation(const char* host, const char* service, + const addrinfo_type* hintsp, addrinfo_type** result) +{ + // Set up linked list of addrinfo structures. + addrinfo_type* aihead = 0; + addrinfo_type** ainext = &aihead; + char* canon = 0; + + // Supply default hints if not specified by caller. + addrinfo_type hints = addrinfo_type(); + hints.ai_family = AF_UNSPEC; + if (hintsp) + hints = *hintsp; + + // If the resolution is not specifically for AF_INET6, remove the AI_V4MAPPED + // and AI_ALL flags. +#if defined(AI_V4MAPPED) + if (hints.ai_family != AF_INET6) + hints.ai_flags &= ~AI_V4MAPPED; +#endif +#if defined(AI_ALL) + if (hints.ai_family != AF_INET6) + hints.ai_flags &= ~AI_ALL; +#endif + + // Basic error checking. + int rc = gai_echeck(host, service, hints.ai_flags, hints.ai_family, + hints.ai_socktype, hints.ai_protocol); + if (rc != 0) + { + freeaddrinfo_emulation(aihead); + return rc; + } + + gai_search search[2]; + int search_count = gai_nsearch(host, &hints, search); + for (gai_search* sptr = search; sptr < search + search_count; ++sptr) + { + // Check for IPv4 dotted decimal string. + in4_addr_type inaddr; + boost::system::error_code ec; + if (socket_ops::inet_pton(AF_INET, sptr->host, &inaddr, 0, ec) == 1) + { + if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + return EAI_FAMILY; + } + if (sptr->family == AF_INET) + { + rc = gai_aistruct(&ainext, &hints, &inaddr, AF_INET); + if (rc != 0) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + return rc; + } + } + continue; + } + + // Check for IPv6 hex string. + in6_addr_type in6addr; + if (socket_ops::inet_pton(AF_INET6, sptr->host, &in6addr, 0, ec) == 1) + { + if (hints.ai_family != AF_UNSPEC && hints.ai_family != AF_INET6) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + return EAI_FAMILY; + } + if (sptr->family == AF_INET6) + { + rc = gai_aistruct(&ainext, &hints, &in6addr, AF_INET6); + if (rc != 0) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + return rc; + } + } + continue; + } + + // Look up hostname. + hostent hent; + char hbuf[8192] = ""; + hostent* hptr = socket_ops::gethostbyname(sptr->host, + sptr->family, &hent, hbuf, sizeof(hbuf), hints.ai_flags, ec); + if (hptr == 0) + { + if (search_count == 2) + { + // Failure is OK if there are multiple searches. + continue; + } + freeaddrinfo_emulation(aihead); + gai_free(canon); + if (ec == boost::asio::error::host_not_found) + return EAI_NONAME; + if (ec == boost::asio::error::host_not_found_try_again) + return EAI_AGAIN; + if (ec == boost::asio::error::no_recovery) + return EAI_FAIL; + if (ec == boost::asio::error::no_data) + return EAI_NONAME; + return EAI_NONAME; + } + + // Check for address family mismatch if one was specified. + if (hints.ai_family != AF_UNSPEC && hints.ai_family != hptr->h_addrtype) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + socket_ops::freehostent(hptr); + return EAI_FAMILY; + } + + // Save canonical name first time. + if (host != 0 && host[0] != '\0' && hptr->h_name && hptr->h_name[0] + && (hints.ai_flags & AI_CANONNAME) && canon == 0) + { + std::size_t canon_len = strlen(hptr->h_name) + 1; + canon = gai_alloc<char>(canon_len); + if (canon == 0) + { + freeaddrinfo_emulation(aihead); + socket_ops::freehostent(hptr); + return EAI_MEMORY; + } + gai_strcpy(canon, hptr->h_name, canon_len); + } + + // Create an addrinfo structure for each returned address. + for (char** ap = hptr->h_addr_list; *ap; ++ap) + { + rc = gai_aistruct(&ainext, &hints, *ap, hptr->h_addrtype); + if (rc != 0) + { + freeaddrinfo_emulation(aihead); + gai_free(canon); + socket_ops::freehostent(hptr); + return EAI_FAMILY; + } + } + + socket_ops::freehostent(hptr); + } + + // Check if we found anything. + if (aihead == 0) + { + gai_free(canon); + return EAI_NONAME; + } + + // Return canonical name in first entry. + if (host != 0 && host[0] != '\0' && (hints.ai_flags & AI_CANONNAME)) + { + if (canon) + { + aihead->ai_canonname = canon; + canon = 0; + } + else + { + std::size_t canonname_len = strlen(search[0].host) + 1; + aihead->ai_canonname = gai_alloc<char>(canonname_len); + if (aihead->ai_canonname == 0) + { + freeaddrinfo_emulation(aihead); + return EAI_MEMORY; + } + gai_strcpy(aihead->ai_canonname, search[0].host, canonname_len); + } + } + gai_free(canon); + + // Process the service name. + if (service != 0 && service[0] != '\0') + { + rc = gai_serv(aihead, &hints, service); + if (rc != 0) + { + freeaddrinfo_emulation(aihead); + return rc; + } + } + + // Return result to caller. + *result = aihead; + return 0; +} + +inline boost::system::error_code getnameinfo_emulation( + const socket_addr_type* sa, std::size_t salen, char* host, + std::size_t hostlen, char* serv, std::size_t servlen, int flags, + boost::system::error_code& ec) +{ + using namespace std; + + const char* addr; + size_t addr_len; + unsigned short port; + switch (sa->sa_family) + { + case AF_INET: + if (salen != sizeof(sockaddr_in4_type)) + { + return ec = boost::asio::error::invalid_argument; + } + addr = reinterpret_cast<const char*>( + &reinterpret_cast<const sockaddr_in4_type*>(sa)->sin_addr); + addr_len = sizeof(in4_addr_type); + port = reinterpret_cast<const sockaddr_in4_type*>(sa)->sin_port; + break; + case AF_INET6: + if (salen != sizeof(sockaddr_in6_type)) + { + return ec = boost::asio::error::invalid_argument; + } + addr = reinterpret_cast<const char*>( + &reinterpret_cast<const sockaddr_in6_type*>(sa)->sin6_addr); + addr_len = sizeof(in6_addr_type); + port = reinterpret_cast<const sockaddr_in6_type*>(sa)->sin6_port; + break; + default: + return ec = boost::asio::error::address_family_not_supported; + } + + if (host && hostlen > 0) + { + if (flags & NI_NUMERICHOST) + { + if (socket_ops::inet_ntop(sa->sa_family, addr, host, hostlen, 0, ec) == 0) + { + return ec; + } + } + else + { + hostent hent; + char hbuf[8192] = ""; + hostent* hptr = socket_ops::gethostbyaddr(addr, + static_cast<int>(addr_len), sa->sa_family, + &hent, hbuf, sizeof(hbuf), ec); + if (hptr && hptr->h_name && hptr->h_name[0] != '\0') + { + if (flags & NI_NOFQDN) + { + char* dot = strchr(hptr->h_name, '.'); + if (dot) + { + *dot = 0; + } + } + gai_strcpy(host, hptr->h_name, hostlen); + socket_ops::freehostent(hptr); + } + else + { + socket_ops::freehostent(hptr); + if (flags & NI_NAMEREQD) + { + return ec = boost::asio::error::host_not_found; + } + if (socket_ops::inet_ntop(sa->sa_family, + addr, host, hostlen, 0, ec) == 0) + { + return ec; + } + } + } + } + + if (serv && servlen > 0) + { + if (flags & NI_NUMERICSERV) + { + if (servlen < 6) + { + return ec = boost::asio::error::no_buffer_space; + } +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE) + sprintf_s(serv, servlen, "%u", ntohs(port)); +#else + sprintf(serv, "%u", ntohs(port)); +#endif + } + else + { +#if defined(BOOST_HAS_THREADS) && defined(BOOST_HAS_PTHREADS) \ + && !defined(BOOST_ASIO_DISABLE_THREADS) + static ::pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + ::pthread_mutex_lock(&mutex); +#endif // defined(BOOST_HAS_THREADS) && defined(BOOST_HAS_PTHREADS) + // && !defined(BOOST_ASIO_DISABLE_THREADS) + servent* sptr = ::getservbyport(port, (flags & NI_DGRAM) ? "udp" : 0); + if (sptr && sptr->s_name && sptr->s_name[0] != '\0') + { + gai_strcpy(serv, sptr->s_name, servlen); + } + else + { + if (servlen < 6) + { + return ec = boost::asio::error::no_buffer_space; + } +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE) + sprintf_s(serv, servlen, "%u", ntohs(port)); +#else + sprintf(serv, "%u", ntohs(port)); +#endif + } +#if defined(BOOST_HAS_THREADS) && defined(BOOST_HAS_PTHREADS) \ + && !defined(BOOST_ASIO_DISABLE_THREADS) + ::pthread_mutex_unlock(&mutex); +#endif // defined(BOOST_HAS_THREADS) && defined(BOOST_HAS_PTHREADS) + // && !defined(BOOST_ASIO_DISABLE_THREADS) + } + } + + ec = boost::system::error_code(); + return ec; +} + +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + // || defined(__MACH__) && defined(__APPLE__) + +inline boost::system::error_code translate_addrinfo_error(int error) +{ + switch (error) + { + case 0: + return boost::system::error_code(); + case EAI_AGAIN: + return boost::asio::error::host_not_found_try_again; + case EAI_BADFLAGS: + return boost::asio::error::invalid_argument; + case EAI_FAIL: + return boost::asio::error::no_recovery; + case EAI_FAMILY: + return boost::asio::error::address_family_not_supported; + case EAI_MEMORY: + return boost::asio::error::no_memory; + case EAI_NONAME: +#if defined(EAI_ADDRFAMILY) + case EAI_ADDRFAMILY: +#endif +#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME) + case EAI_NODATA: +#endif + return boost::asio::error::host_not_found; + case EAI_SERVICE: + return boost::asio::error::service_not_found; + case EAI_SOCKTYPE: + return boost::asio::error::socket_type_not_supported; + default: // Possibly the non-portable EAI_SYSTEM. +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + return boost::system::error_code( + WSAGetLastError(), boost::asio::error::get_system_category()); +#else + return boost::system::error_code( + errno, boost::asio::error::get_system_category()); +#endif + } +} + +boost::system::error_code getaddrinfo(const char* host, + const char* service, const addrinfo_type& hints, + addrinfo_type** result, boost::system::error_code& ec) +{ + host = (host && *host) ? host : 0; + service = (service && *service) ? service : 0; + clear_last_error(); +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) || defined(UNDER_CE) + // Building for Windows XP, Windows Server 2003, or later. + int error = ::getaddrinfo(host, service, &hints, result); + return ec = translate_addrinfo_error(error); +# else + // Building for Windows 2000 or earlier. + typedef int (WSAAPI *gai_t)(const char*, + const char*, const addrinfo_type*, addrinfo_type**); + if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32")) + { + if (gai_t gai = (gai_t)::GetProcAddress(winsock_module, "getaddrinfo")) + { + int error = gai(host, service, &hints, result); + return ec = translate_addrinfo_error(error); + } + } + int error = getaddrinfo_emulation(host, service, &hints, result); + return ec = translate_addrinfo_error(error); +# endif +#elif defined(__MACH__) && defined(__APPLE__) + int error = getaddrinfo_emulation(host, service, &hints, result); + return ec = translate_addrinfo_error(error); +#else + int error = ::getaddrinfo(host, service, &hints, result); + return ec = translate_addrinfo_error(error); +#endif +} + +boost::system::error_code background_getaddrinfo( + const weak_cancel_token_type& cancel_token, const char* host, + const char* service, const addrinfo_type& hints, + addrinfo_type** result, boost::system::error_code& ec) +{ + if (cancel_token.expired()) + ec = boost::asio::error::operation_aborted; + else + socket_ops::getaddrinfo(host, service, hints, result, ec); + return ec; +} + +void freeaddrinfo(addrinfo_type* ai) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) || defined(UNDER_CE) + // Building for Windows XP, Windows Server 2003, or later. + ::freeaddrinfo(ai); +# else + // Building for Windows 2000 or earlier. + typedef int (WSAAPI *fai_t)(addrinfo_type*); + if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32")) + { + if (fai_t fai = (fai_t)::GetProcAddress(winsock_module, "freeaddrinfo")) + { + fai(ai); + return; + } + } + freeaddrinfo_emulation(ai); +# endif +#elif defined(__MACH__) && defined(__APPLE__) + freeaddrinfo_emulation(ai); +#else + ::freeaddrinfo(ai); +#endif +} + +boost::system::error_code getnameinfo(const socket_addr_type* addr, + std::size_t addrlen, char* host, std::size_t hostlen, + char* serv, std::size_t servlen, int flags, boost::system::error_code& ec) +{ +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) || defined(UNDER_CE) + // Building for Windows XP, Windows Server 2003, or later. + clear_last_error(); + int error = ::getnameinfo(addr, static_cast<socklen_t>(addrlen), + host, static_cast<DWORD>(hostlen), + serv, static_cast<DWORD>(servlen), flags); + return ec = translate_addrinfo_error(error); +# else + // Building for Windows 2000 or earlier. + typedef int (WSAAPI *gni_t)(const socket_addr_type*, + int, char*, DWORD, char*, DWORD, int); + if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32")) + { + if (gni_t gni = (gni_t)::GetProcAddress(winsock_module, "getnameinfo")) + { + clear_last_error(); + int error = gni(addr, static_cast<int>(addrlen), + host, static_cast<DWORD>(hostlen), + serv, static_cast<DWORD>(servlen), flags); + return ec = translate_addrinfo_error(error); + } + } + clear_last_error(); + return getnameinfo_emulation(addr, addrlen, + host, hostlen, serv, servlen, flags, ec); +# endif +#elif defined(__MACH__) && defined(__APPLE__) + using namespace std; // For memcpy. + sockaddr_storage_type tmp_addr; + memcpy(&tmp_addr, addr, addrlen); + tmp_addr.ss_len = addrlen; + addr = reinterpret_cast<socket_addr_type*>(&tmp_addr); + clear_last_error(); + return getnameinfo_emulation(addr, addrlen, + host, hostlen, serv, servlen, flags, ec); +#else + clear_last_error(); + int error = ::getnameinfo(addr, addrlen, host, hostlen, serv, servlen, flags); + return ec = translate_addrinfo_error(error); +#endif +} + +boost::system::error_code sync_getnameinfo( + const socket_addr_type* addr, std::size_t addrlen, + char* host, std::size_t hostlen, char* serv, + std::size_t servlen, int sock_type, boost::system::error_code& ec) +{ + // First try resolving with the service name. If that fails try resolving + // but allow the service to be returned as a number. + int flags = (sock_type == SOCK_DGRAM) ? NI_DGRAM : 0; + socket_ops::getnameinfo(addr, addrlen, host, + hostlen, serv, servlen, flags, ec); + if (ec) + { + socket_ops::getnameinfo(addr, addrlen, host, hostlen, + serv, servlen, flags | NI_NUMERICSERV, ec); + } + + return ec; +} + +boost::system::error_code background_getnameinfo( + const weak_cancel_token_type& cancel_token, + const socket_addr_type* addr, std::size_t addrlen, + char* host, std::size_t hostlen, char* serv, + std::size_t servlen, int sock_type, boost::system::error_code& ec) +{ + if (cancel_token.expired()) + { + ec = boost::asio::error::operation_aborted; + } + else + { + // First try resolving with the service name. If that fails try resolving + // but allow the service to be returned as a number. + int flags = (sock_type == SOCK_DGRAM) ? NI_DGRAM : 0; + socket_ops::getnameinfo(addr, addrlen, host, + hostlen, serv, servlen, flags, ec); + if (ec) + { + socket_ops::getnameinfo(addr, addrlen, host, hostlen, + serv, servlen, flags | NI_NUMERICSERV, ec); + } + } + + return ec; +} + +u_long_type network_to_host_long(u_long_type value) +{ + return ntohl(value); +} + +u_long_type host_to_network_long(u_long_type value) +{ + return htonl(value); +} + +u_short_type network_to_host_short(u_short_type value) +{ + return ntohs(value); +} + +u_short_type host_to_network_short(u_short_type value) +{ + return htons(value); +} + +} // namespace socket_ops +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_SOCKET_OPS_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/socket_select_interrupter.ipp b/boost_1_45_0/boost/asio/detail/impl/socket_select_interrupter.ipp new file mode 100644 index 0000000..d697a6e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/socket_select_interrupter.ipp
@@ -0,0 +1,153 @@ +// +// detail/impl/socket_select_interrupter.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_SOCKET_SELECT_INTERRUPTER_IPP +#define BOOST_ASIO_DETAIL_IMPL_SOCKET_SELECT_INTERRUPTER_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + +#include <cstdlib> +#include <boost/asio/detail/socket_holder.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/detail/socket_select_interrupter.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +socket_select_interrupter::socket_select_interrupter() +{ + boost::system::error_code ec; + socket_holder acceptor(socket_ops::socket( + AF_INET, SOCK_STREAM, IPPROTO_TCP, ec)); + if (acceptor.get() == invalid_socket) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + int opt = 1; + socket_ops::state_type acceptor_state = 0; + socket_ops::setsockopt(acceptor.get(), acceptor_state, + SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt), ec); + + using namespace std; // For memset. + sockaddr_in4_type addr; + std::size_t addr_len = sizeof(addr); + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + addr.sin_port = 0; + if (socket_ops::bind(acceptor.get(), (const socket_addr_type*)&addr, + addr_len, ec) == socket_error_retval) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + if (socket_ops::getsockname(acceptor.get(), (socket_addr_type*)&addr, + &addr_len, ec) == socket_error_retval) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + // Some broken firewalls on Windows will intermittently cause getsockname to + // return 0.0.0.0 when the socket is actually bound to 127.0.0.1. We + // explicitly specify the target address here to work around this problem. + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + + if (socket_ops::listen(acceptor.get(), + SOMAXCONN, ec) == socket_error_retval) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + socket_holder client(socket_ops::socket( + AF_INET, SOCK_STREAM, IPPROTO_TCP, ec)); + if (client.get() == invalid_socket) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + if (socket_ops::connect(client.get(), (const socket_addr_type*)&addr, + addr_len, ec) == socket_error_retval) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + socket_holder server(socket_ops::accept(acceptor.get(), 0, 0, ec)); + if (server.get() == invalid_socket) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + ioctl_arg_type non_blocking = 1; + socket_ops::state_type client_state = 0; + if (socket_ops::ioctl(client.get(), client_state, + FIONBIO, &non_blocking, ec)) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + opt = 1; + socket_ops::setsockopt(client.get(), client_state, + IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt), ec); + + non_blocking = 1; + socket_ops::state_type server_state = 0; + if (socket_ops::ioctl(server.get(), server_state, + FIONBIO, &non_blocking, ec)) + boost::asio::detail::throw_error(ec, "socket_select_interrupter"); + + opt = 1; + socket_ops::setsockopt(server.get(), server_state, + IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt), ec); + + read_descriptor_ = server.release(); + write_descriptor_ = client.release(); +} + +socket_select_interrupter::~socket_select_interrupter() +{ + boost::system::error_code ec; + socket_ops::state_type state = socket_ops::internal_non_blocking; + if (read_descriptor_ != invalid_socket) + socket_ops::close(read_descriptor_, state, true, ec); + if (write_descriptor_ != invalid_socket) + socket_ops::close(write_descriptor_, state, true, ec); +} + +void socket_select_interrupter::interrupt() +{ + char byte = 0; + socket_ops::buf b; + socket_ops::init_buf(b, &byte, 1); + boost::system::error_code ec; + socket_ops::send(write_descriptor_, &b, 1, 0, ec); +} + +bool socket_select_interrupter::reset() +{ + char data[1024]; + socket_ops::buf b; + socket_ops::init_buf(b, data, sizeof(data)); + boost::system::error_code ec; + int bytes_read = socket_ops::recv(read_descriptor_, &b, 1, 0, ec); + bool was_interrupted = (bytes_read > 0); + while (bytes_read == sizeof(data)) + bytes_read = socket_ops::recv(read_descriptor_, &b, 1, 0, ec); + return was_interrupted; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + +#endif // BOOST_ASIO_DETAIL_IMPL_SOCKET_SELECT_INTERRUPTER_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/strand_service.hpp b/boost_1_45_0/boost/asio/detail/impl/strand_service.hpp new file mode 100644 index 0000000..e959947 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/strand_service.hpp
@@ -0,0 +1,142 @@ +// +// detail/impl/strand_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_HPP +#define BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/call_stack.hpp> +#include <boost/asio/detail/completion_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +inline strand_service::strand_impl::strand_impl() + : operation(&strand_service::do_complete), + count_(0) +{ +} + +struct strand_service::on_dispatch_exit +{ + io_service_impl* io_service_; + strand_impl* impl_; + + ~on_dispatch_exit() + { + impl_->mutex_.lock(); + bool more_handlers = (--impl_->count_ > 0); + impl_->mutex_.unlock(); + + if (more_handlers) + io_service_->post_immediate_completion(impl_); + } +}; + +inline void strand_service::destroy(strand_service::implementation_type& impl) +{ + impl = 0; +} + +template <typename Handler> +void strand_service::dispatch(strand_service::implementation_type& impl, + Handler handler) +{ + // If we are already in the strand then the handler can run immediately. + if (call_stack<strand_impl>::contains(impl)) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + return; + } + + // Allocate and construct an operation to wrap the handler. + typedef completion_handler<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + // If we are running inside the io_service, and no other handler is queued + // or running, then the handler can run immediately. + bool can_dispatch = call_stack<io_service_impl>::contains(&io_service_); + impl->mutex_.lock(); + bool first = (++impl->count_ == 1); + if (can_dispatch && first) + { + // Immediate invocation is allowed. + impl->mutex_.unlock(); + + // Memory must be releaesed before any upcall is made. + p.reset(); + + // Indicate that this strand is executing on the current thread. + call_stack<strand_impl>::context ctx(impl); + + // Ensure the next handler, if any, is scheduled on block exit. + on_dispatch_exit on_exit = { &io_service_, impl }; + (void)on_exit; + + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + return; + } + + // Immediate invocation is not allowed, so enqueue for later. + impl->queue_.push(p.p); + impl->mutex_.unlock(); + p.v = p.p = 0; + + // The first handler to be enqueued is responsible for scheduling the + // strand. + if (first) + io_service_.post_immediate_completion(impl); +} + +// Request the io_service to invoke the given handler and return immediately. +template <typename Handler> +void strand_service::post(strand_service::implementation_type& impl, + Handler handler) +{ + // Allocate and construct an operation to wrap the handler. + typedef completion_handler<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + // Add the handler to the queue. + impl->mutex_.lock(); + bool first = (++impl->count_ == 1); + impl->queue_.push(p.p); + impl->mutex_.unlock(); + p.v = p.p = 0; + + // The first handler to be enqueue is responsible for scheduling the strand. + if (first) + io_service_.post_immediate_completion(impl); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/strand_service.ipp b/boost_1_45_0/boost/asio/detail/impl/strand_service.ipp new file mode 100644 index 0000000..f94570a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/strand_service.ipp
@@ -0,0 +1,108 @@ +// +// detail/impl/strand_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/call_stack.hpp> +#include <boost/asio/detail/strand_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +struct strand_service::on_do_complete_exit +{ + io_service_impl* owner_; + strand_impl* impl_; + + ~on_do_complete_exit() + { + impl_->mutex_.lock(); + bool more_handlers = (--impl_->count_ > 0); + impl_->mutex_.unlock(); + + if (more_handlers) + owner_->post_immediate_completion(impl_); + } +}; + +strand_service::strand_service(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<strand_service>(io_service), + io_service_(boost::asio::use_service<io_service_impl>(io_service)), + mutex_(), + salt_(0) +{ +} + +void strand_service::shutdown_service() +{ + op_queue<operation> ops; + + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + for (std::size_t i = 0; i < num_implementations; ++i) + if (strand_impl* impl = implementations_[i].get()) + ops.push(impl->queue_); +} + +void strand_service::construct(strand_service::implementation_type& impl) +{ + std::size_t salt = salt_++; + std::size_t index = reinterpret_cast<std::size_t>(&impl); + index += (reinterpret_cast<std::size_t>(&impl) >> 3); + index ^= salt + 0x9e3779b9 + (index << 6) + (index >> 2); + index = index % num_implementations; + + boost::asio::detail::mutex::scoped_lock lock(mutex_); + + if (!implementations_[index]) + implementations_[index].reset(new strand_impl); + impl = implementations_[index].get(); +} + +void strand_service::do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) +{ + if (owner) + { + strand_impl* impl = static_cast<strand_impl*>(base); + + // Get the next handler to be executed. + impl->mutex_.lock(); + operation* o = impl->queue_.front(); + impl->queue_.pop(); + impl->mutex_.unlock(); + + // Indicate that this strand is executing on the current thread. + call_stack<strand_impl>::context ctx(impl); + + // Ensure the next handler, if any, is scheduled on block exit. + on_do_complete_exit on_exit = { owner, impl }; + (void)on_exit; + + o->complete(*owner); + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_STRAND_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/task_io_service.hpp b/boost_1_45_0/boost/asio/detail/impl/task_io_service.hpp new file mode 100644 index 0000000..ed5b2c4 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/task_io_service.hpp
@@ -0,0 +1,62 @@ +// +// detail/impl/task_io_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP +#define BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/call_stack.hpp> +#include <boost/asio/detail/completion_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +void task_io_service::dispatch(Handler handler) +{ + if (call_stack<task_io_service>::contains(this)) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + } + else + post(handler); +} + +template <typename Handler> +void task_io_service::post(Handler handler) +{ + // Allocate and construct an operation to wrap the handler. + typedef completion_handler<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + post_immediate_completion(p.p); + p.v = p.p = 0; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/task_io_service.ipp b/boost_1_45_0/boost/asio/detail/impl/task_io_service.ipp new file mode 100644 index 0000000..4cc2326 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/task_io_service.ipp
@@ -0,0 +1,356 @@ +// +// detail/impl/task_io_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/limits.hpp> +#include <boost/asio/detail/call_stack.hpp> +#include <boost/asio/detail/event.hpp> +#include <boost/asio/detail/reactor.hpp> +#include <boost/asio/detail/task_io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +struct task_io_service::task_cleanup +{ + ~task_cleanup() + { + // Enqueue the completed operations and reinsert the task at the end of + // the operation queue. + lock_->lock(); + task_io_service_->task_interrupted_ = true; + task_io_service_->op_queue_.push(*ops_); + task_io_service_->op_queue_.push(&task_io_service_->task_operation_); + } + + task_io_service* task_io_service_; + mutex::scoped_lock* lock_; + op_queue<operation>* ops_; +}; + +struct task_io_service::work_finished_on_block_exit +{ + ~work_finished_on_block_exit() + { + task_io_service_->work_finished(); + } + + task_io_service* task_io_service_; +}; + +struct task_io_service::idle_thread_info +{ + event wakeup_event; + idle_thread_info* next; +}; + +task_io_service::task_io_service(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<task_io_service>(io_service), + mutex_(), + task_(0), + task_interrupted_(true), + outstanding_work_(0), + stopped_(false), + shutdown_(false), + first_idle_thread_(0) +{ +} + +void task_io_service::init(std::size_t /*concurrency_hint*/) +{ +} + +void task_io_service::shutdown_service() +{ + mutex::scoped_lock lock(mutex_); + shutdown_ = true; + lock.unlock(); + + // Destroy handler objects. + while (!op_queue_.empty()) + { + operation* o = op_queue_.front(); + op_queue_.pop(); + if (o != &task_operation_) + o->destroy(); + } + + // Reset to initial state. + task_ = 0; +} + +void task_io_service::init_task() +{ + mutex::scoped_lock lock(mutex_); + if (!shutdown_ && !task_) + { + task_ = &use_service<reactor>(this->get_io_service()); + op_queue_.push(&task_operation_); + wake_one_thread_and_unlock(lock); + } +} + +std::size_t task_io_service::run(boost::system::error_code& ec) +{ + ec = boost::system::error_code(); + if (outstanding_work_ == 0) + { + stop(); + return 0; + } + + call_stack<task_io_service>::context ctx(this); + + idle_thread_info this_idle_thread; + this_idle_thread.next = 0; + + mutex::scoped_lock lock(mutex_); + + std::size_t n = 0; + for (; do_one(lock, &this_idle_thread); lock.lock()) + if (n != (std::numeric_limits<std::size_t>::max)()) + ++n; + return n; +} + +std::size_t task_io_service::run_one(boost::system::error_code& ec) +{ + ec = boost::system::error_code(); + if (outstanding_work_ == 0) + { + stop(); + return 0; + } + + call_stack<task_io_service>::context ctx(this); + + idle_thread_info this_idle_thread; + this_idle_thread.next = 0; + + mutex::scoped_lock lock(mutex_); + + return do_one(lock, &this_idle_thread); +} + +std::size_t task_io_service::poll(boost::system::error_code& ec) +{ + if (outstanding_work_ == 0) + { + stop(); + ec = boost::system::error_code(); + return 0; + } + + call_stack<task_io_service>::context ctx(this); + + mutex::scoped_lock lock(mutex_); + + std::size_t n = 0; + for (; do_one(lock, 0); lock.lock()) + if (n != (std::numeric_limits<std::size_t>::max)()) + ++n; + return n; +} + +std::size_t task_io_service::poll_one(boost::system::error_code& ec) +{ + ec = boost::system::error_code(); + if (outstanding_work_ == 0) + { + stop(); + return 0; + } + + call_stack<task_io_service>::context ctx(this); + + mutex::scoped_lock lock(mutex_); + + return do_one(lock, 0); +} + +void task_io_service::stop() +{ + mutex::scoped_lock lock(mutex_); + stop_all_threads(lock); +} + +void task_io_service::reset() +{ + mutex::scoped_lock lock(mutex_); + stopped_ = false; +} + +void task_io_service::post_immediate_completion(task_io_service::operation* op) +{ + work_started(); + post_deferred_completion(op); +} + +void task_io_service::post_deferred_completion(task_io_service::operation* op) +{ + mutex::scoped_lock lock(mutex_); + op_queue_.push(op); + wake_one_thread_and_unlock(lock); +} + +void task_io_service::post_deferred_completions( + op_queue<task_io_service::operation>& ops) +{ + if (!ops.empty()) + { + mutex::scoped_lock lock(mutex_); + op_queue_.push(ops); + wake_one_thread_and_unlock(lock); + } +} + +std::size_t task_io_service::do_one(mutex::scoped_lock& lock, + task_io_service::idle_thread_info* this_idle_thread) +{ + bool polling = !this_idle_thread; + bool task_has_run = false; + while (!stopped_) + { + if (!op_queue_.empty()) + { + // Prepare to execute first handler from queue. + operation* o = op_queue_.front(); + op_queue_.pop(); + bool more_handlers = (!op_queue_.empty()); + + if (o == &task_operation_) + { + task_interrupted_ = more_handlers || polling; + + // If the task has already run and we're polling then we're done. + if (task_has_run && polling) + { + task_interrupted_ = true; + op_queue_.push(&task_operation_); + return 0; + } + task_has_run = true; + + if (!more_handlers || !wake_one_idle_thread_and_unlock(lock)) + lock.unlock(); + + op_queue<operation> completed_ops; + task_cleanup c = { this, &lock, &completed_ops }; + (void)c; + + // Run the task. May throw an exception. Only block if the operation + // queue is empty and we're not polling, otherwise we want to return + // as soon as possible. + task_->run(!more_handlers && !polling, completed_ops); + } + else + { + if (more_handlers) + wake_one_thread_and_unlock(lock); + else + lock.unlock(); + + // Ensure the count of outstanding work is decremented on block exit. + work_finished_on_block_exit on_exit = { this }; + (void)on_exit; + + // Complete the operation. May throw an exception. + o->complete(*this); // deletes the operation object + + return 1; + } + } + else if (this_idle_thread) + { + // Nothing to run right now, so just wait for work to do. + this_idle_thread->next = first_idle_thread_; + first_idle_thread_ = this_idle_thread; + this_idle_thread->wakeup_event.clear(lock); + this_idle_thread->wakeup_event.wait(lock); + } + else + { + return 0; + } + } + + return 0; +} + +void task_io_service::stop_all_threads( + mutex::scoped_lock& lock) +{ + stopped_ = true; + + while (first_idle_thread_) + { + idle_thread_info* idle_thread = first_idle_thread_; + first_idle_thread_ = idle_thread->next; + idle_thread->next = 0; + idle_thread->wakeup_event.signal(lock); + } + + if (!task_interrupted_ && task_) + { + task_interrupted_ = true; + task_->interrupt(); + } +} + +bool task_io_service::wake_one_idle_thread_and_unlock( + mutex::scoped_lock& lock) +{ + if (first_idle_thread_) + { + idle_thread_info* idle_thread = first_idle_thread_; + first_idle_thread_ = idle_thread->next; + idle_thread->next = 0; + idle_thread->wakeup_event.signal_and_unlock(lock); + return true; + } + return false; +} + +void task_io_service::wake_one_thread_and_unlock( + mutex::scoped_lock& lock) +{ + if (!wake_one_idle_thread_and_unlock(lock)) + { + if (!task_interrupted_ && task_) + { + task_interrupted_ = true; + task_->interrupt(); + } + lock.unlock(); + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_TASK_IO_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/throw_error.ipp b/boost_1_45_0/boost/asio/detail/impl/throw_error.ipp new file mode 100644 index 0000000..e66cca5 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/throw_error.ipp
@@ -0,0 +1,47 @@ +// +// detail/impl/throw_error.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_THROW_ERROR_IPP +#define BOOST_ASIO_DETAIL_IMPL_THROW_ERROR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/throw_exception.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/system/system_error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +void do_throw_error(const boost::system::error_code& err) +{ + boost::system::system_error e(err); + boost::throw_exception(e); +} + +void do_throw_error(const boost::system::error_code& err, const char* location) +{ + boost::system::system_error e(err, location); + boost::throw_exception(e); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_THROW_ERROR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/timer_queue.ipp b/boost_1_45_0/boost/asio/detail/impl/timer_queue.ipp new file mode 100644 index 0000000..3789ac8 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/timer_queue.ipp
@@ -0,0 +1,87 @@ +// +// detail/impl/timer_queue.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_IPP +#define BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HEADER_ONLY) + +#include <boost/asio/detail/timer_queue.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +timer_queue<time_traits<boost::posix_time::ptime> >::timer_queue() +{ +} + +timer_queue<time_traits<boost::posix_time::ptime> >::~timer_queue() +{ +} + +bool timer_queue<time_traits<boost::posix_time::ptime> >::enqueue_timer( + const time_type& time, per_timer_data& timer, timer_op* op) +{ + return impl_.enqueue_timer(time, timer, op); +} + +bool timer_queue<time_traits<boost::posix_time::ptime> >::empty() const +{ + return impl_.empty(); +} + +long timer_queue<time_traits<boost::posix_time::ptime> >::wait_duration_msec( + long max_duration) const +{ + return impl_.wait_duration_msec(max_duration); +} + +long timer_queue<time_traits<boost::posix_time::ptime> >::wait_duration_usec( + long max_duration) const +{ + return impl_.wait_duration_usec(max_duration); +} + +void timer_queue<time_traits<boost::posix_time::ptime> >::get_ready_timers( + op_queue<operation>& ops) +{ + impl_.get_ready_timers(ops); +} + +void timer_queue<time_traits<boost::posix_time::ptime> >::get_all_timers( + op_queue<operation>& ops) +{ + impl_.get_all_timers(ops); +} + +std::size_t timer_queue<time_traits<boost::posix_time::ptime> >::cancel_timer( + per_timer_data& timer, op_queue<operation>& ops) +{ + return impl_.cancel_timer(timer, ops); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/timer_queue_set.ipp b/boost_1_45_0/boost/asio/detail/impl/timer_queue_set.ipp new file mode 100644 index 0000000..275b9c5 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/timer_queue_set.ipp
@@ -0,0 +1,103 @@ +// +// detail/impl/timer_queue_set.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP +#define BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +timer_queue_set::timer_queue_set() + : first_(0) +{ +} + +void timer_queue_set::insert(timer_queue_base* q) +{ + q->next_ = first_; + first_ = q; +} + +void timer_queue_set::erase(timer_queue_base* q) +{ + if (first_) + { + if (q == first_) + { + first_ = q->next_; + q->next_ = 0; + return; + } + + for (timer_queue_base* p = first_; p->next_; p = p->next_) + { + if (p->next_ == q) + { + p->next_ = q->next_; + q->next_ = 0; + return; + } + } + } +} + +bool timer_queue_set::all_empty() const +{ + for (timer_queue_base* p = first_; p; p = p->next_) + if (!p->empty()) + return false; + return true; +} + +long timer_queue_set::wait_duration_msec(long max_duration) const +{ + long min_duration = max_duration; + for (timer_queue_base* p = first_; p; p = p->next_) + min_duration = p->wait_duration_msec(min_duration); + return min_duration; +} + +long timer_queue_set::wait_duration_usec(long max_duration) const +{ + long min_duration = max_duration; + for (timer_queue_base* p = first_; p; p = p->next_) + min_duration = p->wait_duration_usec(min_duration); + return min_duration; +} + +void timer_queue_set::get_ready_timers(op_queue<operation>& ops) +{ + for (timer_queue_base* p = first_; p; p = p->next_) + p->get_ready_timers(ops); +} + +void timer_queue_set::get_all_timers(op_queue<operation>& ops) +{ + for (timer_queue_base* p = first_; p; p = p->next_) + p->get_all_timers(ops); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_event.ipp b/boost_1_45_0/boost/asio/detail/impl/win_event.ipp new file mode 100644 index 0000000..d383c5b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_event.ipp
@@ -0,0 +1,52 @@ +// +// detail/win_event.ipp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) + +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/win_event.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +win_event::win_event() + : event_(::CreateEvent(0, true, false, 0)) +{ + if (!event_) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "event"); + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_iocp_handle_service.ipp b/boost_1_45_0/boost/asio/detail/impl/win_iocp_handle_service.ipp new file mode 100644 index 0000000..3169632 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_iocp_handle_service.ipp
@@ -0,0 +1,454 @@ +// +// detail/impl/win_iocp_handle_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_HANDLE_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_HANDLE_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/win_iocp_handle_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class win_iocp_handle_service::overlapped_wrapper + : public OVERLAPPED +{ +public: + explicit overlapped_wrapper(boost::system::error_code& ec) + { + Internal = 0; + InternalHigh = 0; + Offset = 0; + OffsetHigh = 0; + + // Create a non-signalled manual-reset event, for GetOverlappedResult. + hEvent = ::CreateEvent(0, TRUE, FALSE, 0); + if (hEvent) + { + // As documented in GetQueuedCompletionStatus, setting the low order + // bit of this event prevents our synchronous writes from being treated + // as completion port events. + *reinterpret_cast<DWORD_PTR*>(&hEvent) |= 1; + } + else + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + } + + ~overlapped_wrapper() + { + if (hEvent) + { + ::CloseHandle(hEvent); + } + } +}; + +win_iocp_handle_service::win_iocp_handle_service( + boost::asio::io_service& io_service) + : iocp_service_(boost::asio::use_service<win_iocp_io_service>(io_service)), + mutex_(), + impl_list_(0) +{ +} + +void win_iocp_handle_service::shutdown_service() +{ + // Close all implementations, causing all operations to complete. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + implementation_type* impl = impl_list_; + while (impl) + { + close_for_destruction(*impl); + impl = impl->next_; + } +} + +void win_iocp_handle_service::construct( + win_iocp_handle_service::implementation_type& impl) +{ + impl.handle_ = INVALID_HANDLE_VALUE; + impl.safe_cancellation_thread_id_ = 0; + + // Insert implementation into linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + impl.next_ = impl_list_; + impl.prev_ = 0; + if (impl_list_) + impl_list_->prev_ = &impl; + impl_list_ = &impl; +} + +void win_iocp_handle_service::destroy( + win_iocp_handle_service::implementation_type& impl) +{ + close_for_destruction(impl); + + // Remove implementation from linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + if (impl_list_ == &impl) + impl_list_ = impl.next_; + if (impl.prev_) + impl.prev_->next_ = impl.next_; + if (impl.next_) + impl.next_->prev_= impl.prev_; + impl.next_ = 0; + impl.prev_ = 0; +} + +boost::system::error_code win_iocp_handle_service::assign( + win_iocp_handle_service::implementation_type& impl, + const native_type& native_handle, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + if (iocp_service_.register_handle(native_handle, ec)) + return ec; + + impl.handle_ = native_handle; + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code win_iocp_handle_service::close( + win_iocp_handle_service::implementation_type& impl, + boost::system::error_code& ec) +{ + if (is_open(impl)) + { + if (!::CloseHandle(impl.handle_)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + impl.handle_ = INVALID_HANDLE_VALUE; + impl.safe_cancellation_thread_id_ = 0; + } + + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code win_iocp_handle_service::cancel( + win_iocp_handle_service::implementation_type& impl, + boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + } + else if (FARPROC cancel_io_ex_ptr = ::GetProcAddress( + ::GetModuleHandleA("KERNEL32"), "CancelIoEx")) + { + // The version of Windows supports cancellation from any thread. + typedef BOOL (WINAPI* cancel_io_ex_t)(HANDLE, LPOVERLAPPED); + cancel_io_ex_t cancel_io_ex = (cancel_io_ex_t)cancel_io_ex_ptr; + if (!cancel_io_ex(impl.handle_, 0)) + { + DWORD last_error = ::GetLastError(); + if (last_error == ERROR_NOT_FOUND) + { + // ERROR_NOT_FOUND means that there were no operations to be + // cancelled. We swallow this error to match the behaviour on other + // platforms. + ec = boost::system::error_code(); + } + else + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + } + else + { + ec = boost::system::error_code(); + } + } + else if (impl.safe_cancellation_thread_id_ == 0) + { + // No operations have been started, so there's nothing to cancel. + ec = boost::system::error_code(); + } + else if (impl.safe_cancellation_thread_id_ == ::GetCurrentThreadId()) + { + // Asynchronous operations have been started from the current thread only, + // so it is safe to try to cancel them using CancelIo. + if (!::CancelIo(impl.handle_)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + else + { + ec = boost::system::error_code(); + } + } + else + { + // Asynchronous operations have been started from more than one thread, + // so cancellation is not safe. + ec = boost::asio::error::operation_not_supported; + } + + return ec; +} + +size_t win_iocp_handle_service::do_write( + win_iocp_handle_service::implementation_type& impl, boost::uint64_t offset, + const boost::asio::const_buffer& buffer, boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to write 0 bytes on a handle is a no-op. + if (boost::asio::buffer_size(buffer) == 0) + { + ec = boost::system::error_code(); + return 0; + } + + overlapped_wrapper overlapped(ec); + if (ec) + { + return 0; + } + + // Write the data. + overlapped.Offset = offset & 0xFFFFFFFF; + overlapped.OffsetHigh = (offset >> 32) & 0xFFFFFFFF; + BOOL ok = ::WriteFile(impl.handle_, + boost::asio::buffer_cast<LPCVOID>(buffer), + static_cast<DWORD>(boost::asio::buffer_size(buffer)), 0, &overlapped); + if (!ok) + { + DWORD last_error = ::GetLastError(); + if (last_error != ERROR_IO_PENDING) + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return 0; + } + } + + // Wait for the operation to complete. + DWORD bytes_transferred = 0; + ok = ::GetOverlappedResult(impl.handle_, + &overlapped, &bytes_transferred, TRUE); + if (!ok) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return 0; + } + + ec = boost::system::error_code(); + return bytes_transferred; +} + +void win_iocp_handle_service::start_write_op( + win_iocp_handle_service::implementation_type& impl, boost::uint64_t offset, + const boost::asio::const_buffer& buffer, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (!is_open(impl)) + { + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + } + else if (boost::asio::buffer_size(buffer) == 0) + { + // A request to write 0 bytes on a handle is a no-op. + iocp_service_.on_completion(op); + } + else + { + DWORD bytes_transferred = 0; + op->Offset = offset & 0xFFFFFFFF; + op->OffsetHigh = (offset >> 32) & 0xFFFFFFFF; + BOOL ok = ::WriteFile(impl.handle_, + boost::asio::buffer_cast<LPCVOID>(buffer), + static_cast<DWORD>(boost::asio::buffer_size(buffer)), + &bytes_transferred, op); + DWORD last_error = ::GetLastError(); + if (!ok && last_error != ERROR_IO_PENDING + && last_error != ERROR_MORE_DATA) + { + iocp_service_.on_completion(op, last_error, bytes_transferred); + } + else + { + iocp_service_.on_pending(op); + } + } +} + +size_t win_iocp_handle_service::do_read( + win_iocp_handle_service::implementation_type& impl, boost::uint64_t offset, + const boost::asio::mutable_buffer& buffer, boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + return 0; + } + + // A request to read 0 bytes on a stream handle is a no-op. + if (boost::asio::buffer_size(buffer) == 0) + { + ec = boost::system::error_code(); + return 0; + } + + overlapped_wrapper overlapped(ec); + if (ec) + { + return 0; + } + + // Read some data. + overlapped.Offset = offset & 0xFFFFFFFF; + overlapped.OffsetHigh = (offset >> 32) & 0xFFFFFFFF; + BOOL ok = ::ReadFile(impl.handle_, + boost::asio::buffer_cast<LPVOID>(buffer), + static_cast<DWORD>(boost::asio::buffer_size(buffer)), 0, &overlapped); + if (!ok) + { + DWORD last_error = ::GetLastError(); + if (last_error != ERROR_IO_PENDING && last_error != ERROR_MORE_DATA) + { + if (last_error == ERROR_HANDLE_EOF) + { + ec = boost::asio::error::eof; + } + else + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + return 0; + } + } + + // Wait for the operation to complete. + DWORD bytes_transferred = 0; + ok = ::GetOverlappedResult(impl.handle_, + &overlapped, &bytes_transferred, TRUE); + if (!ok) + { + DWORD last_error = ::GetLastError(); + if (last_error == ERROR_HANDLE_EOF) + { + ec = boost::asio::error::eof; + } + else + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + return 0; + } + + ec = boost::system::error_code(); + return bytes_transferred; +} + +void win_iocp_handle_service::start_read_op( + win_iocp_handle_service::implementation_type& impl, boost::uint64_t offset, + const boost::asio::mutable_buffer& buffer, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (!is_open(impl)) + { + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + } + else if (boost::asio::buffer_size(buffer) == 0) + { + // A request to read 0 bytes on a handle is a no-op. + iocp_service_.on_completion(op); + } + else + { + DWORD bytes_transferred = 0; + op->Offset = offset & 0xFFFFFFFF; + op->OffsetHigh = (offset >> 32) & 0xFFFFFFFF; + BOOL ok = ::ReadFile(impl.handle_, + boost::asio::buffer_cast<LPVOID>(buffer), + static_cast<DWORD>(boost::asio::buffer_size(buffer)), + &bytes_transferred, op); + DWORD last_error = ::GetLastError(); + if (!ok && last_error != ERROR_IO_PENDING + && last_error != ERROR_MORE_DATA) + { + iocp_service_.on_completion(op, last_error, bytes_transferred); + } + else + { + iocp_service_.on_pending(op); + } + } +} + +void win_iocp_handle_service::update_cancellation_thread_id( + win_iocp_handle_service::implementation_type& impl) +{ + if (impl.safe_cancellation_thread_id_ == 0) + impl.safe_cancellation_thread_id_ = ::GetCurrentThreadId(); + else if (impl.safe_cancellation_thread_id_ != ::GetCurrentThreadId()) + impl.safe_cancellation_thread_id_ = ~DWORD(0); +} + +void win_iocp_handle_service::close_for_destruction(implementation_type& impl) +{ + if (is_open(impl)) + { + ::CloseHandle(impl.handle_); + impl.handle_ = INVALID_HANDLE_VALUE; + impl.safe_cancellation_thread_id_ = 0; + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_HANDLE_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.hpp b/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.hpp new file mode 100644 index 0000000..cccff70 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.hpp
@@ -0,0 +1,117 @@ +// +// detail/impl/win_iocp_io_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/call_stack.hpp> +#include <boost/asio/detail/completion_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +void win_iocp_io_service::dispatch(Handler handler) +{ + if (call_stack<win_iocp_io_service>::contains(this)) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + } + else + post(handler); +} + +template <typename Handler> +void win_iocp_io_service::post(Handler handler) +{ + // Allocate and construct an operation to wrap the handler. + typedef completion_handler<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + post_immediate_completion(p.p); + p.v = p.p = 0; +} + +template <typename Time_Traits> +void win_iocp_io_service::add_timer_queue( + timer_queue<Time_Traits>& queue) +{ + do_add_timer_queue(queue); +} + +template <typename Time_Traits> +void win_iocp_io_service::remove_timer_queue( + timer_queue<Time_Traits>& queue) +{ + do_remove_timer_queue(queue); +} + +template <typename Time_Traits> +void win_iocp_io_service::schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op) +{ + // If the service has been shut down we silently discard the timer. + if (::InterlockedExchangeAdd(&shutdown_, 0) != 0) + { + post_immediate_completion(op); + return; + } + + mutex::scoped_lock lock(dispatch_mutex_); + + bool earliest = queue.enqueue_timer(time, timer, op); + work_started(); + if (earliest) + update_timeout(); +} + +template <typename Time_Traits> +std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer) +{ + // If the service has been shut down we silently ignore the cancellation. + if (::InterlockedExchangeAdd(&shutdown_, 0) != 0) + return 0; + + mutex::scoped_lock lock(dispatch_mutex_); + op_queue<win_iocp_operation> ops; + std::size_t n = queue.cancel_timer(timer, ops); + post_deferred_completions(ops); + return n; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.ipp b/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.ipp new file mode 100644 index 0000000..08b81e9 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_iocp_io_service.ipp
@@ -0,0 +1,499 @@ +// +// detail/impl/win_iocp_io_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/limits.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/win_iocp_io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +struct win_iocp_io_service::work_finished_on_block_exit +{ + ~work_finished_on_block_exit() + { + io_service_->work_finished(); + } + + win_iocp_io_service* io_service_; +}; + +struct win_iocp_io_service::timer_thread_function +{ + void operator()() + { + while (::InterlockedExchangeAdd(&io_service_->shutdown_, 0) == 0) + { + if (::WaitForSingleObject(io_service_->waitable_timer_.handle, + INFINITE) == WAIT_OBJECT_0) + { + ::InterlockedExchange(&io_service_->dispatch_required_, 1); + ::PostQueuedCompletionStatus(io_service_->iocp_.handle, + 0, wake_for_dispatch, 0); + } + } + } + + win_iocp_io_service* io_service_; +}; + +win_iocp_io_service::win_iocp_io_service(boost::asio::io_service& io_service) + : boost::asio::detail::service_base<win_iocp_io_service>(io_service), + iocp_(), + outstanding_work_(0), + stopped_(0), + shutdown_(0), + dispatch_required_(0) +{ +} + +void win_iocp_io_service::init(size_t concurrency_hint) +{ + iocp_.handle = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, + static_cast<DWORD>((std::min<size_t>)(concurrency_hint, DWORD(~0)))); + if (!iocp_.handle) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "iocp"); + } +} + +void win_iocp_io_service::shutdown_service() +{ + ::InterlockedExchange(&shutdown_, 1); + + if (timer_thread_) + { + LARGE_INTEGER timeout; + timeout.QuadPart = 1; + ::SetWaitableTimer(waitable_timer_.handle, &timeout, 1, 0, 0, FALSE); + } + + while (::InterlockedExchangeAdd(&outstanding_work_, 0) > 0) + { + op_queue<win_iocp_operation> ops; + timer_queues_.get_all_timers(ops); + ops.push(completed_ops_); + if (!ops.empty()) + { + while (win_iocp_operation* op = ops.front()) + { + ops.pop(); + ::InterlockedDecrement(&outstanding_work_); + op->destroy(); + } + } + else + { + DWORD bytes_transferred = 0; + dword_ptr_t completion_key = 0; + LPOVERLAPPED overlapped = 0; + ::GetQueuedCompletionStatus(iocp_.handle, &bytes_transferred, + &completion_key, &overlapped, gqcs_timeout); + if (overlapped) + { + ::InterlockedDecrement(&outstanding_work_); + static_cast<win_iocp_operation*>(overlapped)->destroy(); + } + } + } + + if (timer_thread_) + timer_thread_->join(); +} + +boost::system::error_code win_iocp_io_service::register_handle( + HANDLE handle, boost::system::error_code& ec) +{ + if (::CreateIoCompletionPort(handle, iocp_.handle, 0, 0) == 0) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + else + { + ec = boost::system::error_code(); + } + return ec; +} + +size_t win_iocp_io_service::run(boost::system::error_code& ec) +{ + if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0) + { + stop(); + ec = boost::system::error_code(); + return 0; + } + + call_stack<win_iocp_io_service>::context ctx(this); + + size_t n = 0; + while (do_one(true, ec)) + if (n != (std::numeric_limits<size_t>::max)()) + ++n; + return n; +} + +size_t win_iocp_io_service::run_one(boost::system::error_code& ec) +{ + if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0) + { + stop(); + ec = boost::system::error_code(); + return 0; + } + + call_stack<win_iocp_io_service>::context ctx(this); + + return do_one(true, ec); +} + +size_t win_iocp_io_service::poll(boost::system::error_code& ec) +{ + if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0) + { + stop(); + ec = boost::system::error_code(); + return 0; + } + + call_stack<win_iocp_io_service>::context ctx(this); + + size_t n = 0; + while (do_one(false, ec)) + if (n != (std::numeric_limits<size_t>::max)()) + ++n; + return n; +} + +size_t win_iocp_io_service::poll_one(boost::system::error_code& ec) +{ + if (::InterlockedExchangeAdd(&outstanding_work_, 0) == 0) + { + stop(); + ec = boost::system::error_code(); + return 0; + } + + call_stack<win_iocp_io_service>::context ctx(this); + + return do_one(false, ec); +} + +void win_iocp_io_service::stop() +{ + if (::InterlockedExchange(&stopped_, 1) == 0) + { + if (!::PostQueuedCompletionStatus(iocp_.handle, 0, 0, 0)) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "pqcs"); + } + } +} + +void win_iocp_io_service::post_deferred_completion(win_iocp_operation* op) +{ + // Flag the operation as ready. + op->ready_ = 1; + + // Enqueue the operation on the I/O completion port. + if (!::PostQueuedCompletionStatus(iocp_.handle, + 0, overlapped_contains_result, op)) + { + // Out of resources. Put on completed queue instead. + mutex::scoped_lock lock(dispatch_mutex_); + completed_ops_.push(op); + ::InterlockedExchange(&dispatch_required_, 1); + } +} + +void win_iocp_io_service::post_deferred_completions( + op_queue<win_iocp_operation>& ops) +{ + while (win_iocp_operation* op = ops.front()) + { + ops.pop(); + + // Flag the operation as ready. + op->ready_ = 1; + + // Enqueue the operation on the I/O completion port. + if (!::PostQueuedCompletionStatus(iocp_.handle, + 0, overlapped_contains_result, op)) + { + // Out of resources. Put on completed queue instead. + mutex::scoped_lock lock(dispatch_mutex_); + completed_ops_.push(op); + completed_ops_.push(ops); + ::InterlockedExchange(&dispatch_required_, 1); + } + } +} + +void win_iocp_io_service::on_pending(win_iocp_operation* op) +{ + if (::InterlockedCompareExchange(&op->ready_, 1, 0) == 1) + { + // Enqueue the operation on the I/O completion port. + if (!::PostQueuedCompletionStatus(iocp_.handle, + 0, overlapped_contains_result, op)) + { + // Out of resources. Put on completed queue instead. + mutex::scoped_lock lock(dispatch_mutex_); + completed_ops_.push(op); + ::InterlockedExchange(&dispatch_required_, 1); + } + } +} + +void win_iocp_io_service::on_completion(win_iocp_operation* op, + DWORD last_error, DWORD bytes_transferred) +{ + // Flag that the operation is ready for invocation. + op->ready_ = 1; + + // Store results in the OVERLAPPED structure. + op->Internal = reinterpret_cast<ulong_ptr_t>( + &boost::asio::error::get_system_category()); + op->Offset = last_error; + op->OffsetHigh = bytes_transferred; + + // Enqueue the operation on the I/O completion port. + if (!::PostQueuedCompletionStatus(iocp_.handle, + 0, overlapped_contains_result, op)) + { + // Out of resources. Put on completed queue instead. + mutex::scoped_lock lock(dispatch_mutex_); + completed_ops_.push(op); + ::InterlockedExchange(&dispatch_required_, 1); + } +} + +void win_iocp_io_service::on_completion(win_iocp_operation* op, + const boost::system::error_code& ec, DWORD bytes_transferred) +{ + // Flag that the operation is ready for invocation. + op->ready_ = 1; + + // Store results in the OVERLAPPED structure. + op->Internal = reinterpret_cast<ulong_ptr_t>(&ec.category()); + op->Offset = ec.value(); + op->OffsetHigh = bytes_transferred; + + // Enqueue the operation on the I/O completion port. + if (!::PostQueuedCompletionStatus(iocp_.handle, + 0, overlapped_contains_result, op)) + { + // Out of resources. Put on completed queue instead. + mutex::scoped_lock lock(dispatch_mutex_); + completed_ops_.push(op); + ::InterlockedExchange(&dispatch_required_, 1); + } +} + +size_t win_iocp_io_service::do_one(bool block, boost::system::error_code& ec) +{ + for (;;) + { + // Try to acquire responsibility for dispatching timers and completed ops. + if (::InterlockedCompareExchange(&dispatch_required_, 0, 1) == 1) + { + mutex::scoped_lock lock(dispatch_mutex_); + + // Dispatch pending timers and operations. + op_queue<win_iocp_operation> ops; + ops.push(completed_ops_); + timer_queues_.get_ready_timers(ops); + post_deferred_completions(ops); + update_timeout(); + } + + // Get the next operation from the queue. + DWORD bytes_transferred = 0; + dword_ptr_t completion_key = 0; + LPOVERLAPPED overlapped = 0; + ::SetLastError(0); + BOOL ok = ::GetQueuedCompletionStatus(iocp_.handle, &bytes_transferred, + &completion_key, &overlapped, block ? gqcs_timeout : 0); + DWORD last_error = ::GetLastError(); + + if (overlapped) + { + win_iocp_operation* op = static_cast<win_iocp_operation*>(overlapped); + boost::system::error_code result_ec(last_error, + boost::asio::error::get_system_category()); + + // We may have been passed the last_error and bytes_transferred in the + // OVERLAPPED structure itself. + if (completion_key == overlapped_contains_result) + { + result_ec = boost::system::error_code(static_cast<int>(op->Offset), + *reinterpret_cast<boost::system::error_category*>(op->Internal)); + bytes_transferred = op->OffsetHigh; + } + + // Otherwise ensure any result has been saved into the OVERLAPPED + // structure. + else + { + op->Internal = reinterpret_cast<ulong_ptr_t>(&result_ec.category()); + op->Offset = result_ec.value(); + op->OffsetHigh = bytes_transferred; + } + + // Dispatch the operation only if ready. The operation may not be ready + // if the initiating function (e.g. a call to WSARecv) has not yet + // returned. This is because the initiating function still wants access + // to the operation's OVERLAPPED structure. + if (::InterlockedCompareExchange(&op->ready_, 1, 0) == 1) + { + // Ensure the count of outstanding work is decremented on block exit. + work_finished_on_block_exit on_exit = { this }; + (void)on_exit; + + op->complete(*this, result_ec, bytes_transferred); + ec = boost::system::error_code(); + return 1; + } + } + else if (!ok) + { + if (last_error != WAIT_TIMEOUT) + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return 0; + } + + // If we're not polling we need to keep going until we get a real handler. + if (block) + continue; + + ec = boost::system::error_code(); + return 0; + } + else if (completion_key == wake_for_dispatch) + { + // We have been woken up to try to acquire responsibility for dispatching + // timers and completed operations. + } + else + { + // The stopped_ flag is always checked to ensure that any leftover + // interrupts from a previous run invocation are ignored. + if (::InterlockedExchangeAdd(&stopped_, 0) != 0) + { + // Wake up next thread that is blocked on GetQueuedCompletionStatus. + if (!::PostQueuedCompletionStatus(iocp_.handle, 0, 0, 0)) + { + last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return 0; + } + + ec = boost::system::error_code(); + return 0; + } + } + } +} + +void win_iocp_io_service::do_add_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(dispatch_mutex_); + + timer_queues_.insert(&queue); + + if (!waitable_timer_.handle) + { + waitable_timer_.handle = ::CreateWaitableTimer(0, FALSE, 0); + if (waitable_timer_.handle == 0) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "timer"); + } + + LARGE_INTEGER timeout; + timeout.QuadPart = -max_timeout_usec; + timeout.QuadPart *= 10; + ::SetWaitableTimer(waitable_timer_.handle, + &timeout, max_timeout_msec, 0, 0, FALSE); + } + + if (!timer_thread_) + { + timer_thread_function thread_function = { this }; + timer_thread_.reset(new thread(thread_function, 65536)); + } +} + +void win_iocp_io_service::do_remove_timer_queue(timer_queue_base& queue) +{ + mutex::scoped_lock lock(dispatch_mutex_); + + timer_queues_.erase(&queue); +} + +void win_iocp_io_service::update_timeout() +{ + if (timer_thread_) + { + // There's no point updating the waitable timer if the new timeout period + // exceeds the maximum timeout. In that case, we might as well wait for the + // existing period of the timer to expire. + long timeout_usec = timer_queues_.wait_duration_usec(max_timeout_usec); + if (timeout_usec < max_timeout_usec) + { + LARGE_INTEGER timeout; + timeout.QuadPart = -timeout_usec; + timeout.QuadPart *= 10; + ::SetWaitableTimer(waitable_timer_.handle, + &timeout, max_timeout_msec, 0, 0, FALSE); + } + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_IO_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_iocp_serial_port_service.ipp b/boost_1_45_0/boost/asio/detail/impl/win_iocp_serial_port_service.ipp new file mode 100644 index 0000000..bd2310c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_iocp_serial_port_service.ipp
@@ -0,0 +1,182 @@ +// +// detail/impl/win_iocp_serial_port_service.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SERIAL_PORT_SERVICE_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SERIAL_PORT_SERVICE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) && defined(BOOST_ASIO_HAS_SERIAL_PORT) + +#include <cstring> +#include <boost/asio/detail/win_iocp_serial_port_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +win_iocp_serial_port_service::win_iocp_serial_port_service( + boost::asio::io_service& io_service) + : handle_service_(io_service) +{ +} + +void win_iocp_serial_port_service::shutdown_service() +{ +} + +boost::system::error_code win_iocp_serial_port_service::open( + win_iocp_serial_port_service::implementation_type& impl, + const std::string& device, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + // For convenience, add a leading \\.\ sequence if not already present. + std::string name = (device[0] == '\\') ? device : "\\\\.\\" + device; + + // Open a handle to the serial port. + ::HANDLE handle = ::CreateFileA(name.c_str(), + GENERIC_READ | GENERIC_WRITE, 0, 0, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + if (handle == INVALID_HANDLE_VALUE) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + // Determine the initial serial port parameters. + using namespace std; // For memset. + ::DCB dcb; + memset(&dcb, 0, sizeof(DCB)); + dcb.DCBlength = sizeof(DCB); + if (!::GetCommState(handle, &dcb)) + { + DWORD last_error = ::GetLastError(); + ::CloseHandle(handle); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + // Set some default serial port parameters. This implementation does not + // support changing these, so they might as well be in a known state. + dcb.fBinary = TRUE; // Win32 only supports binary mode. + dcb.fDsrSensitivity = FALSE; + dcb.fNull = FALSE; // Do not ignore NULL characters. + dcb.fAbortOnError = FALSE; // Ignore serial framing errors. + if (!::SetCommState(handle, &dcb)) + { + DWORD last_error = ::GetLastError(); + ::CloseHandle(handle); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + // Set up timeouts so that the serial port will behave similarly to a + // network socket. Reads wait for at least one byte, then return with + // whatever they have. Writes return once everything is out the door. + ::COMMTIMEOUTS timeouts; + timeouts.ReadIntervalTimeout = 1; + timeouts.ReadTotalTimeoutMultiplier = 0; + timeouts.ReadTotalTimeoutConstant = 0; + timeouts.WriteTotalTimeoutMultiplier = 0; + timeouts.WriteTotalTimeoutConstant = 0; + if (!::SetCommTimeouts(handle, &timeouts)) + { + DWORD last_error = ::GetLastError(); + ::CloseHandle(handle); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + // We're done. Take ownership of the serial port handle. + if (handle_service_.assign(impl, handle, ec)) + ::CloseHandle(handle); + return ec; +} + +boost::system::error_code win_iocp_serial_port_service::do_set_option( + win_iocp_serial_port_service::implementation_type& impl, + win_iocp_serial_port_service::store_function_type store, + const void* option, boost::system::error_code& ec) +{ + using namespace std; // For memcpy. + + ::DCB dcb; + memset(&dcb, 0, sizeof(DCB)); + dcb.DCBlength = sizeof(DCB); + if (!::GetCommState(handle_service_.native(impl), &dcb)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + if (store(option, dcb, ec)) + return ec; + + if (!::SetCommState(handle_service_.native(impl), &dcb)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code win_iocp_serial_port_service::do_get_option( + const win_iocp_serial_port_service::implementation_type& impl, + win_iocp_serial_port_service::load_function_type load, + void* option, boost::system::error_code& ec) const +{ + using namespace std; // For memset. + + ::DCB dcb; + memset(&dcb, 0, sizeof(DCB)); + dcb.DCBlength = sizeof(DCB); + if (!::GetCommState(handle_service_.native(impl), &dcb)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + return ec; + } + + return load(option, dcb, ec); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) && defined(BOOST_ASIO_HAS_SERIAL_PORT) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SERIAL_PORT_SERVICE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_iocp_socket_service_base.ipp b/boost_1_45_0/boost/asio/detail/impl/win_iocp_socket_service_base.ipp new file mode 100644 index 0000000..e301658 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_iocp_socket_service_base.ipp
@@ -0,0 +1,577 @@ +// +// detail/impl/win_iocp_socket_service_base.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SOCKET_SERVICE_BASE_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SOCKET_SERVICE_BASE_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/win_iocp_socket_service_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +win_iocp_socket_service_base::win_iocp_socket_service_base( + boost::asio::io_service& io_service) + : io_service_(io_service), + iocp_service_(use_service<win_iocp_io_service>(io_service)), + reactor_(0), + mutex_(), + impl_list_(0) +{ +} + +void win_iocp_socket_service_base::shutdown_service() +{ + // Close all implementations, causing all operations to complete. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + base_implementation_type* impl = impl_list_; + while (impl) + { + boost::system::error_code ignored_ec; + close_for_destruction(*impl); + impl = impl->next_; + } +} + +void win_iocp_socket_service_base::construct( + win_iocp_socket_service_base::base_implementation_type& impl) +{ + impl.socket_ = invalid_socket; + impl.state_ = 0; + impl.cancel_token_.reset(); +#if defined(BOOST_ASIO_ENABLE_CANCELIO) + impl.safe_cancellation_thread_id_ = 0; +#endif // defined(BOOST_ASIO_ENABLE_CANCELIO) + + // Insert implementation into linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + impl.next_ = impl_list_; + impl.prev_ = 0; + if (impl_list_) + impl_list_->prev_ = &impl; + impl_list_ = &impl; +} + +void win_iocp_socket_service_base::destroy( + win_iocp_socket_service_base::base_implementation_type& impl) +{ + close_for_destruction(impl); + + // Remove implementation from linked list of all implementations. + boost::asio::detail::mutex::scoped_lock lock(mutex_); + if (impl_list_ == &impl) + impl_list_ = impl.next_; + if (impl.prev_) + impl.prev_->next_ = impl.next_; + if (impl.next_) + impl.next_->prev_= impl.prev_; + impl.next_ = 0; + impl.prev_ = 0; +} + +boost::system::error_code win_iocp_socket_service_base::close( + win_iocp_socket_service_base::base_implementation_type& impl, + boost::system::error_code& ec) +{ + if (is_open(impl)) + { + // Check if the reactor was created, in which case we need to close the + // socket on the reactor as well to cancel any operations that might be + // running there. + reactor* r = static_cast<reactor*>( + interlocked_compare_exchange_pointer( + reinterpret_cast<void**>(&reactor_), 0, 0)); + if (r) + r->close_descriptor(impl.socket_, impl.reactor_data_); + } + + if (socket_ops::close(impl.socket_, impl.state_, false, ec) == 0) + { + impl.socket_ = invalid_socket; + impl.state_ = 0; + impl.cancel_token_.reset(); +#if defined(BOOST_ASIO_ENABLE_CANCELIO) + impl.safe_cancellation_thread_id_ = 0; +#endif // defined(BOOST_ASIO_ENABLE_CANCELIO) + } + + return ec; +} + +boost::system::error_code win_iocp_socket_service_base::cancel( + win_iocp_socket_service_base::base_implementation_type& impl, + boost::system::error_code& ec) +{ + if (!is_open(impl)) + { + ec = boost::asio::error::bad_descriptor; + return ec; + } + else if (FARPROC cancel_io_ex_ptr = ::GetProcAddress( + ::GetModuleHandleA("KERNEL32"), "CancelIoEx")) + { + // The version of Windows supports cancellation from any thread. + typedef BOOL (WINAPI* cancel_io_ex_t)(HANDLE, LPOVERLAPPED); + cancel_io_ex_t cancel_io_ex = (cancel_io_ex_t)cancel_io_ex_ptr; + socket_type sock = impl.socket_; + HANDLE sock_as_handle = reinterpret_cast<HANDLE>(sock); + if (!cancel_io_ex(sock_as_handle, 0)) + { + DWORD last_error = ::GetLastError(); + if (last_error == ERROR_NOT_FOUND) + { + // ERROR_NOT_FOUND means that there were no operations to be + // cancelled. We swallow this error to match the behaviour on other + // platforms. + ec = boost::system::error_code(); + } + else + { + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + } + else + { + ec = boost::system::error_code(); + } + } +#if defined(BOOST_ASIO_ENABLE_CANCELIO) + else if (impl.safe_cancellation_thread_id_ == 0) + { + // No operations have been started, so there's nothing to cancel. + ec = boost::system::error_code(); + } + else if (impl.safe_cancellation_thread_id_ == ::GetCurrentThreadId()) + { + // Asynchronous operations have been started from the current thread only, + // so it is safe to try to cancel them using CancelIo. + socket_type sock = impl.socket_; + HANDLE sock_as_handle = reinterpret_cast<HANDLE>(sock); + if (!::CancelIo(sock_as_handle)) + { + DWORD last_error = ::GetLastError(); + ec = boost::system::error_code(last_error, + boost::asio::error::get_system_category()); + } + else + { + ec = boost::system::error_code(); + } + } + else + { + // Asynchronous operations have been started from more than one thread, + // so cancellation is not safe. + ec = boost::asio::error::operation_not_supported; + } +#else // defined(BOOST_ASIO_ENABLE_CANCELIO) + else + { + // Cancellation is not supported as CancelIo may not be used. + ec = boost::asio::error::operation_not_supported; + } +#endif // defined(BOOST_ASIO_ENABLE_CANCELIO) + + // Cancel any operations started via the reactor. + if (!ec) + { + reactor* r = static_cast<reactor*>( + interlocked_compare_exchange_pointer( + reinterpret_cast<void**>(&reactor_), 0, 0)); + if (r) + r->cancel_ops(impl.socket_, impl.reactor_data_); + } + + return ec; +} + +boost::system::error_code win_iocp_socket_service_base::do_open( + win_iocp_socket_service_base::base_implementation_type& impl, + int family, int type, int protocol, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + socket_holder sock(socket_ops::socket(family, type, protocol, ec)); + if (sock.get() == invalid_socket) + return ec; + + HANDLE sock_as_handle = reinterpret_cast<HANDLE>(sock.get()); + if (iocp_service_.register_handle(sock_as_handle, ec)) + return ec; + + impl.socket_ = sock.release(); + switch (type) + { + case SOCK_STREAM: impl.state_ = socket_ops::stream_oriented; break; + case SOCK_DGRAM: impl.state_ = socket_ops::datagram_oriented; break; + default: impl.state_ = 0; break; + } + impl.cancel_token_.reset(static_cast<void*>(0), socket_ops::noop_deleter()); + ec = boost::system::error_code(); + return ec; +} + +boost::system::error_code win_iocp_socket_service_base::do_assign( + win_iocp_socket_service_base::base_implementation_type& impl, + int type, socket_type native_socket, boost::system::error_code& ec) +{ + if (is_open(impl)) + { + ec = boost::asio::error::already_open; + return ec; + } + + HANDLE sock_as_handle = reinterpret_cast<HANDLE>(native_socket); + if (iocp_service_.register_handle(sock_as_handle, ec)) + return ec; + + impl.socket_ = native_socket; + switch (type) + { + case SOCK_STREAM: impl.state_ = socket_ops::stream_oriented; break; + case SOCK_DGRAM: impl.state_ = socket_ops::datagram_oriented; break; + default: impl.state_ = 0; break; + } + impl.cancel_token_.reset(static_cast<void*>(0), socket_ops::noop_deleter()); + ec = boost::system::error_code(); + return ec; +} + +void win_iocp_socket_service_base::start_send_op( + win_iocp_socket_service_base::base_implementation_type& impl, + WSABUF* buffers, std::size_t buffer_count, + socket_base::message_flags flags, bool noop, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (noop) + iocp_service_.on_completion(op); + else if (!is_open(impl)) + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + else + { + DWORD bytes_transferred = 0; + int result = ::WSASend(impl.socket_, buffers, + static_cast<DWORD>(buffer_count), &bytes_transferred, flags, op, 0); + DWORD last_error = ::WSAGetLastError(); + if (last_error == ERROR_PORT_UNREACHABLE) + last_error = WSAECONNREFUSED; + if (result != 0 && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error, bytes_transferred); + else + iocp_service_.on_pending(op); + } +} + +void win_iocp_socket_service_base::start_send_to_op( + win_iocp_socket_service_base::base_implementation_type& impl, + WSABUF* buffers, std::size_t buffer_count, + const socket_addr_type* addr, int addrlen, + socket_base::message_flags flags, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (!is_open(impl)) + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + else + { + DWORD bytes_transferred = 0; + int result = ::WSASendTo(impl.socket_, buffers, + static_cast<DWORD>(buffer_count), + &bytes_transferred, flags, addr, addrlen, op, 0); + DWORD last_error = ::WSAGetLastError(); + if (last_error == ERROR_PORT_UNREACHABLE) + last_error = WSAECONNREFUSED; + if (result != 0 && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error, bytes_transferred); + else + iocp_service_.on_pending(op); + } +} + +void win_iocp_socket_service_base::start_receive_op( + win_iocp_socket_service_base::base_implementation_type& impl, + WSABUF* buffers, std::size_t buffer_count, + socket_base::message_flags flags, bool noop, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (noop) + iocp_service_.on_completion(op); + else if (!is_open(impl)) + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + else + { + DWORD bytes_transferred = 0; + DWORD recv_flags = flags; + int result = ::WSARecv(impl.socket_, buffers, + static_cast<DWORD>(buffer_count), + &bytes_transferred, &recv_flags, op, 0); + DWORD last_error = ::WSAGetLastError(); + if (last_error == ERROR_NETNAME_DELETED) + last_error = WSAECONNRESET; + else if (last_error == ERROR_PORT_UNREACHABLE) + last_error = WSAECONNREFUSED; + if (result != 0 && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error, bytes_transferred); + else + iocp_service_.on_pending(op); + } +} + +void win_iocp_socket_service_base::start_null_buffers_receive_op( + win_iocp_socket_service_base::base_implementation_type& impl, + socket_base::message_flags flags, reactor_op* op) +{ + if ((impl.state_ & socket_ops::stream_oriented) != 0) + { + // For stream sockets on Windows, we may issue a 0-byte overlapped + // WSARecv to wait until there is data available on the socket. + ::WSABUF buf = { 0, 0 }; + start_receive_op(impl, &buf, 1, flags, false, op); + } + else + { + start_reactor_op(impl, + (flags & socket_base::message_out_of_band) + ? reactor::except_op : reactor::read_op, + op); + } +} + +void win_iocp_socket_service_base::start_receive_from_op( + win_iocp_socket_service_base::base_implementation_type& impl, + WSABUF* buffers, std::size_t buffer_count, socket_addr_type* addr, + socket_base::message_flags flags, int* addrlen, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (!is_open(impl)) + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + else + { + DWORD bytes_transferred = 0; + DWORD recv_flags = flags; + int result = ::WSARecvFrom(impl.socket_, buffers, + static_cast<DWORD>(buffer_count), + &bytes_transferred, &recv_flags, addr, addrlen, op, 0); + DWORD last_error = ::WSAGetLastError(); + if (last_error == ERROR_PORT_UNREACHABLE) + last_error = WSAECONNREFUSED; + if (result != 0 && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error, bytes_transferred); + else + iocp_service_.on_pending(op); + } +} + +void win_iocp_socket_service_base::start_accept_op( + win_iocp_socket_service_base::base_implementation_type& impl, + bool peer_is_open, socket_holder& new_socket, int family, int type, + int protocol, void* output_buffer, DWORD address_length, operation* op) +{ + update_cancellation_thread_id(impl); + iocp_service_.work_started(); + + if (!is_open(impl)) + iocp_service_.on_completion(op, boost::asio::error::bad_descriptor); + else if (peer_is_open) + iocp_service_.on_completion(op, boost::asio::error::already_open); + else + { + boost::system::error_code ec; + new_socket.reset(socket_ops::socket(family, type, protocol, ec)); + if (new_socket.get() == invalid_socket) + iocp_service_.on_completion(op, ec); + else + { + DWORD bytes_read = 0; + BOOL result = ::AcceptEx(impl.socket_, new_socket.get(), output_buffer, + 0, address_length, address_length, &bytes_read, op); + DWORD last_error = ::WSAGetLastError(); + if (!result && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error); + else + iocp_service_.on_pending(op); + } + } +} + +void win_iocp_socket_service_base::restart_accept_op( + socket_type s, socket_holder& new_socket, int family, int type, + int protocol, void* output_buffer, DWORD address_length, operation* op) +{ + new_socket.reset(); + iocp_service_.work_started(); + + boost::system::error_code ec; + new_socket.reset(socket_ops::socket(family, type, protocol, ec)); + if (new_socket.get() == invalid_socket) + iocp_service_.on_completion(op, ec); + else + { + DWORD bytes_read = 0; + BOOL result = ::AcceptEx(s, new_socket.get(), output_buffer, + 0, address_length, address_length, &bytes_read, op); + DWORD last_error = ::WSAGetLastError(); + if (!result && last_error != WSA_IO_PENDING) + iocp_service_.on_completion(op, last_error); + else + iocp_service_.on_pending(op); + } +} + +void win_iocp_socket_service_base::start_reactor_op( + win_iocp_socket_service_base::base_implementation_type& impl, + int op_type, reactor_op* op) +{ + reactor& r = get_reactor(); + update_cancellation_thread_id(impl); + + if (is_open(impl)) + { + r.start_op(op_type, impl.socket_, impl.reactor_data_, op, false); + return; + } + else + op->ec_ = boost::asio::error::bad_descriptor; + + iocp_service_.post_immediate_completion(op); +} + +void win_iocp_socket_service_base::start_connect_op( + win_iocp_socket_service_base::base_implementation_type& impl, + reactor_op* op, const socket_addr_type* addr, std::size_t addrlen) +{ + reactor& r = get_reactor(); + update_cancellation_thread_id(impl); + + if ((impl.state_ & socket_ops::non_blocking) != 0 + || socket_ops::set_internal_non_blocking( + impl.socket_, impl.state_, op->ec_)) + { + if (socket_ops::connect(impl.socket_, addr, addrlen, op->ec_) != 0) + { + if (op->ec_ == boost::asio::error::in_progress + || op->ec_ == boost::asio::error::would_block) + { + op->ec_ = boost::system::error_code(); + r.start_op(reactor::connect_op, impl.socket_, + impl.reactor_data_, op, false); + return; + } + } + } + + r.post_immediate_completion(op); +} + +void win_iocp_socket_service_base::close_for_destruction( + win_iocp_socket_service_base::base_implementation_type& impl) +{ + if (is_open(impl)) + { + // Check if the reactor was created, in which case we need to close the + // socket on the reactor as well to cancel any operations that might be + // running there. + reactor* r = static_cast<reactor*>( + interlocked_compare_exchange_pointer( + reinterpret_cast<void**>(&reactor_), 0, 0)); + if (r) + r->close_descriptor(impl.socket_, impl.reactor_data_); + } + + boost::system::error_code ignored_ec; + socket_ops::close(impl.socket_, impl.state_, true, ignored_ec); + impl.socket_ = invalid_socket; + impl.state_ = 0; + impl.cancel_token_.reset(); +#if defined(BOOST_ASIO_ENABLE_CANCELIO) + impl.safe_cancellation_thread_id_ = 0; +#endif // defined(BOOST_ASIO_ENABLE_CANCELIO) +} + +void win_iocp_socket_service_base::update_cancellation_thread_id( + win_iocp_socket_service_base::base_implementation_type& impl) +{ +#if defined(BOOST_ASIO_ENABLE_CANCELIO) + if (impl.safe_cancellation_thread_id_ == 0) + impl.safe_cancellation_thread_id_ = ::GetCurrentThreadId(); + else if (impl.safe_cancellation_thread_id_ != ::GetCurrentThreadId()) + impl.safe_cancellation_thread_id_ = ~DWORD(0); +#else // defined(BOOST_ASIO_ENABLE_CANCELIO) + (void)impl; +#endif // defined(BOOST_ASIO_ENABLE_CANCELIO) +} + +reactor& win_iocp_socket_service_base::get_reactor() +{ + reactor* r = static_cast<reactor*>( + interlocked_compare_exchange_pointer( + reinterpret_cast<void**>(&reactor_), 0, 0)); + if (!r) + { + r = &(use_service<reactor>(io_service_)); + interlocked_exchange_pointer(reinterpret_cast<void**>(&reactor_), r); + } + return *r; +} + +void* win_iocp_socket_service_base::interlocked_compare_exchange_pointer( + void** dest, void* exch, void* cmp) +{ +#if defined(_M_IX86) + return reinterpret_cast<void*>(InterlockedCompareExchange( + reinterpret_cast<PLONG>(dest), reinterpret_cast<LONG>(exch), + reinterpret_cast<LONG>(cmp))); +#else + return InterlockedCompareExchangePointer(dest, exch, cmp); +#endif +} + +void* win_iocp_socket_service_base::interlocked_exchange_pointer( + void** dest, void* val) +{ +#if defined(_M_IX86) + return reinterpret_cast<void*>(InterlockedExchange( + reinterpret_cast<PLONG>(dest), reinterpret_cast<LONG>(val))); +#else + return InterlockedExchangePointer(dest, val); +#endif +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_IOCP_SOCKET_SERVICE_BASE_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_mutex.ipp b/boost_1_45_0/boost/asio/detail/impl/win_mutex.ipp new file mode 100644 index 0000000..65ffb3b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_mutex.ipp
@@ -0,0 +1,80 @@ +// +// detail/impl/win_mutex.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_MUTEX_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_MUTEX_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) + +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/win_mutex.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +win_mutex::win_mutex() +{ + int error = do_init(); + boost::system::error_code ec(error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "mutex"); +} + +int win_mutex::do_init() +{ +#if defined(__MINGW32__) + // Not sure if MinGW supports structured exception handling, so for now + // we'll just call the Windows API and hope. +# if defined(UNDER_CE) + ::InitializeCriticalSection(&crit_section_); +# else + if (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)) + return ::GetLastError(); +# endif + return 0; +#else + __try + { +# if defined(UNDER_CE) + ::InitializeCriticalSection(&crit_section_); +# else + if (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)) + return ::GetLastError(); +# endif + } + __except(GetExceptionCode() == STATUS_NO_MEMORY + ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + return ERROR_OUTOFMEMORY; + } + + return 0; +#endif +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_MUTEX_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_thread.ipp b/boost_1_45_0/boost/asio/detail/impl/win_thread.ipp new file mode 100644 index 0000000..22d2300 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_thread.ipp
@@ -0,0 +1,140 @@ +// +// detail/impl/win_thread.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_THREAD_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_THREAD_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) && !defined(UNDER_CE) + +#include <process.h> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/win_thread.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +win_thread::~win_thread() +{ + ::CloseHandle(thread_); + + // The exit_event_ handle is deliberately allowed to leak here since it + // is an error for the owner of an internal thread not to join() it. +} + +void win_thread::join() +{ + HANDLE handles[2] = { exit_event_, thread_ }; + ::WaitForMultipleObjects(2, handles, FALSE, INFINITE); + ::CloseHandle(exit_event_); + if (terminate_threads()) + { + ::TerminateThread(thread_, 0); + } + else + { + ::QueueUserAPC(apc_function, thread_, 0); + ::WaitForSingleObject(thread_, INFINITE); + } +} + +void win_thread::start_thread(func_base* arg, unsigned int stack_size) +{ + ::HANDLE entry_event = 0; + arg->entry_event_ = entry_event = ::CreateEvent(0, true, false, 0); + if (!entry_event) + { + DWORD last_error = ::GetLastError(); + delete arg; + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "thread.entry_event"); + } + + arg->exit_event_ = exit_event_ = ::CreateEvent(0, true, false, 0); + if (!exit_event_) + { + DWORD last_error = ::GetLastError(); + delete arg; + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "thread.exit_event"); + } + + unsigned int thread_id = 0; + thread_ = reinterpret_cast<HANDLE>(::_beginthreadex(0, + stack_size, win_thread_function, arg, 0, &thread_id)); + if (!thread_) + { + DWORD last_error = ::GetLastError(); + delete arg; + if (entry_event) + ::CloseHandle(entry_event); + if (exit_event_) + ::CloseHandle(exit_event_); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "thread"); + } + + if (entry_event) + { + ::WaitForSingleObject(entry_event, INFINITE); + ::CloseHandle(entry_event); + } +} + +unsigned int __stdcall win_thread_function(void* arg) +{ + std::auto_ptr<win_thread::func_base> func( + static_cast<win_thread::func_base*>(arg)); + + ::SetEvent(func->entry_event_); + + func->run(); + + // Signal that the thread has finished its work, but rather than returning go + // to sleep to put the thread into a well known state. If the thread is being + // joined during global object destruction then it may be killed using + // TerminateThread (to avoid a deadlock in DllMain). Otherwise, the SleepEx + // call will be interrupted using QueueUserAPC and the thread will shut down + // cleanly. + HANDLE exit_event = func->exit_event_; + func.reset(); + ::SetEvent(exit_event); + ::SleepEx(INFINITE, TRUE); + + return 0; +} + +#if defined(WINVER) && (WINVER < 0x0500) +void __stdcall apc_function(ULONG) {} +#else +void __stdcall apc_function(ULONG_PTR) {} +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) && !defined(UNDER_CE) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_THREAD_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/win_tss_ptr.ipp b/boost_1_45_0/boost/asio/detail/impl/win_tss_ptr.ipp new file mode 100644 index 0000000..7da9be3 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/win_tss_ptr.ipp
@@ -0,0 +1,59 @@ +// +// detail/impl/win_tss_ptr.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP +#define BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) + +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/win_tss_ptr.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +DWORD win_tss_ptr_create() +{ +#if defined(UNDER_CE) + enum { out_of_indexes = 0xFFFFFFFF }; +#else + enum { out_of_indexes = TLS_OUT_OF_INDEXES }; +#endif + + DWORD tss_key = ::TlsAlloc(); + if (tss_key == out_of_indexes) + { + DWORD last_error = ::GetLastError(); + boost::system::error_code ec(last_error, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "tss"); + } + return tss_key; +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
diff --git a/boost_1_45_0/boost/asio/detail/impl/winsock_init.ipp b/boost_1_45_0/boost/asio/detail/impl/winsock_init.ipp new file mode 100644 index 0000000..082ea84 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/impl/winsock_init.ipp
@@ -0,0 +1,71 @@ +// +// detail/impl/winsock_init.ipp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP +#define BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/winsock_init.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +void winsock_init_base::startup(data& d, + unsigned char major, unsigned char minor) +{ + if (::InterlockedIncrement(&d.init_count_) == 1) + { + WSADATA wsa_data; + long result = ::WSAStartup(MAKEWORD(major, minor), &wsa_data); + ::InterlockedExchange(&d.result_, result); + } +} + +void winsock_init_base::cleanup(data& d) +{ + if (::InterlockedDecrement(&d.init_count_) == 0) + { + ::WSACleanup(); + } +} + +void winsock_init_base::throw_on_error(data& d) +{ + long result = ::InterlockedExchangeAdd(&d.result_, 0); + if (result != 0) + { + boost::system::error_code ec(result, + boost::asio::error::get_system_category()); + boost::asio::detail::throw_error(ec, "winsock"); + } +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP
diff --git a/boost_1_45_0/boost/asio/detail/io_control.hpp b/boost_1_45_0/boost/asio/detail/io_control.hpp new file mode 100644 index 0000000..cb02fee --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/io_control.hpp
@@ -0,0 +1,137 @@ +// +// detail/io_control.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_IO_CONTROL_HPP +#define BOOST_ASIO_DETAIL_IO_CONTROL_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <boost/config.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace io_control { + +// IO control command for non-blocking I/O. +class non_blocking_io +{ +public: + // Default constructor. + non_blocking_io() + : value_(0) + { + } + + // Construct with a specific command value. + non_blocking_io(bool value) + : value_(value ? 1 : 0) + { + } + + // Get the name of the IO control command. + int name() const + { + return FIONBIO; + } + + // Set the value of the I/O control command. + void set(bool value) + { + value_ = value ? 1 : 0; + } + + // Get the current value of the I/O control command. + bool get() const + { + return value_ != 0; + } + + // Get the address of the command data. + detail::ioctl_arg_type* data() + { + return &value_; + } + + // Get the address of the command data. + const detail::ioctl_arg_type* data() const + { + return &value_; + } + +private: + detail::ioctl_arg_type value_; +}; + +// I/O control command for getting number of bytes available. +class bytes_readable +{ +public: + // Default constructor. + bytes_readable() + : value_(0) + { + } + + // Construct with a specific command value. + bytes_readable(std::size_t value) + : value_(static_cast<detail::ioctl_arg_type>(value)) + { + } + + // Get the name of the IO control command. + int name() const + { + return FIONREAD; + } + + // Set the value of the I/O control command. + void set(std::size_t value) + { + value_ = static_cast<detail::ioctl_arg_type>(value); + } + + // Get the current value of the I/O control command. + std::size_t get() const + { + return static_cast<std::size_t>(value_); + } + + // Get the address of the command data. + detail::ioctl_arg_type* data() + { + return &value_; + } + + // Get the address of the command data. + const detail::ioctl_arg_type* data() const + { + return &value_; + } + +private: + detail::ioctl_arg_type value_; +}; + +} // namespace io_control +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_IO_CONTROL_HPP
diff --git a/boost_1_45_0/boost/asio/detail/kqueue_reactor.hpp b/boost_1_45_0/boost/asio/detail/kqueue_reactor.hpp new file mode 100644 index 0000000..eb2a243 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/kqueue_reactor.hpp
@@ -0,0 +1,193 @@ +// +// detail/kqueue_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP +#define BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_KQUEUE) + +#include <cstddef> +#include <sys/types.h> +#include <sys/event.h> +#include <sys/time.h> +#include <boost/asio/detail/kqueue_reactor_fwd.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/object_pool.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/select_interrupter.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/detail/timer_queue_fwd.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> + +// Older versions of Mac OS X may not define EV_OOBAND. +#if !defined(EV_OOBAND) +# define EV_OOBAND EV_FLAG1 +#endif // !defined(EV_OOBAND) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class kqueue_reactor + : public boost::asio::detail::service_base<kqueue_reactor> +{ +public: + enum op_types { read_op = 0, write_op = 1, + connect_op = 1, except_op = 2, max_ops = 3 }; + + // Per-descriptor queues. + struct descriptor_state + { + friend class kqueue_reactor; + friend class object_pool_access; + mutex mutex_; + op_queue<reactor_op> op_queue_[max_ops]; + bool shutdown_; + descriptor_state* next_; + descriptor_state* prev_; + }; + + // Per-descriptor data. + typedef descriptor_state* per_descriptor_data; + + // Constructor. + BOOST_ASIO_DECL kqueue_reactor(boost::asio::io_service& io_service); + + // Destructor. + BOOST_ASIO_DECL ~kqueue_reactor(); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task. + BOOST_ASIO_DECL void init_task(); + + // Register a socket with the reactor. Returns 0 on success, system error + // code on failure. + BOOST_ASIO_DECL int register_descriptor(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Post a reactor operation for immediate completion. + void post_immediate_completion(reactor_op* op) + { + io_service_.post_immediate_completion(op); + } + + // Start a new operation. The reactor operation will be performed when the + // given descriptor is flagged as ready, or an error has occurred. + BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor, + per_descriptor_data& descriptor_data, + reactor_op* op, bool allow_speculative); + + // Cancel all operations associated with the given descriptor. The + // handlers associated with the descriptor will be invoked with the + // operation_aborted error. + BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Cancel any operations that are running against the descriptor and remove + // its registration from the reactor. + BOOST_ASIO_DECL void close_descriptor(socket_type descriptor, + per_descriptor_data& descriptor_data); + + // Add a new timer queue to the reactor. + template <typename Time_Traits> + void add_timer_queue(timer_queue<Time_Traits>& queue); + + // Remove a timer queue from the reactor. + template <typename Time_Traits> + void remove_timer_queue(timer_queue<Time_Traits>& queue); + + // Schedule a new operation in the given timer queue to expire at the + // specified absolute time. + template <typename Time_Traits> + void schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op); + + // Cancel the timer operations associated with the given token. Returns the + // number of operations that have been posted or dispatched. + template <typename Time_Traits> + std::size_t cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer); + + // Run the kqueue loop. + BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops); + + // Interrupt the kqueue loop. + BOOST_ASIO_DECL void interrupt(); + +private: + // Create the kqueue file descriptor. Throws an exception if the descriptor + // cannot be created. + BOOST_ASIO_DECL static int do_kqueue_create(); + + // Helper function to add a new timer queue. + BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); + + // Helper function to remove a timer queue. + BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); + + // Get the timeout value for the kevent call. + BOOST_ASIO_DECL timespec* get_timeout(timespec& ts); + + // The io_service implementation used to post completions. + io_service_impl& io_service_; + + // Mutex to protect access to internal data. + mutex mutex_; + + // The kqueue file descriptor. + int kqueue_fd_; + + // The interrupter is used to break a blocking kevent call. + select_interrupter interrupter_; + + // The timer queues. + timer_queue_set timer_queues_; + + // Whether the service has been shut down. + bool shutdown_; + + // Mutex to protect access to the registered descriptors. + mutex registered_descriptors_mutex_; + + // Keep track of all registered descriptors. + object_pool<descriptor_state> registered_descriptors_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/kqueue_reactor.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/kqueue_reactor.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_KQUEUE) + +#endif // BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/kqueue_reactor_fwd.hpp b/boost_1_45_0/boost/asio/detail/kqueue_reactor_fwd.hpp new file mode 100644 index 0000000..97f8c96 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/kqueue_reactor_fwd.hpp
@@ -0,0 +1,35 @@ +// +// detail/kqueue_reactor_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2005 Stefan Arentz (stefan at soze dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP +#define BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_KQUEUE) + +namespace boost { +namespace asio { +namespace detail { + +class kqueue_reactor; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // defined(BOOST_ASIO_HAS_KQUEUE) + +#endif // BOOST_ASIO_DETAIL_KQUEUE_REACTOR_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/local_free_on_block_exit.hpp b/boost_1_45_0/boost/asio/detail/local_free_on_block_exit.hpp new file mode 100644 index 0000000..6c8e038 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/local_free_on_block_exit.hpp
@@ -0,0 +1,59 @@ +// +// detail/local_free_on_block_exit.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP +#define BOOST_ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class local_free_on_block_exit + : private noncopyable +{ +public: + // Constructor blocks all signals for the calling thread. + explicit local_free_on_block_exit(void* p) + : p_(p) + { + } + + // Destructor restores the previous signal mask. + ~local_free_on_block_exit() + { + ::LocalFree(p_); + } + +private: + void* p_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/macos_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/macos_fenced_block.hpp new file mode 100644 index 0000000..a653aee --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/macos_fenced_block.hpp
@@ -0,0 +1,55 @@ +// +// detail/macos_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__MACH__) && defined(__APPLE__) + +#include <libkern/OSAtomic.h> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class macos_fenced_block + : private noncopyable +{ +public: + // Constructor. + macos_fenced_block() + { + OSMemoryBarrier(); + } + + // Destructor. + ~macos_fenced_block() + { + OSMemoryBarrier(); + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__MACH__) && defined(__APPLE__) + +#endif // BOOST_ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/mutex.hpp b/boost_1_45_0/boost/asio/detail/mutex.hpp new file mode 100644 index 0000000..f601996 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/mutex.hpp
@@ -0,0 +1,46 @@ +// +// detail/mutex.hpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_MUTEX_HPP +#define BOOST_ASIO_DETAIL_MUTEX_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +# include <boost/asio/detail/null_mutex.hpp> +#elif defined(BOOST_WINDOWS) +# include <boost/asio/detail/win_mutex.hpp> +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/asio/detail/posix_mutex.hpp> +#else +# error Only Windows and POSIX are supported! +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +typedef null_mutex mutex; +#elif defined(BOOST_WINDOWS) +typedef win_mutex mutex; +#elif defined(BOOST_HAS_PTHREADS) +typedef posix_mutex mutex; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_MUTEX_HPP
diff --git a/boost_1_45_0/boost/asio/detail/noncopyable.hpp b/boost_1_45_0/boost/asio/detail/noncopyable.hpp new file mode 100644 index 0000000..65ae9a2 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/noncopyable.hpp
@@ -0,0 +1,55 @@ +// +// detail/noncopyable.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NONCOPYABLE_HPP +#define BOOST_ASIO_DETAIL_NONCOPYABLE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/noncopyable.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +// Redefine the noncopyable class for Borland C++ since that compiler does not +// apply the empty base optimisation unless the base class contains a dummy +// char data member. +class noncopyable +{ +protected: + noncopyable() {} + ~noncopyable() {} +private: + noncopyable(const noncopyable&); + const noncopyable& operator=(const noncopyable&); + char dummy_; +}; +#else +using boost::noncopyable; +#endif + +} // namespace detail + +using boost::asio::detail::noncopyable; + +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_NONCOPYABLE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_event.hpp b/boost_1_45_0/boost/asio/detail/null_event.hpp new file mode 100644 index 0000000..3acc26c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_event.hpp
@@ -0,0 +1,77 @@ +// +// detail/null_event.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_EVENT_HPP +#define BOOST_ASIO_DETAIL_NULL_EVENT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class null_event + : private noncopyable +{ +public: + // Constructor. + null_event() + { + } + + // Destructor. + ~null_event() + { + } + + // Signal the event. + template <typename Lock> + void signal(Lock&) + { + } + + // Signal the event and unlock the mutex. + template <typename Lock> + void signal_and_unlock(Lock&) + { + } + + // Reset the event. + template <typename Lock> + void clear(Lock&) + { + } + + // Wait for the event to become signalled. + template <typename Lock> + void wait(Lock&) + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_NULL_EVENT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/null_fenced_block.hpp new file mode 100644 index 0000000..ead4c87 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_fenced_block.hpp
@@ -0,0 +1,45 @@ +// +// detail/null_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_NULL_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class null_fenced_block + : private noncopyable +{ +public: + // Constructor. + null_fenced_block() + { + } + + // Destructor. + ~null_fenced_block() + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_NULL_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_mutex.hpp b/boost_1_45_0/boost/asio/detail/null_mutex.hpp new file mode 100644 index 0000000..8fca31c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_mutex.hpp
@@ -0,0 +1,66 @@ +// +// detail/null_mutex.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_MUTEX_HPP +#define BOOST_ASIO_DETAIL_NULL_MUTEX_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/scoped_lock.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class null_mutex + : private noncopyable +{ +public: + typedef boost::asio::detail::scoped_lock<null_mutex> scoped_lock; + + // Constructor. + null_mutex() + { + } + + // Destructor. + ~null_mutex() + { + } + + // Lock the mutex. + void lock() + { + } + + // Unlock the mutex. + void unlock() + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_NULL_MUTEX_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_signal_blocker.hpp b/boost_1_45_0/boost/asio/detail/null_signal_blocker.hpp new file mode 100644 index 0000000..9eeccb9 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_signal_blocker.hpp
@@ -0,0 +1,71 @@ +// +// detail/null_signal_blocker.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP +#define BOOST_ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) \ + || defined(BOOST_ASIO_DISABLE_THREADS) \ + || defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class null_signal_blocker + : private noncopyable +{ +public: + // Constructor blocks all signals for the calling thread. + null_signal_blocker() + { + } + + // Destructor restores the previous signal mask. + ~null_signal_blocker() + { + } + + // Block all signals for the calling thread. + void block() + { + } + + // Restore the previous signal mask. + void unblock() + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_HAS_THREADS) + // || defined(BOOST_ASIO_DISABLE_THREADS) + // || defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + +#endif // BOOST_ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_thread.hpp b/boost_1_45_0/boost/asio/detail/null_thread.hpp new file mode 100644 index 0000000..1745011 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_thread.hpp
@@ -0,0 +1,63 @@ +// +// detail/null_thread.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_THREAD_HPP +#define BOOST_ASIO_DETAIL_NULL_THREAD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class null_thread + : private noncopyable +{ +public: + // Constructor. + template <typename Function> + null_thread(Function, unsigned int = 0) + { + boost::asio::detail::throw_error( + boost::asio::error::operation_not_supported, "thread"); + } + + // Destructor. + ~null_thread() + { + } + + // Wait for the thread to exit. + void join() + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_NULL_THREAD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/null_tss_ptr.hpp b/boost_1_45_0/boost/asio/detail/null_tss_ptr.hpp new file mode 100644 index 0000000..3eff2dc --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/null_tss_ptr.hpp
@@ -0,0 +1,70 @@ +// +// detail/null_tss_ptr.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP +#define BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename T> +class null_tss_ptr + : private noncopyable +{ +public: + // Constructor. + null_tss_ptr() + : value_(0) + { + } + + // Destructor. + ~null_tss_ptr() + { + } + + // Get the value. + operator T*() const + { + return value_; + } + + // Set the value. + void operator=(T* value) + { + value_ = value; + } + +private: + T* value_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_NULL_TSS_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/object_pool.hpp b/boost_1_45_0/boost/asio/detail/object_pool.hpp new file mode 100644 index 0000000..87f3902 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/object_pool.hpp
@@ -0,0 +1,148 @@ +// +// detail/object_pool.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_OBJECT_POOL_HPP +#define BOOST_ASIO_DETAIL_OBJECT_POOL_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Object> +class object_pool; + +class object_pool_access +{ +public: + template <typename Object> + static Object* create() + { + return new Object; + } + + template <typename Object> + static void destroy(Object* o) + { + delete o; + } + + template <typename Object> + static Object*& next(Object* o) + { + return o->next_; + } + + template <typename Object> + static Object*& prev(Object* o) + { + return o->prev_; + } +}; + +template <typename Object> +class object_pool + : private noncopyable +{ +public: + // Constructor. + object_pool() + : live_list_(0), + free_list_(0) + { + } + + // Destructor destroys all objects. + ~object_pool() + { + destroy_list(live_list_); + destroy_list(free_list_); + } + + // Get the object at the start of the live list. + Object* first() + { + return live_list_; + } + + // Allocate a new object. + Object* alloc() + { + Object* o = free_list_; + if (o) + free_list_ = object_pool_access::next(free_list_); + else + o = object_pool_access::create<Object>(); + + object_pool_access::next(o) = live_list_; + object_pool_access::prev(o) = 0; + if (live_list_) + object_pool_access::prev(live_list_) = o; + live_list_ = o; + + return o; + } + + // Free an object. Moves it to the free list. No destructors are run. + void free(Object* o) + { + if (live_list_ == o) + live_list_ = object_pool_access::next(o); + + if (object_pool_access::prev(o)) + { + object_pool_access::next(object_pool_access::prev(o)) + = object_pool_access::next(o); + } + + if (object_pool_access::next(o)) + { + object_pool_access::prev(object_pool_access::next(o)) + = object_pool_access::prev(o); + } + + object_pool_access::next(o) = free_list_; + object_pool_access::prev(o) = 0; + free_list_ = o; + } + +private: + // Helper function to destroy all elements in a list. + void destroy_list(Object* list) + { + while (list) + { + Object* o = list; + list = object_pool_access::next(o); + object_pool_access::destroy(o); + } + } + + // The list of live objects. + Object* live_list_; + + // The free list. + Object* free_list_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_OBJECT_POOL_HPP
diff --git a/boost_1_45_0/boost/asio/detail/old_win_sdk_compat.hpp b/boost_1_45_0/boost/asio/detail/old_win_sdk_compat.hpp new file mode 100644 index 0000000..10cd898 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/old_win_sdk_compat.hpp
@@ -0,0 +1,340 @@ +// +// detail/old_win_sdk_compat.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_OLD_WIN_SDK_COMPAT_HPP +#define BOOST_ASIO_DETAIL_OLD_WIN_SDK_COMPAT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +// Guess whether we are building against on old Platform SDK. +#if !defined(IN6ADDR_ANY_INIT) +#define BOOST_ASIO_HAS_OLD_WIN_SDK 1 +#endif // !defined(IN6ADDR_ANY_INIT) + +#if defined(BOOST_ASIO_HAS_OLD_WIN_SDK) + +// Emulation of types that are missing from old Platform SDKs. +// +// N.B. this emulation is also used if building for a Windows 2000 target with +// a recent (i.e. Vista or later) SDK, as the SDK does not provide IPv6 support +// in that case. + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +enum +{ + sockaddr_storage_maxsize = 128, // Maximum size. + sockaddr_storage_alignsize = (sizeof(__int64)), // Desired alignment. + sockaddr_storage_pad1size = (sockaddr_storage_alignsize - sizeof(short)), + sockaddr_storage_pad2size = (sockaddr_storage_maxsize - + (sizeof(short) + sockaddr_storage_pad1size + sockaddr_storage_alignsize)) +}; + +struct sockaddr_storage_emulation +{ + short ss_family; + char __ss_pad1[sockaddr_storage_pad1size]; + __int64 __ss_align; + char __ss_pad2[sockaddr_storage_pad2size]; +}; + +struct in6_addr_emulation +{ + union + { + u_char Byte[16]; + u_short Word[8]; + } u; +}; + +#if !defined(s6_addr) +# define _S6_un u +# define _S6_u8 Byte +# define s6_addr _S6_un._S6_u8 +#endif // !defined(s6_addr) + +struct sockaddr_in6_emulation +{ + short sin6_family; + u_short sin6_port; + u_long sin6_flowinfo; + in6_addr_emulation sin6_addr; + u_long sin6_scope_id; +}; + +struct ipv6_mreq_emulation +{ + in6_addr_emulation ipv6mr_multiaddr; + unsigned int ipv6mr_interface; +}; + +#if !defined(IN6ADDR_ANY_INIT) +# define IN6ADDR_ANY_INIT { 0 } +#endif + +#if !defined(IN6ADDR_LOOPBACK_INIT) +# define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } +#endif + +struct addrinfo_emulation +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + char* ai_canonname; + sockaddr* ai_addr; + addrinfo_emulation* ai_next; +}; + +#if !defined(AI_PASSIVE) +# define AI_PASSIVE 0x1 +#endif + +#if !defined(AI_CANONNAME) +# define AI_CANONNAME 0x2 +#endif + +#if !defined(AI_NUMERICHOST) +# define AI_NUMERICHOST 0x4 +#endif + +#if !defined(EAI_AGAIN) +# define EAI_AGAIN WSATRY_AGAIN +#endif + +#if !defined(EAI_BADFLAGS) +# define EAI_BADFLAGS WSAEINVAL +#endif + +#if !defined(EAI_FAIL) +# define EAI_FAIL WSANO_RECOVERY +#endif + +#if !defined(EAI_FAMILY) +# define EAI_FAMILY WSAEAFNOSUPPORT +#endif + +#if !defined(EAI_MEMORY) +# define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY +#endif + +#if !defined(EAI_NODATA) +# define EAI_NODATA WSANO_DATA +#endif + +#if !defined(EAI_NONAME) +# define EAI_NONAME WSAHOST_NOT_FOUND +#endif + +#if !defined(EAI_SERVICE) +# define EAI_SERVICE WSATYPE_NOT_FOUND +#endif + +#if !defined(EAI_SOCKTYPE) +# define EAI_SOCKTYPE WSAESOCKTNOSUPPORT +#endif + +#if !defined(NI_NOFQDN) +# define NI_NOFQDN 0x01 +#endif + +#if !defined(NI_NUMERICHOST) +# define NI_NUMERICHOST 0x02 +#endif + +#if !defined(NI_NAMEREQD) +# define NI_NAMEREQD 0x04 +#endif + +#if !defined(NI_NUMERICSERV) +# define NI_NUMERICSERV 0x08 +#endif + +#if !defined(NI_DGRAM) +# define NI_DGRAM 0x10 +#endif + +#if !defined(IPPROTO_IPV6) +# define IPPROTO_IPV6 41 +#endif + +#if !defined(IPV6_UNICAST_HOPS) +# define IPV6_UNICAST_HOPS 4 +#endif + +#if !defined(IPV6_MULTICAST_IF) +# define IPV6_MULTICAST_IF 9 +#endif + +#if !defined(IPV6_MULTICAST_HOPS) +# define IPV6_MULTICAST_HOPS 10 +#endif + +#if !defined(IPV6_MULTICAST_LOOP) +# define IPV6_MULTICAST_LOOP 11 +#endif + +#if !defined(IPV6_JOIN_GROUP) +# define IPV6_JOIN_GROUP 12 +#endif + +#if !defined(IPV6_LEAVE_GROUP) +# define IPV6_LEAVE_GROUP 13 +#endif + +inline int IN6_IS_ADDR_UNSPECIFIED(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0) + && (a->s6_addr[1] == 0) + && (a->s6_addr[2] == 0) + && (a->s6_addr[3] == 0) + && (a->s6_addr[4] == 0) + && (a->s6_addr[5] == 0) + && (a->s6_addr[6] == 0) + && (a->s6_addr[7] == 0) + && (a->s6_addr[8] == 0) + && (a->s6_addr[9] == 0) + && (a->s6_addr[10] == 0) + && (a->s6_addr[11] == 0) + && (a->s6_addr[12] == 0) + && (a->s6_addr[13] == 0) + && (a->s6_addr[14] == 0) + && (a->s6_addr[15] == 0)); +} + +inline int IN6_IS_ADDR_LOOPBACK(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0) + && (a->s6_addr[1] == 0) + && (a->s6_addr[2] == 0) + && (a->s6_addr[3] == 0) + && (a->s6_addr[4] == 0) + && (a->s6_addr[5] == 0) + && (a->s6_addr[6] == 0) + && (a->s6_addr[7] == 0) + && (a->s6_addr[8] == 0) + && (a->s6_addr[9] == 0) + && (a->s6_addr[10] == 0) + && (a->s6_addr[11] == 0) + && (a->s6_addr[12] == 0) + && (a->s6_addr[13] == 0) + && (a->s6_addr[14] == 0) + && (a->s6_addr[15] == 1)); +} + +inline int IN6_IS_ADDR_MULTICAST(const in6_addr_emulation* a) +{ + return (a->s6_addr[0] == 0xff); +} + +inline int IN6_IS_ADDR_LINKLOCAL(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0xfe) && ((a->s6_addr[1] & 0xc0) == 0x80)); +} + +inline int IN6_IS_ADDR_SITELOCAL(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0xfe) && ((a->s6_addr[1] & 0xc0) == 0xc0)); +} + +inline int IN6_IS_ADDR_V4MAPPED(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0) + && (a->s6_addr[1] == 0) + && (a->s6_addr[2] == 0) + && (a->s6_addr[3] == 0) + && (a->s6_addr[4] == 0) + && (a->s6_addr[5] == 0) + && (a->s6_addr[6] == 0) + && (a->s6_addr[7] == 0) + && (a->s6_addr[8] == 0) + && (a->s6_addr[9] == 0) + && (a->s6_addr[10] == 0xff) + && (a->s6_addr[11] == 0xff)); +} + +inline int IN6_IS_ADDR_V4COMPAT(const in6_addr_emulation* a) +{ + return ((a->s6_addr[0] == 0) + && (a->s6_addr[1] == 0) + && (a->s6_addr[2] == 0) + && (a->s6_addr[3] == 0) + && (a->s6_addr[4] == 0) + && (a->s6_addr[5] == 0) + && (a->s6_addr[6] == 0) + && (a->s6_addr[7] == 0) + && (a->s6_addr[8] == 0) + && (a->s6_addr[9] == 0) + && (a->s6_addr[10] == 0xff) + && (a->s6_addr[11] == 0xff) + && !((a->s6_addr[12] == 0) + && (a->s6_addr[13] == 0) + && (a->s6_addr[14] == 0) + && ((a->s6_addr[15] == 0) || (a->s6_addr[15] == 1)))); +} + +inline int IN6_IS_ADDR_MC_NODELOCAL(const in6_addr_emulation* a) +{ + return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 1); +} + +inline int IN6_IS_ADDR_MC_LINKLOCAL(const in6_addr_emulation* a) +{ + return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 2); +} + +inline int IN6_IS_ADDR_MC_SITELOCAL(const in6_addr_emulation* a) +{ + return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 5); +} + +inline int IN6_IS_ADDR_MC_ORGLOCAL(const in6_addr_emulation* a) +{ + return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 8); +} + +inline int IN6_IS_ADDR_MC_GLOBAL(const in6_addr_emulation* a) +{ + return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 0xe); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_OLD_WIN_SDK) + +// Even newer Platform SDKs that support IPv6 may not define IPV6_V6ONLY. +#if !defined(IPV6_V6ONLY) +# define IPV6_V6ONLY 27 +#endif + +// Some SDKs (e.g. Windows CE) don't define IPPROTO_ICMPV6. +#if !defined(IPPROTO_ICMPV6) +# define IPPROTO_ICMPV6 58 +#endif + +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_OLD_WIN_SDK_COMPAT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/op_queue.hpp b/boost_1_45_0/boost/asio/detail/op_queue.hpp new file mode 100644 index 0000000..e35e82d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/op_queue.hpp
@@ -0,0 +1,158 @@ +// +// detail/op_queue.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_OP_QUEUE_HPP +#define BOOST_ASIO_DETAIL_OP_QUEUE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Operation> +class op_queue; + +class op_queue_access +{ +public: + template <typename Operation> + static Operation* next(Operation* o) + { + return static_cast<Operation*>(o->next_); + } + + template <typename Operation1, typename Operation2> + static void next(Operation1*& o1, Operation2* o2) + { + o1->next_ = o2; + } + + template <typename Operation> + static void destroy(Operation* o) + { + o->destroy(); + } + + template <typename Operation> + static Operation*& front(op_queue<Operation>& q) + { + return q.front_; + } + + template <typename Operation> + static Operation*& back(op_queue<Operation>& q) + { + return q.back_; + } +}; + +template <typename Operation> +class op_queue + : private noncopyable +{ +public: + // Constructor. + op_queue() + : front_(0), + back_(0) + { + } + + // Destructor destroys all operations. + ~op_queue() + { + while (Operation* op = front_) + { + pop(); + op_queue_access::destroy(op); + } + } + + // Get the operation at the front of the queue. + Operation* front() + { + return front_; + } + + // Pop an operation from the front of the queue. + void pop() + { + if (front_) + { + Operation* tmp = front_; + front_ = op_queue_access::next(front_); + if (front_ == 0) + back_ = 0; + op_queue_access::next(tmp, static_cast<Operation*>(0)); + } + } + + // Push an operation on to the back of the queue. + void push(Operation* h) + { + op_queue_access::next(h, static_cast<Operation*>(0)); + if (back_) + { + op_queue_access::next(back_, h); + back_ = h; + } + else + { + front_ = back_ = h; + } + } + + // Push all operations from another queue on to the back of the queue. The + // source queue may contain operations of a derived type. + template <typename OtherOperation> + void push(op_queue<OtherOperation>& q) + { + if (Operation* other_front = op_queue_access::front(q)) + { + if (back_) + op_queue_access::next(back_, other_front); + else + front_ = other_front; + back_ = op_queue_access::back(q); + op_queue_access::front(q) = 0; + op_queue_access::back(q) = 0; + } + } + + // Whether the queue is empty. + bool empty() const + { + return front_ == 0; + } + +private: + friend class op_queue_access; + + // The front of the queue. + Operation* front_; + + // The back of the queue. + Operation* back_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_OP_QUEUE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/operation.hpp b/boost_1_45_0/boost/asio/detail/operation.hpp new file mode 100644 index 0000000..e42455c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/operation.hpp
@@ -0,0 +1,40 @@ +// +// detail/operation.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_OPERATION_HPP +#define BOOST_ASIO_DETAIL_OPERATION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/win_iocp_operation.hpp> +#else +# include <boost/asio/detail/task_io_service_operation.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_ASIO_HAS_IOCP) +typedef win_iocp_operation operation; +#else +typedef task_io_service_operation operation; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_OPERATION_HPP
diff --git a/boost_1_45_0/boost/asio/detail/pipe_select_interrupter.hpp b/boost_1_45_0/boost/asio/detail/pipe_select_interrupter.hpp new file mode 100644 index 0000000..054f731 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/pipe_select_interrupter.hpp
@@ -0,0 +1,80 @@ +// +// detail/pipe_select_interrupter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP +#define BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) +#if !defined(__CYGWIN__) +#if !defined(__SYMBIAN32__) +#if !defined(BOOST_ASIO_HAS_EVENTFD) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class pipe_select_interrupter +{ +public: + // Constructor. + BOOST_ASIO_DECL pipe_select_interrupter(); + + // Destructor. + BOOST_ASIO_DECL ~pipe_select_interrupter(); + + // Interrupt the select call. + BOOST_ASIO_DECL void interrupt(); + + // Reset the select interrupt. Returns true if the call was interrupted. + BOOST_ASIO_DECL bool reset(); + + // Get the read descriptor to be passed to select. + int read_descriptor() const + { + return read_descriptor_; + } + +private: + // The read end of a connection used to interrupt the select call. This file + // descriptor is passed to select such that when it is time to stop, a single + // byte will be written on the other end of the connection and this + // descriptor will become readable. + int read_descriptor_; + + // The write end of a connection used to interrupt the select call. A single + // byte may be written to this to wake up the select which is waiting for the + // other end to become readable. + int write_descriptor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/pipe_select_interrupter.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_ASIO_HAS_EVENTFD) +#endif // !defined(__SYMBIAN32__) +#endif // !defined(__CYGWIN__) +#endif // !defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_PIPE_SELECT_INTERRUPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/pop_options.hpp b/boost_1_45_0/boost/asio/detail/pop_options.hpp new file mode 100644 index 0000000..d589cb7 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/pop_options.hpp
@@ -0,0 +1,98 @@ +// +// detail/pop_options.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// No header guard + +#if defined(__COMO__) + +// Comeau C++ + +#elif defined(__DMC__) + +// Digital Mars C++ + +#elif defined(__INTEL_COMPILER) || defined(__ICL) \ + || defined(__ICC) || defined(__ECC) + +// Intel C++ + +#elif defined(__GNUC__) + +// GNU C++ + +# if defined(__MINGW32__) || defined(__CYGWIN__) +# pragma pack (pop) +# endif + +# if defined(__OBJC__) +# if !defined(__APPLE_CC__) || (__APPLE_CC__ <= 1) +# if defined(BOOST_ASIO_OBJC_WORKAROUND) +# undef Protocol +# undef id +# undef BOOST_ASIO_OBJC_WORKAROUND +# endif +# endif +# endif + +#elif defined(__KCC) + +// Kai C++ + +#elif defined(__sgi) + +// SGI MIPSpro C++ + +#elif defined(__DECCXX) + +// Compaq Tru64 Unix cxx + +#elif defined(__ghs) + +// Greenhills C++ + +#elif defined(__BORLANDC__) + +// Borland C++ + +# pragma option pop +# pragma nopushoptwarn +# pragma nopackwarning + +#elif defined(__MWERKS__) + +// Metrowerks CodeWarrior + +#elif defined(__SUNPRO_CC) + +// Sun Workshop Compiler C++ + +#elif defined(__HP_aCC) + +// HP aCC + +#elif defined(__MRC__) || defined(__SC__) + +// MPW MrCpp or SCpp + +#elif defined(__IBMCPP__) + +// IBM Visual Age + +#elif defined(_MSC_VER) + +// Microsoft Visual C++ +// +// Must remain the last #elif since some other vendors (Metrowerks, for example) +// also #define _MSC_VER + +# pragma warning (pop) +# pragma pack (pop) + +#endif
diff --git a/boost_1_45_0/boost/asio/detail/posix_event.hpp b/boost_1_45_0/boost/asio/detail/posix_event.hpp new file mode 100644 index 0000000..13fa3d4 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_event.hpp
@@ -0,0 +1,100 @@ +// +// detail/posix_event.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_EVENT_HPP +#define BOOST_ASIO_DETAIL_POSIX_EVENT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <boost/assert.hpp> +#include <pthread.h> +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class posix_event + : private noncopyable +{ +public: + // Constructor. + BOOST_ASIO_DECL posix_event(); + + // Destructor. + ~posix_event() + { + ::pthread_cond_destroy(&cond_); + } + + // Signal the event. + template <typename Lock> + void signal(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + (void)lock; + signalled_ = true; + ::pthread_cond_signal(&cond_); // Ignore EINVAL. + } + + // Signal the event and unlock the mutex. + template <typename Lock> + void signal_and_unlock(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + signalled_ = true; + lock.unlock(); + ::pthread_cond_signal(&cond_); // Ignore EINVAL. + } + + // Reset the event. + template <typename Lock> + void clear(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + (void)lock; + signalled_ = false; + } + + // Wait for the event to become signalled. + template <typename Lock> + void wait(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + while (!signalled_) + ::pthread_cond_wait(&cond_, &lock.mutex().mutex_); // Ignore EINVAL. + } + +private: + ::pthread_cond_t cond_; + bool signalled_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/posix_event.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_POSIX_EVENT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/posix_fd_set_adapter.hpp b/boost_1_45_0/boost/asio/detail/posix_fd_set_adapter.hpp new file mode 100644 index 0000000..5395eb9 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_fd_set_adapter.hpp
@@ -0,0 +1,82 @@ +// +// detail/posix_fd_set_adapter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP +#define BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <cstring> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements. +class posix_fd_set_adapter +{ +public: + posix_fd_set_adapter() + : max_descriptor_(invalid_socket) + { + using namespace std; // Needed for memset on Solaris. + FD_ZERO(&fd_set_); + } + + bool set(socket_type descriptor) + { + if (descriptor < (socket_type)FD_SETSIZE) + { + if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_) + max_descriptor_ = descriptor; + FD_SET(descriptor, &fd_set_); + return true; + } + return false; + } + + bool is_set(socket_type descriptor) const + { + return FD_ISSET(descriptor, &fd_set_) != 0; + } + + operator fd_set*() + { + return &fd_set_; + } + + socket_type max_descriptor() const + { + return max_descriptor_; + } + +private: + mutable fd_set fd_set_; + socket_type max_descriptor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/posix_mutex.hpp b/boost_1_45_0/boost/asio/detail/posix_mutex.hpp new file mode 100644 index 0000000..4fcd8ac --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_mutex.hpp
@@ -0,0 +1,78 @@ +// +// detail/posix_mutex.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP +#define BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <pthread.h> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/scoped_lock.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class posix_event; + +class posix_mutex + : private noncopyable +{ +public: + typedef boost::asio::detail::scoped_lock<posix_mutex> scoped_lock; + + // Constructor. + BOOST_ASIO_DECL posix_mutex(); + + // Destructor. + ~posix_mutex() + { + ::pthread_mutex_destroy(&mutex_); // Ignore EBUSY. + } + + // Lock the mutex. + void lock() + { + (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL. + } + + // Unlock the mutex. + void unlock() + { + (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL. + } + +private: + friend class posix_event; + ::pthread_mutex_t mutex_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/posix_mutex.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP
diff --git a/boost_1_45_0/boost/asio/detail/posix_signal_blocker.hpp b/boost_1_45_0/boost/asio/detail/posix_signal_blocker.hpp new file mode 100644 index 0000000..247a7a8 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_signal_blocker.hpp
@@ -0,0 +1,87 @@ +// +// detail/posix_signal_blocker.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_SIGNAL_BLOCKER_HPP +#define BOOST_ASIO_DETAIL_POSIX_SIGNAL_BLOCKER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <csignal> +#include <pthread.h> +#include <signal.h> +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class posix_signal_blocker + : private noncopyable +{ +public: + // Constructor blocks all signals for the calling thread. + posix_signal_blocker() + : blocked_(false) + { + sigset_t new_mask; + sigfillset(&new_mask); + blocked_ = (pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask_) == 0); + } + + // Destructor restores the previous signal mask. + ~posix_signal_blocker() + { + if (blocked_) + pthread_sigmask(SIG_SETMASK, &old_mask_, 0); + } + + // Block all signals for the calling thread. + void block() + { + if (!blocked_) + { + sigset_t new_mask; + sigfillset(&new_mask); + blocked_ = (pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask_) == 0); + } + } + + // Restore the previous signal mask. + void unblock() + { + if (blocked_) + blocked_ = (pthread_sigmask(SIG_SETMASK, &old_mask_, 0) != 0); + } + +private: + // Have signals been blocked. + bool blocked_; + + // The previous signal mask. + sigset_t old_mask_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_POSIX_SIGNAL_BLOCKER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/posix_thread.hpp b/boost_1_45_0/boost/asio/detail/posix_thread.hpp new file mode 100644 index 0000000..a87e396 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_thread.hpp
@@ -0,0 +1,107 @@ +// +// detail/posix_thread.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_THREAD_HPP +#define BOOST_ASIO_DETAIL_POSIX_THREAD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <pthread.h> +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +extern "C" +{ + BOOST_ASIO_DECL void* boost_asio_detail_posix_thread_function(void* arg); +} + +class posix_thread + : private noncopyable +{ +public: + // Constructor. + template <typename Function> + posix_thread(Function f) + : joined_(false) + { + start_thread(new func<Function>(f)); + } + + // Destructor. + BOOST_ASIO_DECL ~posix_thread(); + + // Wait for the thread to exit. + BOOST_ASIO_DECL void join(); + +private: + friend void* boost_asio_detail_posix_thread_function(void* arg); + + class func_base + { + public: + virtual ~func_base() {} + virtual void run() = 0; + }; + + struct auto_func_base_ptr + { + func_base* ptr; + ~auto_func_base_ptr() { delete ptr; } + }; + + template <typename Function> + class func + : public func_base + { + public: + func(Function f) + : f_(f) + { + } + + virtual void run() + { + f_(); + } + + private: + Function f_; + }; + + BOOST_ASIO_DECL void start_thread(func_base* arg); + + ::pthread_t thread_; + bool joined_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/posix_thread.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_POSIX_THREAD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/posix_tss_ptr.hpp b/boost_1_45_0/boost/asio/detail/posix_tss_ptr.hpp new file mode 100644 index 0000000..dfe8369 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/posix_tss_ptr.hpp
@@ -0,0 +1,82 @@ +// +// detail/posix_tss_ptr.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_POSIX_TSS_PTR_HPP +#define BOOST_ASIO_DETAIL_POSIX_TSS_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#include <pthread.h> +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Helper function to create thread-specific storage. +BOOST_ASIO_DECL void posix_tss_ptr_create(pthread_key_t& key); + +template <typename T> +class posix_tss_ptr + : private noncopyable +{ +public: + // Constructor. + posix_tss_ptr() + { + posix_tss_ptr_create(tss_key_); + } + + // Destructor. + ~posix_tss_ptr() + { + ::pthread_key_delete(tss_key_); + } + + // Get the value. + operator T*() const + { + return static_cast<T*>(::pthread_getspecific(tss_key_)); + } + + // Set the value. + void operator=(T* value) + { + ::pthread_setspecific(tss_key_, value); + } + +private: + // Thread-specific storage to allow unlocked access to determine whether a + // thread is a member of the pool. + pthread_key_t tss_key_; + +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/posix_tss_ptr.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_HAS_PTHREADS) && !defined(BOOST_ASIO_DISABLE_THREADS) + +#endif // BOOST_ASIO_DETAIL_POSIX_TSS_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/push_options.hpp b/boost_1_45_0/boost/asio/detail/push_options.hpp new file mode 100644 index 0000000..587aef9 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/push_options.hpp
@@ -0,0 +1,126 @@ +// +// detail/push_options.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// No header guard + +#if defined(__COMO__) + +// Comeau C++ + +#elif defined(__DMC__) + +// Digital Mars C++ + +#elif defined(__INTEL_COMPILER) || defined(__ICL) \ + || defined(__ICC) || defined(__ECC) + +// Intel C++ + +#elif defined(__GNUC__) + +// GNU C++ + +# if defined(__MINGW32__) || defined(__CYGWIN__) +# pragma pack (push, 8) +# endif + +# if defined(__OBJC__) +# if !defined(__APPLE_CC__) || (__APPLE_CC__ <= 1) +# if !defined(BOOST_ASIO_DISABLE_OBJC_WORKAROUND) +# if !defined(Protocol) && !defined(id) +# define Protocol cpp_Protocol +# define id cpp_id +# define BOOST_ASIO_OBJC_WORKAROUND +# endif +# endif +# endif +# endif + +#elif defined(__KCC) + +// Kai C++ + +#elif defined(__sgi) + +// SGI MIPSpro C++ + +#elif defined(__DECCXX) + +// Compaq Tru64 Unix cxx + +#elif defined(__ghs) + +// Greenhills C++ + +#elif defined(__BORLANDC__) + +// Borland C++ + +# pragma option push -a8 -b -Ve- -Vx- -w-inl -vi- +# pragma nopushoptwarn +# pragma nopackwarning +# if !defined(__MT__) +# error Multithreaded RTL must be selected. +# endif // !defined(__MT__) + +#elif defined(__MWERKS__) + +// Metrowerks CodeWarrior + +#elif defined(__SUNPRO_CC) + +// Sun Workshop Compiler C++ + +#elif defined(__HP_aCC) + +// HP aCC + +#elif defined(__MRC__) || defined(__SC__) + +// MPW MrCpp or SCpp + +#elif defined(__IBMCPP__) + +// IBM Visual Age + +#elif defined(_MSC_VER) + +// Microsoft Visual C++ +// +// Must remain the last #elif since some other vendors (Metrowerks, for example) +// also #define _MSC_VER + +# pragma warning (disable:4103) +# pragma warning (push) +# pragma warning (disable:4127) +# pragma warning (disable:4244) +# pragma warning (disable:4355) +# pragma warning (disable:4512) +# pragma warning (disable:4675) +# if defined(_M_IX86) && defined(_Wp64) +// The /Wp64 option is broken. If you want to check 64 bit portability, use a +// 64 bit compiler! +# pragma warning (disable:4311) +# pragma warning (disable:4312) +# endif // defined(_M_IX86) && defined(_Wp64) +# pragma pack (push, 8) +// Note that if the /Og optimisation flag is enabled with MSVC6, the compiler +// has a tendency to incorrectly optimise away some calls to member template +// functions, even though those functions contain code that should not be +// optimised away! Therefore we will always disable this optimisation option +// for the MSVC6 compiler. +# if (_MSC_VER < 1300) +# pragma optimize ("g", off) +# endif +# if !defined(_MT) +# error Multithreaded RTL must be selected. +# endif // !defined(_MT) + +#endif
diff --git a/boost_1_45_0/boost/asio/detail/reactive_descriptor_service.hpp b/boost_1_45_0/boost/asio/detail/reactive_descriptor_service.hpp new file mode 100644 index 0000000..993211a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_descriptor_service.hpp
@@ -0,0 +1,255 @@ +// +// detail/reactive_descriptor_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_DESCRIPTOR_SERVICE_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_DESCRIPTOR_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/descriptor_ops.hpp> +#include <boost/asio/detail/descriptor_read_op.hpp> +#include <boost/asio/detail/descriptor_write_op.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/reactive_null_buffers_op.hpp> +#include <boost/asio/detail/reactor.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class reactive_descriptor_service +{ +public: + // The native type of a descriptor. + typedef int native_type; + + // The implementation type of the descriptor. + class implementation_type + : private boost::asio::detail::noncopyable + { + public: + // Default constructor. + implementation_type() + : descriptor_(-1), + state_(0) + { + } + + private: + // Only this service will have access to the internal values. + friend class reactive_descriptor_service; + + // The native descriptor representation. + int descriptor_; + + // The current state of the descriptor. + descriptor_ops::state_type state_; + + // Per-descriptor data used by the reactor. + reactor::per_descriptor_data reactor_data_; + }; + + // Constructor. + BOOST_ASIO_DECL reactive_descriptor_service( + boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new descriptor implementation. + BOOST_ASIO_DECL void construct(implementation_type& impl); + + // Destroy a descriptor implementation. + BOOST_ASIO_DECL void destroy(implementation_type& impl); + + // Assign a native descriptor to a descriptor implementation. + BOOST_ASIO_DECL boost::system::error_code assign(implementation_type& impl, + const native_type& native_descriptor, boost::system::error_code& ec); + + // Determine whether the descriptor is open. + bool is_open(const implementation_type& impl) const + { + return impl.descriptor_ != -1; + } + + // Destroy a descriptor implementation. + BOOST_ASIO_DECL boost::system::error_code close(implementation_type& impl, + boost::system::error_code& ec); + + // Get the native descriptor representation. + native_type native(const implementation_type& impl) const + { + return impl.descriptor_; + } + + // Cancel all operations associated with the descriptor. + BOOST_ASIO_DECL boost::system::error_code cancel(implementation_type& impl, + boost::system::error_code& ec); + + // Perform an IO control command on the descriptor. + template <typename IO_Control_Command> + boost::system::error_code io_control(implementation_type& impl, + IO_Control_Command& command, boost::system::error_code& ec) + { + descriptor_ops::ioctl(impl.descriptor_, impl.state_, + command.name(), static_cast<ioctl_arg_type*>(command.data()), ec); + return ec; + } + + // Write some data to the descriptor. + template <typename ConstBufferSequence> + size_t write_some(implementation_type& impl, + const ConstBufferSequence& buffers, boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(buffers); + + return descriptor_ops::sync_write(impl.descriptor_, impl.state_, + bufs.buffers(), bufs.count(), bufs.all_empty(), ec); + } + + // Wait until data can be written without blocking. + size_t write_some(implementation_type& impl, + const null_buffers&, boost::system::error_code& ec) + { + // Wait for descriptor to become ready. + descriptor_ops::poll_write(impl.descriptor_, ec); + + return 0; + } + + // Start an asynchronous write. The data being sent must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_write_some(implementation_type& impl, + const ConstBufferSequence& buffers, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef descriptor_write_op<ConstBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.descriptor_, buffers, handler); + + start_op(impl, reactor::write_op, p.p, true, + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence>::all_empty(buffers)); + p.v = p.p = 0; + } + + // Start an asynchronous wait until data can be written without blocking. + template <typename Handler> + void async_write_some(implementation_type& impl, + const null_buffers&, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + start_op(impl, reactor::write_op, p.p, false, false); + p.v = p.p = 0; + } + + // Read some data from the stream. Returns the number of bytes read. + template <typename MutableBufferSequence> + size_t read_some(implementation_type& impl, + const MutableBufferSequence& buffers, boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(buffers); + + return descriptor_ops::sync_read(impl.descriptor_, impl.state_, + bufs.buffers(), bufs.count(), bufs.all_empty(), ec); + } + + // Wait until data can be read without blocking. + size_t read_some(implementation_type& impl, + const null_buffers&, boost::system::error_code& ec) + { + // Wait for descriptor to become ready. + descriptor_ops::poll_read(impl.descriptor_, ec); + + return 0; + } + + // Start an asynchronous read. The buffer for the data being read must be + // valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_read_some(implementation_type& impl, + const MutableBufferSequence& buffers, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef descriptor_read_op<MutableBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.descriptor_, buffers, handler); + + start_op(impl, reactor::read_op, p.p, true, + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence>::all_empty(buffers)); + p.v = p.p = 0; + } + + // Wait until data can be read without blocking. + template <typename Handler> + void async_read_some(implementation_type& impl, + const null_buffers&, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + start_op(impl, reactor::read_op, p.p, false, false); + p.v = p.p = 0; + } + +private: + // Start the asynchronous operation. + BOOST_ASIO_DECL void start_op(implementation_type& impl, int op_type, + reactor_op* op, bool non_blocking, bool noop); + + // The selector that performs event demultiplexing for the service. + reactor& reactor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/reactive_descriptor_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_REACTIVE_DESCRIPTOR_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_null_buffers_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_null_buffers_op.hpp new file mode 100644 index 0000000..a2a6911 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_null_buffers_op.hpp
@@ -0,0 +1,85 @@ +// +// detail/reactive_null_buffers_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_NULL_BUFFERS_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_NULL_BUFFERS_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/reactor_op.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +class reactive_null_buffers_op : public reactor_op +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_null_buffers_op); + + reactive_null_buffers_op(Handler handler) + : reactor_op(&reactive_null_buffers_op::do_perform, + &reactive_null_buffers_op::do_complete), + handler_(handler) + { + } + + static bool do_perform(reactor_op*) + { + return true; + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_null_buffers_op* o(static_cast<reactive_null_buffers_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_NULL_BUFFERS_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_serial_port_service.hpp b/boost_1_45_0/boost/asio/detail/reactive_serial_port_service.hpp new file mode 100644 index 0000000..0955f1d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_serial_port_service.hpp
@@ -0,0 +1,219 @@ +// +// detail/reactive_serial_port_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SERIAL_PORT_SERVICE_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SERIAL_PORT_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_SERIAL_PORT) +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <string> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/serial_port_base.hpp> +#include <boost/asio/detail/descriptor_ops.hpp> +#include <boost/asio/detail/reactive_descriptor_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Extend reactive_descriptor_service to provide serial port support. +class reactive_serial_port_service +{ +public: + // The native type of a serial port. + typedef reactive_descriptor_service::native_type native_type; + + // The implementation type of the serial port. + typedef reactive_descriptor_service::implementation_type implementation_type; + + BOOST_ASIO_DECL reactive_serial_port_service( + boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new serial port implementation. + void construct(implementation_type& impl) + { + descriptor_service_.construct(impl); + } + + // Destroy a serial port implementation. + void destroy(implementation_type& impl) + { + descriptor_service_.destroy(impl); + } + + // Open the serial port using the specified device name. + BOOST_ASIO_DECL boost::system::error_code open(implementation_type& impl, + const std::string& device, boost::system::error_code& ec); + + // Assign a native descriptor to a serial port implementation. + boost::system::error_code assign(implementation_type& impl, + const native_type& native_descriptor, boost::system::error_code& ec) + { + return descriptor_service_.assign(impl, native_descriptor, ec); + } + + // Determine whether the serial port is open. + bool is_open(const implementation_type& impl) const + { + return descriptor_service_.is_open(impl); + } + + // Destroy a serial port implementation. + boost::system::error_code close(implementation_type& impl, + boost::system::error_code& ec) + { + return descriptor_service_.close(impl, ec); + } + + // Get the native serial port representation. + native_type native(implementation_type& impl) + { + return descriptor_service_.native(impl); + } + + // Cancel all operations associated with the serial port. + boost::system::error_code cancel(implementation_type& impl, + boost::system::error_code& ec) + { + return descriptor_service_.cancel(impl, ec); + } + + // Set an option on the serial port. + template <typename SettableSerialPortOption> + boost::system::error_code set_option(implementation_type& impl, + const SettableSerialPortOption& option, boost::system::error_code& ec) + { + return do_set_option(impl, + &reactive_serial_port_service::store_option<SettableSerialPortOption>, + &option, ec); + } + + // Get an option from the serial port. + template <typename GettableSerialPortOption> + boost::system::error_code get_option(const implementation_type& impl, + GettableSerialPortOption& option, boost::system::error_code& ec) const + { + return do_get_option(impl, + &reactive_serial_port_service::load_option<GettableSerialPortOption>, + &option, ec); + } + + // Send a break sequence to the serial port. + boost::system::error_code send_break(implementation_type& impl, + boost::system::error_code& ec) + { + errno = 0; + descriptor_ops::error_wrapper(::tcsendbreak( + descriptor_service_.native(impl), 0), ec); + return ec; + } + + // Write the given data. Returns the number of bytes sent. + template <typename ConstBufferSequence> + size_t write_some(implementation_type& impl, + const ConstBufferSequence& buffers, boost::system::error_code& ec) + { + return descriptor_service_.write_some(impl, buffers, ec); + } + + // Start an asynchronous write. The data being written must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_write_some(implementation_type& impl, + const ConstBufferSequence& buffers, Handler handler) + { + descriptor_service_.async_write_some(impl, buffers, handler); + } + + // Read some data. Returns the number of bytes received. + template <typename MutableBufferSequence> + size_t read_some(implementation_type& impl, + const MutableBufferSequence& buffers, boost::system::error_code& ec) + { + return descriptor_service_.read_some(impl, buffers, ec); + } + + // Start an asynchronous read. The buffer for the data being received must be + // valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_read_some(implementation_type& impl, + const MutableBufferSequence& buffers, Handler handler) + { + descriptor_service_.async_read_some(impl, buffers, handler); + } + +private: + // Function pointer type for storing a serial port option. + typedef boost::system::error_code (*store_function_type)( + const void*, termios&, boost::system::error_code&); + + // Helper function template to store a serial port option. + template <typename SettableSerialPortOption> + static boost::system::error_code store_option(const void* option, + termios& storage, boost::system::error_code& ec) + { + return static_cast<const SettableSerialPortOption*>(option)->store( + storage, ec); + } + + // Helper function to set a serial port option. + BOOST_ASIO_DECL boost::system::error_code do_set_option( + implementation_type& impl, store_function_type store, + const void* option, boost::system::error_code& ec); + + // Function pointer type for loading a serial port option. + typedef boost::system::error_code (*load_function_type)( + void*, const termios&, boost::system::error_code&); + + // Helper function template to load a serial port option. + template <typename GettableSerialPortOption> + static boost::system::error_code load_option(void* option, + const termios& storage, boost::system::error_code& ec) + { + return static_cast<GettableSerialPortOption*>(option)->load(storage, ec); + } + + // Helper function to get a serial port option. + BOOST_ASIO_DECL boost::system::error_code do_get_option( + const implementation_type& impl, load_function_type load, + void* option, boost::system::error_code& ec) const; + + // The implementation used for initiating asynchronous operations. + reactive_descriptor_service descriptor_service_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/reactive_serial_port_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#endif // defined(BOOST_ASIO_HAS_SERIAL_PORT) + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SERIAL_PORT_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_accept_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_accept_op.hpp new file mode 100644 index 0000000..3b2413f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_accept_op.hpp
@@ -0,0 +1,133 @@ +// +// detail/reactive_socket_accept_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_ACCEPT_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_ACCEPT_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_holder.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Socket, typename Protocol> +class reactive_socket_accept_op_base : public reactor_op +{ +public: + reactive_socket_accept_op_base(socket_type socket, + socket_ops::state_type state, Socket& peer, const Protocol& protocol, + typename Protocol::endpoint* peer_endpoint, func_type complete_func) + : reactor_op(&reactive_socket_accept_op_base::do_perform, complete_func), + socket_(socket), + state_(state), + peer_(peer), + protocol_(protocol), + peer_endpoint_(peer_endpoint) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_accept_op_base* o( + static_cast<reactive_socket_accept_op_base*>(base)); + + std::size_t addrlen = o->peer_endpoint_ ? o->peer_endpoint_->capacity() : 0; + socket_type new_socket = invalid_socket; + bool result = socket_ops::non_blocking_accept(o->socket_, + o->state_, o->peer_endpoint_ ? o->peer_endpoint_->data() : 0, + o->peer_endpoint_ ? &addrlen : 0, o->ec_, new_socket); + + // On success, assign new connection to peer socket object. + if (new_socket >= 0) + { + socket_holder new_socket_holder(new_socket); + if (o->peer_endpoint_) + o->peer_endpoint_->resize(addrlen); + if (!o->peer_.assign(o->protocol_, new_socket, o->ec_)) + new_socket_holder.release(); + } + + return result; + } + +private: + socket_type socket_; + socket_ops::state_type state_; + Socket& peer_; + Protocol protocol_; + typename Protocol::endpoint* peer_endpoint_; +}; + +template <typename Socket, typename Protocol, typename Handler> +class reactive_socket_accept_op : + public reactive_socket_accept_op_base<Socket, Protocol> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_accept_op); + + reactive_socket_accept_op(socket_type socket, + socket_ops::state_type state, Socket& peer, const Protocol& protocol, + typename Protocol::endpoint* peer_endpoint, Handler handler) + : reactive_socket_accept_op_base<Socket, Protocol>(socket, state, peer, + protocol, peer_endpoint, &reactive_socket_accept_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_accept_op* o(static_cast<reactive_socket_accept_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder1<Handler, boost::system::error_code> + handler(o->handler_, o->ec_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_ACCEPT_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_connect_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_connect_op.hpp new file mode 100644 index 0000000..2bfb55d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_connect_op.hpp
@@ -0,0 +1,103 @@ +// +// detail/reactive_socket_connect_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_CONNECT_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_CONNECT_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class reactive_socket_connect_op_base : public reactor_op +{ +public: + reactive_socket_connect_op_base(socket_type socket, func_type complete_func) + : reactor_op(&reactive_socket_connect_op_base::do_perform, complete_func), + socket_(socket) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_connect_op_base* o( + static_cast<reactive_socket_connect_op_base*>(base)); + + return socket_ops::non_blocking_connect(o->socket_, o->ec_); + } + +private: + socket_type socket_; +}; + +template <typename Handler> +class reactive_socket_connect_op : public reactive_socket_connect_op_base +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_connect_op); + + reactive_socket_connect_op(socket_type socket, Handler handler) + : reactive_socket_connect_op_base(socket, + &reactive_socket_connect_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_connect_op* o + (static_cast<reactive_socket_connect_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder1<Handler, boost::system::error_code> + handler(o->handler_, o->ec_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_CONNECT_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_recv_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_recv_op.hpp new file mode 100644 index 0000000..d58aa3f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_recv_op.hpp
@@ -0,0 +1,120 @@ +// +// detail/reactive_socket_recv_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename MutableBufferSequence> +class reactive_socket_recv_op_base : public reactor_op +{ +public: + reactive_socket_recv_op_base(socket_type socket, + socket_ops::state_type state, const MutableBufferSequence& buffers, + socket_base::message_flags flags, func_type complete_func) + : reactor_op(&reactive_socket_recv_op_base::do_perform, complete_func), + socket_(socket), + state_(state), + buffers_(buffers), + flags_(flags) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_recv_op_base* o( + static_cast<reactive_socket_recv_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(o->buffers_); + + return socket_ops::non_blocking_recv(o->socket_, + bufs.buffers(), bufs.count(), o->flags_, + (o->state_ & socket_ops::stream_oriented), + o->ec_, o->bytes_transferred_); + } + +private: + socket_type socket_; + socket_ops::state_type state_; + MutableBufferSequence buffers_; + socket_base::message_flags flags_; +}; + +template <typename MutableBufferSequence, typename Handler> +class reactive_socket_recv_op : + public reactive_socket_recv_op_base<MutableBufferSequence> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_recv_op); + + reactive_socket_recv_op(socket_type socket, + socket_ops::state_type state, const MutableBufferSequence& buffers, + socket_base::message_flags flags, Handler handler) + : reactive_socket_recv_op_base<MutableBufferSequence>(socket, state, + buffers, flags, &reactive_socket_recv_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_recv_op* o(static_cast<reactive_socket_recv_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECV_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_recvfrom_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_recvfrom_op.hpp new file mode 100644 index 0000000..469b6a5 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_recvfrom_op.hpp
@@ -0,0 +1,130 @@ +// +// detail/reactive_socket_recvfrom_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVFROM_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVFROM_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename MutableBufferSequence, typename Endpoint> +class reactive_socket_recvfrom_op_base : public reactor_op +{ +public: + reactive_socket_recvfrom_op_base(socket_type socket, int protocol_type, + const MutableBufferSequence& buffers, Endpoint& endpoint, + socket_base::message_flags flags, func_type complete_func) + : reactor_op(&reactive_socket_recvfrom_op_base::do_perform, complete_func), + socket_(socket), + protocol_type_(protocol_type), + buffers_(buffers), + sender_endpoint_(endpoint), + flags_(flags) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_recvfrom_op_base* o( + static_cast<reactive_socket_recvfrom_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(o->buffers_); + + std::size_t addr_len = o->sender_endpoint_.capacity(); + bool result = socket_ops::non_blocking_recvfrom(o->socket_, + bufs.buffers(), bufs.count(), o->flags_, + o->sender_endpoint_.data(), &addr_len, + o->ec_, o->bytes_transferred_); + + if (result && !o->ec_) + o->sender_endpoint_.resize(addr_len); + + return result; + } + +private: + socket_type socket_; + int protocol_type_; + MutableBufferSequence buffers_; + Endpoint& sender_endpoint_; + socket_base::message_flags flags_; +}; + +template <typename MutableBufferSequence, typename Endpoint, typename Handler> +class reactive_socket_recvfrom_op : + public reactive_socket_recvfrom_op_base<MutableBufferSequence, Endpoint> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_recvfrom_op); + + reactive_socket_recvfrom_op(socket_type socket, int protocol_type, + const MutableBufferSequence& buffers, Endpoint& endpoint, + socket_base::message_flags flags, Handler handler) + : reactive_socket_recvfrom_op_base<MutableBufferSequence, Endpoint>( + socket, protocol_type, buffers, endpoint, flags, + &reactive_socket_recvfrom_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_recvfrom_op* o( + static_cast<reactive_socket_recvfrom_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVFROM_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_send_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_send_op.hpp new file mode 100644 index 0000000..157d075 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_send_op.hpp
@@ -0,0 +1,117 @@ +// +// detail/reactive_socket_send_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SEND_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SEND_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename ConstBufferSequence> +class reactive_socket_send_op_base : public reactor_op +{ +public: + reactive_socket_send_op_base(socket_type socket, + const ConstBufferSequence& buffers, + socket_base::message_flags flags, func_type complete_func) + : reactor_op(&reactive_socket_send_op_base::do_perform, complete_func), + socket_(socket), + buffers_(buffers), + flags_(flags) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_send_op_base* o( + static_cast<reactive_socket_send_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(o->buffers_); + + return socket_ops::non_blocking_send(o->socket_, + bufs.buffers(), bufs.count(), o->flags_, + o->ec_, o->bytes_transferred_); + } + +private: + socket_type socket_; + ConstBufferSequence buffers_; + socket_base::message_flags flags_; +}; + +template <typename ConstBufferSequence, typename Handler> +class reactive_socket_send_op : + public reactive_socket_send_op_base<ConstBufferSequence> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_send_op); + + reactive_socket_send_op(socket_type socket, + const ConstBufferSequence& buffers, + socket_base::message_flags flags, Handler handler) + : reactive_socket_send_op_base<ConstBufferSequence>(socket, + buffers, flags, &reactive_socket_send_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_send_op* o(static_cast<reactive_socket_send_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SEND_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_sendto_op.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_sendto_op.hpp new file mode 100644 index 0000000..6199ec2 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_sendto_op.hpp
@@ -0,0 +1,120 @@ +// +// detail/reactive_socket_sendto_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename ConstBufferSequence, typename Endpoint> +class reactive_socket_sendto_op_base : public reactor_op +{ +public: + reactive_socket_sendto_op_base(socket_type socket, + const ConstBufferSequence& buffers, const Endpoint& endpoint, + socket_base::message_flags flags, func_type complete_func) + : reactor_op(&reactive_socket_sendto_op_base::do_perform, complete_func), + socket_(socket), + buffers_(buffers), + destination_(endpoint), + flags_(flags) + { + } + + static bool do_perform(reactor_op* base) + { + reactive_socket_sendto_op_base* o( + static_cast<reactive_socket_sendto_op_base*>(base)); + + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(o->buffers_); + + return socket_ops::non_blocking_sendto(o->socket_, + bufs.buffers(), bufs.count(), o->flags_, + o->destination_.data(), o->destination_.size(), + o->ec_, o->bytes_transferred_); + } + +private: + socket_type socket_; + ConstBufferSequence buffers_; + Endpoint destination_; + socket_base::message_flags flags_; +}; + +template <typename ConstBufferSequence, typename Endpoint, typename Handler> +class reactive_socket_sendto_op : + public reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint> +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_sendto_op); + + reactive_socket_sendto_op(socket_type socket, + const ConstBufferSequence& buffers, const Endpoint& endpoint, + socket_base::message_flags flags, Handler handler) + : reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>(socket, + buffers, endpoint, flags, &reactive_socket_sendto_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + reactive_socket_sendto_op* o(static_cast<reactive_socket_sendto_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, o->ec_, o->bytes_transferred_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SENDTO_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_service.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_service.hpp new file mode 100644 index 0000000..7288881 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_service.hpp
@@ -0,0 +1,392 @@ +// +// detail/reactive_socket_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/socket_base.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/reactive_null_buffers_op.hpp> +#include <boost/asio/detail/reactive_socket_accept_op.hpp> +#include <boost/asio/detail/reactive_socket_connect_op.hpp> +#include <boost/asio/detail/reactive_socket_recvfrom_op.hpp> +#include <boost/asio/detail/reactive_socket_sendto_op.hpp> +#include <boost/asio/detail/reactive_socket_service_base.hpp> +#include <boost/asio/detail/reactor.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_holder.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Protocol> +class reactive_socket_service : + public reactive_socket_service_base +{ +public: + // The protocol type. + typedef Protocol protocol_type; + + // The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + // The native type of a socket. + typedef socket_type native_type; + + // The implementation type of the socket. + struct implementation_type : + reactive_socket_service_base::base_implementation_type + { + // Default constructor. + implementation_type() + : protocol_(endpoint_type().protocol()) + { + } + + // The protocol associated with the socket. + protocol_type protocol_; + }; + + // Constructor. + reactive_socket_service(boost::asio::io_service& io_service) + : reactive_socket_service_base(io_service) + { + } + + // Open a new socket implementation. + boost::system::error_code open(implementation_type& impl, + const protocol_type& protocol, boost::system::error_code& ec) + { + if (!do_open(impl, protocol.family(), + protocol.type(), protocol.protocol(), ec)) + impl.protocol_ = protocol; + return ec; + } + + // Assign a native socket to a socket implementation. + boost::system::error_code assign(implementation_type& impl, + const protocol_type& protocol, const native_type& native_socket, + boost::system::error_code& ec) + { + if (!do_assign(impl, protocol.type(), native_socket, ec)) + impl.protocol_ = protocol; + return ec; + } + + // Get the native socket representation. + native_type native(implementation_type& impl) + { + return impl.socket_; + } + + // Bind the socket to the specified local endpoint. + boost::system::error_code bind(implementation_type& impl, + const endpoint_type& endpoint, boost::system::error_code& ec) + { + socket_ops::bind(impl.socket_, endpoint.data(), endpoint.size(), ec); + return ec; + } + + // Set a socket option. + template <typename Option> + boost::system::error_code set_option(implementation_type& impl, + const Option& option, boost::system::error_code& ec) + { + socket_ops::setsockopt(impl.socket_, impl.state_, + option.level(impl.protocol_), option.name(impl.protocol_), + option.data(impl.protocol_), option.size(impl.protocol_), ec); + return ec; + } + + // Set a socket option. + template <typename Option> + boost::system::error_code get_option(const implementation_type& impl, + Option& option, boost::system::error_code& ec) const + { + std::size_t size = option.size(impl.protocol_); + socket_ops::getsockopt(impl.socket_, impl.state_, + option.level(impl.protocol_), option.name(impl.protocol_), + option.data(impl.protocol_), &size, ec); + if (!ec) + option.resize(impl.protocol_, size); + return ec; + } + + // Get the local endpoint. + endpoint_type local_endpoint(const implementation_type& impl, + boost::system::error_code& ec) const + { + endpoint_type endpoint; + std::size_t addr_len = endpoint.capacity(); + if (socket_ops::getsockname(impl.socket_, endpoint.data(), &addr_len, ec)) + return endpoint_type(); + endpoint.resize(addr_len); + return endpoint; + } + + // Get the remote endpoint. + endpoint_type remote_endpoint(const implementation_type& impl, + boost::system::error_code& ec) const + { + endpoint_type endpoint; + std::size_t addr_len = endpoint.capacity(); + if (socket_ops::getpeername(impl.socket_, + endpoint.data(), &addr_len, false, ec)) + return endpoint_type(); + endpoint.resize(addr_len); + return endpoint; + } + + // Send a datagram to the specified endpoint. Returns the number of bytes + // sent. + template <typename ConstBufferSequence> + size_t send_to(implementation_type& impl, const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(buffers); + + return socket_ops::sync_sendto(impl.socket_, impl.state_, + bufs.buffers(), bufs.count(), flags, + destination.data(), destination.size(), ec); + } + + // Wait until data can be sent without blocking. + size_t send_to(implementation_type& impl, const null_buffers&, + const endpoint_type&, socket_base::message_flags, + boost::system::error_code& ec) + { + // Wait for socket to become ready. + socket_ops::poll_write(impl.socket_, ec); + + return 0; + } + + // Start an asynchronous send. The data being sent must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_send_to(implementation_type& impl, + const ConstBufferSequence& buffers, + const endpoint_type& destination, socket_base::message_flags flags, + Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_sendto_op<ConstBufferSequence, + endpoint_type, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.socket_, buffers, destination, flags, handler); + + start_op(impl, reactor::write_op, p.p, true, false); + p.v = p.p = 0; + } + + // Start an asynchronous wait until data can be sent without blocking. + template <typename Handler> + void async_send_to(implementation_type& impl, const null_buffers&, + const endpoint_type&, socket_base::message_flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + start_op(impl, reactor::write_op, p.p, false, false); + p.v = p.p = 0; + } + + // Receive a datagram with the endpoint of the sender. Returns the number of + // bytes received. + template <typename MutableBufferSequence> + size_t receive_from(implementation_type& impl, + const MutableBufferSequence& buffers, + endpoint_type& sender_endpoint, socket_base::message_flags flags, + boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(buffers); + + std::size_t addr_len = sender_endpoint.capacity(); + std::size_t bytes_recvd = socket_ops::sync_recvfrom( + impl.socket_, impl.state_, bufs.buffers(), bufs.count(), + flags, sender_endpoint.data(), &addr_len, ec); + + if (!ec) + sender_endpoint.resize(addr_len); + + return bytes_recvd; + } + + // Wait until data can be received without blocking. + size_t receive_from(implementation_type& impl, const null_buffers&, + endpoint_type& sender_endpoint, socket_base::message_flags, + boost::system::error_code& ec) + { + // Wait for socket to become ready. + socket_ops::poll_read(impl.socket_, ec); + + // Reset endpoint since it can be given no sensible value at this time. + sender_endpoint = endpoint_type(); + + return 0; + } + + // Start an asynchronous receive. The buffer for the data being received and + // the sender_endpoint object must both be valid for the lifetime of the + // asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_receive_from(implementation_type& impl, + const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, + socket_base::message_flags flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_recvfrom_op<MutableBufferSequence, + endpoint_type, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + int protocol_type = impl.protocol_.type(); + p.p = new (p.v) op(impl.socket_, protocol_type, + buffers, sender_endpoint, flags, handler); + + start_op(impl, + (flags & socket_base::message_out_of_band) + ? reactor::except_op : reactor::read_op, + p.p, true, false); + p.v = p.p = 0; + } + + // Wait until data can be received without blocking. + template <typename Handler> + void async_receive_from(implementation_type& impl, + const null_buffers&, endpoint_type& sender_endpoint, + socket_base::message_flags flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + // Reset endpoint since it can be given no sensible value at this time. + sender_endpoint = endpoint_type(); + + start_op(impl, + (flags & socket_base::message_out_of_band) + ? reactor::except_op : reactor::read_op, + p.p, false, false); + p.v = p.p = 0; + } + + // Accept a new connection. + template <typename Socket> + boost::system::error_code accept(implementation_type& impl, + Socket& peer, endpoint_type* peer_endpoint, boost::system::error_code& ec) + { + // We cannot accept a socket that is already open. + if (peer.is_open()) + { + ec = boost::asio::error::already_open; + return ec; + } + + std::size_t addr_len = peer_endpoint ? peer_endpoint->capacity() : 0; + socket_holder new_socket(socket_ops::sync_accept(impl.socket_, + impl.state_, peer_endpoint ? peer_endpoint->data() : 0, + peer_endpoint ? &addr_len : 0, ec)); + + // On success, assign new connection to peer socket object. + if (new_socket.get() != invalid_socket) + { + if (peer_endpoint) + peer_endpoint->resize(addr_len); + if (!peer.assign(impl.protocol_, new_socket.get(), ec)) + new_socket.release(); + } + + return ec; + } + + // Start an asynchronous accept. The peer and peer_endpoint objects + // must be valid until the accept's handler is invoked. + template <typename Socket, typename Handler> + void async_accept(implementation_type& impl, Socket& peer, + endpoint_type* peer_endpoint, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_accept_op<Socket, Protocol, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.socket_, impl.state_, peer, + impl.protocol_, peer_endpoint, handler); + + start_accept_op(impl, p.p, peer.is_open()); + p.v = p.p = 0; + } + + // Connect the socket to the specified endpoint. + boost::system::error_code connect(implementation_type& impl, + const endpoint_type& peer_endpoint, boost::system::error_code& ec) + { + socket_ops::sync_connect(impl.socket_, + peer_endpoint.data(), peer_endpoint.size(), ec); + return ec; + } + + // Start an asynchronous connect. + template <typename Handler> + void async_connect(implementation_type& impl, + const endpoint_type& peer_endpoint, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_connect_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.socket_, handler); + + start_connect_op(impl, p.p, peer_endpoint.data(), peer_endpoint.size()); + p.v = p.p = 0; + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactive_socket_service_base.hpp b/boost_1_45_0/boost/asio/detail/reactive_socket_service_base.hpp new file mode 100644 index 0000000..1733ce1 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactive_socket_service_base.hpp
@@ -0,0 +1,300 @@ +// +// detail/reactive_socket_service_base.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_BASE_HPP +#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_BASE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/buffer.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/socket_base.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/reactive_null_buffers_op.hpp> +#include <boost/asio/detail/reactive_socket_recv_op.hpp> +#include <boost/asio/detail/reactive_socket_send_op.hpp> +#include <boost/asio/detail/reactor.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_holder.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class reactive_socket_service_base +{ +public: + // The native type of a socket. + typedef socket_type native_type; + + // The implementation type of the socket. + struct base_implementation_type + { + // The native socket representation. + socket_type socket_; + + // The current state of the socket. + socket_ops::state_type state_; + + // Per-descriptor data used by the reactor. + reactor::per_descriptor_data reactor_data_; + }; + + // Constructor. + BOOST_ASIO_DECL reactive_socket_service_base( + boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new socket implementation. + BOOST_ASIO_DECL void construct(base_implementation_type& impl); + + // Destroy a socket implementation. + BOOST_ASIO_DECL void destroy(base_implementation_type& impl); + + // Determine whether the socket is open. + bool is_open(const base_implementation_type& impl) const + { + return impl.socket_ != invalid_socket; + } + + // Destroy a socket implementation. + BOOST_ASIO_DECL boost::system::error_code close( + base_implementation_type& impl, boost::system::error_code& ec); + + // Get the native socket representation. + native_type native(base_implementation_type& impl) + { + return impl.socket_; + } + + // Cancel all operations associated with the socket. + BOOST_ASIO_DECL boost::system::error_code cancel( + base_implementation_type& impl, boost::system::error_code& ec); + + // Determine whether the socket is at the out-of-band data mark. + bool at_mark(const base_implementation_type& impl, + boost::system::error_code& ec) const + { + return socket_ops::sockatmark(impl.socket_, ec); + } + + // Determine the number of bytes available for reading. + std::size_t available(const base_implementation_type& impl, + boost::system::error_code& ec) const + { + return socket_ops::available(impl.socket_, ec); + } + + // Place the socket into the state where it will listen for new connections. + boost::system::error_code listen(base_implementation_type& impl, + int backlog, boost::system::error_code& ec) + { + socket_ops::listen(impl.socket_, backlog, ec); + return ec; + } + + // Perform an IO control command on the socket. + template <typename IO_Control_Command> + boost::system::error_code io_control(base_implementation_type& impl, + IO_Control_Command& command, boost::system::error_code& ec) + { + socket_ops::ioctl(impl.socket_, impl.state_, command.name(), + static_cast<ioctl_arg_type*>(command.data()), ec); + return ec; + } + + /// Disable sends or receives on the socket. + boost::system::error_code shutdown(base_implementation_type& impl, + socket_base::shutdown_type what, boost::system::error_code& ec) + { + socket_ops::shutdown(impl.socket_, what, ec); + return ec; + } + + // Send the given data to the peer. + template <typename ConstBufferSequence> + size_t send(base_implementation_type& impl, + const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence> bufs(buffers); + + return socket_ops::sync_send(impl.socket_, impl.state_, + bufs.buffers(), bufs.count(), flags, bufs.all_empty(), ec); + } + + // Wait until data can be sent without blocking. + size_t send(base_implementation_type& impl, const null_buffers&, + socket_base::message_flags, boost::system::error_code& ec) + { + // Wait for socket to become ready. + socket_ops::poll_write(impl.socket_, ec); + + return 0; + } + + // Start an asynchronous send. The data being sent must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_send(base_implementation_type& impl, + const ConstBufferSequence& buffers, + socket_base::message_flags flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_send_op<ConstBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.socket_, buffers, flags, handler); + + start_op(impl, reactor::write_op, p.p, true, + ((impl.state_ & socket_ops::stream_oriented) + && buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence>::all_empty(buffers))); + p.v = p.p = 0; + } + + // Start an asynchronous wait until data can be sent without blocking. + template <typename Handler> + void async_send(base_implementation_type& impl, const null_buffers&, + socket_base::message_flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + start_op(impl, reactor::write_op, p.p, false, false); + p.v = p.p = 0; + } + + // Receive some data from the peer. Returns the number of bytes received. + template <typename MutableBufferSequence> + size_t receive(base_implementation_type& impl, + const MutableBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence> bufs(buffers); + + return socket_ops::sync_recv(impl.socket_, impl.state_, + bufs.buffers(), bufs.count(), flags, bufs.all_empty(), ec); + } + + // Wait until data can be received without blocking. + size_t receive(base_implementation_type& impl, const null_buffers&, + socket_base::message_flags, boost::system::error_code& ec) + { + // Wait for socket to become ready. + socket_ops::poll_read(impl.socket_, ec); + + return 0; + } + + // Start an asynchronous receive. The buffer for the data being received + // must be valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_receive(base_implementation_type& impl, + const MutableBufferSequence& buffers, + socket_base::message_flags flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_socket_recv_op<MutableBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl.socket_, impl.state_, buffers, flags, handler); + + start_op(impl, + (flags & socket_base::message_out_of_band) + ? reactor::except_op : reactor::read_op, + p.p, (flags & socket_base::message_out_of_band) == 0, + ((impl.state_ & socket_ops::stream_oriented) + && buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence>::all_empty(buffers))); + p.v = p.p = 0; + } + + // Wait until data can be received without blocking. + template <typename Handler> + void async_receive(base_implementation_type& impl, const null_buffers&, + socket_base::message_flags flags, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef reactive_null_buffers_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + + start_op(impl, + (flags & socket_base::message_out_of_band) + ? reactor::except_op : reactor::read_op, + p.p, false, false); + p.v = p.p = 0; + } + +protected: + // Open a new socket implementation. + BOOST_ASIO_DECL boost::system::error_code do_open( + base_implementation_type& impl, int af, + int type, int protocol, boost::system::error_code& ec); + + // Assign a native socket to a socket implementation. + BOOST_ASIO_DECL boost::system::error_code do_assign( + base_implementation_type& impl, int type, + const native_type& native_socket, boost::system::error_code& ec); + + // Start the asynchronous read or write operation. + BOOST_ASIO_DECL void start_op(base_implementation_type& impl, int op_type, + reactor_op* op, bool non_blocking, bool noop); + + // Start the asynchronous accept operation. + BOOST_ASIO_DECL void start_accept_op(base_implementation_type& impl, + reactor_op* op, bool peer_is_open); + + // Start the asynchronous connect operation. + BOOST_ASIO_DECL void start_connect_op(base_implementation_type& impl, + reactor_op* op, const socket_addr_type* addr, size_t addrlen); + + // The selector that performs event demultiplexing for the service. + reactor& reactor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/reactive_socket_service_base.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_SERVICE_BASE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactor.hpp b/boost_1_45_0/boost/asio/detail/reactor.hpp new file mode 100644 index 0000000..468276d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactor.hpp
@@ -0,0 +1,30 @@ +// +// detail/reactor.hpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTOR_HPP +#define BOOST_ASIO_DETAIL_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/reactor_fwd.hpp> + +#if defined(BOOST_ASIO_HAS_EPOLL) +# include <boost/asio/detail/epoll_reactor.hpp> +#elif defined(BOOST_ASIO_HAS_KQUEUE) +# include <boost/asio/detail/kqueue_reactor.hpp> +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +# include <boost/asio/detail/dev_poll_reactor.hpp> +#else +# include <boost/asio/detail/select_reactor.hpp> +#endif + +#endif // BOOST_ASIO_DETAIL_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactor_fwd.hpp b/boost_1_45_0/boost/asio/detail/reactor_fwd.hpp new file mode 100644 index 0000000..3fae83c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactor_fwd.hpp
@@ -0,0 +1,52 @@ +// +// detail/reactor_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTOR_FWD_HPP +#define BOOST_ASIO_DETAIL_REACTOR_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/select_reactor_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_EPOLL) +# include <boost/asio/detail/epoll_reactor_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_KQUEUE) +# include <boost/asio/detail/kqueue_reactor_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +# include <boost/asio/detail/dev_poll_reactor_fwd.hpp> +#else +# include <boost/asio/detail/select_reactor_fwd.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_ASIO_HAS_IOCP) +typedef select_reactor reactor; +#elif defined(BOOST_ASIO_HAS_EPOLL) +typedef epoll_reactor reactor; +#elif defined(BOOST_ASIO_HAS_KQUEUE) +typedef kqueue_reactor reactor; +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +typedef dev_poll_reactor reactor; +#else +typedef select_reactor reactor; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_REACTOR_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactor_op.hpp b/boost_1_45_0/boost/asio/detail/reactor_op.hpp new file mode 100644 index 0000000..ed4a33d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactor_op.hpp
@@ -0,0 +1,63 @@ +// +// detail/reactor_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTOR_OP_HPP +#define BOOST_ASIO_DETAIL_REACTOR_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class reactor_op + : public operation +{ +public: + // The error code to be passed to the completion handler. + boost::system::error_code ec_; + + // The number of bytes transferred, to be passed to the completion handler. + std::size_t bytes_transferred_; + + // Perform the operation. Returns true if it is finished. + bool perform() + { + return perform_func_(this); + } + +protected: + typedef bool (*perform_func_type)(reactor_op*); + + reactor_op(perform_func_type perform_func, func_type complete_func) + : operation(complete_func), + bytes_transferred_(0), + perform_func_(perform_func) + { + } + +private: + perform_func_type perform_func_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTOR_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/reactor_op_queue.hpp b/boost_1_45_0/boost/asio/detail/reactor_op_queue.hpp new file mode 100644 index 0000000..830e9b3 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/reactor_op_queue.hpp
@@ -0,0 +1,202 @@ +// +// detail/reactor_op_queue.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REACTOR_OP_QUEUE_HPP +#define BOOST_ASIO_DETAIL_REACTOR_OP_QUEUE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/hash_map.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Descriptor> +class reactor_op_queue + : private noncopyable +{ +public: + // Constructor. + reactor_op_queue() + : operations_() + { + } + + // Add a new operation to the queue. Returns true if this is the only + // operation for the given descriptor, in which case the reactor's event + // demultiplexing function call may need to be interrupted and restarted. + bool enqueue_operation(Descriptor descriptor, reactor_op* op) + { + typedef typename operations_map::iterator iterator; + typedef typename operations_map::value_type value_type; + std::pair<iterator, bool> entry = + operations_.insert(value_type(descriptor, operations())); + entry.first->second.op_queue_.push(op); + return entry.second; + } + + // Cancel all operations associated with the descriptor. Any operations + // pending for the descriptor will be notified that they have been cancelled + // next time perform_cancellations is called. Returns true if any operations + // were cancelled, in which case the reactor's event demultiplexing function + // may need to be interrupted and restarted. + bool cancel_operations(Descriptor descriptor, op_queue<operation>& ops, + const boost::system::error_code& ec = + boost::asio::error::operation_aborted) + { + typename operations_map::iterator i = operations_.find(descriptor); + if (i != operations_.end()) + { + while (reactor_op* op = i->second.op_queue_.front()) + { + op->ec_ = ec; + i->second.op_queue_.pop(); + ops.push(op); + } + operations_.erase(i); + return true; + } + + return false; + } + + // Whether there are no operations in the queue. + bool empty() const + { + return operations_.empty(); + } + + // Determine whether there are any operations associated with the descriptor. + bool has_operation(Descriptor descriptor) const + { + return operations_.find(descriptor) != operations_.end(); + } + + // Perform the operations corresponding to the descriptor. Returns true if + // there are still unfinished operations queued for the descriptor. + bool perform_operations(Descriptor descriptor, op_queue<operation>& ops) + { + typename operations_map::iterator i = operations_.find(descriptor); + if (i != operations_.end()) + { + while (reactor_op* op = i->second.op_queue_.front()) + { + if (op->perform()) + { + i->second.op_queue_.pop(); + ops.push(op); + } + else + { + return true; + } + } + operations_.erase(i); + } + return false; + } + + // Fill a descriptor set with the descriptors corresponding to each active + // operation. The op_queue is used only when descriptors fail to be added to + // the descriptor set. + template <typename Descriptor_Set> + void get_descriptors(Descriptor_Set& descriptors, op_queue<operation>& ops) + { + typename operations_map::iterator i = operations_.begin(); + while (i != operations_.end()) + { + Descriptor descriptor = i->first; + ++i; + if (!descriptors.set(descriptor)) + { + boost::system::error_code ec(error::fd_set_failure); + cancel_operations(descriptor, ops, ec); + } + } + } + + // Perform the operations corresponding to the ready file descriptors + // contained in the given descriptor set. + template <typename Descriptor_Set> + void perform_operations_for_descriptors( + const Descriptor_Set& descriptors, op_queue<operation>& ops) + { + typename operations_map::iterator i = operations_.begin(); + while (i != operations_.end()) + { + typename operations_map::iterator op_iter = i++; + if (descriptors.is_set(op_iter->first)) + { + while (reactor_op* op = op_iter->second.op_queue_.front()) + { + if (op->perform()) + { + op_iter->second.op_queue_.pop(); + ops.push(op); + } + else + { + break; + } + } + + if (op_iter->second.op_queue_.empty()) + operations_.erase(op_iter); + } + } + } + + // Get all operations owned by the queue. + void get_all_operations(op_queue<operation>& ops) + { + typename operations_map::iterator i = operations_.begin(); + while (i != operations_.end()) + { + typename operations_map::iterator op_iter = i++; + ops.push(op_iter->second.op_queue_); + operations_.erase(op_iter); + } + } + +private: + struct operations + { + operations() {} + operations(const operations&) {} + void operator=(const operations&) {} + + // The operations waiting on the desccriptor. + op_queue<reactor_op> op_queue_; + }; + + // The type for a map of operations. + typedef hash_map<Descriptor, operations> operations_map; + + // The operations that are currently executing asynchronously. + operations_map operations_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_REACTOR_OP_QUEUE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/regex_fwd.hpp b/boost_1_45_0/boost/asio/detail/regex_fwd.hpp new file mode 100644 index 0000000..2ccb5d1 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/regex_fwd.hpp
@@ -0,0 +1,31 @@ +// +// detail/regex_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_REGEX_FWD_HPP +#define BOOST_ASIO_DETAIL_REGEX_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/regex_fwd.hpp> +#include <boost/regex/v4/match_flags.hpp> + +namespace boost { + +template <class BidiIterator> +struct sub_match; + +template <class BidiIterator, class Allocator> +class match_results; + +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_REGEX_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/resolve_endpoint_op.hpp b/boost_1_45_0/boost/asio/detail/resolve_endpoint_op.hpp new file mode 100644 index 0000000..ccf5f53 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/resolve_endpoint_op.hpp
@@ -0,0 +1,118 @@ +// +// detail/resolve_endpoint_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_RESOLVER_ENDPOINT_OP_HPP +#define BOOST_ASIO_DETAIL_RESOLVER_ENDPOINT_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/ip/basic_resolver_iterator.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Protocol, typename Handler> +class resolve_endpoint_op : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(resolve_endpoint_op); + + typedef typename Protocol::endpoint endpoint_type; + typedef boost::asio::ip::basic_resolver_iterator<Protocol> iterator_type; + + resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token, + const endpoint_type& endpoint, io_service_impl& ios, Handler handler) + : operation(&resolve_endpoint_op::do_complete), + cancel_token_(cancel_token), + endpoint_(endpoint), + io_service_impl_(ios), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the operation object. + resolve_endpoint_op* o(static_cast<resolve_endpoint_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + if (owner && owner != &o->io_service_impl_) + { + // The operation is being run on the worker io_service. Time to perform + // the resolver operation. + + // Perform the blocking endpoint resolution operation. + char host_name[NI_MAXHOST]; + char service_name[NI_MAXSERV]; + socket_ops::background_getnameinfo(o->cancel_token_, o->endpoint_.data(), + o->endpoint_.size(), host_name, NI_MAXHOST, service_name, NI_MAXSERV, + o->endpoint_.protocol().type(), o->ec_); + o->iter_ = iterator_type::create(o->endpoint_, host_name, service_name); + + // Pass operation back to main io_service for completion. + o->io_service_impl_.post_deferred_completion(o); + p.v = p.p = 0; + } + else + { + // The operation has been returned to the main io_service. The completion + // handler is ready to be delivered. + + // Make a copy of the handler so that the memory can be deallocated + // before the upcall is made. Even if we're not about to make an upcall, + // a sub-object of the handler may be the true owner of the memory + // associated with the handler. Consequently, a local copy of the handler + // is required to ensure that any owning sub-object remains valid until + // after we have deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, iterator_type> + handler(o->handler_, o->ec_, o->iter_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + } + +private: + socket_ops::weak_cancel_token_type cancel_token_; + endpoint_type endpoint_; + io_service_impl& io_service_impl_; + Handler handler_; + boost::system::error_code ec_; + iterator_type iter_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_RESOLVER_ENDPOINT_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/resolve_op.hpp b/boost_1_45_0/boost/asio/detail/resolve_op.hpp new file mode 100644 index 0000000..aff6104 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/resolve_op.hpp
@@ -0,0 +1,128 @@ +// +// detail/resolve_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_RESOLVE_OP_HPP +#define BOOST_ASIO_DETAIL_RESOLVE_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/ip/basic_resolver_iterator.hpp> +#include <boost/asio/ip/basic_resolver_query.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Protocol, typename Handler> +class resolve_op : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(resolve_op); + + typedef boost::asio::ip::basic_resolver_query<Protocol> query_type; + typedef boost::asio::ip::basic_resolver_iterator<Protocol> iterator_type; + + resolve_op(socket_ops::weak_cancel_token_type cancel_token, + const query_type& query, io_service_impl& ios, Handler handler) + : operation(&resolve_op::do_complete), + cancel_token_(cancel_token), + query_(query), + io_service_impl_(ios), + handler_(handler), + addrinfo_(0) + { + } + + ~resolve_op() + { + if (addrinfo_) + socket_ops::freeaddrinfo(addrinfo_); + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the operation object. + resolve_op* o(static_cast<resolve_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + if (owner && owner != &o->io_service_impl_) + { + // The operation is being run on the worker io_service. Time to perform + // the resolver operation. + + // Perform the blocking host resolution operation. + socket_ops::background_getaddrinfo(o->cancel_token_, + o->query_.host_name().c_str(), o->query_.service_name().c_str(), + o->query_.hints(), &o->addrinfo_, o->ec_); + + // Pass operation back to main io_service for completion. + o->io_service_impl_.post_deferred_completion(o); + p.v = p.p = 0; + } + else + { + // The operation has been returned to the main io_service. The completion + // handler is ready to be delivered. + + // Make a copy of the handler so that the memory can be deallocated + // before the upcall is made. Even if we're not about to make an upcall, + // a sub-object of the handler may be the true owner of the memory + // associated with the handler. Consequently, a local copy of the handler + // is required to ensure that any owning sub-object remains valid until + // after we have deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, iterator_type> + handler(o->handler_, o->ec_, iterator_type()); + p.h = boost::addressof(handler.handler_); + if (o->addrinfo_) + { + handler.arg2_ = iterator_type::create(o->addrinfo_, + o->query_.host_name(), o->query_.service_name()); + } + p.reset(); + + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + } + +private: + socket_ops::weak_cancel_token_type cancel_token_; + query_type query_; + io_service_impl& io_service_impl_; + Handler handler_; + boost::system::error_code ec_; + boost::asio::detail::addrinfo_type* addrinfo_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_RESOLVE_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/resolver_service.hpp b/boost_1_45_0/boost/asio/detail/resolver_service.hpp new file mode 100644 index 0000000..1b734a0 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/resolver_service.hpp
@@ -0,0 +1,121 @@ +// +// detail/resolver_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_RESOLVER_SERVICE_HPP +#define BOOST_ASIO_DETAIL_RESOLVER_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/ip/basic_resolver_iterator.hpp> +#include <boost/asio/ip/basic_resolver_query.hpp> +#include <boost/asio/detail/resolve_endpoint_op.hpp> +#include <boost/asio/detail/resolve_op.hpp> +#include <boost/asio/detail/resolver_service_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Protocol> +class resolver_service : public resolver_service_base +{ +public: + // The implementation type of the resolver. A cancellation token is used to + // indicate to the background thread that the operation has been cancelled. + typedef socket_ops::shared_cancel_token_type implementation_type; + + // The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + // The query type. + typedef boost::asio::ip::basic_resolver_query<Protocol> query_type; + + // The iterator type. + typedef boost::asio::ip::basic_resolver_iterator<Protocol> iterator_type; + + // Constructor. + resolver_service(boost::asio::io_service& io_service) + : resolver_service_base(io_service) + { + } + + // Resolve a query to a list of entries. + iterator_type resolve(implementation_type&, const query_type& query, + boost::system::error_code& ec) + { + boost::asio::detail::addrinfo_type* address_info = 0; + + socket_ops::getaddrinfo(query.host_name().c_str(), + query.service_name().c_str(), query.hints(), &address_info, ec); + auto_addrinfo auto_address_info(address_info); + + return ec ? iterator_type() : iterator_type::create( + address_info, query.host_name(), query.service_name()); + } + + // Asynchronously resolve a query to a list of entries. + template <typename Handler> + void async_resolve(implementation_type& impl, const query_type& query, + Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef resolve_op<Protocol, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl, query, io_service_impl_, handler); + + start_resolve_op(p.p); + p.v = p.p = 0; + } + + // Resolve an endpoint to a list of entries. + iterator_type resolve(implementation_type&, + const endpoint_type& endpoint, boost::system::error_code& ec) + { + char host_name[NI_MAXHOST]; + char service_name[NI_MAXSERV]; + socket_ops::sync_getnameinfo(endpoint.data(), endpoint.size(), + host_name, NI_MAXHOST, service_name, NI_MAXSERV, + endpoint.protocol().type(), ec); + + return ec ? iterator_type() : iterator_type::create( + endpoint, host_name, service_name); + } + + // Asynchronously resolve an endpoint to a list of entries. + template <typename Handler> + void async_resolve(implementation_type& impl, const endpoint_type& endpoint, + Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef resolve_endpoint_op<Protocol, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(impl, endpoint, io_service_impl_, handler); + + start_resolve_op(p.p); + p.v = p.p = 0; + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_RESOLVER_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/resolver_service_base.hpp b/boost_1_45_0/boost/asio/detail/resolver_service_base.hpp new file mode 100644 index 0000000..cc6ede6 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/resolver_service_base.hpp
@@ -0,0 +1,125 @@ +// +// detail/resolver_service_base.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP +#define BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/operation.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/thread.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class resolver_service_base +{ +public: + // The implementation type of the resolver. A cancellation token is used to + // indicate to the background thread that the operation has been cancelled. + typedef socket_ops::shared_cancel_token_type implementation_type; + + // Constructor. + BOOST_ASIO_DECL resolver_service_base(boost::asio::io_service& io_service); + + // Destructor. + BOOST_ASIO_DECL ~resolver_service_base(); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new resolver implementation. + BOOST_ASIO_DECL void construct(implementation_type& impl); + + // Destroy a resolver implementation. + BOOST_ASIO_DECL void destroy(implementation_type&); + + // Cancel pending asynchronous operations. + BOOST_ASIO_DECL void cancel(implementation_type& impl); + +protected: + // Helper function to start an asynchronous resolve operation. + BOOST_ASIO_DECL void start_resolve_op(operation* op); + + // Helper class to perform exception-safe cleanup of addrinfo objects. + class auto_addrinfo + : private boost::asio::detail::noncopyable + { + public: + explicit auto_addrinfo(boost::asio::detail::addrinfo_type* ai) + : ai_(ai) + { + } + + ~auto_addrinfo() + { + if (ai_) + socket_ops::freeaddrinfo(ai_); + } + + operator boost::asio::detail::addrinfo_type*() + { + return ai_; + } + + private: + boost::asio::detail::addrinfo_type* ai_; + }; + + // Helper class to run the work io_service in a thread. + class work_io_service_runner; + + // Start the work thread if it's not already running. + BOOST_ASIO_DECL void start_work_thread(); + + // The io_service implementation used to post completions. + io_service_impl& io_service_impl_; + +private: + // Mutex to protect access to internal data. + boost::asio::detail::mutex mutex_; + + // Private io_service used for performing asynchronous host resolution. + boost::scoped_ptr<boost::asio::io_service> work_io_service_; + + // The work io_service implementation used to post completions. + io_service_impl& work_io_service_impl_; + + // Work for the private io_service to perform. + boost::scoped_ptr<boost::asio::io_service::work> work_; + + // Thread used for running the work io_service's run loop. + boost::scoped_ptr<boost::asio::detail::thread> work_thread_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/resolver_service_base.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_RESOLVER_SERVICE_BASE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/scoped_lock.hpp b/boost_1_45_0/boost/asio/detail/scoped_lock.hpp new file mode 100644 index 0000000..247411e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/scoped_lock.hpp
@@ -0,0 +1,93 @@ +// +// detail/scoped_lock.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP +#define BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/noncopyable.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Helper class to lock and unlock a mutex automatically. +template <typename Mutex> +class scoped_lock + : private noncopyable +{ +public: + // Constructor acquires the lock. + scoped_lock(Mutex& m) + : mutex_(m) + { + mutex_.lock(); + locked_ = true; + } + + // Destructor releases the lock. + ~scoped_lock() + { + if (locked_) + mutex_.unlock(); + } + + // Explicitly acquire the lock. + void lock() + { + if (!locked_) + { + mutex_.lock(); + locked_ = true; + } + } + + // Explicitly release the lock. + void unlock() + { + if (locked_) + { + mutex_.unlock(); + locked_ = false; + } + } + + // Test whether the lock is held. + bool locked() const + { + return locked_; + } + + // Get the underlying mutex. + Mutex& mutex() + { + return mutex_; + } + +private: + // The underlying mutex. + Mutex& mutex_; + + // Whether the mutex is currently locked or unlocked. + bool locked_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_SCOPED_LOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/select_interrupter.hpp b/boost_1_45_0/boost/asio/detail/select_interrupter.hpp new file mode 100644 index 0000000..9683e63 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/select_interrupter.hpp
@@ -0,0 +1,44 @@ +// +// detail/select_interrupter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SELECT_INTERRUPTER_HPP +#define BOOST_ASIO_DETAIL_SELECT_INTERRUPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) +# include <boost/asio/detail/socket_select_interrupter.hpp> +#elif defined(BOOST_ASIO_HAS_EVENTFD) +# include <boost/asio/detail/eventfd_select_interrupter.hpp> +#else +# include <boost/asio/detail/pipe_select_interrupter.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) +typedef socket_select_interrupter select_interrupter; +#elif defined(BOOST_ASIO_HAS_EVENTFD) +typedef eventfd_select_interrupter select_interrupter; +#else +typedef pipe_select_interrupter select_interrupter; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_SELECT_INTERRUPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/select_reactor.hpp b/boost_1_45_0/boost/asio/detail/select_reactor.hpp new file mode 100644 index 0000000..55a819d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/select_reactor.hpp
@@ -0,0 +1,196 @@ +// +// detail/select_reactor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP +#define BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) \ + || (!defined(BOOST_ASIO_HAS_DEV_POLL) \ + && !defined(BOOST_ASIO_HAS_EPOLL) \ + && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#include <cstddef> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/reactor_op_queue.hpp> +#include <boost/asio/detail/select_interrupter.hpp> +#include <boost/asio/detail/select_reactor_fwd.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/detail/timer_queue_fwd.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> +#include <boost/asio/io_service.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/thread.hpp> +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class select_reactor + : public boost::asio::detail::service_base<select_reactor> +{ +public: +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + enum { read_op = 0, write_op = 1, except_op = 2, + max_select_ops = 3, connect_op = 3, max_ops = 4 }; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + enum { read_op = 0, write_op = 1, except_op = 2, + max_select_ops = 3, connect_op = 1, max_ops = 3 }; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + + // Per-descriptor data. + struct per_descriptor_data + { + }; + + // Constructor. + BOOST_ASIO_DECL select_reactor(boost::asio::io_service& io_service); + + // Destructor. + BOOST_ASIO_DECL ~select_reactor(); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task, but only if the reactor is not in its own thread. + BOOST_ASIO_DECL void init_task(); + + // Register a socket with the reactor. Returns 0 on success, system error + // code on failure. + BOOST_ASIO_DECL int register_descriptor(socket_type, per_descriptor_data&); + + // Post a reactor operation for immediate completion. + void post_immediate_completion(reactor_op* op) + { + io_service_.post_immediate_completion(op); + } + + // Start a new operation. The reactor operation will be performed when the + // given descriptor is flagged as ready, or an error has occurred. + BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor, + per_descriptor_data&, reactor_op* op, bool); + + // Cancel all operations associated with the given descriptor. The + // handlers associated with the descriptor will be invoked with the + // operation_aborted error. + BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, per_descriptor_data&); + + // Cancel any operations that are running against the descriptor and remove + // its registration from the reactor. + BOOST_ASIO_DECL void close_descriptor(socket_type descriptor, + per_descriptor_data&); + + // Add a new timer queue to the reactor. + template <typename Time_Traits> + void add_timer_queue(timer_queue<Time_Traits>& queue); + + // Remove a timer queue from the reactor. + template <typename Time_Traits> + void remove_timer_queue(timer_queue<Time_Traits>& queue); + + // Schedule a new operation in the given timer queue to expire at the + // specified absolute time. + template <typename Time_Traits> + void schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op); + + // Cancel the timer operations associated with the given token. Returns the + // number of operations that have been posted or dispatched. + template <typename Time_Traits> + std::size_t cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer); + + // Run select once until interrupted or events are ready to be dispatched. + BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops); + + // Interrupt the select loop. + BOOST_ASIO_DECL void interrupt(); + +private: +#if defined(BOOST_ASIO_HAS_IOCP) + // Run the select loop in the thread. + BOOST_ASIO_DECL void run_thread(); + + // Entry point for the select loop thread. + BOOST_ASIO_DECL static void call_run_thread(select_reactor* reactor); +#endif // defined(BOOST_ASIO_HAS_IOCP) + + // Helper function to add a new timer queue. + BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); + + // Helper function to remove a timer queue. + BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); + + // Get the timeout value for the select call. + BOOST_ASIO_DECL timeval* get_timeout(timeval& tv); + + // Cancel all operations associated with the given descriptor. This function + // does not acquire the select_reactor's mutex. + BOOST_ASIO_DECL void cancel_ops_unlocked(socket_type descriptor, + const boost::system::error_code& ec); + + // The io_service implementation used to post completions. + io_service_impl& io_service_; + + // Mutex to protect access to internal data. + boost::asio::detail::mutex mutex_; + + // The interrupter is used to break a blocking select call. + select_interrupter interrupter_; + + // The queues of read, write and except operations. + reactor_op_queue<socket_type> op_queue_[max_ops]; + + // The timer queues. + timer_queue_set timer_queues_; + +#if defined(BOOST_ASIO_HAS_IOCP) + // Does the reactor loop thread need to stop. + bool stop_thread_; + + // The thread that is running the reactor loop. + boost::asio::detail::thread* thread_; +#endif // defined(BOOST_ASIO_HAS_IOCP) + + // Whether the service has been shut down. + bool shutdown_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/select_reactor.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/select_reactor.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_IOCP) + // || (!defined(BOOST_ASIO_HAS_DEV_POLL) + // && !defined(BOOST_ASIO_HAS_EPOLL) + // && !defined(BOOST_ASIO_HAS_KQUEUE)) + +#endif // BOOST_ASIO_DETAIL_SELECT_REACTOR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/select_reactor_fwd.hpp b/boost_1_45_0/boost/asio/detail/select_reactor_fwd.hpp new file mode 100644 index 0000000..f4f9f65 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/select_reactor_fwd.hpp
@@ -0,0 +1,28 @@ +// +// detail/select_reactor_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SELECT_REACTOR_FWD_HPP +#define BOOST_ASIO_DETAIL_SELECT_REACTOR_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { +namespace detail { + +class select_reactor; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_SELECT_REACTOR_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/service_registry.hpp b/boost_1_45_0/boost/asio/detail/service_registry.hpp new file mode 100644 index 0000000..6ba30f1 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/service_registry.hpp
@@ -0,0 +1,154 @@ +// +// detail/service_registry.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SERVICE_REGISTRY_HPP +#define BOOST_ASIO_DETAIL_SERVICE_REGISTRY_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <typeinfo> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/io_service.hpp> + +#if defined(BOOST_NO_TYPEID) +# if !defined(BOOST_ASIO_NO_TYPEID) +# define BOOST_ASIO_NO_TYPEID +# endif // !defined(BOOST_ASIO_NO_TYPEID) +#endif // defined(BOOST_NO_TYPEID) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility push (default) +# endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +#endif // defined(__GNUC__) + +template <typename T> +class typeid_wrapper {}; + +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility pop +# endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +#endif // defined(__GNUC__) + +class service_registry + : private noncopyable +{ +public: + // Constructor. + BOOST_ASIO_DECL service_registry(boost::asio::io_service& o); + + // Destructor. + BOOST_ASIO_DECL ~service_registry(); + + // Get the service object corresponding to the specified service type. Will + // create a new service object automatically if no such object already + // exists. Ownership of the service object is not transferred to the caller. + template <typename Service> + Service& use_service(); + + // Add a service object. Throws on error, in which case ownership of the + // object is retained by the caller. + template <typename Service> + void add_service(Service* new_service); + + // Check whether a service object of the specified type already exists. + template <typename Service> + bool has_service() const; + +private: + // Initialise a service's key based on its id. + BOOST_ASIO_DECL static void init_key( + boost::asio::io_service::service::key& key, + const boost::asio::io_service::id& id); + +#if !defined(BOOST_ASIO_NO_TYPEID) + // Initialise a service's key based on its id. + template <typename Service> + static void init_key(boost::asio::io_service::service::key& key, + const boost::asio::detail::service_id<Service>& /*id*/); +#endif // !defined(BOOST_ASIO_NO_TYPEID) + + // Check if a service matches the given id. + BOOST_ASIO_DECL static bool keys_match( + const boost::asio::io_service::service::key& key1, + const boost::asio::io_service::service::key& key2); + + // The type of a factory function used for creating a service instance. + typedef boost::asio::io_service::service* + (*factory_type)(boost::asio::io_service&); + + // Factory function for creating a service instance. + template <typename Service> + static boost::asio::io_service::service* create( + boost::asio::io_service& owner); + + // Destroy a service instance. + BOOST_ASIO_DECL static void destroy( + boost::asio::io_service::service* service); + + // Helper class to manage service pointers. + struct auto_service_ptr; + friend struct auto_service_ptr; + struct auto_service_ptr + { + boost::asio::io_service::service* ptr_; + ~auto_service_ptr() { destroy(ptr_); } + }; + + // Get the service object corresponding to the specified service key. Will + // create a new service object automatically if no such object already + // exists. Ownership of the service object is not transferred to the caller. + BOOST_ASIO_DECL boost::asio::io_service::service* do_use_service( + const boost::asio::io_service::service::key& key, + factory_type factory); + + // Add a service object. Returns false on error, in which case ownership of + // the object is retained by the caller. + BOOST_ASIO_DECL void do_add_service( + const boost::asio::io_service::service::key& key, + boost::asio::io_service::service* new_service); + + // Check whether a service object with the specified key already exists. + BOOST_ASIO_DECL bool do_has_service( + const boost::asio::io_service::service::key& key) const; + + // Mutex to protect access to internal data. + mutable boost::asio::detail::mutex mutex_; + + // The owner of this service registry and the services it contains. + boost::asio::io_service& owner_; + + // The first service in the list of contained services. + boost::asio::io_service::service* first_service_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/service_registry.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/service_registry.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_SERVICE_REGISTRY_HPP
diff --git a/boost_1_45_0/boost/asio/detail/service_registry_fwd.hpp b/boost_1_45_0/boost/asio/detail/service_registry_fwd.hpp new file mode 100644 index 0000000..8713a30 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/service_registry_fwd.hpp
@@ -0,0 +1,28 @@ +// +// detail/service_registry_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SERVICE_REGISTRY_FWD_HPP +#define BOOST_ASIO_DETAIL_SERVICE_REGISTRY_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { +namespace detail { + +class service_registry; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_SERVICE_REGISTRY_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/shared_ptr.hpp b/boost_1_45_0/boost/asio/detail/shared_ptr.hpp new file mode 100644 index 0000000..0c5586e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/shared_ptr.hpp
@@ -0,0 +1,40 @@ +// +// detail/shared_ptr.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SHARED_PTR_HPP +#define BOOST_ASIO_DETAIL_SHARED_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +# include <memory> +#else +# include <boost/shared_ptr.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +using std::shared_ptr; +#else +using boost::shared_ptr; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_SHARED_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/signal_blocker.hpp b/boost_1_45_0/boost/asio/detail/signal_blocker.hpp new file mode 100644 index 0000000..67eaac0 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/signal_blocker.hpp
@@ -0,0 +1,44 @@ +// +// detail/signal_blocker.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SIGNAL_BLOCKER_HPP +#define BOOST_ASIO_DETAIL_SIGNAL_BLOCKER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) \ + || defined(BOOST_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) +# include <boost/asio/detail/null_signal_blocker.hpp> +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/asio/detail/posix_signal_blocker.hpp> +#else +# error Only Windows and POSIX are supported! +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) \ + || defined(BOOST_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__) +typedef null_signal_blocker signal_blocker; +#elif defined(BOOST_HAS_PTHREADS) +typedef posix_signal_blocker signal_blocker; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_SIGNAL_BLOCKER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/signal_init.hpp b/boost_1_45_0/boost/asio/detail/signal_init.hpp new file mode 100644 index 0000000..76d21bf --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/signal_init.hpp
@@ -0,0 +1,49 @@ +// +// detail/signal_init.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP +#define BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#include <csignal> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <int Signal = SIGPIPE> +class signal_init +{ +public: + // Constructor. + signal_init() + { + std::signal(Signal, SIG_IGN); + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/socket_holder.hpp b/boost_1_45_0/boost/asio/detail/socket_holder.hpp new file mode 100644 index 0000000..7815acc --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/socket_holder.hpp
@@ -0,0 +1,100 @@ +// +// detail/socket_holder.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_HOLDER_HPP +#define BOOST_ASIO_DETAIL_SOCKET_HOLDER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/socket_ops.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Implement the resource acquisition is initialisation idiom for sockets. +class socket_holder + : private noncopyable +{ +public: + // Construct as an uninitialised socket. + socket_holder() + : socket_(invalid_socket) + { + } + + // Construct to take ownership of the specified socket. + explicit socket_holder(socket_type s) + : socket_(s) + { + } + + // Destructor. + ~socket_holder() + { + if (socket_ != invalid_socket) + { + boost::system::error_code ec; + socket_ops::state_type state = 0; + socket_ops::close(socket_, state, true, ec); + } + } + + // Get the underlying socket. + socket_type get() const + { + return socket_; + } + + // Reset to an uninitialised socket. + void reset() + { + if (socket_ != invalid_socket) + { + boost::system::error_code ec; + socket_ops::state_type state = 0; + socket_ops::close(socket_, state, true, ec); + socket_ = invalid_socket; + } + } + + // Reset to take ownership of the specified socket. + void reset(socket_type s) + { + reset(); + socket_ = s; + } + + // Release ownership of the socket. + socket_type release() + { + socket_type tmp = socket_; + socket_ = invalid_socket; + return tmp; + } + +private: + // The underlying socket. + socket_type socket_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_SOCKET_HOLDER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/socket_ops.hpp b/boost_1_45_0/boost/asio/detail/socket_ops.hpp new file mode 100644 index 0000000..a32b4cc --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/socket_ops.hpp
@@ -0,0 +1,291 @@ +// +// detail/socket_ops.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_OPS_HPP +#define BOOST_ASIO_DETAIL_SOCKET_OPS_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#include <boost/system/error_code.hpp> +#include <boost/asio/detail/shared_ptr.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/weak_ptr.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace socket_ops { + +// Socket state bits. +enum +{ + // The user wants a non-blocking socket. + user_set_non_blocking = 1, + + // The socket has been set non-blocking. + internal_non_blocking = 2, + + // Helper "state" used to determine whether the socket is non-blocking. + non_blocking = user_set_non_blocking | internal_non_blocking, + + // User wants connection_aborted errors, which are disabled by default. + enable_connection_aborted = 4, + + // The user set the linger option. Needs to be checked when closing. + user_set_linger = 8, + + // The socket is stream-oriented. + stream_oriented = 16, + + // The socket is datagram-oriented. + datagram_oriented = 32 +}; + +typedef unsigned char state_type; + +struct noop_deleter { void operator()(void*) {} }; +typedef shared_ptr<void> shared_cancel_token_type; +typedef weak_ptr<void> weak_cancel_token_type; + +BOOST_ASIO_DECL socket_type accept(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL socket_type sync_accept(socket_type s, + state_type state, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec); + +#if defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL void complete_iocp_accept(socket_type s, + void* output_buffer, DWORD address_length, + socket_addr_type* addr, std::size_t* addrlen, + socket_type new_socket, boost::system::error_code& ec); + +#else // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL bool non_blocking_accept(socket_type s, + state_type state, socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec, socket_type& new_socket); + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL int bind(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL int close(socket_type s, state_type& state, + bool destruction, boost::system::error_code& ec); + +BOOST_ASIO_DECL bool set_internal_non_blocking(socket_type s, + state_type& state, boost::system::error_code& ec); + +BOOST_ASIO_DECL int shutdown(socket_type s, + int what, boost::system::error_code& ec); + +BOOST_ASIO_DECL int connect(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL void sync_connect(socket_type s, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL bool non_blocking_connect( + socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL int socketpair(int af, int type, int protocol, + socket_type sv[2], boost::system::error_code& ec); + +BOOST_ASIO_DECL bool sockatmark(socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL size_t available(socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL int listen(socket_type s, + int backlog, boost::system::error_code& ec); + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef WSABUF buf; +#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef iovec buf; +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +BOOST_ASIO_DECL void init_buf(buf& b, void* data, size_t size); + +BOOST_ASIO_DECL void init_buf(buf& b, const void* data, size_t size); + +BOOST_ASIO_DECL int recv(socket_type s, buf* bufs, size_t count, int flags, + boost::system::error_code& ec); + +BOOST_ASIO_DECL size_t sync_recv(socket_type s, state_type state, buf* bufs, + size_t count, int flags, bool all_empty, boost::system::error_code& ec); + +#if defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL void complete_iocp_recv(state_type state, + const weak_cancel_token_type& cancel_token, bool all_empty, + boost::system::error_code& ec, size_t bytes_transferred); + +#else // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL bool non_blocking_recv(socket_type s, + buf* bufs, size_t count, int flags, bool is_stream, + boost::system::error_code& ec, size_t& bytes_transferred); + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL int recvfrom(socket_type s, buf* bufs, size_t count, int flags, + socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec); + +BOOST_ASIO_DECL size_t sync_recvfrom(socket_type s, state_type state, + buf* bufs, size_t count, int flags, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec); + +#if defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL void complete_iocp_recvfrom( + const weak_cancel_token_type& cancel_token, + boost::system::error_code& ec); + +#else // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL bool non_blocking_recvfrom(socket_type s, + buf* bufs, size_t count, int flags, + socket_addr_type* addr, std::size_t* addrlen, + boost::system::error_code& ec, size_t& bytes_transferred); + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL int send(socket_type s, const buf* bufs, + size_t count, int flags, boost::system::error_code& ec); + +BOOST_ASIO_DECL size_t sync_send(socket_type s, state_type state, + const buf* bufs, size_t count, int flags, + bool all_empty, boost::system::error_code& ec); + +#if defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL void complete_iocp_send( + const weak_cancel_token_type& cancel_token, + boost::system::error_code& ec); + +#else // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL bool non_blocking_send(socket_type s, + const buf* bufs, size_t count, int flags, + boost::system::error_code& ec, size_t& bytes_transferred); + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL int sendto(socket_type s, const buf* bufs, size_t count, + int flags, const socket_addr_type* addr, std::size_t addrlen, + boost::system::error_code& ec); + +BOOST_ASIO_DECL size_t sync_sendto(socket_type s, state_type state, + const buf* bufs, size_t count, int flags, const socket_addr_type* addr, + std::size_t addrlen, boost::system::error_code& ec); + +#if !defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL bool non_blocking_sendto(socket_type s, + const buf* bufs, size_t count, int flags, + const socket_addr_type* addr, std::size_t addrlen, + boost::system::error_code& ec, size_t& bytes_transferred); + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +BOOST_ASIO_DECL socket_type socket(int af, int type, int protocol, + boost::system::error_code& ec); + +BOOST_ASIO_DECL int setsockopt(socket_type s, state_type& state, + int level, int optname, const void* optval, + std::size_t optlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL int getsockopt(socket_type s, state_type state, + int level, int optname, void* optval, + size_t* optlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL int getpeername(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, bool cached, boost::system::error_code& ec); + +BOOST_ASIO_DECL int getsockname(socket_type s, socket_addr_type* addr, + std::size_t* addrlen, boost::system::error_code& ec); + +BOOST_ASIO_DECL int ioctl(socket_type s, state_type& state, + int cmd, ioctl_arg_type* arg, boost::system::error_code& ec); + +BOOST_ASIO_DECL int select(int nfds, fd_set* readfds, fd_set* writefds, + fd_set* exceptfds, timeval* timeout, boost::system::error_code& ec); + +BOOST_ASIO_DECL int poll_read(socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL int poll_write(socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL int poll_connect(socket_type s, boost::system::error_code& ec); + +BOOST_ASIO_DECL const char* inet_ntop(int af, const void* src, char* dest, + size_t length, unsigned long scope_id, boost::system::error_code& ec); + +BOOST_ASIO_DECL int inet_pton(int af, const char* src, void* dest, + unsigned long* scope_id, boost::system::error_code& ec); + +BOOST_ASIO_DECL int gethostname(char* name, + int namelen, boost::system::error_code& ec); + +BOOST_ASIO_DECL boost::system::error_code getaddrinfo(const char* host, + const char* service, const addrinfo_type& hints, + addrinfo_type** result, boost::system::error_code& ec); + +BOOST_ASIO_DECL boost::system::error_code background_getaddrinfo( + const weak_cancel_token_type& cancel_token, const char* host, + const char* service, const addrinfo_type& hints, + addrinfo_type** result, boost::system::error_code& ec); + +BOOST_ASIO_DECL void freeaddrinfo(addrinfo_type* ai); + +BOOST_ASIO_DECL boost::system::error_code getnameinfo( + const socket_addr_type* addr, std::size_t addrlen, + char* host, std::size_t hostlen, char* serv, + std::size_t servlen, int flags, boost::system::error_code& ec); + +BOOST_ASIO_DECL boost::system::error_code sync_getnameinfo( + const socket_addr_type* addr, std::size_t addrlen, + char* host, std::size_t hostlen, char* serv, + std::size_t servlen, int sock_type, boost::system::error_code& ec); + +BOOST_ASIO_DECL boost::system::error_code background_getnameinfo( + const weak_cancel_token_type& cancel_token, + const socket_addr_type* addr, std::size_t addrlen, + char* host, std::size_t hostlen, char* serv, + std::size_t servlen, int sock_type, boost::system::error_code& ec); + +BOOST_ASIO_DECL u_long_type network_to_host_long(u_long_type value); + +BOOST_ASIO_DECL u_long_type host_to_network_long(u_long_type value); + +BOOST_ASIO_DECL u_short_type network_to_host_short(u_short_type value); + +BOOST_ASIO_DECL u_short_type host_to_network_short(u_short_type value); + +} // namespace socket_ops +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/socket_ops.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_SOCKET_OPS_HPP
diff --git a/boost_1_45_0/boost/asio/detail/socket_option.hpp b/boost_1_45_0/boost/asio/detail/socket_option.hpp new file mode 100644 index 0000000..37efa83 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/socket_option.hpp
@@ -0,0 +1,319 @@ +// +// detail/socket_option.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_OPTION_HPP +#define BOOST_ASIO_DETAIL_SOCKET_OPTION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <stdexcept> +#include <boost/config.hpp> +#include <boost/throw_exception.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { +namespace socket_option { + +// Helper template for implementing boolean-based options. +template <int Level, int Name> +class boolean +{ +public: + // Default constructor. + boolean() + : value_(0) + { + } + + // Construct with a specific option value. + explicit boolean(bool v) + : value_(v ? 1 : 0) + { + } + + // Set the current value of the boolean. + boolean& operator=(bool v) + { + value_ = v ? 1 : 0; + return *this; + } + + // Get the current value of the boolean. + bool value() const + { + return !!value_; + } + + // Convert to bool. + operator bool() const + { + return !!value_; + } + + // Test for false. + bool operator!() const + { + return !value_; + } + + // Get the level of the socket option. + template <typename Protocol> + int level(const Protocol&) const + { + return Level; + } + + // Get the name of the socket option. + template <typename Protocol> + int name(const Protocol&) const + { + return Name; + } + + // Get the address of the boolean data. + template <typename Protocol> + int* data(const Protocol&) + { + return &value_; + } + + // Get the address of the boolean data. + template <typename Protocol> + const int* data(const Protocol&) const + { + return &value_; + } + + // Get the size of the boolean data. + template <typename Protocol> + std::size_t size(const Protocol&) const + { + return sizeof(value_); + } + + // Set the size of the boolean data. + template <typename Protocol> + void resize(const Protocol&, std::size_t s) + { + // On some platforms (e.g. Windows Vista), the getsockopt function will + // return the size of a boolean socket option as one byte, even though a + // four byte integer was passed in. + switch (s) + { + case sizeof(char): + value_ = *reinterpret_cast<char*>(&value_) ? 1 : 0; + break; + case sizeof(value_): + break; + default: + { + std::length_error ex("boolean socket option resize"); + boost::throw_exception(ex); + } + } + } + +private: + int value_; +}; + +// Helper template for implementing integer options. +template <int Level, int Name> +class integer +{ +public: + // Default constructor. + integer() + : value_(0) + { + } + + // Construct with a specific option value. + explicit integer(int v) + : value_(v) + { + } + + // Set the value of the int option. + integer& operator=(int v) + { + value_ = v; + return *this; + } + + // Get the current value of the int option. + int value() const + { + return value_; + } + + // Get the level of the socket option. + template <typename Protocol> + int level(const Protocol&) const + { + return Level; + } + + // Get the name of the socket option. + template <typename Protocol> + int name(const Protocol&) const + { + return Name; + } + + // Get the address of the int data. + template <typename Protocol> + int* data(const Protocol&) + { + return &value_; + } + + // Get the address of the int data. + template <typename Protocol> + const int* data(const Protocol&) const + { + return &value_; + } + + // Get the size of the int data. + template <typename Protocol> + std::size_t size(const Protocol&) const + { + return sizeof(value_); + } + + // Set the size of the int data. + template <typename Protocol> + void resize(const Protocol&, std::size_t s) + { + if (s != sizeof(value_)) + { + std::length_error ex("integer socket option resize"); + boost::throw_exception(ex); + } + } + +private: + int value_; +}; + +// Helper template for implementing linger options. +template <int Level, int Name> +class linger +{ +public: + // Default constructor. + linger() + { + value_.l_onoff = 0; + value_.l_linger = 0; + } + + // Construct with specific option values. + linger(bool e, int t) + { + enabled(e); + timeout BOOST_PREVENT_MACRO_SUBSTITUTION(t); + } + + // Set the value for whether linger is enabled. + void enabled(bool value) + { + value_.l_onoff = value ? 1 : 0; + } + + // Get the value for whether linger is enabled. + bool enabled() const + { + return value_.l_onoff != 0; + } + + // Set the value for the linger timeout. + void timeout BOOST_PREVENT_MACRO_SUBSTITUTION(int value) + { +#if defined(WIN32) + value_.l_linger = static_cast<u_short>(value); +#else + value_.l_linger = value; +#endif + } + + // Get the value for the linger timeout. + int timeout BOOST_PREVENT_MACRO_SUBSTITUTION() const + { + return static_cast<int>(value_.l_linger); + } + + // Get the level of the socket option. + template <typename Protocol> + int level(const Protocol&) const + { + return Level; + } + + // Get the name of the socket option. + template <typename Protocol> + int name(const Protocol&) const + { + return Name; + } + + // Get the address of the linger data. + template <typename Protocol> + ::linger* data(const Protocol&) + { + return &value_; + } + + // Get the address of the linger data. + template <typename Protocol> + const ::linger* data(const Protocol&) const + { + return &value_; + } + + // Get the size of the linger data. + template <typename Protocol> + std::size_t size(const Protocol&) const + { + return sizeof(value_); + } + + // Set the size of the int data. + template <typename Protocol> + void resize(const Protocol&, std::size_t s) + { + if (s != sizeof(value_)) + { + std::length_error ex("linger socket option resize"); + boost::throw_exception(ex); + } + } + +private: + ::linger value_; +}; + +} // namespace socket_option +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_SOCKET_OPTION_HPP
diff --git a/boost_1_45_0/boost/asio/detail/socket_select_interrupter.hpp b/boost_1_45_0/boost/asio/detail/socket_select_interrupter.hpp new file mode 100644 index 0000000..b674514 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/socket_select_interrupter.hpp
@@ -0,0 +1,80 @@ +// +// detail/socket_select_interrupter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP +#define BOOST_ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) \ + || defined(__CYGWIN__) \ + || defined(__SYMBIAN32__) + +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class socket_select_interrupter +{ +public: + // Constructor. + BOOST_ASIO_DECL socket_select_interrupter(); + + // Destructor. + BOOST_ASIO_DECL ~socket_select_interrupter(); + + // Interrupt the select call. + BOOST_ASIO_DECL void interrupt(); + + // Reset the select interrupt. Returns true if the call was interrupted. + BOOST_ASIO_DECL bool reset(); + + // Get the read descriptor to be passed to select. + socket_type read_descriptor() const + { + return read_descriptor_; + } + +private: + // The read end of a connection used to interrupt the select call. This file + // descriptor is passed to select such that when it is time to stop, a single + // byte will be written on the other end of the connection and this + // descriptor will become readable. + socket_type read_descriptor_; + + // The write end of a connection used to interrupt the select call. A single + // byte may be written to this to wake up the select which is waiting for the + // other end to become readable. + socket_type write_descriptor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/socket_select_interrupter.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_WINDOWS) + // || defined(__CYGWIN__) + // || defined(__SYMBIAN32__) + +#endif // BOOST_ASIO_DETAIL_SOCKET_SELECT_INTERRUPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/socket_types.hpp b/boost_1_45_0/boost/asio/detail/socket_types.hpp new file mode 100644 index 0000000..616e85a --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/socket_types.hpp
@@ -0,0 +1,176 @@ +// +// detail/socket_types.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP +#define BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +# if defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_) +# error WinSock.h has already been included +# endif // defined(_WINSOCKAPI_) && !defined(_WINSOCK2API_) +# if defined(__BORLANDC__) +# include <stdlib.h> // Needed for __errno +# if !defined(_WSPIAPI_H_) +# define _WSPIAPI_H_ +# define BOOST_ASIO_WSPIAPI_H_DEFINED +# endif // !defined(_WSPIAPI_H_) +# endif // defined(__BORLANDC__) +# include <winsock2.h> +# include <ws2tcpip.h> +# include <mswsock.h> +# if defined(BOOST_ASIO_WSPIAPI_H_DEFINED) +# undef _WSPIAPI_H_ +# undef BOOST_ASIO_WSPIAPI_H_DEFINED +# endif // defined(BOOST_ASIO_WSPIAPI_H_DEFINED) +# if !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS) +# if defined(UNDER_CE) +# pragma comment(lib, "ws2.lib") +# elif defined(_MSC_VER) || defined(__BORLANDC__) +# pragma comment(lib, "ws2_32.lib") +# pragma comment(lib, "mswsock.lib") +# endif // defined(_MSC_VER) || defined(__BORLANDC__) +# endif // !defined(BOOST_ASIO_NO_DEFAULT_LINKED_LIBS) +# include <boost/asio/detail/old_win_sdk_compat.hpp> +#else +# include <sys/ioctl.h> +# if !defined(__SYMBIAN32__) +# include <sys/poll.h> +# endif +# include <sys/types.h> +# include <sys/stat.h> +# include <fcntl.h> +# if defined(__hpux) +# include <sys/time.h> +# endif +# if !defined(__hpux) || defined(__SELECT) +# include <sys/select.h> +# endif +# include <sys/socket.h> +# include <sys/uio.h> +# include <sys/un.h> +# include <netinet/in.h> +# if !defined(__SYMBIAN32__) +# include <netinet/tcp.h> +# endif +# include <arpa/inet.h> +# include <netdb.h> +# include <net/if.h> +# include <limits.h> +# if defined(__sun) +# include <sys/filio.h> +# include <sys/sockio.h> +# endif +#endif + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +typedef SOCKET socket_type; +const SOCKET invalid_socket = INVALID_SOCKET; +const int socket_error_retval = SOCKET_ERROR; +const int max_addr_v4_str_len = 256; +const int max_addr_v6_str_len = 256; +typedef sockaddr socket_addr_type; +typedef in_addr in4_addr_type; +typedef ip_mreq in4_mreq_type; +typedef sockaddr_in sockaddr_in4_type; +# if defined(BOOST_ASIO_HAS_OLD_WIN_SDK) +typedef in6_addr_emulation in6_addr_type; +typedef ipv6_mreq_emulation in6_mreq_type; +typedef sockaddr_in6_emulation sockaddr_in6_type; +typedef sockaddr_storage_emulation sockaddr_storage_type; +typedef addrinfo_emulation addrinfo_type; +# else +typedef in6_addr in6_addr_type; +typedef ipv6_mreq in6_mreq_type; +typedef sockaddr_in6 sockaddr_in6_type; +typedef sockaddr_storage sockaddr_storage_type; +typedef addrinfo addrinfo_type; +# endif +typedef unsigned long ioctl_arg_type; +typedef u_long u_long_type; +typedef u_short u_short_type; +const int shutdown_receive = SD_RECEIVE; +const int shutdown_send = SD_SEND; +const int shutdown_both = SD_BOTH; +const int message_peek = MSG_PEEK; +const int message_out_of_band = MSG_OOB; +const int message_do_not_route = MSG_DONTROUTE; +# if defined (_WIN32_WINNT) +const int max_iov_len = 64; +# else +const int max_iov_len = 16; +# endif +#else +typedef int socket_type; +const int invalid_socket = -1; +const int socket_error_retval = -1; +const int max_addr_v4_str_len = INET_ADDRSTRLEN; +#if defined(INET6_ADDRSTRLEN) +const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE; +#else // defined(INET6_ADDRSTRLEN) +const int max_addr_v6_str_len = 256; +#endif // defined(INET6_ADDRSTRLEN) +typedef sockaddr socket_addr_type; +typedef in_addr in4_addr_type; +# if defined(__hpux) +// HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined. +struct in4_mreq_type +{ + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; +# else +typedef ip_mreq in4_mreq_type; +# endif +typedef sockaddr_in sockaddr_in4_type; +typedef in6_addr in6_addr_type; +typedef ipv6_mreq in6_mreq_type; +typedef sockaddr_in6 sockaddr_in6_type; +typedef sockaddr_storage sockaddr_storage_type; +typedef sockaddr_un sockaddr_un_type; +typedef addrinfo addrinfo_type; +typedef int ioctl_arg_type; +typedef uint32_t u_long_type; +typedef uint16_t u_short_type; +const int shutdown_receive = SHUT_RD; +const int shutdown_send = SHUT_WR; +const int shutdown_both = SHUT_RDWR; +const int message_peek = MSG_PEEK; +const int message_out_of_band = MSG_OOB; +const int message_do_not_route = MSG_DONTROUTE; +# if defined(IOV_MAX) +const int max_iov_len = IOV_MAX; +# else +// POSIX platforms are not required to define IOV_MAX. +const int max_iov_len = 16; +# endif +#endif +const int custom_socket_option_level = 0xA5100000; +const int enable_connection_aborted_option = 1; +const int always_fail_option = 2; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_SOCKET_TYPES_HPP
diff --git a/boost_1_45_0/boost/asio/detail/solaris_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/solaris_fenced_block.hpp new file mode 100644 index 0000000..db6cb98 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/solaris_fenced_block.hpp
@@ -0,0 +1,55 @@ +// +// detail/solaris_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(__sun) + +#include <atomic.h> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class solaris_fenced_block + : private noncopyable +{ +public: + // Constructor. + solaris_fenced_block() + { + membar_consumer(); + } + + // Destructor. + ~solaris_fenced_block() + { + membar_producer(); + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(__sun) + +#endif // BOOST_ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/strand_service.hpp b/boost_1_45_0/boost/asio/detail/strand_service.hpp new file mode 100644 index 0000000..24bec7c --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/strand_service.hpp
@@ -0,0 +1,122 @@ +// +// detail/strand_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_STRAND_SERVICE_HPP +#define BOOST_ASIO_DETAIL_STRAND_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Default service implementation for a strand. +class strand_service + : public boost::asio::detail::service_base<strand_service> +{ +private: + // Helper class to re-post the strand on exit. + struct on_do_complete_exit; + + // Helper class to re-post the strand on exit. + struct on_dispatch_exit; + +public: + + // The underlying implementation of a strand. + class strand_impl + : public operation + { + public: + strand_impl(); + + private: + // Only this service will have access to the internal values. + friend class strand_service; + friend struct on_do_complete_exit; + friend struct on_dispatch_exit; + + // Mutex to protect access to internal data. + boost::asio::detail::mutex mutex_; + + // The count of handlers in the strand, including the upcall (if any). + std::size_t count_; + + // The handlers waiting on the strand. + op_queue<operation> queue_; + }; + + typedef strand_impl* implementation_type; + + // Construct a new strand service for the specified io_service. + BOOST_ASIO_DECL explicit strand_service(boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new strand implementation. + BOOST_ASIO_DECL void construct(implementation_type& impl); + + // Destroy a strand implementation. + void destroy(implementation_type& impl); + + // Request the io_service to invoke the given handler. + template <typename Handler> + void dispatch(implementation_type& impl, Handler handler); + + // Request the io_service to invoke the given handler and return immediately. + template <typename Handler> + void post(implementation_type& impl, Handler handler); + +private: + BOOST_ASIO_DECL static void do_complete(io_service_impl* owner, + operation* base, boost::system::error_code ec, + std::size_t bytes_transferred); + + // The io_service implementation used to post completions. + io_service_impl& io_service_; + + // Mutex to protect access to the array of implementations. + boost::asio::detail::mutex mutex_; + + // Number of implementations shared between all strand objects. + enum { num_implementations = 193 }; + + // The head of a linked list of all implementations. + boost::scoped_ptr<strand_impl> implementations_[num_implementations]; + + // Extra value used when hashing to prevent recycled memory locations from + // getting the same strand implementation. + std::size_t salt_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/strand_service.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/strand_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_STRAND_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/task_io_service.hpp b/boost_1_45_0/boost/asio/detail/task_io_service.hpp new file mode 100644 index 0000000..a9a7053 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/task_io_service.hpp
@@ -0,0 +1,178 @@ +// +// detail/task_io_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_HPP +#define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/detail/atomic_count.hpp> +#include <boost/system/error_code.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/reactor_fwd.hpp> +#include <boost/asio/detail/task_io_service_fwd.hpp> +#include <boost/asio/detail/task_io_service_operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class task_io_service + : public boost::asio::detail::service_base<task_io_service> +{ +public: + typedef task_io_service_operation operation; + + // Constructor. + BOOST_ASIO_DECL task_io_service(boost::asio::io_service& io_service); + + // How many concurrent threads are likely to run the io_service. + BOOST_ASIO_DECL void init(std::size_t concurrency_hint); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task, if required. + BOOST_ASIO_DECL void init_task(); + + // Run the event loop until interrupted or no more work. + BOOST_ASIO_DECL std::size_t run(boost::system::error_code& ec); + + // Run until interrupted or one operation is performed. + BOOST_ASIO_DECL std::size_t run_one(boost::system::error_code& ec); + + // Poll for operations without blocking. + BOOST_ASIO_DECL std::size_t poll(boost::system::error_code& ec); + + // Poll for one operation without blocking. + BOOST_ASIO_DECL std::size_t poll_one(boost::system::error_code& ec); + + // Interrupt the event processing loop. + BOOST_ASIO_DECL void stop(); + + // Reset in preparation for a subsequent run invocation. + BOOST_ASIO_DECL void reset(); + + // Notify that some work has started. + void work_started() + { + ++outstanding_work_; + } + + // Notify that some work has finished. + void work_finished() + { + if (--outstanding_work_ == 0) + stop(); + } + + // Request invocation of the given handler. + template <typename Handler> + void dispatch(Handler handler); + + // Request invocation of the given handler and return immediately. + template <typename Handler> + void post(Handler handler); + + // Request invocation of the given operation and return immediately. Assumes + // that work_started() has not yet been called for the operation. + BOOST_ASIO_DECL void post_immediate_completion(operation* op); + + // Request invocation of the given operation and return immediately. Assumes + // that work_started() was previously called for the operation. + BOOST_ASIO_DECL void post_deferred_completion(operation* op); + + // Request invocation of the given operations and return immediately. Assumes + // that work_started() was previously called for each operation. + BOOST_ASIO_DECL void post_deferred_completions(op_queue<operation>& ops); + +private: + // Structure containing information about an idle thread. + struct idle_thread_info; + + // Run at most one operation. Blocks only if this_idle_thread is non-null. + BOOST_ASIO_DECL std::size_t do_one(mutex::scoped_lock& lock, + idle_thread_info* this_idle_thread); + + // Stop the task and all idle threads. + BOOST_ASIO_DECL void stop_all_threads(mutex::scoped_lock& lock); + + // Wakes a single idle thread and unlocks the mutex. Returns true if an idle + // thread was found. If there is no idle thread, returns false and leaves the + // mutex locked. + BOOST_ASIO_DECL bool wake_one_idle_thread_and_unlock( + mutex::scoped_lock& lock); + + // Wake a single idle thread, or the task, and always unlock the mutex. + BOOST_ASIO_DECL void wake_one_thread_and_unlock( + mutex::scoped_lock& lock); + + // Helper class to perform task-related operations on block exit. + struct task_cleanup; + friend struct task_cleanup; + + // Helper class to call work_finished() on block exit. + struct work_finished_on_block_exit; + + // Mutex to protect access to internal data. + mutex mutex_; + + // The task to be run by this service. + reactor* task_; + + // Operation object to represent the position of the task in the queue. + struct task_operation : operation + { + task_operation() : operation(0) {} + } task_operation_; + + // Whether the task has been interrupted. + bool task_interrupted_; + + // The count of unfinished work. + boost::detail::atomic_count outstanding_work_; + + // The queue of handlers that are ready to be delivered. + op_queue<operation> op_queue_; + + // Flag to indicate that the dispatcher has been stopped. + bool stopped_; + + // Flag to indicate that the dispatcher has been shut down. + bool shutdown_; + + // The threads that are currently idle. + idle_thread_info* first_idle_thread_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/task_io_service.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/task_io_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // !defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/task_io_service_fwd.hpp b/boost_1_45_0/boost/asio/detail/task_io_service_fwd.hpp new file mode 100644 index 0000000..24dd11b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/task_io_service_fwd.hpp
@@ -0,0 +1,28 @@ +// +// detail/task_io_service_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_FWD_HPP +#define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { +namespace detail { + +class task_io_service; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/task_io_service_operation.hpp b/boost_1_45_0/boost/asio/detail/task_io_service_operation.hpp new file mode 100644 index 0000000..e234c07 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/task_io_service_operation.hpp
@@ -0,0 +1,71 @@ +// +// detail/task_io_service_operation.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP +#define BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/system/error_code.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/task_io_service_fwd.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Base class for all operations. A function pointer is used instead of virtual +// functions to avoid the associated overhead. +class task_io_service_operation +{ +public: + void complete(task_io_service& owner) + { + func_(&owner, this, boost::system::error_code(), 0); + } + + void destroy() + { + func_(0, this, boost::system::error_code(), 0); + } + +protected: + typedef void (*func_type)(task_io_service*, + task_io_service_operation*, + boost::system::error_code, std::size_t); + + task_io_service_operation(func_type func) + : next_(0), + func_(func) + { + } + + // Prevents deletion through this type. + ~task_io_service_operation() + { + } + +private: + friend class op_queue_access; + task_io_service_operation* next_; + func_type func_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_TASK_IO_SERVICE_OPERATION_HPP
diff --git a/boost_1_45_0/boost/asio/detail/thread.hpp b/boost_1_45_0/boost/asio/detail/thread.hpp new file mode 100644 index 0000000..8848cd0 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/thread.hpp
@@ -0,0 +1,54 @@ +// +// detail/thread.hpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_THREAD_HPP +#define BOOST_ASIO_DETAIL_THREAD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +# include <boost/asio/detail/null_thread.hpp> +#elif defined(BOOST_WINDOWS) +# if defined(UNDER_CE) +# include <boost/asio/detail/wince_thread.hpp> +# else +# include <boost/asio/detail/win_thread.hpp> +# endif +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/asio/detail/posix_thread.hpp> +#else +# error Only Windows and POSIX are supported! +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +typedef null_thread thread; +#elif defined(BOOST_WINDOWS) +# if defined(UNDER_CE) +typedef wince_thread thread; +# else +typedef win_thread thread; +# endif +#elif defined(BOOST_HAS_PTHREADS) +typedef posix_thread thread; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_THREAD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/throw_error.hpp b/boost_1_45_0/boost/asio/detail/throw_error.hpp new file mode 100644 index 0000000..713a196 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/throw_error.hpp
@@ -0,0 +1,55 @@ +// +// detail/throw_error.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_THROW_ERROR_HPP +#define BOOST_ASIO_DETAIL_THROW_ERROR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/system/error_code.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +BOOST_ASIO_DECL void do_throw_error(const boost::system::error_code& err); + +BOOST_ASIO_DECL void do_throw_error(const boost::system::error_code& err, + const char* location); + +inline void throw_error(const boost::system::error_code& err) +{ + if (err) + do_throw_error(err); +} + +inline void throw_error(const boost::system::error_code& err, + const char* location) +{ + if (err) + do_throw_error(err, location); +} + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/throw_error.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_THROW_ERROR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_op.hpp b/boost_1_45_0/boost/asio/detail/timer_op.hpp new file mode 100644 index 0000000..8f82339 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_op.hpp
@@ -0,0 +1,47 @@ +// +// detail/timer_op.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_OP_HPP +#define BOOST_ASIO_DETAIL_TIMER_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class timer_op + : public operation +{ +public: + // The error code to be passed to the completion handler. + boost::system::error_code ec_; + +protected: + timer_op(func_type func) + : operation(func) + { + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_TIMER_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_queue.hpp b/boost_1_45_0/boost/asio/detail/timer_queue.hpp new file mode 100644 index 0000000..09eb825 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_queue.hpp
@@ -0,0 +1,373 @@ +// +// detail/timer_queue.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_HPP +#define BOOST_ASIO_DETAIL_TIMER_QUEUE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <cstddef> +#include <vector> +#include <boost/config.hpp> +#include <boost/limits.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/time_traits.hpp> + +#include <boost/asio/detail/push_options.hpp> +#include <boost/date_time/posix_time/posix_time_types.hpp> +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +class timer_queue + : public timer_queue_base +{ +public: + // The time type. + typedef typename Time_Traits::time_type time_type; + + // The duration type. + typedef typename Time_Traits::duration_type duration_type; + + // Per-timer data. + class per_timer_data + { + public: + per_timer_data() : next_(0), prev_(0) {} + + private: + friend class timer_queue; + + // The operations waiting on the timer. + op_queue<timer_op> op_queue_; + + // The index of the timer in the heap. + std::size_t heap_index_; + + // Pointers to adjacent timers in a linked list. + per_timer_data* next_; + per_timer_data* prev_; + }; + + // Constructor. + timer_queue() + : timers_(), + heap_() + { + } + + // Add a new timer to the queue. Returns true if this is the timer that is + // earliest in the queue, in which case the reactor's event demultiplexing + // function call may need to be interrupted and restarted. + bool enqueue_timer(const time_type& time, per_timer_data& timer, timer_op* op) + { + // Enqueue the timer object. + if (timer.prev_ == 0 && &timer != timers_) + { + if (this->is_positive_infinity(time)) + { + // No heap entry is required for timers that never expire. + timer.heap_index_ = (std::numeric_limits<std::size_t>::max)(); + } + else + { + // Put the new timer at the correct position in the heap. This is done + // first since push_back() can throw due to allocation failure. + timer.heap_index_ = heap_.size(); + heap_entry entry = { time, &timer }; + heap_.push_back(entry); + up_heap(heap_.size() - 1); + } + + // Insert the new timer into the linked list of active timers. + timer.next_ = timers_; + timer.prev_ = 0; + if (timers_) + timers_->prev_ = &timer; + timers_ = &timer; + } + + // Enqueue the individual timer operation. + timer.op_queue_.push(op); + + // Interrupt reactor only if newly added timer is first to expire. + return timer.heap_index_ == 0 && timer.op_queue_.front() == op; + } + + // Whether there are no timers in the queue. + virtual bool empty() const + { + return timers_ == 0; + } + + // Get the time for the timer that is earliest in the queue. + virtual long wait_duration_msec(long max_duration) const + { + if (heap_.empty()) + return max_duration; + + boost::posix_time::time_duration duration = Time_Traits::to_posix_duration( + Time_Traits::subtract(heap_[0].time_, Time_Traits::now())); + + if (duration > boost::posix_time::milliseconds(max_duration)) + duration = boost::posix_time::milliseconds(max_duration); + else if (duration <= boost::posix_time::milliseconds(0)) + duration = boost::posix_time::milliseconds(0); + else if (duration < boost::posix_time::milliseconds(1)) + duration = boost::posix_time::milliseconds(1); + + return duration.total_milliseconds(); + } + + // Get the time for the timer that is earliest in the queue. + virtual long wait_duration_usec(long max_duration) const + { + if (heap_.empty()) + return max_duration; + + boost::posix_time::time_duration duration = Time_Traits::to_posix_duration( + Time_Traits::subtract(heap_[0].time_, Time_Traits::now())); + + if (duration > boost::posix_time::microseconds(max_duration)) + duration = boost::posix_time::microseconds(max_duration); + else if (duration <= boost::posix_time::microseconds(0)) + duration = boost::posix_time::microseconds(0); + else if (duration < boost::posix_time::microseconds(1)) + duration = boost::posix_time::microseconds(1); + + return duration.total_microseconds(); + } + + // Dequeue all timers not later than the current time. + virtual void get_ready_timers(op_queue<operation>& ops) + { + const time_type now = Time_Traits::now(); + while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_)) + { + per_timer_data* timer = heap_[0].timer_; + ops.push(timer->op_queue_); + remove_timer(*timer); + } + } + + // Dequeue all timers. + virtual void get_all_timers(op_queue<operation>& ops) + { + while (timers_) + { + per_timer_data* timer = timers_; + timers_ = timers_->next_; + ops.push(timer->op_queue_); + timer->next_ = 0; + timer->prev_ = 0; + } + + heap_.clear(); + } + + // Cancel and dequeue the timers with the given token. + std::size_t cancel_timer(per_timer_data& timer, op_queue<operation>& ops) + { + std::size_t num_cancelled = 0; + if (timer.prev_ != 0 || &timer == timers_) + { + while (timer_op* op = timer.op_queue_.front()) + { + op->ec_ = boost::asio::error::operation_aborted; + timer.op_queue_.pop(); + ops.push(op); + ++num_cancelled; + } + remove_timer(timer); + } + return num_cancelled; + } + +private: + // Move the item at the given index up the heap to its correct position. + void up_heap(std::size_t index) + { + std::size_t parent = (index - 1) / 2; + while (index > 0 + && Time_Traits::less_than(heap_[index].time_, heap_[parent].time_)) + { + swap_heap(index, parent); + index = parent; + parent = (index - 1) / 2; + } + } + + // Move the item at the given index down the heap to its correct position. + void down_heap(std::size_t index) + { + std::size_t child = index * 2 + 1; + while (child < heap_.size()) + { + std::size_t min_child = (child + 1 == heap_.size() + || Time_Traits::less_than( + heap_[child].time_, heap_[child + 1].time_)) + ? child : child + 1; + if (Time_Traits::less_than(heap_[index].time_, heap_[min_child].time_)) + break; + swap_heap(index, min_child); + index = min_child; + child = index * 2 + 1; + } + } + + // Swap two entries in the heap. + void swap_heap(std::size_t index1, std::size_t index2) + { + heap_entry tmp = heap_[index1]; + heap_[index1] = heap_[index2]; + heap_[index2] = tmp; + heap_[index1].timer_->heap_index_ = index1; + heap_[index2].timer_->heap_index_ = index2; + } + + // Remove a timer from the heap and list of timers. + void remove_timer(per_timer_data& timer) + { + // Remove the timer from the heap. + std::size_t index = timer.heap_index_; + if (!heap_.empty() && index < heap_.size()) + { + if (index == heap_.size() - 1) + { + heap_.pop_back(); + } + else + { + swap_heap(index, heap_.size() - 1); + heap_.pop_back(); + std::size_t parent = (index - 1) / 2; + if (index > 0 && Time_Traits::less_than( + heap_[index].time_, heap_[parent].time_)) + up_heap(index); + else + down_heap(index); + } + } + + // Remove the timer from the linked list of active timers. + if (timers_ == &timer) + timers_ = timer.next_; + if (timer.prev_) + timer.prev_->next_ = timer.next_; + if (timer.next_) + timer.next_->prev_= timer.prev_; + timer.next_ = 0; + timer.prev_ = 0; + } + + // Determine if the specified absolute time is positive infinity. + template <typename Time_Type> + static bool is_positive_infinity(const Time_Type&) + { + return false; + } + + // Determine if the specified absolute time is positive infinity. + static bool is_positive_infinity(const boost::posix_time::ptime& time) + { + return time == boost::posix_time::pos_infin; + } + + // The head of a linked list of all active timers. + per_timer_data* timers_; + + struct heap_entry + { + // The time when the timer should fire. + time_type time_; + + // The associated timer with enqueued operations. + per_timer_data* timer_; + }; + + // The heap of timers, with the earliest timer at the front. + std::vector<heap_entry> heap_; +}; + +#if !defined(BOOST_ASIO_HEADER_ONLY) + +struct forwarding_posix_time_traits : time_traits<boost::posix_time::ptime> {}; + +// Template specialisation for the commonly used instantation. +template <> +class timer_queue<time_traits<boost::posix_time::ptime> > + : public timer_queue_base +{ +public: + // The time type. + typedef boost::posix_time::ptime time_type; + + // The duration type. + typedef boost::posix_time::time_duration duration_type; + + // Per-timer data. + typedef timer_queue<forwarding_posix_time_traits>::per_timer_data + per_timer_data; + + // Constructor. + BOOST_ASIO_DECL timer_queue(); + + // Destructor. + BOOST_ASIO_DECL virtual ~timer_queue(); + + // Add a new timer to the queue. Returns true if this is the timer that is + // earliest in the queue, in which case the reactor's event demultiplexing + // function call may need to be interrupted and restarted. + BOOST_ASIO_DECL bool enqueue_timer(const time_type& time, + per_timer_data& timer, timer_op* op); + + // Whether there are no timers in the queue. + BOOST_ASIO_DECL virtual bool empty() const; + + // Get the time for the timer that is earliest in the queue. + BOOST_ASIO_DECL virtual long wait_duration_msec(long max_duration) const; + + // Get the time for the timer that is earliest in the queue. + BOOST_ASIO_DECL virtual long wait_duration_usec(long max_duration) const; + + // Dequeue all timers not later than the current time. + BOOST_ASIO_DECL virtual void get_ready_timers(op_queue<operation>& ops); + + // Dequeue all timers. + BOOST_ASIO_DECL virtual void get_all_timers(op_queue<operation>& ops); + + // Cancel and dequeue the timers with the given token. + BOOST_ASIO_DECL std::size_t cancel_timer( + per_timer_data& timer, op_queue<operation>& ops); + +private: + timer_queue<forwarding_posix_time_traits> impl_; +}; + +#endif // !defined(BOOST_ASIO_HEADER_ONLY) + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_queue_base.hpp b/boost_1_45_0/boost/asio/detail/timer_queue_base.hpp new file mode 100644 index 0000000..0290308 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_queue_base.hpp
@@ -0,0 +1,67 @@ +// +// detail/timer_queue_base.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_BASE_HPP +#define BOOST_ASIO_DETAIL_TIMER_QUEUE_BASE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class timer_queue_base + : private noncopyable +{ +public: + // Constructor. + timer_queue_base() : next_(0) {} + + // Destructor. + virtual ~timer_queue_base() {} + + // Whether there are no timers in the queue. + virtual bool empty() const = 0; + + // Get the time to wait until the next timer. + virtual long wait_duration_msec(long max_duration) const = 0; + + // Get the time to wait until the next timer. + virtual long wait_duration_usec(long max_duration) const = 0; + + // Dequeue all ready timers. + virtual void get_ready_timers(op_queue<operation>& ops) = 0; + + // Dequeue all timers. + virtual void get_all_timers(op_queue<operation>& ops) = 0; + +private: + friend class timer_queue_set; + + // Next timer queue in the set. + timer_queue_base* next_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_BASE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_queue_fwd.hpp b/boost_1_45_0/boost/asio/detail/timer_queue_fwd.hpp new file mode 100644 index 0000000..0a62a44 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_queue_fwd.hpp
@@ -0,0 +1,29 @@ +// +// detail/timer_queue_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_FWD_HPP +#define BOOST_ASIO_DETAIL_TIMER_QUEUE_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +namespace boost { +namespace asio { +namespace detail { + +template <typename Time_Traits> +class timer_queue; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_queue_set.hpp b/boost_1_45_0/boost/asio/detail/timer_queue_set.hpp new file mode 100644 index 0000000..c2cea66 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_queue_set.hpp
@@ -0,0 +1,68 @@ +// +// detail/timer_queue_set.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_QUEUE_SET_HPP +#define BOOST_ASIO_DETAIL_TIMER_QUEUE_SET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class timer_queue_set +{ +public: + // Constructor. + BOOST_ASIO_DECL timer_queue_set(); + + // Add a timer queue to the set. + BOOST_ASIO_DECL void insert(timer_queue_base* q); + + // Remove a timer queue from the set. + BOOST_ASIO_DECL void erase(timer_queue_base* q); + + // Determine whether all queues are empty. + BOOST_ASIO_DECL bool all_empty() const; + + // Get the wait duration in milliseconds. + BOOST_ASIO_DECL long wait_duration_msec(long max_duration) const; + + // Get the wait duration in microseconds. + BOOST_ASIO_DECL long wait_duration_usec(long max_duration) const; + + // Dequeue all ready timers. + BOOST_ASIO_DECL void get_ready_timers(op_queue<operation>& ops); + + // Dequeue all timers. + BOOST_ASIO_DECL void get_all_timers(op_queue<operation>& ops); + +private: + timer_queue_base* first_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/timer_queue_set.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // BOOST_ASIO_DETAIL_TIMER_QUEUE_SET_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_scheduler.hpp b/boost_1_45_0/boost/asio/detail/timer_scheduler.hpp new file mode 100644 index 0000000..ec80f40 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_scheduler.hpp
@@ -0,0 +1,33 @@ +// +// detail/timer_scheduler.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_SCHEDULER_HPP +#define BOOST_ASIO_DETAIL_TIMER_SCHEDULER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/timer_scheduler_fwd.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/win_iocp_io_service.hpp> +#elif defined(BOOST_ASIO_HAS_EPOLL) +# include <boost/asio/detail/epoll_reactor.hpp> +#elif defined(BOOST_ASIO_HAS_KQUEUE) +# include <boost/asio/detail/kqueue_reactor.hpp> +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +# include <boost/asio/detail/dev_poll_reactor.hpp> +#else +# include <boost/asio/detail/select_reactor.hpp> +#endif + +#endif // BOOST_ASIO_DETAIL_TIMER_SCHEDULER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/timer_scheduler_fwd.hpp b/boost_1_45_0/boost/asio/detail/timer_scheduler_fwd.hpp new file mode 100644 index 0000000..77d6c99 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/timer_scheduler_fwd.hpp
@@ -0,0 +1,52 @@ +// +// detail/timer_scheduler_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP +#define BOOST_ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) +# include <boost/asio/detail/win_iocp_io_service_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_EPOLL) +# include <boost/asio/detail/epoll_reactor_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_KQUEUE) +# include <boost/asio/detail/kqueue_reactor_fwd.hpp> +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +# include <boost/asio/detail/dev_poll_reactor_fwd.hpp> +#else +# include <boost/asio/detail/select_reactor_fwd.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(BOOST_ASIO_HAS_IOCP) +typedef win_iocp_io_service timer_scheduler; +#elif defined(BOOST_ASIO_HAS_EPOLL) +typedef epoll_reactor timer_scheduler; +#elif defined(BOOST_ASIO_HAS_KQUEUE) +typedef kqueue_reactor timer_scheduler; +#elif defined(BOOST_ASIO_HAS_DEV_POLL) +typedef dev_poll_reactor timer_scheduler; +#else +typedef select_reactor timer_scheduler; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/tss_ptr.hpp b/boost_1_45_0/boost/asio/detail/tss_ptr.hpp new file mode 100644 index 0000000..8edf15b --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/tss_ptr.hpp
@@ -0,0 +1,65 @@ +// +// detail/tss_ptr.hpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_TSS_PTR_HPP +#define BOOST_ASIO_DETAIL_TSS_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) +# include <boost/asio/detail/null_tss_ptr.hpp> +#elif defined(BOOST_WINDOWS) +# include <boost/asio/detail/win_tss_ptr.hpp> +#elif defined(BOOST_HAS_PTHREADS) +# include <boost/asio/detail/posix_tss_ptr.hpp> +#else +# error Only Windows and POSIX are supported! +#endif + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename T> +class tss_ptr +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + : public null_tss_ptr<T> +#elif defined(BOOST_WINDOWS) + : public win_tss_ptr<T> +#elif defined(BOOST_HAS_PTHREADS) + : public posix_tss_ptr<T> +#endif +{ +public: + void operator=(T* value) + { +#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS) + null_tss_ptr<T>::operator=(value); +#elif defined(BOOST_WINDOWS) + win_tss_ptr<T>::operator=(value); +#elif defined(BOOST_HAS_PTHREADS) + posix_tss_ptr<T>::operator=(value); +#endif + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_TSS_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/wait_handler.hpp b/boost_1_45_0/boost/asio/detail/wait_handler.hpp new file mode 100644 index 0000000..e451f19 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/wait_handler.hpp
@@ -0,0 +1,78 @@ +// +// detail/wait_handler.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WAIT_HANDLER_HPP +#define BOOST_ASIO_DETAIL_WAIT_HANDLER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/timer_op.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +class wait_handler : public timer_op +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(wait_handler); + + wait_handler(Handler h) + : timer_op(&wait_handler::do_complete), + handler_(h) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/) + { + // Take ownership of the handler object. + wait_handler* h(static_cast<wait_handler*>(base)); + ptr p = { boost::addressof(h->handler_), h, h }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder1<Handler, boost::system::error_code> + handler(h->handler_, h->ec_); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_DETAIL_WAIT_HANDLER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/weak_ptr.hpp b/boost_1_45_0/boost/asio/detail/weak_ptr.hpp new file mode 100644 index 0000000..9a14297 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/weak_ptr.hpp
@@ -0,0 +1,41 @@ +// +// detail/weak_ptr.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WEAK_PTR_HPP +#define BOOST_ASIO_DETAIL_WEAK_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> +#include <boost/version.hpp> + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +# include <memory> +#else +# include <boost/weak_ptr.hpp> +#endif + +namespace boost { +namespace asio { +namespace detail { + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +using std::weak_ptr; +#else +using boost::weak_ptr; +#endif + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // BOOST_ASIO_DETAIL_WEAK_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_event.hpp b/boost_1_45_0/boost/asio/detail/win_event.hpp new file mode 100644 index 0000000..736ebb2 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_event.hpp
@@ -0,0 +1,98 @@ +// +// detail/win_event.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_EVENT_HPP +#define BOOST_ASIO_DETAIL_WIN_EVENT_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) + +#include <boost/assert.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class win_event + : private noncopyable +{ +public: + // Constructor. + BOOST_ASIO_DECL win_event(); + + // Destructor. + ~win_event() + { + ::CloseHandle(event_); + } + + // Signal the event. + template <typename Lock> + void signal(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + (void)lock; + ::SetEvent(event_); + } + + // Signal the event and unlock the mutex. + template <typename Lock> + void signal_and_unlock(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + lock.unlock(); + ::SetEvent(event_); + } + + // Reset the event. + template <typename Lock> + void clear(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + (void)lock; + ::ResetEvent(event_); + } + + // Wait for the event to become signalled. + template <typename Lock> + void wait(Lock& lock) + { + BOOST_ASSERT(lock.locked()); + lock.unlock(); + ::WaitForSingleObject(event_, INFINITE); + lock.lock(); + } + +private: + HANDLE event_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/win_event.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_WINDOWS) + +#endif // BOOST_ASIO_DETAIL_WIN_EVENT_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_fd_set_adapter.hpp b/boost_1_45_0/boost/asio/detail/win_fd_set_adapter.hpp new file mode 100644 index 0000000..4a5d7fa --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_fd_set_adapter.hpp
@@ -0,0 +1,92 @@ +// +// detail/win_fd_set_adapter.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP +#define BOOST_ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements. +class win_fd_set_adapter +{ +public: + enum { win_fd_set_size = 1024 }; + + win_fd_set_adapter() + : max_descriptor_(invalid_socket) + { + fd_set_.fd_count = 0; + } + + bool set(socket_type descriptor) + { + for (u_int i = 0; i < fd_set_.fd_count; ++i) + if (fd_set_.fd_array[i] == descriptor) + return true; + if (fd_set_.fd_count < win_fd_set_size) + { + fd_set_.fd_array[fd_set_.fd_count++] = descriptor; + return true; + } + return false; + } + + bool is_set(socket_type descriptor) const + { + return !!__WSAFDIsSet(descriptor, + const_cast<fd_set*>(reinterpret_cast<const fd_set*>(&fd_set_))); + } + + operator fd_set*() + { + return reinterpret_cast<fd_set*>(&fd_set_); + } + + socket_type max_descriptor() const + { + return max_descriptor_; + } + +private: + // This structure is defined to be compatible with the Windows API fd_set + // structure, but without being dependent on the value of FD_SETSIZE. + struct win_fd_set + { + u_int fd_count; + SOCKET fd_array[win_fd_set_size]; + }; + + win_fd_set fd_set_; + socket_type max_descriptor_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) + +#endif // BOOST_ASIO_DETAIL_WIN_FD_SET_ADAPTER_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_fenced_block.hpp b/boost_1_45_0/boost/asio/detail/win_fenced_block.hpp new file mode 100644 index 0000000..928395e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_fenced_block.hpp
@@ -0,0 +1,81 @@ +// +// detail/win_fenced_block.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_FENCED_BLOCK_HPP +#define BOOST_ASIO_DETAIL_WIN_FENCED_BLOCK_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_WINDOWS) && !defined(UNDER_CE) + +#include <boost/asio/detail/socket_types.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class win_fenced_block + : private noncopyable +{ +public: + // Constructor. + win_fenced_block() + { +#if defined(__BORLANDC__) + LONG barrier = 0; + ::InterlockedExchange(&barrier, 1); +#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier)) +# if defined(_M_IX86) +# pragma warning(push) +# pragma warning(disable:4793) + LONG barrier; + __asm { xchg barrier, eax } +# pragma warning(pop) +# endif // defined(_M_IX86) +#else + MemoryBarrier(); +#endif + } + + // Destructor. + ~win_fenced_block() + { +#if defined(__BORLANDC__) + LONG barrier = 0; + ::InterlockedExchange(&barrier, 1); +#elif defined(BOOST_MSVC) && ((BOOST_MSVC < 1400) || !defined(MemoryBarrier)) +# if defined(_M_IX86) +# pragma warning(push) +# pragma warning(disable:4793) + LONG barrier; + __asm { xchg barrier, eax } +# pragma warning(pop) +# endif // defined(_M_IX86) +#else + MemoryBarrier(); +#endif + } +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_WINDOWS) && !defined(UNDER_CE) + +#endif // BOOST_ASIO_DETAIL_WIN_FENCED_BLOCK_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_handle_read_op.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_handle_read_op.hpp new file mode 100644 index 0000000..f1a9b1f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_handle_read_op.hpp
@@ -0,0 +1,103 @@ +// +// detail/win_iocp_handle_read_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_READ_OP_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_READ_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/error.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename MutableBufferSequence, typename Handler> +class win_iocp_handle_read_op : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_read_op); + + win_iocp_handle_read_op(const MutableBufferSequence& buffers, Handler handler) + : operation(&win_iocp_handle_read_op::do_complete), + buffers_(buffers), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code ec, std::size_t bytes_transferred) + { + // Take ownership of the operation object. + win_iocp_handle_read_op* o(static_cast<win_iocp_handle_read_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + if (owner) + { + // Check whether buffers are still valid. + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence>::validate(o->buffers_); + } +#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_HANDLE_EOF) + ec = boost::asio::error::eof; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, ec, bytes_transferred); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + MutableBufferSequence buffers_; + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_READ_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_handle_service.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_handle_service.hpp new file mode 100644 index 0000000..291a06f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_handle_service.hpp
@@ -0,0 +1,286 @@ +// +// detail/win_iocp_handle_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/cstdint.hpp> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/operation.hpp> +#include <boost/asio/detail/win_iocp_handle_read_op.hpp> +#include <boost/asio/detail/win_iocp_handle_write_op.hpp> +#include <boost/asio/detail/win_iocp_io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class win_iocp_handle_service +{ +public: + // The native type of a stream handle. + typedef HANDLE native_type; + + // The implementation type of the stream handle. + class implementation_type + { + public: + // Default constructor. + implementation_type() + : handle_(INVALID_HANDLE_VALUE), + safe_cancellation_thread_id_(0), + next_(0), + prev_(0) + { + } + + private: + // Only this service will have access to the internal values. + friend class win_iocp_handle_service; + + // The native stream handle representation. + native_type handle_; + + // The ID of the thread from which it is safe to cancel asynchronous + // operations. 0 means no asynchronous operations have been started yet. + // ~0 means asynchronous operations have been started from more than one + // thread, and cancellation is not supported for the handle. + DWORD safe_cancellation_thread_id_; + + // Pointers to adjacent handle implementations in linked list. + implementation_type* next_; + implementation_type* prev_; + }; + + BOOST_ASIO_DECL win_iocp_handle_service(boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new handle implementation. + BOOST_ASIO_DECL void construct(implementation_type& impl); + + // Destroy a handle implementation. + BOOST_ASIO_DECL void destroy(implementation_type& impl); + + // Assign a native handle to a handle implementation. + BOOST_ASIO_DECL boost::system::error_code assign(implementation_type& impl, + const native_type& native_handle, boost::system::error_code& ec); + + // Determine whether the handle is open. + bool is_open(const implementation_type& impl) const + { + return impl.handle_ != INVALID_HANDLE_VALUE; + } + + // Destroy a handle implementation. + BOOST_ASIO_DECL boost::system::error_code close(implementation_type& impl, + boost::system::error_code& ec); + + // Get the native handle representation. + native_type native(const implementation_type& impl) const + { + return impl.handle_; + } + + // Cancel all operations associated with the handle. + BOOST_ASIO_DECL boost::system::error_code cancel(implementation_type& impl, + boost::system::error_code& ec); + + // Write the given data. Returns the number of bytes written. + template <typename ConstBufferSequence> + size_t write_some(implementation_type& impl, + const ConstBufferSequence& buffers, boost::system::error_code& ec) + { + return write_some_at(impl, 0, buffers, ec); + } + + // Write the given data at the specified offset. Returns the number of bytes + // written. + template <typename ConstBufferSequence> + size_t write_some_at(implementation_type& impl, boost::uint64_t offset, + const ConstBufferSequence& buffers, boost::system::error_code& ec) + { + boost::asio::const_buffer buffer = + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence>::first(buffers); + + return do_write(impl, offset, buffer, ec); + } + + // Start an asynchronous write. The data being written must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_write_some(implementation_type& impl, + const ConstBufferSequence& buffers, Handler handler) + { + async_write_some_at(impl, 0, buffers, handler); + } + + // Start an asynchronous write at a specified offset. The data being written + // must be valid for the lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_write_some_at(implementation_type& impl, boost::uint64_t offset, + const ConstBufferSequence& buffers, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(buffers, handler); + + start_write_op(impl, offset, + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence>::first(buffers), p.p); + p.v = p.p = 0; + } + + // Read some data. Returns the number of bytes received. + template <typename MutableBufferSequence> + size_t read_some(implementation_type& impl, + const MutableBufferSequence& buffers, boost::system::error_code& ec) + { + return read_some_at(impl, 0, buffers, ec); + } + + // Read some data at a specified offset. Returns the number of bytes received. + template <typename MutableBufferSequence> + size_t read_some_at(implementation_type& impl, boost::uint64_t offset, + const MutableBufferSequence& buffers, boost::system::error_code& ec) + { + boost::asio::mutable_buffer buffer = + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence>::first(buffers); + + return do_read(impl, offset, buffer, ec); + } + + // Start an asynchronous read. The buffer for the data being received must be + // valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_read_some(implementation_type& impl, + const MutableBufferSequence& buffers, Handler handler) + { + async_read_some_at(impl, 0, buffers, handler); + } + + // Start an asynchronous read at a specified offset. The buffer for the data + // being received must be valid for the lifetime of the asynchronous + // operation. + template <typename MutableBufferSequence, typename Handler> + void async_read_some_at(implementation_type& impl, boost::uint64_t offset, + const MutableBufferSequence& buffers, Handler handler) + { + // Allocate and construct an operation to wrap the handler. + typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(buffers, handler); + + start_read_op(impl, offset, + buffer_sequence_adapter<boost::asio::mutable_buffer, + MutableBufferSequence>::first(buffers), p.p); + p.v = p.p = 0; + } + +private: + // Prevent the use of the null_buffers type with this service. + size_t write_some(implementation_type& impl, + const null_buffers& buffers, boost::system::error_code& ec); + size_t write_some_at(implementation_type& impl, boost::uint64_t offset, + const null_buffers& buffers, boost::system::error_code& ec); + template <typename Handler> + void async_write_some(implementation_type& impl, + const null_buffers& buffers, Handler handler); + template <typename Handler> + void async_write_some_at(implementation_type& impl, boost::uint64_t offset, + const null_buffers& buffers, Handler handler); + size_t read_some(implementation_type& impl, + const null_buffers& buffers, boost::system::error_code& ec); + size_t read_some_at(implementation_type& impl, boost::uint64_t offset, + const null_buffers& buffers, boost::system::error_code& ec); + template <typename Handler> + void async_read_some(implementation_type& impl, + const null_buffers& buffers, Handler handler); + template <typename Handler> + void async_read_some_at(implementation_type& impl, boost::uint64_t offset, + const null_buffers& buffers, Handler handler); + + // Helper class for waiting for synchronous operations to complete. + class overlapped_wrapper; + + // Helper function to perform a synchronous write operation. + BOOST_ASIO_DECL size_t do_write(implementation_type& impl, + boost::uint64_t offset, const boost::asio::const_buffer& buffer, + boost::system::error_code& ec); + + // Helper function to start a write operation. + BOOST_ASIO_DECL void start_write_op(implementation_type& impl, + boost::uint64_t offset, const boost::asio::const_buffer& buffer, + operation* op); + + // Helper function to perform a synchronous write operation. + BOOST_ASIO_DECL size_t do_read(implementation_type& impl, + boost::uint64_t offset, const boost::asio::mutable_buffer& buffer, + boost::system::error_code& ec); + + // Helper function to start a read operation. + BOOST_ASIO_DECL void start_read_op(implementation_type& impl, + boost::uint64_t offset, const boost::asio::mutable_buffer& buffer, + operation* op); + + // Update the ID of the thread from which cancellation is safe. + BOOST_ASIO_DECL void update_cancellation_thread_id(implementation_type& impl); + + // Helper function to close a handle when the associated object is being + // destroyed. + BOOST_ASIO_DECL void close_for_destruction(implementation_type& impl); + + // The IOCP service used for running asynchronous operations and dispatching + // handlers. + win_iocp_io_service& iocp_service_; + + // Mutex to protect access to the linked list of implementations. + mutex mutex_; + + // The head of a linked list of all implementations. + implementation_type* impl_list_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/win_iocp_handle_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_handle_write_op.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_handle_write_op.hpp new file mode 100644 index 0000000..971f174 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_handle_write_op.hpp
@@ -0,0 +1,99 @@ +// +// detail/win_iocp_handle_write_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_WRITE_OP_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_WRITE_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/error.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename ConstBufferSequence, typename Handler> +class win_iocp_handle_write_op : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_write_op); + + win_iocp_handle_write_op(const ConstBufferSequence& buffers, Handler handler) + : operation(&win_iocp_handle_write_op::do_complete), + buffers_(buffers), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code ec, std::size_t bytes_transferred) + { + // Take ownership of the operation object. + win_iocp_handle_write_op* o(static_cast<win_iocp_handle_write_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + +#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + if (owner) + { + // Check whether buffers are still valid. + buffer_sequence_adapter<boost::asio::const_buffer, + ConstBufferSequence>::validate(o->buffers_); + } +#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, ec, bytes_transferred); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + ConstBufferSequence buffers_; + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_HANDLE_WRITE_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_io_service.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_io_service.hpp new file mode 100644 index 0000000..235424e --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_io_service.hpp
@@ -0,0 +1,267 @@ +// +// detail/win_iocp_io_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/scoped_ptr.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/mutex.hpp> +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/timer_op.hpp> +#include <boost/asio/detail/timer_queue_base.hpp> +#include <boost/asio/detail/timer_queue_fwd.hpp> +#include <boost/asio/detail/timer_queue_set.hpp> +#include <boost/asio/detail/win_iocp_io_service_fwd.hpp> +#include <boost/asio/detail/win_iocp_operation.hpp> +#include <boost/asio/detail/thread.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +class timer_op; + +class win_iocp_io_service + : public boost::asio::detail::service_base<win_iocp_io_service> +{ +public: + // Constructor. + BOOST_ASIO_DECL win_iocp_io_service(boost::asio::io_service& io_service); + + BOOST_ASIO_DECL void init(size_t concurrency_hint); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Initialise the task. Nothing to do here. + void init_task() + { + } + + // Register a handle with the IO completion port. + BOOST_ASIO_DECL boost::system::error_code register_handle( + HANDLE handle, boost::system::error_code& ec); + + // Run the event loop until stopped or no more work. + BOOST_ASIO_DECL size_t run(boost::system::error_code& ec); + + // Run until stopped or one operation is performed. + BOOST_ASIO_DECL size_t run_one(boost::system::error_code& ec); + + // Poll for operations without blocking. + BOOST_ASIO_DECL size_t poll(boost::system::error_code& ec); + + // Poll for one operation without blocking. + BOOST_ASIO_DECL size_t poll_one(boost::system::error_code& ec); + + // Stop the event processing loop. + BOOST_ASIO_DECL void stop(); + + // Reset in preparation for a subsequent run invocation. + void reset() + { + ::InterlockedExchange(&stopped_, 0); + } + + // Notify that some work has started. + void work_started() + { + ::InterlockedIncrement(&outstanding_work_); + } + + // Notify that some work has finished. + void work_finished() + { + if (::InterlockedDecrement(&outstanding_work_) == 0) + stop(); + } + + // Request invocation of the given handler. + template <typename Handler> + void dispatch(Handler handler); + + // Request invocation of the given handler and return immediately. + template <typename Handler> + void post(Handler handler); + + // Request invocation of the given operation and return immediately. Assumes + // that work_started() has not yet been called for the operation. + void post_immediate_completion(win_iocp_operation* op) + { + work_started(); + post_deferred_completion(op); + } + + // Request invocation of the given operation and return immediately. Assumes + // that work_started() was previously called for the operation. + BOOST_ASIO_DECL void post_deferred_completion(win_iocp_operation* op); + + // Request invocation of the given operation and return immediately. Assumes + // that work_started() was previously called for the operations. + BOOST_ASIO_DECL void post_deferred_completions( + op_queue<win_iocp_operation>& ops); + + // Called after starting an overlapped I/O operation that did not complete + // immediately. The caller must have already called work_started() prior to + // starting the operation. + BOOST_ASIO_DECL void on_pending(win_iocp_operation* op); + + // Called after starting an overlapped I/O operation that completed + // immediately. The caller must have already called work_started() prior to + // starting the operation. + BOOST_ASIO_DECL void on_completion(win_iocp_operation* op, + DWORD last_error = 0, DWORD bytes_transferred = 0); + + // Called after starting an overlapped I/O operation that completed + // immediately. The caller must have already called work_started() prior to + // starting the operation. + BOOST_ASIO_DECL void on_completion(win_iocp_operation* op, + const boost::system::error_code& ec, DWORD bytes_transferred = 0); + + // Add a new timer queue to the service. + template <typename Time_Traits> + void add_timer_queue(timer_queue<Time_Traits>& timer_queue); + + // Remove a timer queue from the service. + template <typename Time_Traits> + void remove_timer_queue(timer_queue<Time_Traits>& timer_queue); + + // Schedule a new operation in the given timer queue to expire at the + // specified absolute time. + template <typename Time_Traits> + void schedule_timer(timer_queue<Time_Traits>& queue, + const typename Time_Traits::time_type& time, + typename timer_queue<Time_Traits>::per_timer_data& timer, timer_op* op); + + // Cancel the timer associated with the given token. Returns the number of + // handlers that have been posted or dispatched. + template <typename Time_Traits> + std::size_t cancel_timer(timer_queue<Time_Traits>& queue, + typename timer_queue<Time_Traits>::per_timer_data& timer); + +private: +#if defined(WINVER) && (WINVER < 0x0500) + typedef DWORD dword_ptr_t; + typedef ULONG ulong_ptr_t; +#else // defined(WINVER) && (WINVER < 0x0500) + typedef DWORD_PTR dword_ptr_t; + typedef ULONG_PTR ulong_ptr_t; +#endif // defined(WINVER) && (WINVER < 0x0500) + + // Dequeues at most one operation from the I/O completion port, and then + // executes it. Returns the number of operations that were dequeued (i.e. + // either 0 or 1). + BOOST_ASIO_DECL size_t do_one(bool block, boost::system::error_code& ec); + + // Helper function to add a new timer queue. + BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); + + // Helper function to remove a timer queue. + BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); + + // Called to recalculate and update the timeout. + BOOST_ASIO_DECL void update_timeout(); + + // Helper class to call work_finished() on block exit. + struct work_finished_on_block_exit; + + // Helper class for managing a HANDLE. + struct auto_handle + { + HANDLE handle; + auto_handle() : handle(0) {} + ~auto_handle() { if (handle) ::CloseHandle(handle); } + }; + + // The IO completion port used for queueing operations. + auto_handle iocp_; + + // The count of unfinished work. + long outstanding_work_; + + // Flag to indicate whether the event loop has been stopped. + long stopped_; + + // Flag to indicate whether the service has been shut down. + long shutdown_; + + enum + { + // Timeout to use with GetQueuedCompletionStatus. Some versions of windows + // have a "bug" where a call to GetQueuedCompletionStatus can appear stuck + // even though there are events waiting on the queue. Using a timeout helps + // to work around the issue. + gqcs_timeout = 500, + + // Maximum waitable timer timeout, in milliseconds. + max_timeout_msec = 5 * 60 * 1000, + + // Maximum waitable timer timeout, in microseconds. + max_timeout_usec = max_timeout_msec * 1000, + + // Completion key value used to wake up a thread to dispatch timers or + // completed operations. + wake_for_dispatch = 1, + + // Completion key value to indicate that an operation has posted with the + // original last_error and bytes_transferred values stored in the fields of + // the OVERLAPPED structure. + overlapped_contains_result = 2 + }; + + // Function object for processing timeouts in a background thread. + struct timer_thread_function; + friend struct timer_thread_function; + + // Background thread used for processing timeouts. + boost::scoped_ptr<thread> timer_thread_; + + // A waitable timer object used for waiting for timeouts. + auto_handle waitable_timer_; + + // Non-zero if timers or completed operations need to be dispatched. + long dispatch_required_; + + // Mutex for protecting access to the timer queues and completed operations. + mutex dispatch_mutex_; + + // The timer queues. + timer_queue_set timer_queues_; + + // The operations that are ready to dispatch. + op_queue<win_iocp_operation> completed_ops_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#include <boost/asio/detail/impl/win_iocp_io_service.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/detail/impl/win_iocp_io_service.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_io_service_fwd.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_io_service_fwd.hpp new file mode 100644 index 0000000..1357603 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_io_service_fwd.hpp
@@ -0,0 +1,35 @@ +// +// detail/win_iocp_io_service_fwd.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_FWD_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_FWD_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +namespace boost { +namespace asio { +namespace detail { + +class win_iocp_io_service; +class win_iocp_overlapped_ptr; + +} // namespace detail +} // namespace asio +} // namespace boost + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_IO_SERVICE_FWD_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_null_buffers_op.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_null_buffers_op.hpp new file mode 100644 index 0000000..ed1c28f --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_null_buffers_op.hpp
@@ -0,0 +1,114 @@ +// +// detail/win_iocp_null_buffers_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_NULL_BUFFERS_OP_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_NULL_BUFFERS_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/buffer_sequence_adapter.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/reactor_op.hpp> +#include <boost/asio/detail/socket_ops.hpp> +#include <boost/asio/error.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +class win_iocp_null_buffers_op : public reactor_op +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_null_buffers_op); + + win_iocp_null_buffers_op(socket_ops::weak_cancel_token_type cancel_token, + Handler handler) + : reactor_op(&win_iocp_null_buffers_op::do_perform, + &win_iocp_null_buffers_op::do_complete), + cancel_token_(cancel_token), + handler_(handler) + { + } + + static bool do_perform(reactor_op*) + { + return true; + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code ec, std::size_t bytes_transferred) + { + // Take ownership of the operation object. + win_iocp_null_buffers_op* o(static_cast<win_iocp_null_buffers_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // The reactor may have stored a result in the operation object. + if (o->ec_) + ec = o->ec_; + + // Map non-portable errors to their portable counterparts. + if (ec.value() == ERROR_NETNAME_DELETED) + { + if (o->cancel_token_.expired()) + ec = boost::asio::error::operation_aborted; + else + ec = boost::asio::error::connection_reset; + } + else if (ec.value() == ERROR_PORT_UNREACHABLE) + { + ec = boost::asio::error::connection_refused; + } + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, ec, bytes_transferred); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + socket_ops::weak_cancel_token_type cancel_token_; + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_NULL_BUFFERS_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_operation.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_operation.hpp new file mode 100644 index 0000000..c9b3041 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_operation.hpp
@@ -0,0 +1,92 @@ +// +// detail/win_iocp_operation.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/detail/op_queue.hpp> +#include <boost/asio/detail/win_iocp_io_service_fwd.hpp> +#include <boost/system/error_code.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Base class for all operations. A function pointer is used instead of virtual +// functions to avoid the associated overhead. +class win_iocp_operation + : public OVERLAPPED +{ +public: + void complete(win_iocp_io_service& owner, + const boost::system::error_code& ec = boost::system::error_code(), + std::size_t bytes_transferred = 0) + { + func_(&owner, this, ec, bytes_transferred); + } + + void destroy() + { + func_(0, this, boost::system::error_code(), 0); + } + +protected: + typedef void (*func_type)(win_iocp_io_service*, + win_iocp_operation*, boost::system::error_code, std::size_t); + + win_iocp_operation(func_type func) + : next_(0), + func_(func) + { + reset(); + } + + // Prevents deletion through this type. + ~win_iocp_operation() + { + } + + void reset() + { + Internal = 0; + InternalHigh = 0; + Offset = 0; + OffsetHigh = 0; + hEvent = 0; + ready_ = 0; + } + +private: + friend class op_queue_access; + friend class win_iocp_io_service; + win_iocp_operation* next_; + func_type func_; + long ready_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_OPERATION_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_op.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_op.hpp new file mode 100644 index 0000000..911449d --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_op.hpp
@@ -0,0 +1,86 @@ +// +// detail/win_iocp_overlapped_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_OP_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/asio/error.hpp> +#include <boost/utility/addressof.hpp> +#include <boost/asio/detail/bind_handler.hpp> +#include <boost/asio/detail/fenced_block.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/handler_invoke_helpers.hpp> +#include <boost/asio/detail/operation.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +template <typename Handler> +class win_iocp_overlapped_op : public operation +{ +public: + BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_overlapped_op); + + win_iocp_overlapped_op(Handler handler) + : operation(&win_iocp_overlapped_op::do_complete), + handler_(handler) + { + } + + static void do_complete(io_service_impl* owner, operation* base, + boost::system::error_code ec, std::size_t bytes_transferred) + { + // Take ownership of the operation object. + win_iocp_overlapped_op* o(static_cast<win_iocp_overlapped_op*>(base)); + ptr p = { boost::addressof(o->handler_), o, o }; + + // Make a copy of the handler so that the memory can be deallocated before + // the upcall is made. Even if we're not about to make an upcall, a + // sub-object of the handler may be the true owner of the memory associated + // with the handler. Consequently, a local copy of the handler is required + // to ensure that any owning sub-object remains valid until after we have + // deallocated the memory here. + detail::binder2<Handler, boost::system::error_code, std::size_t> + handler(o->handler_, ec, bytes_transferred); + p.h = boost::addressof(handler.handler_); + p.reset(); + + // Make the upcall if required. + if (owner) + { + boost::asio::detail::fenced_block b; + boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); + } + } + +private: + Handler handler_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_OP_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_ptr.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_ptr.hpp new file mode 100644 index 0000000..5589c11 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_overlapped_ptr.hpp
@@ -0,0 +1,142 @@ +// +// detail/win_iocp_overlapped_ptr.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_PTR_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_PTR_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) + +#include <boost/utility/addressof.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/handler_alloc_helpers.hpp> +#include <boost/asio/detail/noncopyable.hpp> +#include <boost/asio/detail/win_iocp_overlapped_op.hpp> +#include <boost/asio/detail/win_iocp_io_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Wraps a handler to create an OVERLAPPED object for use with overlapped I/O. +class win_iocp_overlapped_ptr + : private noncopyable +{ +public: + // Construct an empty win_iocp_overlapped_ptr. + win_iocp_overlapped_ptr() + : ptr_(0), + iocp_service_(0) + { + } + + // Construct an win_iocp_overlapped_ptr to contain the specified handler. + template <typename Handler> + explicit win_iocp_overlapped_ptr( + boost::asio::io_service& io_service, Handler handler) + : ptr_(0), + iocp_service_(0) + { + this->reset(io_service, handler); + } + + // Destructor automatically frees the OVERLAPPED object unless released. + ~win_iocp_overlapped_ptr() + { + reset(); + } + + // Reset to empty. + void reset() + { + if (ptr_) + { + ptr_->destroy(); + ptr_ = 0; + iocp_service_->work_finished(); + iocp_service_ = 0; + } + } + + // Reset to contain the specified handler, freeing any current OVERLAPPED + // object. + template <typename Handler> + void reset(boost::asio::io_service& io_service, Handler handler) + { + typedef win_iocp_overlapped_op<Handler> op; + typename op::ptr p = { boost::addressof(handler), + boost_asio_handler_alloc_helpers::allocate( + sizeof(op), handler), 0 }; + p.p = new (p.v) op(handler); + io_service.impl_.work_started(); + reset(); + ptr_ = p.p; + p.v = p.p = 0; + iocp_service_ = &io_service.impl_; + } + + // Get the contained OVERLAPPED object. + OVERLAPPED* get() + { + return ptr_; + } + + // Get the contained OVERLAPPED object. + const OVERLAPPED* get() const + { + return ptr_; + } + + // Release ownership of the OVERLAPPED object. + OVERLAPPED* release() + { + if (ptr_) + iocp_service_->on_pending(ptr_); + + OVERLAPPED* tmp = ptr_; + ptr_ = 0; + iocp_service_ = 0; + return tmp; + } + + // Post completion notification for overlapped operation. Releases ownership. + void complete(const boost::system::error_code& ec, + std::size_t bytes_transferred) + { + if (ptr_) + { + iocp_service_->on_completion(ptr_, ec, + static_cast<DWORD>(bytes_transferred)); + ptr_ = 0; + iocp_service_ = 0; + } + } + +private: + win_iocp_operation* ptr_; + win_iocp_io_service* iocp_service_; +}; + +} // namespace detail +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // defined(BOOST_ASIO_HAS_IOCP) + +#endif // BOOST_ASIO_DETAIL_WIN_IOCP_OVERLAPPED_PTR_HPP
diff --git a/boost_1_45_0/boost/asio/detail/win_iocp_serial_port_service.hpp b/boost_1_45_0/boost/asio/detail/win_iocp_serial_port_service.hpp new file mode 100644 index 0000000..a0caa69 --- /dev/null +++ b/boost_1_45_0/boost/asio/detail/win_iocp_serial_port_service.hpp
@@ -0,0 +1,214 @@ +// +// detail/win_iocp_serial_port_service.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_SERIAL_PORT_SERVICE_HPP +#define BOOST_ASIO_DETAIL_WIN_IOCP_SERIAL_PORT_SERVICE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if defined(BOOST_ASIO_HAS_IOCP) && defined(BOOST_ASIO_HAS_SERIAL_PORT) + +#include <string> +#include <boost/asio/error.hpp> +#include <boost/asio/io_service.hpp> +#include <boost/asio/detail/win_iocp_handle_service.hpp> + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace detail { + +// Extend win_iocp_handle_service to provide serial port support. +class win_iocp_serial_port_service +{ +public: + // The native type of a serial port. + typedef win_iocp_handle_service::native_type native_type; + + // The implementation type of the serial port. + typedef win_iocp_handle_service::implementation_type implementation_type; + + // Constructor. + BOOST_ASIO_DECL win_iocp_serial_port_service( + boost::asio::io_service& io_service); + + // Destroy all user-defined handler objects owned by the service. + BOOST_ASIO_DECL void shutdown_service(); + + // Construct a new serial port implementation. + void construct(implementation_type& impl) + { + handle_service_.construct(impl); + } + + // Destroy a serial port implementation. + void destroy(implementation_type& impl) + { + handle_service_.destroy(impl); + } + + // Open the serial port using the specified device name. + BOOST_ASIO_DECL boost::system::error_code open(implementation_type& impl, + const std::string& device, boost::system::error_code& ec); + + // Assign a native handle to a serial port implementation. + boost::system::error_code assign(implementation_type& impl, + const native_type& native_handle, boost::system::error_code& ec) + { + return handle_service_.assign(impl, native_handle, ec); + } + + // Determine whether the serial port is open. + bool is_open(const implementation_type& impl) const + { + return handle_service_.is_open(impl); + } + + // Destroy a serial port implementation. + boost::system::error_code close(implementation_type& impl, + boost::system::error_code& ec) + { + return handle_service_.close(impl, ec); + } + + // Get the native serial port representation. + native_type native(implementation_type& impl) + { + return handle_service_.native(impl); + } + + // Cancel all operations associated with the handle. + boost::system::error_code cancel(implementation_type& impl, + boost::system::error_code& ec) + { + return handle_service_.cancel(impl, ec); + } + + // Set an option on the serial port. + template <typename SettableSerialPortOption> + boost::system::error_code set_option(implementation_type& impl, + const SettableSerialPortOption& option, boost::system::error_code& ec) + { + return do_set_option(impl, + &win_iocp_serial_port_service::store_option<SettableSerialPortOption>, + &option, ec); + } + + // Get an option from the serial port. + template <typename GettableSerialPortOption> + boost::system::error_code get_option(const implementation_type& impl, + GettableSerialPortOption& option, boost::system::error_code& ec) const + { + return do_get_option(impl, + &win_iocp_serial_port_service::load_option<GettableSerialPortOption>, + &option, ec); + } + + // Send a break sequence to the serial port. + boost::system::error_code send_break(implementation_type&, + boost::system::error_code& ec) + { + ec = boost::asio::error::operation_not_supported; + return ec; + } + + // Write the given data. Returns the number of bytes sent. + template <typename ConstBufferSequence> + size_t write_some(implementation_type& impl, + const ConstBufferSequence& buffers, boost::system::error_code& ec) + { + return handle_service_.write_some(impl, buffers, ec); + } + + // Start an asynchronous write. The data being written must be valid for the + // lifetime of the asynchronous operation. + template <typename ConstBufferSequence, typename Handler> + void async_write_some(implementation_type& impl, + const ConstBufferSequence& buffers, Handler handler) + { + handle_service_.async_write_some(impl, buffers, handler); + } + + // Read some data. Returns the number of bytes received. + template <typename MutableBufferSequence> + size_t read_some(implementation_type& impl, + const MutableBufferSequence& buffers, boost::system::error_code& ec) + { + return handle_service_.read_some(impl, buffers, ec); + } + + // Start an asynchronous read. The buffer for the data being received must be + // valid for the lifetime of the asynchronous operation. + template <typename MutableBufferSequence, typename Handler> + void async_read_some(implementation_type& impl, + const MutableBufferSequence& buffers, Handler handler) + { + handle_service_.async_read_some(impl, buffers, handler); + } + +private: + // Function pointer type for storing a serial port option. + typedef boost::system::error_code (*store_function_type)( + const void*, ::DCB&, boost::system::error_code&); + + // Helper function template to store a serial port option. + template <typename SettableSerialPortOption> + static boost::system::error_code store_option(const void* option, + ::DCB& storage, boost::system::error_code& ec) + { + return static_cast<const SettableSerialPortOption*>(option)->store( + storage, ec); + } + + // Helper function to set a serial port option. + BOOST_ASIO_DECL boost::system::error_code do_set_option( + implementation_type& impl, store_function_type store, + const void* option, boost::system::error_code& ec); + + // Function pointer type for loading a serial port option. + typedef boost::system::error_code (*load_function_type)( + void*, const ::DCB&, boost::system::error_code&); + + // Helper function template to load a serial port option. + template <typename GettableSerialPortOption> + static boost::system::error_code load_option(void* option, + const ::DCB& storage, boost::system::error_code& ec) + { + return static_cast<GettableSerialPortOption*>(option)->load(storage, ec); + } + + // Helper function to get a serial port option. + BOOST_ASIO_DECL boost::system::error_code do_get_option( + const implementation_type& impl, load_function_type load, + void* option, boost::system::error_code& ec) const; + + // The implementation used for initiating asynchronous operations. + win_iocp_handle_service handle_service_; +}; <