diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 15:46:49 (GMT) |
commit | f53a1ef582494458301b97bf6e546be52d7ff7e8 (patch) | |
tree | 7571b5cbcbd8a8f1dd1c966c9045b6cb69f0e295 /3rdParty/Boost/src/libs | |
parent | 638345680d72ca6acaf123f2c8c1c391f696e371 (diff) | |
download | swift-f53a1ef582494458301b97bf6e546be52d7ff7e8.zip swift-f53a1ef582494458301b97bf6e546be52d7ff7e8.tar.bz2 |
Moving submodule contents back.
Diffstat (limited to '3rdParty/Boost/src/libs')
45 files changed, 10941 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp new file mode 100644 index 0000000..bbef7f6 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/date_generators.cpp @@ -0,0 +1,38 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland, Bart Garst + * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + */ + + + +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif +#include "boost/date_time/date_generators.hpp" + +namespace boost { +namespace date_time { + + const char* const _nth_as_str[] = {"out of range", "first", "second", + "third", "fourth", "fifth"}; + + //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5. + BOOST_DATE_TIME_DECL const char* nth_as_str(int ele) + { + if(ele >= 1 || ele <= 5) { + return _nth_as_str[ele]; + } + else { + return _nth_as_str[0]; + } + } + +} } //namespace date_time + + + + + diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp new file mode 100644 index 0000000..efca973 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_month.cpp @@ -0,0 +1,173 @@ +/* Copyright (c) 2002-2005 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland, Bart Garst + * $Date: 2008-11-23 06:13:35 -0500 (Sun, 23 Nov 2008) $ + */ + + + +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif +#include "boost/date_time/gregorian/greg_month.hpp" +#include "boost/date_time/gregorian/greg_facet.hpp" +#include "boost/date_time/date_format_simple.hpp" +#include "boost/date_time/compiler_config.hpp" +#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) +#include "boost/date_time/gregorian/formatters_limited.hpp" +#else +#include "boost/date_time/gregorian/formatters.hpp" +#endif +#include "boost/date_time/date_parsing.hpp" +#include "boost/date_time/gregorian/parsers.hpp" + +#include "greg_names.hpp" +namespace boost { +namespace gregorian { + + /*! Returns a shared pointer to a map of Month strings & numbers. + * Strings are both full names and abbreviations. + * Ex. ("jan",1), ("february",2), etc... + * Note: All characters are lowercase - for case insensitivity + */ + greg_month::month_map_ptr_type greg_month::get_month_map_ptr() + { + static month_map_ptr_type month_map_ptr(new greg_month::month_map_type()); + + if(month_map_ptr->empty()) { + std::string s(""); + for(unsigned short i = 1; i <= 12; ++i) { + greg_month m(static_cast<month_enum>(i)); + s = m.as_long_string(); + s = date_time::convert_to_lower(s); + month_map_ptr->insert(std::make_pair(s, i)); + s = m.as_short_string(); + s = date_time::convert_to_lower(s); + month_map_ptr->insert(std::make_pair(s, i)); + } + } + return month_map_ptr; + } + + + //! Returns 3 char english string for the month ex: Jan, Feb, Mar, Apr + const char* + greg_month::as_short_string() const + { + return short_month_names[value_-1]; + } + + //! Returns full name of month as string in english ex: January, February + const char* + greg_month::as_long_string() const + { + return long_month_names[value_-1]; + } + + //! Return special_value from string argument + /*! Return special_value from string argument. If argument is + * not one of the special value names (defined in names.hpp), + * return 'not_special' */ + special_values special_value_from_string(const std::string& s) { + short i = date_time::find_match(special_value_names, + special_value_names, + date_time::NumSpecialValues, + s); + if(i >= date_time::NumSpecialValues) { // match not found + return not_special; + } + else { + return static_cast<special_values>(i); + } + } + + +#ifndef BOOST_NO_STD_WSTRING + //! Returns 3 wchar_t english string for the month ex: Jan, Feb, Mar, Apr + const wchar_t* + greg_month::as_short_wstring() const + { + return w_short_month_names[value_-1]; + } + + //! Returns full name of month as wchar_t string in english ex: January, February + const wchar_t* + greg_month::as_long_wstring() const + { + return w_long_month_names[value_-1]; + } +#endif // BOOST_NO_STD_WSTRING + +#ifndef BOOST_DATE_TIME_NO_LOCALE + /*! creates an all_date_names_put object with the correct set of names. + * This function is only called in the event of an exception where + * the imbued locale containing the needed facet is for some reason + * unreachable. + */ + BOOST_DATE_TIME_DECL + boost::date_time::all_date_names_put<greg_facet_config, char>* + create_facet_def(char type) + { + typedef + boost::date_time::all_date_names_put<greg_facet_config, char> facet_def; + + return new facet_def(short_month_names, + long_month_names, + special_value_names, + short_weekday_names, + long_weekday_names); + } + + //! generates a locale with the set of gregorian name-strings of type char* + BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char type){ + typedef boost::date_time::all_date_names_put<greg_facet_config, char> facet_def; + return std::locale(loc, new facet_def(short_month_names, + long_month_names, + special_value_names, + short_weekday_names, + long_weekday_names) + ); + } + +#ifndef BOOST_NO_STD_WSTRING + /*! creates an all_date_names_put object with the correct set of names. + * This function is only called in the event of an exception where + * the imbued locale containing the needed facet is for some reason + * unreachable. + */ + BOOST_DATE_TIME_DECL + boost::date_time::all_date_names_put<greg_facet_config, wchar_t>* + create_facet_def(wchar_t type) + { + typedef + boost::date_time::all_date_names_put<greg_facet_config,wchar_t> facet_def; + + return new facet_def(w_short_month_names, + w_long_month_names, + w_special_value_names, + w_short_weekday_names, + w_long_weekday_names); + } + + //! generates a locale with the set of gregorian name-strings of type wchar_t* + BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t type){ + typedef boost::date_time::all_date_names_put<greg_facet_config, wchar_t> facet_def; + return std::locale(loc, new facet_def(w_short_month_names, + w_long_month_names, + w_special_value_names, + w_short_weekday_names, + w_long_weekday_names) + ); + } +#endif // BOOST_NO_STD_WSTRING +#endif // BOOST_DATE_TIME_NO_LOCALE + +} } //namespace gregorian + + + + + + diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp new file mode 100644 index 0000000..76a1a24 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_names.hpp @@ -0,0 +1,43 @@ +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland, Bart Garst + * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + */ + + + +#ifndef DATE_TIME_SRC_GREG_NAMES_HPP___ +#define DATE_TIME_SRC_GREG_NAMES_HPP___ + +#include "boost/date_time/gregorian/greg_month.hpp" +#include "boost/date_time/special_defs.hpp" +namespace boost { +namespace gregorian { + + + const char* const short_month_names[NumMonths]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", "NAM"}; + const char* const long_month_names[NumMonths]={"January","February","March","April","May","June","July","August","September","October","November","December","NotAMonth"}; + const char* const special_value_names[date_time::NumSpecialValues]={"not-a-date-time","-infinity","+infinity","min_date_time","max_date_time","not_special"}; + + + const char* const short_weekday_names[]={"Sun", "Mon", "Tue", + "Wed", "Thu", "Fri", "Sat"}; + const char* const long_weekday_names[]= {"Sunday","Monday","Tuesday", + "Wednesday", "Thursday", + "Friday", "Saturday"}; + +#ifndef BOOST_NO_STD_WSTRING + const wchar_t* const w_short_month_names[NumMonths]={L"Jan",L"Feb",L"Mar",L"Apr",L"May",L"Jun",L"Jul",L"Aug",L"Sep",L"Oct",L"Nov",L"Dec",L"NAM"}; + const wchar_t* const w_long_month_names[NumMonths]={L"January",L"February",L"March",L"April",L"May",L"June",L"July",L"August",L"September",L"October",L"November",L"December",L"NotAMonth"}; + const wchar_t* const w_special_value_names[date_time::NumSpecialValues]={L"not-a-date-time",L"-infinity",L"+infinity",L"min_date_time",L"max_date_time",L"not_special"}; + + const wchar_t* const w_short_weekday_names[]={L"Sun", L"Mon", L"Tue", + L"Wed", L"Thu", L"Fri", L"Sat"}; + const wchar_t* const w_long_weekday_names[]= {L"Sunday",L"Monday",L"Tuesday", + L"Wednesday", L"Thursday", + L"Friday", L"Saturday"}; +#endif // BOOST_NO_STD_WSTRING +} } // boost::gregorian +#endif // DATE_TIME_SRC_GREG_NAMES_HPP___ diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp new file mode 100644 index 0000000..4057d29 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/greg_weekday.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland, Bart Garst + * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + */ + + + +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif +#include "boost/date_time/gregorian/greg_weekday.hpp" + +#include "greg_names.hpp" + +namespace boost { +namespace gregorian { + + //! Return a 3 digit english string of the day of week (eg: Sun) + const char* + greg_weekday::as_short_string() const + { + return short_weekday_names[value_]; + } + //! Return a point to a long english string representing day of week + const char* + greg_weekday::as_long_string() const + { + return long_weekday_names[value_]; + } + +#ifndef BOOST_NO_STD_WSTRING + //! Return a 3 digit english wchar_t string of the day of week (eg: Sun) + const wchar_t* + greg_weekday::as_short_wstring() const + { + return w_short_weekday_names[value_]; + } + //! Return a point to a long english wchar_t string representing day of week + const wchar_t* + greg_weekday::as_long_wstring() const + { + return w_long_weekday_names[value_]; + } +#endif // BOOST_NO_STD_WSTRING + +} } //namespace gregorian + diff --git a/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp b/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp new file mode 100644 index 0000000..a856e79 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/gregorian/gregorian_types.cpp @@ -0,0 +1,62 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland + * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + */ + + +/** @defgroup date_basics Date Basics + This page summarizes some of the key user types and functions needed + to write programs using the gregorian date system. This is not a + comprehensive list, but rather some key types to start exploring. + + +**/ + +/** @defgroup date_alg Date Algorithms / Generators + Date algorithms or generators are tools for generating other dates or + schedules of dates. A generator function starts with some part of a + date such as a month and day and is supplied another part to then + generate a final date. + +**/ + +/** @defgroup date_format Date Formatting + The functions on these page are some of the key formatting functions + for dates. +**/ + + +//File doesn't have a current purpose except to generate docs +//and keep it changeable without recompiles +/*! @example days_alive.cpp + Calculate the number of days you have been living using durations and dates. +*/ +/*! @example days_till_new_year.cpp + Calculate the number of days till new years +*/ +/*! @example print_month.cpp + Simple utility to print out days of the month with the days of a month. Demontstrates date iteration (date_time::date_itr). +*/ +/*! @example localization.cpp + An example showing localized stream-based I/O. +*/ +/*! @example dates_as_strings.cpp + Various parsing and output of strings (mostly supported for + compilers that do not support localized streams). +*/ +/*! @example period_calc.cpp + Calculates if a date is in an 'irregular' collection of periods using + period calculation functions. +*/ +/*! @example print_holidays.cpp + This is an example of using functors to define a holiday schedule + */ +/*! @example localization.cpp + Demonstrates the use of facets to localize date output for Gregorian dates. + */ + + + diff --git a/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp b/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp new file mode 100644 index 0000000..06ef563 --- /dev/null +++ b/3rdParty/Boost/src/libs/date_time/src/posix_time/posix_time_types.cpp @@ -0,0 +1,35 @@ + +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is subject to the + * Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + * Author: Jeff Garland + * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + */ + + +//File doesn't have a current purpose except to generate docs +//and keep it changeable without recompiles + +/** @defgroup time_basics Time Basics + +**/ + +/** @defgroup time_format Time Formatting + +**/ + + + +/*! @example local_utc_conversion.cpp + Demonstrate utc to local and local to utc calculations including dst. +*/ +/*! @example time_periods.cpp Demonstrate some simple uses of time periods. +*/ +/*! @example print_hours.cpp Demonstrate time iteration, clock retrieval, and simple calculation. + */ +/*! @example time_math.cpp Various types of calculations with times and time durations. + */ + + + diff --git a/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp b/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp new file mode 100644 index 0000000..658ab6a --- /dev/null +++ b/3rdParty/Boost/src/libs/detail/utf8_codecvt_facet.cpp @@ -0,0 +1,269 @@ +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// utf8_codecvt_facet.cpp + +// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu) +// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu). +// 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) + +// Please see the comments in <boost/detail/utf8_codecvt_facet.hpp> to +// learn how this file should be used. + +#include <boost/detail/utf8_codecvt_facet.hpp> + +#include <cstdlib> // for multi-byte converson routines +#include <cassert> + +#include <boost/limits.hpp> +#include <boost/config.hpp> + +// If we don't have wstring, then Unicode support +// is not available anyway, so we don't need to even +// compiler this file. This also fixes the problem +// with mingw, which can compile this file, but will +// generate link error when building DLL. +#ifndef BOOST_NO_STD_WSTRING + +BOOST_UTF8_BEGIN_NAMESPACE + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// implementation for wchar_t + +// Translate incoming UTF-8 into UCS-4 +std::codecvt_base::result utf8_codecvt_facet::do_in( + std::mbstate_t& /*state*/, + const char * from, + const char * from_end, + const char * & from_next, + wchar_t * to, + wchar_t * to_end, + wchar_t * & to_next +) const { + // Basic algorithm: The first octet determines how many + // octets total make up the UCS-4 character. The remaining + // "continuing octets" all begin with "10". To convert, subtract + // the amount that specifies the number of octets from the first + // octet. Subtract 0x80 (1000 0000) from each continuing octet, + // then mash the whole lot together. Note that each continuing + // octet only uses 6 bits as unique values, so only shift by + // multiples of 6 to combine. + while (from != from_end && to != to_end) { + + // Error checking on the first octet + if (invalid_leading_octet(*from)){ + from_next = from; + to_next = to; + return std::codecvt_base::error; + } + + // The first octet is adjusted by a value dependent upon + // the number of "continuing octets" encoding the character + const int cont_octet_count = get_cont_octet_count(*from); + const wchar_t octet1_modifier_table[] = { + 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc + }; + + // The unsigned char conversion is necessary in case char is + // signed (I learned this the hard way) + wchar_t ucs_result = + (unsigned char)(*from++) - octet1_modifier_table[cont_octet_count]; + + // Invariants : + // 1) At the start of the loop, 'i' continuing characters have been + // processed + // 2) *from points to the next continuing character to be processed. + int i = 0; + while(i != cont_octet_count && from != from_end) { + + // Error checking on continuing characters + if (invalid_continuing_octet(*from)) { + from_next = from; + to_next = to; + return std::codecvt_base::error; + } + + ucs_result *= (1 << 6); + + // each continuing character has an extra (10xxxxxx)b attached to + // it that must be removed. + ucs_result += (unsigned char)(*from++) - 0x80; + ++i; + } + + // If the buffer ends with an incomplete unicode character... + if (from == from_end && i != cont_octet_count) { + // rewind "from" to before the current character translation + from_next = from - (i+1); + to_next = to; + return std::codecvt_base::partial; + } + *to++ = ucs_result; + } + from_next = from; + to_next = to; + + // Were we done converting or did we run out of destination space? + if(from == from_end) return std::codecvt_base::ok; + else return std::codecvt_base::partial; +} + +std::codecvt_base::result utf8_codecvt_facet::do_out( + std::mbstate_t& /*state*/, + const wchar_t * from, + const wchar_t * from_end, + const wchar_t * & from_next, + char * to, + char * to_end, + char * & to_next +) const +{ + // RG - consider merging this table with the other one + const wchar_t octet1_modifier_table[] = { + 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc + }; + + wchar_t max_wchar = (std::numeric_limits<wchar_t>::max)(); + while (from != from_end && to != to_end) { + + // Check for invalid UCS-4 character + if (*from > max_wchar) { + from_next = from; + to_next = to; + return std::codecvt_base::error; + } + + int cont_octet_count = get_cont_octet_out_count(*from); + + // RG - comment this formula better + int shift_exponent = (cont_octet_count) * 6; + + // Process the first character + *to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] + + (unsigned char)(*from / (1 << shift_exponent))); + + // Process the continuation characters + // Invariants: At the start of the loop: + // 1) 'i' continuing octets have been generated + // 2) '*to' points to the next location to place an octet + // 3) shift_exponent is 6 more than needed for the next octet + int i = 0; + while (i != cont_octet_count && to != to_end) { + shift_exponent -= 6; + *to++ = static_cast<char>(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6))); + ++i; + } + // If we filled up the out buffer before encoding the character + if(to == to_end && i != cont_octet_count) { + from_next = from; + to_next = to - (i+1); + return std::codecvt_base::partial; + } + *from++; + } + from_next = from; + to_next = to; + // Were we done or did we run out of destination space + if(from == from_end) return std::codecvt_base::ok; + else return std::codecvt_base::partial; +} + +// How many char objects can I process to get <= max_limit +// wchar_t objects? +int utf8_codecvt_facet::do_length( + BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &, + const char * from, + const char * from_end, + std::size_t max_limit +#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) +) const throw() +#else +) const +#endif +{ + // RG - this code is confusing! I need a better way to express it. + // and test cases. + + // Invariants: + // 1) last_octet_count has the size of the last measured character + // 2) char_count holds the number of characters shown to fit + // within the bounds so far (no greater than max_limit) + // 3) from_next points to the octet 'last_octet_count' before the + // last measured character. + int last_octet_count=0; + std::size_t char_count = 0; + const char* from_next = from; + // Use "<" because the buffer may represent incomplete characters + while (from_next+last_octet_count <= from_end && char_count <= max_limit) { + from_next += last_octet_count; + last_octet_count = (get_octet_count(*from_next)); + ++char_count; + } + return static_cast<int>(from_next-from_end); +} + +unsigned int utf8_codecvt_facet::get_octet_count( + unsigned char lead_octet +){ + // if the 0-bit (MSB) is 0, then 1 character + if (lead_octet <= 0x7f) return 1; + + // Otherwise the count number of consecutive 1 bits starting at MSB +// assert(0xc0 <= lead_octet && lead_octet <= 0xfd); + + if (0xc0 <= lead_octet && lead_octet <= 0xdf) return 2; + else if (0xe0 <= lead_octet && lead_octet <= 0xef) return 3; + else if (0xf0 <= lead_octet && lead_octet <= 0xf7) return 4; + else if (0xf8 <= lead_octet && lead_octet <= 0xfb) return 5; + else return 6; +} +BOOST_UTF8_END_NAMESPACE + +namespace { +template<std::size_t s> +int get_cont_octet_out_count_impl(wchar_t word){ + if (word < 0x80) { + return 0; + } + if (word < 0x800) { + return 1; + } + return 2; +} + +// note the following code will generate on some platforms where +// wchar_t is defined as UCS2. The warnings are superfluous as +// the specialization is never instantitiated with such compilers. +template<> +int get_cont_octet_out_count_impl<4>(wchar_t word){ + if (word < 0x80) { + return 0; + } + if (word < 0x800) { + return 1; + } + if (word < 0x10000) { + return 2; + } + if (word < 0x200000) { + return 3; + } + if (word < 0x4000000) { + return 4; + } + return 5; +} + +} // namespace anonymous + +BOOST_UTF8_BEGIN_NAMESPACE +// How many "continuing octets" will be needed for this word +// == total octets - 1. +int utf8_codecvt_facet::get_cont_octet_out_count( + wchar_t word +) const { + return get_cont_octet_out_count_impl<sizeof(wchar_t)>(word); +} +BOOST_UTF8_END_NAMESPACE + +#endif diff --git a/3rdParty/Boost/src/libs/filesystem/src/operations.cpp b/3rdParty/Boost/src/libs/filesystem/src/operations.cpp new file mode 100644 index 0000000..0c74504 --- /dev/null +++ b/3rdParty/Boost/src/libs/filesystem/src/operations.cpp @@ -0,0 +1,1367 @@ +// operations.cpp ----------------------------------------------------------// + +// Copyright 2002-2005 Beman Dawes +// Copyright 2001 Dietmar Kuehl +// 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/filesystem + +//----------------------------------------------------------------------------// + +// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_FILESYSTEM_SOURCE + +#define _POSIX_PTHREAD_SEMANTICS // Sun readdir_r() needs this + +// enable the XPG-compliant version of readdir_r() on AIX +#if defined(_AIX) +# define _LINUX_SOURCE_COMPAT +#endif + +#if !(defined(__HP_aCC) && defined(_ILP32) && \ + !defined(_STATVFS_ACPP_PROBLEMS_FIXED)) +#define _FILE_OFFSET_BITS 64 // at worst, these defines may have no effect, +#endif +#define __USE_FILE_OFFSET64 // but that is harmless on Windows and on POSIX + // 64-bit systems or on 32-bit systems which don't have files larger + // than can be represented by a traditional POSIX/UNIX off_t type. + // OTOH, defining them should kick in 64-bit off_t's (and thus + // st_size) on 32-bit systems that provide the Large File + // Support (LFS) interface, such as Linux, Solaris, and IRIX. + // The defines are given before any headers are included to + // ensure that they are available to all included headers. + // That is required at least on Solaris, and possibly on other + // systems as well. + +// for some compilers (CodeWarrior, for example), windows.h +// is getting included by some other boost header, so do this early: +#if !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x0500 // Default to Windows 2K or later +#endif + + +#include <boost/filesystem/operations.hpp> +#include <boost/scoped_array.hpp> +#include <boost/throw_exception.hpp> +#include <boost/detail/workaround.hpp> + +namespace fs = boost::filesystem; +using boost::system::error_code; +using boost::system::system_category; + +# if defined(BOOST_WINDOWS_API) +# include <windows.h> +# if defined(__BORLANDC__) || defined(__MWERKS__) +# if defined(__BORLANDC__) + using std::time_t; +# endif +# include <utime.h> +# else +# include <sys/utime.h> +# endif + +# else // BOOST_POSIX_API +# include <sys/types.h> +# if !defined(__APPLE__) && !defined(__OpenBSD__) +# include <sys/statvfs.h> +# define BOOST_STATVFS statvfs +# define BOOST_STATVFS_F_FRSIZE vfs.f_frsize +# else +#ifdef __OpenBSD__ +# include <sys/param.h> +#endif +# include <sys/mount.h> +# define BOOST_STATVFS statfs +# define BOOST_STATVFS_F_FRSIZE static_cast<boost::uintmax_t>( vfs.f_bsize ) +# endif +# include <dirent.h> +# include <unistd.h> +# include <fcntl.h> +# include <utime.h> +# include "limits.h" +# endif + +// BOOST_FILESYSTEM_STATUS_CACHE enables file_status cache in +// dir_itr_increment. The config tests are placed here because some of the +// macros being tested come from dirent.h. +// +// TODO: find out what macros indicate dirent::d_type present in more libraries +# if defined(BOOST_WINDOWS_API) \ + || (defined(_DIRENT_HAVE_D_TYPE) /* defined by GNU C library if d_type present */ \ + && !(defined(__SUNPRO_CC) && !defined(__sun))) // _DIRENT_HAVE_D_TYPE wrong for Sun compiler on Linux +# define BOOST_FILESYSTEM_STATUS_CACHE +# endif + +#include <sys/stat.h> // even on Windows some functions use stat() +#include <string> +#include <cstring> +#include <cstdio> // for remove, rename +#include <cerrno> +#include <cassert> +// #include <iostream> // for debugging only; comment out when not in use + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std { using ::strcmp; using ::remove; using ::rename; } +#endif + +// helpers -----------------------------------------------------------------// + +namespace +{ + const error_code ok; + + bool is_empty_directory( const std::string & dir_path ) + { + static const fs::directory_iterator end_itr; + return fs::directory_iterator(fs::path(dir_path)) == end_itr; + } + +#ifdef BOOST_WINDOWS_API + +// For Windows, the xxxA form of various function names is used to avoid +// inadvertently getting wide forms of the functions. (The undecorated +// forms are actually macros, so can misfire if the user has various +// other macros defined. There was a bug report of this happening.) + + inline DWORD get_file_attributes( const char * ph ) + { return ::GetFileAttributesA( ph ); } + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + inline DWORD get_file_attributes( const wchar_t * ph ) + { return ::GetFileAttributesW( ph ); } + + bool is_empty_directory( const std::wstring & dir_path ) + { + static const fs::wdirectory_iterator wend_itr; + return fs::wdirectory_iterator(fs::wpath(dir_path)) == wend_itr; + } + + inline BOOL get_file_attributes_ex( const wchar_t * ph, + WIN32_FILE_ATTRIBUTE_DATA & fad ) + { return ::GetFileAttributesExW( ph, ::GetFileExInfoStandard, &fad ); } + + HANDLE create_file( const wchar_t * ph, DWORD dwDesiredAccess, + DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile ) + { + return ::CreateFileW( ph, dwDesiredAccess, dwShareMode, + lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, + hTemplateFile ); + } + + inline DWORD get_current_directory( DWORD sz, wchar_t * buf ) + { return ::GetCurrentDirectoryW( sz, buf ); } + + inline bool set_current_directory( const wchar_t * buf ) + { return ::SetCurrentDirectoryW( buf ) != 0 ; } + + inline bool get_free_disk_space( const std::wstring & ph, + PULARGE_INTEGER avail, PULARGE_INTEGER total, PULARGE_INTEGER free ) + { return ::GetDiskFreeSpaceExW( ph.c_str(), avail, total, free ) != 0; } + + inline std::size_t get_full_path_name( + const std::wstring & ph, std::size_t len, wchar_t * buf, wchar_t ** p ) + { + return static_cast<std::size_t>( + ::GetFullPathNameW( ph.c_str(), + static_cast<DWORD>(len), buf, p )); + } + + inline bool remove_directory( const std::wstring & ph ) + { return ::RemoveDirectoryW( ph.c_str() ) != 0; } + + inline bool delete_file( const std::wstring & ph ) + { return ::DeleteFileW( ph.c_str() ) != 0; } + + inline bool create_directory( const std::wstring & dir ) + { return ::CreateDirectoryW( dir.c_str(), 0 ) != 0; } + +#if _WIN32_WINNT >= 0x500 + inline bool create_hard_link( const std::wstring & to_ph, + const std::wstring & from_ph ) + { return ::CreateHardLinkW( from_ph.c_str(), to_ph.c_str(), 0 ) != 0; } +#endif + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + template< class String > + fs::file_status status_template( const String & ph, error_code & ec ) + { + DWORD attr( get_file_attributes( ph.c_str() ) ); + if ( attr == 0xFFFFFFFF ) + { + ec = error_code( ::GetLastError(), system_category ); + if ((ec.value() == ERROR_FILE_NOT_FOUND) + || (ec.value() == ERROR_PATH_NOT_FOUND) + || (ec.value() == ERROR_INVALID_NAME) // "tools/jam/src/:sys:stat.h", "//foo" + || (ec.value() == ERROR_INVALID_DRIVE) // USB card reader with no card inserted + || (ec.value() == ERROR_INVALID_PARAMETER) // ":sys:stat.h" + || (ec.value() == ERROR_BAD_PATHNAME) // "//nosuch" on Win64 + || (ec.value() == ERROR_BAD_NETPATH)) // "//nosuch" on Win32 + { + ec = ok; // these are not considered errors; + // the status is considered not found + return fs::file_status( fs::file_not_found ); + } + else if ((ec.value() == ERROR_SHARING_VIOLATION)) + { + ec = ok; // these are not considered errors; + // the file exists but the type is not known + return fs::file_status( fs::type_unknown ); + } + return fs::file_status( fs::status_unknown ); + } + ec = ok;; + return (attr & FILE_ATTRIBUTE_DIRECTORY) + ? fs::file_status( fs::directory_file ) + : fs::file_status( fs::regular_file ); + } + + BOOL get_file_attributes_ex( const char * ph, + WIN32_FILE_ATTRIBUTE_DATA & fad ) + { return ::GetFileAttributesExA( ph, ::GetFileExInfoStandard, &fad ); } + + template< class String > + boost::filesystem::detail::query_pair + is_empty_template( const String & ph ) + { + WIN32_FILE_ATTRIBUTE_DATA fad; + if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 ) + return std::make_pair( error_code( ::GetLastError(), system_category ), false ); + return std::make_pair( ok, + ( fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + ? is_empty_directory( ph ) + :( !fad.nFileSizeHigh && !fad.nFileSizeLow ) ); + } + + HANDLE create_file( const char * ph, DWORD dwDesiredAccess, + DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile ) + { + return ::CreateFileA( ph, dwDesiredAccess, dwShareMode, + lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, + hTemplateFile ); + } + + // Thanks to Jeremy Maitin-Shepard for much help and for permission to + // base the equivalent() implementation on portions of his + // file-equivalence-win32.cpp experimental code. + struct handle_wrapper + { + HANDLE handle; + handle_wrapper( HANDLE h ) + : handle(h) {} + ~handle_wrapper() + { + if ( handle != INVALID_HANDLE_VALUE ) + ::CloseHandle(handle); + } + }; + + template< class String > + boost::filesystem::detail::query_pair + equivalent_template( const String & ph1, const String & ph2 ) + { + // Note well: Physical location on external media is part of the + // equivalence criteria. If there are no open handles, physical location + // can change due to defragmentation or other relocations. Thus handles + // must be held open until location information for both paths has + // been retrieved. + handle_wrapper p1( + create_file( + ph1.c_str(), + 0, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + 0, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + 0 ) ); + int error1(0); // save error code in case we have to throw + if ( p1.handle == INVALID_HANDLE_VALUE ) + error1 = ::GetLastError(); + handle_wrapper p2( + create_file( + ph2.c_str(), + 0, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + 0, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + 0 ) ); + if ( p1.handle == INVALID_HANDLE_VALUE + || p2.handle == INVALID_HANDLE_VALUE ) + { + if ( p1.handle != INVALID_HANDLE_VALUE + || p2.handle != INVALID_HANDLE_VALUE ) + { return std::make_pair( ok, false ); } + assert( p1.handle == INVALID_HANDLE_VALUE + && p2.handle == INVALID_HANDLE_VALUE ); + { return std::make_pair( error_code( error1, system_category), false ); } + } + // at this point, both handles are known to be valid + BY_HANDLE_FILE_INFORMATION info1, info2; + if ( !::GetFileInformationByHandle( p1.handle, &info1 ) ) + { return std::make_pair( error_code( ::GetLastError(), system_category ), false ); } + if ( !::GetFileInformationByHandle( p2.handle, &info2 ) ) + { return std::make_pair( error_code( ::GetLastError(), system_category ), false ); } + // In theory, volume serial numbers are sufficient to distinguish between + // devices, but in practice VSN's are sometimes duplicated, so last write + // time and file size are also checked. + return std::make_pair( ok, + info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber + && info1.nFileIndexHigh == info2.nFileIndexHigh + && info1.nFileIndexLow == info2.nFileIndexLow + && info1.nFileSizeHigh == info2.nFileSizeHigh + && info1.nFileSizeLow == info2.nFileSizeLow + && info1.ftLastWriteTime.dwLowDateTime + == info2.ftLastWriteTime.dwLowDateTime + && info1.ftLastWriteTime.dwHighDateTime + == info2.ftLastWriteTime.dwHighDateTime ); + } + + template< class String > + boost::filesystem::detail::uintmax_pair + file_size_template( const String & ph ) + { + WIN32_FILE_ATTRIBUTE_DATA fad; + // by now, intmax_t is 64-bits on all Windows compilers + if ( get_file_attributes_ex( ph.c_str(), fad ) == 0 ) + return std::make_pair( error_code( ::GetLastError(), system_category ), 0 ); + if ( (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) !=0 ) + return std::make_pair( error_code( ERROR_FILE_NOT_FOUND, system_category), 0 ); + return std::make_pair( ok, + (static_cast<boost::uintmax_t>(fad.nFileSizeHigh) + << (sizeof(fad.nFileSizeLow)*8)) + + fad.nFileSizeLow ); + } + + inline bool get_free_disk_space( const std::string & ph, + PULARGE_INTEGER avail, PULARGE_INTEGER total, PULARGE_INTEGER free ) + { return ::GetDiskFreeSpaceExA( ph.c_str(), avail, total, free ) != 0; } + + template< class String > + boost::filesystem::detail::space_pair + space_template( String & ph ) + { + ULARGE_INTEGER avail, total, free; + boost::filesystem::detail::space_pair result; + if ( get_free_disk_space( ph, &avail, &total, &free ) ) + { + result.first = ok; + result.second.capacity + = (static_cast<boost::uintmax_t>(total.HighPart) << 32) + + total.LowPart; + result.second.free + = (static_cast<boost::uintmax_t>(free.HighPart) << 32) + + free.LowPart; + result.second.available + = (static_cast<boost::uintmax_t>(avail.HighPart) << 32) + + avail.LowPart; + } + else + { + result.first = error_code( ::GetLastError(), system_category ); + result.second.capacity = result.second.free + = result.second.available = 0; + } + return result; + } + + inline DWORD get_current_directory( DWORD sz, char * buf ) + { return ::GetCurrentDirectoryA( sz, buf ); } + + template< class String > + error_code + get_current_path_template( String & ph ) + { + DWORD sz; + if ( (sz = get_current_directory( 0, + static_cast<typename String::value_type*>(0) )) == 0 ) + { sz = 1; } + typedef typename String::value_type value_type; + boost::scoped_array<value_type> buf( new value_type[sz] ); + if ( get_current_directory( sz, buf.get() ) == 0 ) + return error_code( ::GetLastError(), system_category ); + ph = buf.get(); + return ok; + } + + inline bool set_current_directory( const char * buf ) + { return ::SetCurrentDirectoryA( buf ) != 0; } + + template< class String > + error_code + set_current_path_template( const String & ph ) + { + return error_code( set_current_directory( ph.c_str() ) + ? 0 : ::GetLastError(), system_category ); + } + + inline std::size_t get_full_path_name( + const std::string & ph, std::size_t len, char * buf, char ** p ) + { + return static_cast<std::size_t>( + ::GetFullPathNameA( ph.c_str(), + static_cast<DWORD>(len), buf, p )); + } + + const std::size_t buf_size( 128 ); + + template<class String> + error_code + get_full_path_name_template( const String & ph, String & target ) + { + typename String::value_type buf[buf_size]; + typename String::value_type * pfn; + std::size_t len = get_full_path_name( ph, + buf_size , buf, &pfn ); + if ( len == 0 ) return error_code( ::GetLastError(), system_category ); + if ( len > buf_size ) + { + typedef typename String::value_type value_type; + boost::scoped_array<value_type> big_buf( new value_type[len] ); + if ( (len=get_full_path_name( ph, len , big_buf.get(), &pfn )) + == 0 ) return error_code( ::GetLastError(), system_category ); + big_buf[len] = '\0'; + target = big_buf.get(); + return ok; + } + buf[len] = '\0'; + target = buf; + return ok; + } + + template<class String> + error_code + get_file_write_time( const String & ph, FILETIME & last_write_time ) + { + handle_wrapper hw( + create_file( ph.c_str(), 0, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) ); + if ( hw.handle == INVALID_HANDLE_VALUE ) + return error_code( ::GetLastError(), system_category ); + return error_code( ::GetFileTime( hw.handle, 0, 0, &last_write_time ) != 0 + ? 0 : ::GetLastError(), system_category ); + } + + template<class String> + error_code + set_file_write_time( const String & ph, const FILETIME & last_write_time ) + { + handle_wrapper hw( + create_file( ph.c_str(), FILE_WRITE_ATTRIBUTES, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0, + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ) ); + if ( hw.handle == INVALID_HANDLE_VALUE ) + return error_code( ::GetLastError(), system_category ); + return error_code( ::SetFileTime( hw.handle, 0, 0, &last_write_time ) != 0 + ? 0 : ::GetLastError(), system_category ); + } + + // these constants come from inspecting some Microsoft sample code + std::time_t to_time_t( const FILETIME & ft ) + { + __int64 t = (static_cast<__int64>( ft.dwHighDateTime ) << 32) + + ft.dwLowDateTime; +# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0 + t -= 116444736000000000LL; +# else + t -= 116444736000000000; +# endif + t /= 10000000; + return static_cast<std::time_t>( t ); + } + + void to_FILETIME( std::time_t t, FILETIME & ft ) + { + __int64 temp = t; + temp *= 10000000; +# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 // > VC++ 7.0 + temp += 116444736000000000LL; +# else + temp += 116444736000000000; +# endif + ft.dwLowDateTime = static_cast<DWORD>( temp ); + ft.dwHighDateTime = static_cast<DWORD>( temp >> 32 ); + } + + template<class String> + boost::filesystem::detail::time_pair + last_write_time_template( const String & ph ) + { + FILETIME lwt; + error_code ec( + get_file_write_time( ph, lwt ) ); + return std::make_pair( ec, to_time_t( lwt ) ); + } + + template<class String> + error_code + last_write_time_template( const String & ph, const std::time_t new_time ) + { + FILETIME lwt; + to_FILETIME( new_time, lwt ); + return set_file_write_time( ph, lwt ); + } + + bool remove_directory( const std::string & ph ) + { return ::RemoveDirectoryA( ph.c_str() ) != 0; } + + bool delete_file( const std::string & ph ) + { return ::DeleteFileA( ph.c_str() ) != 0; } + + template<class String> + error_code + remove_template( const String & ph ) + { + // TODO: test this code in the presence of Vista symlinks, + // including dangling, self-referal, and cyclic symlinks + error_code ec; + fs::file_status sf( fs::detail::status_api( ph, ec ) ); + if ( ec ) + return ec; + if ( sf.type() == fs::file_not_found ) + return ok; + if ( fs::is_directory( sf ) ) + { + if ( !remove_directory( ph ) ) + return error_code(::GetLastError(), system_category); + } + else + { + if ( !delete_file( ph ) ) return error_code(::GetLastError(), system_category); + } + return ok; + } + + inline bool create_directory( const std::string & dir ) + { return ::CreateDirectoryA( dir.c_str(), 0 ) != 0; } + + template<class String> + boost::filesystem::detail::query_pair + create_directory_template( const String & dir_ph ) + { + error_code error, dummy; + if ( create_directory( dir_ph ) ) return std::make_pair( error, true ); + error = error_code( ::GetLastError(), system_category ); + // an error here may simply mean the postcondition is already met + if ( error.value() == ERROR_ALREADY_EXISTS + && fs::is_directory( fs::detail::status_api( dir_ph, dummy ) ) ) + return std::make_pair( ok, false ); + return std::make_pair( error, false ); + } + +#if _WIN32_WINNT >= 0x500 + inline bool create_hard_link( const std::string & to_ph, + const std::string & from_ph ) + { return ::CreateHardLinkA( from_ph.c_str(), to_ph.c_str(), 0 ) != 0; } +#endif + +#if _WIN32_WINNT >= 0x500 + template<class String> + error_code + create_hard_link_template( const String & to_ph, + const String & from_ph ) + { + return error_code( create_hard_link( to_ph.c_str(), from_ph.c_str() ) + ? 0 : ::GetLastError(), system_category ); + } +#endif + +#else // BOOST_POSIX_API + + int posix_remove( const char * p ) + { +# if defined(__QNXNTO__) || (defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))) + // Some Metrowerks C library versions fail on directories because of a + // known Metrowerks coding error in ::remove. Workaround is to call + // rmdir() or unlink() as indicated. + // Same bug also reported for QNX, with the same fix. + int err = ::unlink( p ); + if ( err == 0 || errno != EPERM ) + return err; + return ::rmdir( p ); +# else + return std::remove( p ); +# endif + } + +#endif +} // unnamed namespace + +namespace boost +{ + namespace filesystem + { + namespace detail + { + BOOST_FILESYSTEM_DECL system::error_code throws; + +// free functions ----------------------------------------------------------// + + BOOST_FILESYSTEM_DECL error_code not_found_error() + { +# ifdef BOOST_WINDOWS_API + return error_code(ERROR_PATH_NOT_FOUND, system_category); +# else + return error_code(ENOENT, system_category); +# endif + } + + BOOST_FILESYSTEM_DECL bool possible_large_file_size_support() + { +# ifdef BOOST_POSIX_API + struct stat lcl_stat; + return sizeof( lcl_stat.st_size ) > 4; +# else + return true; +# endif + } + +# ifdef BOOST_WINDOWS_API + + BOOST_FILESYSTEM_DECL fs::file_status + status_api( const std::string & ph, error_code & ec ) + { return status_template( ph, ec ); } + +# ifndef BOOST_FILESYSTEM_NARROW_ONLY + + BOOST_FILESYSTEM_DECL fs::file_status + status_api( const std::wstring & ph, error_code & ec ) + { return status_template( ph, ec ); } + + BOOST_FILESYSTEM_DECL bool symbolic_link_exists_api( const std::wstring & ) + { return false; } + + BOOST_FILESYSTEM_DECL + fs::detail::query_pair is_empty_api( const std::wstring & ph ) + { return is_empty_template( ph ); } + + BOOST_FILESYSTEM_DECL + fs::detail::query_pair + equivalent_api( const std::wstring & ph1, const std::wstring & ph2 ) + { return equivalent_template( ph1, ph2 ); } + + BOOST_FILESYSTEM_DECL + fs::detail::uintmax_pair file_size_api( const std::wstring & ph ) + { return file_size_template( ph ); } + + BOOST_FILESYSTEM_DECL + fs::detail::space_pair space_api( const std::wstring & ph ) + { return space_template( ph ); } + + BOOST_FILESYSTEM_DECL + error_code + get_current_path_api( std::wstring & ph ) + { return get_current_path_template( ph ); } + + BOOST_FILESYSTEM_DECL + error_code + set_current_path_api( const std::wstring & ph ) + { return set_current_path_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + get_full_path_name_api( const std::wstring & ph, std::wstring & target ) + { return get_full_path_name_template( ph, target ); } + + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::wstring & ph ) + { return last_write_time_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + last_write_time_api( const std::wstring & ph, std::time_t new_value ) + { return last_write_time_template( ph, new_value ); } + + BOOST_FILESYSTEM_DECL fs::detail::query_pair + create_directory_api( const std::wstring & ph ) + { return create_directory_template( ph ); } + +#if _WIN32_WINNT >= 0x500 + BOOST_FILESYSTEM_DECL error_code + create_hard_link_api( const std::wstring & to_ph, + const std::wstring & from_ph ) + { return create_hard_link_template( to_ph, from_ph ); } +#endif + + BOOST_FILESYSTEM_DECL error_code + create_symlink_api( const std::wstring & /*to_ph*/, + const std::wstring & /*from_ph*/ ) + { return error_code( ERROR_NOT_SUPPORTED, system_category ); } + + BOOST_FILESYSTEM_DECL error_code + remove_api( const std::wstring & ph ) { return remove_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + rename_api( const std::wstring & from, const std::wstring & to ) + { + return error_code( ::MoveFileW( from.c_str(), to.c_str() ) + ? 0 : ::GetLastError(), system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + copy_file_api( const std::wstring & from, const std::wstring & to ) + { + return error_code( ::CopyFileW( from.c_str(), to.c_str(), /*fail_if_exists=*/true ) + ? 0 : ::GetLastError(), system_category ); + } + + BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph, + std::ios_base::openmode mode ) // true if succeeds + { + DWORD access( + ((mode & std::ios_base::in) == 0 ? 0 : GENERIC_READ) + | ((mode & std::ios_base::out) == 0 ? 0 : GENERIC_WRITE) ); + + DWORD disposition(0); // see 27.8.1.3 Table 92 + if ( (mode&~std::ios_base::binary) + == (std::ios_base::out|std::ios_base::app) ) + disposition = OPEN_ALWAYS; + else if ( (mode&~(std::ios_base::binary|std::ios_base::out)) + == std::ios_base::in ) disposition = OPEN_EXISTING; + else if ( ((mode&~(std::ios_base::binary|std::ios_base::trunc)) + == std::ios_base::out ) + || ((mode&~std::ios_base::binary) + == (std::ios_base::in|std::ios_base::out|std::ios_base::trunc)) ) + disposition = CREATE_ALWAYS; + else assert( 0 && "invalid mode argument" ); + + HANDLE handle ( ::CreateFileW( ph.c_str(), access, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 0, + disposition, (mode &std::ios_base::out) != 0 + ? FILE_ATTRIBUTE_ARCHIVE : FILE_ATTRIBUTE_NORMAL, 0 ) ); + if ( handle == INVALID_HANDLE_VALUE ) return false; + ::CloseHandle( handle ); + return true; + } + + BOOST_FILESYSTEM_DECL std::string narrow_path_api( + const std::wstring & ph ) // return is empty if fails + { + std::string narrow_short_form; + std::wstring short_form; + for ( DWORD buf_sz( static_cast<DWORD>( ph.size()+1 ));; ) + { + boost::scoped_array<wchar_t> buf( new wchar_t[buf_sz] ); + DWORD sz( ::GetShortPathNameW( ph.c_str(), buf.get(), buf_sz ) ); + if ( sz == 0 ) return narrow_short_form; + if ( sz <= buf_sz ) + { + short_form += buf.get(); + break; + } + buf_sz = sz + 1; + } + // contributed by Takeshi Mouri: + int narrow_sz( ::WideCharToMultiByte( CP_ACP, 0, + short_form.c_str(), static_cast<int>(short_form.size()), 0, 0, 0, 0 ) ); + boost::scoped_array<char> narrow_buf( new char[narrow_sz] ); + ::WideCharToMultiByte( CP_ACP, 0, + short_form.c_str(), static_cast<int>(short_form.size()), + narrow_buf.get(), narrow_sz, 0, 0 ); + narrow_short_form.assign(narrow_buf.get(), narrow_sz); + + return narrow_short_form; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_first( void *& handle, const std::wstring & dir, + std::wstring & target, file_status & sf, file_status & symlink_sf ) + { + // use a form of search Sebastian Martel reports will work with Win98 + std::wstring dirpath( dir ); + dirpath += (dirpath.empty() + || dirpath[dirpath.size()-1] != L'\\') ? L"\\*" : L"*"; + + WIN32_FIND_DATAW data; + if ( (handle = ::FindFirstFileW( dirpath.c_str(), &data )) + == INVALID_HANDLE_VALUE ) + { + handle = 0; + return error_code( ::GetLastError() == ERROR_FILE_NOT_FOUND + ? 0 : ::GetLastError(), system_category ); + } + target = data.cFileName; + if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + { sf.type( directory_file ); symlink_sf.type( directory_file ); } + else { sf.type( regular_file ); symlink_sf.type( regular_file ); } + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_increment( void *& handle, std::wstring & target, + file_status & sf, file_status & symlink_sf ) + { + WIN32_FIND_DATAW data; + if ( ::FindNextFileW( handle, &data ) == 0 ) // fails + { + int error = ::GetLastError(); + dir_itr_close( handle ); + return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category ); + } + target = data.cFileName; + if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + { sf.type( directory_file ); symlink_sf.type( directory_file ); } + else { sf.type( regular_file ); symlink_sf.type( regular_file ); } + return ok; + } + +# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // suggested by Walter Landry + BOOST_FILESYSTEM_DECL bool symbolic_link_exists_api( const std::string & ) + { return false; } + + BOOST_FILESYSTEM_DECL + fs::detail::query_pair is_empty_api( const std::string & ph ) + { return is_empty_template( ph ); } + + BOOST_FILESYSTEM_DECL + fs::detail::query_pair + equivalent_api( const std::string & ph1, const std::string & ph2 ) + { return equivalent_template( ph1, ph2 ); } + + BOOST_FILESYSTEM_DECL + fs::detail::uintmax_pair file_size_api( const std::string & ph ) + { return file_size_template( ph ); } + + BOOST_FILESYSTEM_DECL + fs::detail::space_pair space_api( const std::string & ph ) + { return space_template( ph ); } + + BOOST_FILESYSTEM_DECL + error_code + get_current_path_api( std::string & ph ) + { return get_current_path_template( ph ); } + + BOOST_FILESYSTEM_DECL + error_code + set_current_path_api( const std::string & ph ) + { return set_current_path_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + get_full_path_name_api( const std::string & ph, std::string & target ) + { return get_full_path_name_template( ph, target ); } + + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::string & ph ) + { return last_write_time_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + last_write_time_api( const std::string & ph, std::time_t new_value ) + { return last_write_time_template( ph, new_value ); } + + BOOST_FILESYSTEM_DECL fs::detail::query_pair + create_directory_api( const std::string & ph ) + { return create_directory_template( ph ); } + +#if _WIN32_WINNT >= 0x500 + BOOST_FILESYSTEM_DECL error_code + create_hard_link_api( const std::string & to_ph, + const std::string & from_ph ) + { + return create_hard_link_template( to_ph, from_ph ); + } +#endif + + BOOST_FILESYSTEM_DECL error_code + create_symlink_api( const std::string & /*to_ph*/, + const std::string & /*from_ph*/ ) + { return error_code( ERROR_NOT_SUPPORTED, system_category ); } + + BOOST_FILESYSTEM_DECL error_code + remove_api( const std::string & ph ) { return remove_template( ph ); } + + BOOST_FILESYSTEM_DECL error_code + rename_api( const std::string & from, const std::string & to ) + { + return error_code( ::MoveFileA( from.c_str(), to.c_str() ) + ? 0 : ::GetLastError(), system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + copy_file_api( const std::string & from, const std::string & to ) + { + return error_code( ::CopyFileA( from.c_str(), to.c_str(), /*fail_if_exists=*/true ) + ? 0 : ::GetLastError(), system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_first( void *& handle, const std::string & dir, + std::string & target, file_status & sf, file_status & symlink_sf ) + // Note: an empty root directory has no "." or ".." entries, so this + // causes a ERROR_FILE_NOT_FOUND error which we do not considered an + // error. It is treated as eof instead. + { + // use a form of search Sebastian Martel reports will work with Win98 + std::string dirpath( dir ); + dirpath += (dirpath.empty() + || (dirpath[dirpath.size()-1] != '\\' + && dirpath[dirpath.size()-1] != ':')) ? "\\*" : "*"; + + WIN32_FIND_DATAA data; + if ( (handle = ::FindFirstFileA( dirpath.c_str(), &data )) + == INVALID_HANDLE_VALUE ) + { + handle = 0; + return error_code( ::GetLastError() == ERROR_FILE_NOT_FOUND + ? 0 : ::GetLastError(), system_category ); + } + target = data.cFileName; + if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + { sf.type( directory_file ); symlink_sf.type( directory_file ); } + else { sf.type( regular_file ); symlink_sf.type( regular_file ); } + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_close( void *& handle ) + { + if ( handle != 0 ) + { + bool ok = ::FindClose( handle ) != 0; + handle = 0; + return error_code( ok ? 0 : ::GetLastError(), system_category ); + } + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_increment( void *& handle, std::string & target, + file_status & sf, file_status & symlink_sf ) + { + WIN32_FIND_DATAA data; + if ( ::FindNextFileA( handle, &data ) == 0 ) // fails + { + int error = ::GetLastError(); + dir_itr_close( handle ); + return error_code( error == ERROR_NO_MORE_FILES ? 0 : error, system_category ); + } + target = data.cFileName; + if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + { sf.type( directory_file ); symlink_sf.type( directory_file ); } + else { sf.type( regular_file ); symlink_sf.type( regular_file ); } + return ok; + } + +# else // BOOST_POSIX_API + + BOOST_FILESYSTEM_DECL fs::file_status + status_api( const std::string & ph, error_code & ec ) + { + struct stat path_stat; + if ( ::stat( ph.c_str(), &path_stat ) != 0 ) + { + if ( errno == ENOENT || errno == ENOTDIR ) + { + ec = ok; + return fs::file_status( fs::file_not_found ); + } + ec = error_code( errno, system_category ); + return fs::file_status( fs::status_unknown ); + } + ec = ok; + if ( S_ISDIR( path_stat.st_mode ) ) + return fs::file_status( fs::directory_file ); + if ( S_ISREG( path_stat.st_mode ) ) + return fs::file_status( fs::regular_file ); + if ( S_ISBLK( path_stat.st_mode ) ) + return fs::file_status( fs::block_file ); + if ( S_ISCHR( path_stat.st_mode ) ) + return fs::file_status( fs::character_file ); + if ( S_ISFIFO( path_stat.st_mode ) ) + return fs::file_status( fs::fifo_file ); + if ( S_ISSOCK( path_stat.st_mode ) ) + return fs::file_status( fs::socket_file ); + return fs::file_status( fs::type_unknown ); + } + + BOOST_FILESYSTEM_DECL fs::file_status + symlink_status_api( const std::string & ph, error_code & ec ) + { + struct stat path_stat; + if ( ::lstat( ph.c_str(), &path_stat ) != 0 ) + { + if ( errno == ENOENT || errno == ENOTDIR ) + { + ec = ok; + return fs::file_status( fs::file_not_found ); + } + ec = error_code( errno, system_category ); + return fs::file_status( fs::status_unknown ); + } + ec = ok; + if ( S_ISREG( path_stat.st_mode ) ) + return fs::file_status( fs::regular_file ); + if ( S_ISDIR( path_stat.st_mode ) ) + return fs::file_status( fs::directory_file ); + if ( S_ISLNK( path_stat.st_mode ) ) + return fs::file_status( fs::symlink_file ); + if ( S_ISBLK( path_stat.st_mode ) ) + return fs::file_status( fs::block_file ); + if ( S_ISCHR( path_stat.st_mode ) ) + return fs::file_status( fs::character_file ); + if ( S_ISFIFO( path_stat.st_mode ) ) + return fs::file_status( fs::fifo_file ); + if ( S_ISSOCK( path_stat.st_mode ) ) + return fs::file_status( fs::socket_file ); + return fs::file_status( fs::type_unknown ); + } + + // suggested by Walter Landry + BOOST_FILESYSTEM_DECL bool + symbolic_link_exists_api( const std::string & ph ) + { + struct stat path_stat; + return ::lstat( ph.c_str(), &path_stat ) == 0 + && S_ISLNK( path_stat.st_mode ); + } + + BOOST_FILESYSTEM_DECL query_pair + is_empty_api( const std::string & ph ) + { + struct stat path_stat; + if ( (::stat( ph.c_str(), &path_stat )) != 0 ) + return std::make_pair( error_code( errno, system_category ), false ); + return std::make_pair( ok, S_ISDIR( path_stat.st_mode ) + ? is_empty_directory( ph ) + : path_stat.st_size == 0 ); + } + + BOOST_FILESYSTEM_DECL query_pair + equivalent_api( const std::string & ph1, const std::string & ph2 ) + { + struct stat s2; + int e2( ::stat( ph2.c_str(), &s2 ) ); + struct stat s1; + int e1( ::stat( ph1.c_str(), &s1 ) ); + if ( e1 != 0 || e2 != 0 ) + return std::make_pair( error_code( e1 != 0 && e2 != 0 ? errno : 0, system_category ), false ); + // at this point, both stats are known to be valid + return std::make_pair( ok, + s1.st_dev == s2.st_dev + && s1.st_ino == s2.st_ino + // According to the POSIX stat specs, "The st_ino and st_dev fields + // taken together uniquely identify the file within the system." + // Just to be sure, size and mod time are also checked. + && s1.st_size == s2.st_size + && s1.st_mtime == s2.st_mtime ); + } + + BOOST_FILESYSTEM_DECL uintmax_pair + file_size_api( const std::string & ph ) + { + struct stat path_stat; + if ( ::stat( ph.c_str(), &path_stat ) != 0 ) + return std::make_pair( error_code( errno, system_category ), 0 ); + if ( !S_ISREG( path_stat.st_mode ) ) + return std::make_pair( error_code( EPERM, system_category ), 0 ); + return std::make_pair( ok, + static_cast<boost::uintmax_t>(path_stat.st_size) ); + } + + BOOST_FILESYSTEM_DECL space_pair + space_api( const std::string & ph ) + { + struct BOOST_STATVFS vfs; + space_pair result; + if ( ::BOOST_STATVFS( ph.c_str(), &vfs ) != 0 ) + { + result.first = error_code( errno, system_category ); + result.second.capacity = result.second.free + = result.second.available = 0; + } + else + { + result.first = ok; + result.second.capacity + = static_cast<boost::uintmax_t>(vfs.f_blocks) * BOOST_STATVFS_F_FRSIZE; + result.second.free + = static_cast<boost::uintmax_t>(vfs.f_bfree) * BOOST_STATVFS_F_FRSIZE; + result.second.available + = static_cast<boost::uintmax_t>(vfs.f_bavail) * BOOST_STATVFS_F_FRSIZE; + } + return result; + } + + BOOST_FILESYSTEM_DECL time_pair + last_write_time_api( const std::string & ph ) + { + struct stat path_stat; + if ( ::stat( ph.c_str(), &path_stat ) != 0 ) + return std::make_pair( error_code( errno, system_category ), 0 ); + return std::make_pair( ok, path_stat.st_mtime ); + } + + BOOST_FILESYSTEM_DECL error_code + last_write_time_api( const std::string & ph, std::time_t new_value ) + { + struct stat path_stat; + if ( ::stat( ph.c_str(), &path_stat ) != 0 ) + return error_code( errno, system_category ); + ::utimbuf buf; + buf.actime = path_stat.st_atime; // utime() updates access time too:-( + buf.modtime = new_value; + return error_code( ::utime( ph.c_str(), &buf ) != 0 ? errno : 0, system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + get_current_path_api( std::string & ph ) + { + for ( long path_max = 32;; path_max *=2 ) // loop 'til buffer large enough + { + boost::scoped_array<char> + buf( new char[static_cast<std::size_t>(path_max)] ); + if ( ::getcwd( buf.get(), static_cast<std::size_t>(path_max) ) == 0 ) + { + if ( errno != ERANGE + // bug in some versions of the Metrowerks C lib on the Mac: wrong errno set +# if defined(__MSL__) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) + && errno != 0 +# endif + ) return error_code( errno, system_category ); + } + else + { + ph = buf.get(); + break; + } + } + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + set_current_path_api( const std::string & ph ) + { + return error_code( ::chdir( ph.c_str() ) + ? errno : 0, system_category ); + } + + BOOST_FILESYSTEM_DECL fs::detail::query_pair + create_directory_api( const std::string & ph ) + { + if ( ::mkdir( ph.c_str(), S_IRWXU|S_IRWXG|S_IRWXO ) == 0 ) + { return std::make_pair( ok, true ); } + int ec=errno; + error_code dummy; + if ( ec != EEXIST + || !fs::is_directory( status_api( ph, dummy ) ) ) + { return std::make_pair( error_code( ec, system_category ), false ); } + return std::make_pair( ok, false ); + } + + BOOST_FILESYSTEM_DECL error_code + create_hard_link_api( const std::string & to_ph, + const std::string & from_ph ) + { + return error_code( ::link( to_ph.c_str(), from_ph.c_str() ) == 0 + ? 0 : errno, system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + create_symlink_api( const std::string & to_ph, + const std::string & from_ph ) + { + return error_code( ::symlink( to_ph.c_str(), from_ph.c_str() ) == 0 + ? 0 : errno, system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + remove_api( const std::string & ph ) + { + if ( posix_remove( ph.c_str() ) == 0 ) + return ok; + int error = errno; + // POSIX says "If the directory is not an empty directory, rmdir() + // shall fail and set errno to EEXIST or ENOTEMPTY." + // Linux uses ENOTEMPTY, Solaris uses EEXIST. + if ( error == EEXIST ) error = ENOTEMPTY; + + error_code ec; + + // ignore errors if post-condition satisfied + return status_api(ph, ec).type() == file_not_found + ? ok : error_code( error, system_category ) ; + } + + BOOST_FILESYSTEM_DECL error_code + rename_api( const std::string & from, const std::string & to ) + { + // POSIX is too permissive so must check + error_code dummy; + if ( fs::exists( status_api( to, dummy ) ) ) + return error_code( EEXIST, system_category ); + return error_code( std::rename( from.c_str(), to.c_str() ) != 0 + ? errno : 0, system_category ); + } + + BOOST_FILESYSTEM_DECL error_code + copy_file_api( const std::string & from_file_ph, + const std::string & to_file_ph ) + { + const std::size_t buf_sz = 32768; + boost::scoped_array<char> buf( new char [buf_sz] ); + int infile=-1, outfile=-1; // -1 means not open + struct stat from_stat; + + if ( ::stat( from_file_ph.c_str(), &from_stat ) != 0 + || (infile = ::open( from_file_ph.c_str(), + O_RDONLY )) < 0 + || (outfile = ::open( to_file_ph.c_str(), + O_WRONLY | O_CREAT | O_EXCL, + from_stat.st_mode )) < 0 ) + { + if ( infile >= 0 ) ::close( infile ); + return error_code( errno, system_category ); + } + + ssize_t sz, sz_read=1, sz_write; + while ( sz_read > 0 + && (sz_read = ::read( infile, buf.get(), buf_sz )) > 0 ) + { + // Allow for partial writes - see Advanced Unix Programming (2nd Ed.), + // Marc Rochkind, Addison-Wesley, 2004, page 94 + sz_write = 0; + do + { + if ( (sz = ::write( outfile, buf.get() + sz_write, + sz_read - sz_write )) < 0 ) + { + sz_read = sz; // cause read loop termination + break; // and error to be thrown after closes + } + sz_write += sz; + } while ( sz_write < sz_read ); + } + + if ( ::close( infile) < 0 ) sz_read = -1; + if ( ::close( outfile) < 0 ) sz_read = -1; + + return error_code( sz_read < 0 ? errno : 0, system_category ); + } + + // this code is based on Stevens and Rago, Advanced Programming in the + // UNIX envirnment, 2nd Ed., ISBN 0-201-43307-9, page 49 + error_code path_max( std::size_t & result ) + { +# ifdef PATH_MAX + static std::size_t max = PATH_MAX; +# else + static std::size_t max = 0; +# endif + if ( max == 0 ) + { + errno = 0; + long tmp = ::pathconf( "/", _PC_NAME_MAX ); + if ( tmp < 0 ) + { + if ( errno == 0 ) // indeterminate + max = 4096; // guess + else return error_code( errno, system_category ); + } + else max = static_cast<std::size_t>( tmp + 1 ); // relative root + } + result = max; + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_first( void *& handle, void *& buffer, + const std::string & dir, std::string & target, + file_status &, file_status & ) + { + if ( (handle = ::opendir( dir.c_str() )) == 0 ) + return error_code( errno, system_category ); + target = std::string( "." ); // string was static but caused trouble + // when iteration called from dtor, after + // static had already been destroyed + std::size_t path_size; + error_code ec = path_max( path_size ); + if ( ec ) return ec; + dirent de; + buffer = std::malloc( (sizeof(dirent) - sizeof(de.d_name)) + + path_size + 1 ); // + 1 for "/0" + return ok; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_close( void *& handle, void*& buffer ) + { + std::free( buffer ); + buffer = 0; + if ( handle == 0 ) return ok; + DIR * h( static_cast<DIR*>(handle) ); + handle = 0; + return error_code( ::closedir( h ) == 0 ? 0 : errno, system_category ); + } + + // warning: the only dirent member updated is d_name + inline int readdir_r_simulator( DIR * dirp, struct dirent * entry, + struct dirent ** result ) // *result set to 0 on end of directory + { + errno = 0; + + # if !defined(__CYGWIN__) \ + && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ + && defined(_SC_THREAD_SAFE_FUNCTIONS) \ + && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0) \ + && (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT))) + if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) >= 0 ) + { return ::readdir_r( dirp, entry, result ); } + # endif + + struct dirent * p; + *result = 0; + if ( (p = ::readdir( dirp )) == 0 ) + return errno; + std::strcpy( entry->d_name, p->d_name ); + *result = entry; + return 0; + } + + BOOST_FILESYSTEM_DECL error_code + dir_itr_increment( void *& handle, void *& buffer, + std::string & target, file_status & sf, file_status & symlink_sf ) + { + BOOST_ASSERT( buffer != 0 ); + dirent * entry( static_cast<dirent *>(buffer) ); + dirent * result; + int return_code; + if ( (return_code = readdir_r_simulator( static_cast<DIR*>(handle), + entry, &result )) != 0 ) return error_code( errno, system_category ); + if ( result == 0 ) return dir_itr_close( handle, buffer ); + target = entry->d_name; +# ifdef BOOST_FILESYSTEM_STATUS_CACHE + if ( entry->d_type == DT_UNKNOWN ) // filesystem does not supply d_type value + { + sf = symlink_sf = fs::file_status(fs::status_unknown); + } + else // filesystem supplies d_type value + { + if ( entry->d_type == DT_DIR ) + sf = symlink_sf = fs::file_status( fs::directory_file ); + else if ( entry->d_type == DT_REG ) + sf = symlink_sf = fs::file_status( fs::regular_file ); + else if ( entry->d_type == DT_LNK ) + { + sf = fs::file_status( fs::status_unknown ); + symlink_sf = fs::file_status( fs::symlink_file ); + } + else sf = symlink_sf = fs::file_status( fs::status_unknown ); + } +# else + sf = symlink_sf = fs::file_status( fs::status_unknown ); +# endif + return ok; + } + +# endif + } // namespace detail + } // namespace filesystem +} // namespace boost diff --git a/3rdParty/Boost/src/libs/filesystem/src/path.cpp b/3rdParty/Boost/src/libs/filesystem/src/path.cpp new file mode 100644 index 0000000..6d7d40c --- /dev/null +++ b/3rdParty/Boost/src/libs/filesystem/src/path.cpp @@ -0,0 +1,163 @@ +// path.cpp ----------------------------------------------------------------// + +// Copyright 2005 Beman Dawes + +// Distributed under the 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/filesystem + +//----------------------------------------------------------------------------// + +// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_FILESYSTEM_SOURCE + +#include <boost/filesystem/config.hpp> + +#ifndef BOOST_FILESYSTEM_NARROW_ONLY + +#include <boost/filesystem/path.hpp> +#include <boost/scoped_array.hpp> + +#include <locale> +#include <boost/cerrno.hpp> +#include <boost/system/error_code.hpp> + +#include <cwchar> // for std::mbstate_t + +namespace +{ + // std::locale construction can throw (if LC_MESSAGES is wrong, for example), + // so a static at function scope is used to ensure that exceptions can be + // caught. (A previous version was at namespace scope, so initialization + // occurred before main(), preventing exceptions from being caught.) + std::locale & loc() + { +#if !defined(macintosh) && !defined(__APPLE__) && !defined(__APPLE_CC__) + // ISO C calls this "the locale-specific native environment": + static std::locale lc(""); +#else + static std::locale lc = std::locale(); // Mac OS doesn't support locale("") +#endif + return lc; + } + + const std::codecvt<wchar_t, char, std::mbstate_t> *& + converter() + { + static const std::codecvt<wchar_t, char, std::mbstate_t> * + cvtr( + &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> > + ( loc() ) ); + return cvtr; + } + + bool locked(false); +} // unnamed namespace + +namespace boost +{ + namespace filesystem + { + bool wpath_traits::imbue( const std::locale & new_loc, const std::nothrow_t & ) + { + if ( locked ) return false; + locked = true; + loc() = new_loc; + converter() = &std::use_facet + <std::codecvt<wchar_t, char, std::mbstate_t> >( loc() ); + return true; + } + + void wpath_traits::imbue( const std::locale & new_loc ) + { + if ( locked ) boost::throw_exception( + wfilesystem_error( + "boost::filesystem::wpath_traits::imbue() after lockdown", + make_error_code( system::posix::not_supported ) ) ); + imbue( new_loc, std::nothrow ); + } + + //namespace detail + //{ + // BOOST_FILESYSTEM_DECL + // const char * what( const char * sys_err_what, + // const path & path1, const path & path2, std::string & target) + // { + // try + // { + // if ( target.empty() ) + // { + // target = sys_err_what; + // if ( !path1.empty() ) + // { + // target += ": \""; + // target += path1.file_string(); + // target += "\""; + // } + // if ( !path2.empty() ) + // { + // target += ", \""; + // target += path2.file_string(); + // target += "\""; + // } + // } + // return target.c_str(); + // } + // catch (...) + // { + // return sys_err_what; + // } + // } + //} + +# ifdef BOOST_POSIX_API + +// Because this is POSIX only code, we don't have to worry about ABI issues +// described in http://www.boost.org/more/separate_compilation.html + + wpath_traits::external_string_type + wpath_traits::to_external( const wpath & ph, + const internal_string_type & src ) + { + locked = true; + std::size_t work_size( converter()->max_length() * (src.size()+1) ); + boost::scoped_array<char> work( new char[ work_size ] ); + std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports + const internal_string_type::value_type * from_next; + external_string_type::value_type * to_next; + if ( converter()->out( + state, src.c_str(), src.c_str()+src.size(), from_next, work.get(), + work.get()+work_size, to_next ) != std::codecvt_base::ok ) + boost::throw_exception( boost::filesystem::wfilesystem_error( + "boost::filesystem::wpath::to_external conversion error", + ph, system::error_code( system::posix::invalid_argument, system::system_category ) ) ); + *to_next = '\0'; + return external_string_type( work.get() ); + } + + wpath_traits::internal_string_type + wpath_traits::to_internal( const external_string_type & src ) + { + locked = true; + std::size_t work_size( src.size()+1 ); + boost::scoped_array<wchar_t> work( new wchar_t[ work_size ] ); + std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports + const external_string_type::value_type * from_next; + internal_string_type::value_type * to_next; + if ( converter()->in( + state, src.c_str(), src.c_str()+src.size(), from_next, work.get(), + work.get()+work_size, to_next ) != std::codecvt_base::ok ) + boost::throw_exception( boost::filesystem::wfilesystem_error( + "boost::filesystem::wpath::to_internal conversion error", + system::error_code( system::posix::invalid_argument, system::system_category ) ) ); + *to_next = L'\0'; + return internal_string_type( work.get() ); + } +# endif // BOOST_POSIX_API + + } // namespace filesystem +} // namespace boost + +#endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY diff --git a/3rdParty/Boost/src/libs/filesystem/src/portability.cpp b/3rdParty/Boost/src/libs/filesystem/src/portability.cpp new file mode 100644 index 0000000..347180a --- /dev/null +++ b/3rdParty/Boost/src/libs/filesystem/src/portability.cpp @@ -0,0 +1,115 @@ +// portability.cpp ---------------------------------------------------------// + +// Copyright 2002-2005 Beman Dawes +// 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/filesystem + +//----------------------------------------------------------------------------// + +// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_FILESYSTEM_SOURCE + +#include <boost/filesystem/config.hpp> +#include <boost/filesystem/path.hpp> + +namespace fs = boost::filesystem; + +#include <cstring> // SGI MIPSpro compilers need this + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::strerror; } +# endif + +//----------------------------------------------------------------------------// + +namespace +{ + const char invalid_chars[] = + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F" + "<>:\"/\\|"; + // note that the terminating '\0' is part of the string - thus the size below + // is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I + const std::string windows_invalid_chars( invalid_chars, sizeof(invalid_chars) ); + + const std::string valid_posix( + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-" ); + +} // unnamed namespace + +namespace boost +{ + namespace filesystem + { + + // name_check functions ----------------------------------------------// + +# ifdef BOOST_WINDOWS + BOOST_FILESYSTEM_DECL bool native( const std::string & name ) + { + return windows_name( name ); + } +# else + BOOST_FILESYSTEM_DECL bool native( const std::string & name ) + { + return name.size() != 0 + && name[0] != ' ' + && name.find('/') == std::string::npos; + } +# endif + + BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name ) + { + return name.size() != 0 + && name.find_first_not_of( valid_posix ) == std::string::npos; + } + + BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name ) + { + return name.size() != 0 + && name[0] != ' ' + && name.find_first_of( windows_invalid_chars ) == std::string::npos + && *(name.end()-1) != ' ' + && (*(name.end()-1) != '.' + || name.length() == 1 || name == ".."); + } + + BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name ) + { + return + name.size() != 0 + && ( name == "." + || name == ".." + || (windows_name( name ) + && portable_posix_name( name ) + && name[0] != '.' && name[0] != '-')); + } + + BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name ) + { + return + name == "." + || name == ".." + || (portable_name( name ) + && name.find('.') == std::string::npos); + } + + BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name ) + { + std::string::size_type pos; + return + portable_name( name ) + && name != "." + && name != ".." + && ( (pos = name.find( '.' )) == std::string::npos + || (name.find( '.', pos+1 ) == std::string::npos + && (pos + 5) > name.length() )) + ; + } + + } // namespace filesystem +} // namespace boost diff --git a/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.cpp b/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.cpp new file mode 100644 index 0000000..3fe3e95 --- /dev/null +++ b/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.cpp @@ -0,0 +1,20 @@ +// Copyright Vladimir Prus 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) + +#define BOOST_FILESYSTEM_SOURCE +#include <boost/filesystem/config.hpp> + +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace filesystem { namespace detail { + +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL + +#include "libs/detail/utf8_codecvt_facet.cpp" + + +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL diff --git a/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.hpp b/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.hpp new file mode 100644 index 0000000..3b78fb1 --- /dev/null +++ b/3rdParty/Boost/src/libs/filesystem/src/utf8_codecvt_facet.hpp @@ -0,0 +1,24 @@ +// 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 http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP +#define BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP + +#include <boost/filesystem/config.hpp> + +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace filesystem { namespace detail { + +#define BOOST_UTF8_END_NAMESPACE }}} +#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL + +#include <boost/detail/utf8_codecvt_facet.hpp> + +#undef BOOST_UTF8_BEGIN_NAMESPACE +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL + +#endif diff --git a/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp new file mode 100644 index 0000000..da960eb --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/c_regex_traits.cpp @@ -0,0 +1,206 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: c_regex_traits.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements out of line c_regex_traits<char> members + */ + + +#define BOOST_REGEX_SOURCE + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) + +#include <boost/regex/v4/c_regex_traits.hpp> +#include <boost/regex/v4/primary_transform.hpp> +#include <boost/regex/v4/regex_traits_defaults.hpp> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::strxfrm; using ::isspace; + using ::ispunct; using ::isalpha; + using ::isalnum; using ::iscntrl; + using ::isprint; using ::isupper; + using ::islower; using ::isdigit; + using ::isxdigit; using ::strtol; +} +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost{ + +c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2) +{ + std::string result(10, ' '); + std::size_t s = result.size(); + std::size_t r; + std::string src(p1, p2); + while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), s))) + { + result.append(r - s + 3, ' '); + s = result.size(); + } + result.erase(r); + return result; +} + +c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform_primary(const char* p1, const char* p2) +{ + static char s_delim; + static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast<c_regex_traits<char>*>(0), &s_delim); + std::string result; + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(s_collate_type) + { + case ::boost::re_detail::sort_C: + case ::boost::re_detail::sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + for(std::string::size_type i = 0; i < result.size(); ++i) + result[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(result[i]))); + result = transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case ::boost::re_detail::sort_fixed: + { + // get a regular sort key, and then truncate it: + result = transform(p1, p2); + result.erase(s_delim); + break; + } + case ::boost::re_detail::sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result = transform(p1, p2); + if(result.size() && (result[0] == s_delim)) + break; + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == s_delim) + break; + } + result.erase(i); + break; + } + if(result.empty()) + result = std::string(1, char(0)); + return result; +} + +enum +{ + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11 +}; + +c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_classname(const char* p1, const char* p2) +{ + static const char_class_type masks[] = + { + 0, + char_class_alnum, + char_class_alpha, + char_class_blank, + char_class_cntrl, + char_class_digit, + char_class_digit, + char_class_graph, + char_class_lower, + char_class_lower, + char_class_print, + char_class_punct, + char_class_space, + char_class_space, + char_class_upper, + char_class_unicode, + char_class_upper, + char_class_alnum | char_class_word, + char_class_alnum | char_class_word, + char_class_xdigit, + }; + + int id = ::boost::re_detail::get_default_class_id(p1, p2); + if(id < 0) + { + std::string s(p1, p2); + for(std::string::size_type i = 0; i < s.size(); ++i) + s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i]))); + id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); + } + BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); + return masks[id+1]; +} + +bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask) +{ + return + ((mask & char_class_space) && (std::isspace)(static_cast<unsigned char>(c))) + || ((mask & char_class_print) && (std::isprint)(static_cast<unsigned char>(c))) + || ((mask & char_class_cntrl) && (std::iscntrl)(static_cast<unsigned char>(c))) + || ((mask & char_class_upper) && (std::isupper)(static_cast<unsigned char>(c))) + || ((mask & char_class_lower) && (std::islower)(static_cast<unsigned char>(c))) + || ((mask & char_class_alpha) && (std::isalpha)(static_cast<unsigned char>(c))) + || ((mask & char_class_digit) && (std::isdigit)(static_cast<unsigned char>(c))) + || ((mask & char_class_punct) && (std::ispunct)(static_cast<unsigned char>(c))) + || ((mask & char_class_xdigit) && (std::isxdigit)(static_cast<unsigned char>(c))) + || ((mask & char_class_blank) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::re_detail::is_separator(c)) + || ((mask & char_class_word) && (c == '_')); +} + +c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::lookup_collatename(const char* p1, const char* p2) +{ + std::string s(p1, p2); + s = ::boost::re_detail::lookup_default_collate_name(s); + if(s.empty() && (p2-p1 == 1)) + s.append(1, *p1); + return s; +} + +int BOOST_REGEX_CALL c_regex_traits<char>::value(char c, int radix) +{ + char b[2] = { c, '\0', }; + char* ep; + int result = std::strtol(b, &ep, radix); + if(ep == b) + return -1; + return result; +} + +} +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#endif diff --git a/3rdParty/Boost/src/libs/regex/src/cpp_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/cpp_regex_traits.cpp new file mode 100644 index 0000000..9ed66be --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/cpp_regex_traits.cpp @@ -0,0 +1,117 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE cpp_regex_traits.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Implements cpp_regex_traits<char> (and associated helper classes). + */ + +#define BOOST_REGEX_SOURCE +#include <boost/config.hpp> +#ifndef BOOST_NO_STD_LOCALE +#include <boost/regex/regex_traits.hpp> +#include <boost/regex/pattern_except.hpp> + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::memset; +} +#endif + +namespace boost{ namespace re_detail{ + +void cpp_regex_traits_char_layer<char>::init() +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + std::memset(m_char_map, 0, sizeof(m_char_map)); +#ifndef BOOST_NO_STD_MESSAGES +#ifndef __IBMCPP__ + std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1); +#else + std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1); +#endif + std::string cat_name(cpp_regex_traits<char>::get_catalog_name()); + if(cat_name.size()) + { + cat = this->m_pmessages->open( + cat_name, + this->m_locale); + if((int)cat < 0) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if((int)cat >= 0) + { +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i)); + for(string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[static_cast<unsigned char>(mss[j])] = i; + } + } + this->m_pmessages->close(cat); +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + this->m_pmessages->close(cat); + throw; + } +#endif + } + else + { +#endif + for(regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j) + { + const char* ptr = get_default_syntax(j); + while(ptr && *ptr) + { + m_char_map[static_cast<unsigned char>(*ptr)] = j; + ++ptr; + } + } +#ifndef BOOST_NO_STD_MESSAGES + } +#endif + // + // finish off by calculating our escape types: + // + unsigned char i = 'A'; + do + { + if(m_char_map[i] == 0) + { + if(this->m_pctype->is(std::ctype_base::lower, i)) + m_char_map[i] = regex_constants::escape_type_class; + else if(this->m_pctype->is(std::ctype_base::upper, i)) + m_char_map[i] = regex_constants::escape_type_not_class; + } + }while(0xFF != i++); +} + +} // re_detail +} // boost +#endif + diff --git a/3rdParty/Boost/src/libs/regex/src/cregex.cpp b/3rdParty/Boost/src/libs/regex/src/cregex.cpp new file mode 100644 index 0000000..fb12373 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/cregex.cpp @@ -0,0 +1,648 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: cregex.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements high level class boost::RexEx + */ + + +#define BOOST_REGEX_SOURCE + +#include <boost/regex.hpp> +#include <boost/cregex.hpp> +#if !defined(BOOST_NO_STD_STRING) +#include <map> +#include <list> +#include <boost/regex/v4/fileiter.hpp> +typedef boost::match_flag_type match_flag_type; +#include <cstdio> + +#ifdef BOOST_MSVC +#pragma warning(disable:4309) +#endif + +namespace boost{ + +#ifdef __BORLANDC__ +#if __BORLANDC__ < 0x530 +// +// we need to instantiate the vector classes we use +// since declaring a reference to type doesn't seem to +// do the job... +std::vector<std::size_t> inst1; +std::vector<std::string> inst2; +#endif +#endif + +namespace{ + +template <class iterator> +std::string to_string(iterator i, iterator j) +{ + std::string s; + while(i != j) + { + s.append(1, *i); + ++i; + } + return s; +} + +inline std::string to_string(const char* i, const char* j) +{ + return std::string(i, j); +} + +} +namespace re_detail{ + +class RegExData +{ +public: + enum type + { + type_pc, + type_pf, + type_copy + }; + regex e; + cmatch m; +#ifndef BOOST_REGEX_NO_FILEITER + match_results<mapfile::iterator> fm; +#endif + type t; + const char* pbase; +#ifndef BOOST_REGEX_NO_FILEITER + mapfile::iterator fbase; +#endif + std::map<int, std::string, std::less<int> > strings; + std::map<int, std::ptrdiff_t, std::less<int> > positions; + void update(); + void clean(); + RegExData() : e(), m(), +#ifndef BOOST_REGEX_NO_FILEITER + fm(), +#endif + t(type_copy), pbase(0), +#ifndef BOOST_REGEX_NO_FILEITER + fbase(), +#endif + strings(), positions() {} +}; + +void RegExData::update() +{ + strings.erase(strings.begin(), strings.end()); + positions.erase(positions.begin(), positions.end()); + if(t == type_pc) + { + for(unsigned int i = 0; i < m.size(); ++i) + { + if(m[i].matched) strings[i] = std::string(m[i].first, m[i].second); + positions[i] = m[i].matched ? m[i].first - pbase : -1; + } + } +#ifndef BOOST_REGEX_NO_FILEITER + else + { + for(unsigned int i = 0; i < fm.size(); ++i) + { + if(fm[i].matched) strings[i] = to_string(fm[i].first, fm[i].second); + positions[i] = fm[i].matched ? fm[i].first - fbase : -1; + } + } +#endif + t = type_copy; +} + +void RegExData::clean() +{ +#ifndef BOOST_REGEX_NO_FILEITER + fbase = mapfile::iterator(); + fm = match_results<mapfile::iterator>(); +#endif +} + +} // namespace + +RegEx::RegEx() +{ + pdata = new re_detail::RegExData(); +} + +RegEx::RegEx(const RegEx& o) +{ + pdata = new re_detail::RegExData(*(o.pdata)); +} + +RegEx::~RegEx() +{ + delete pdata; +} + +RegEx::RegEx(const char* c, bool icase) +{ + pdata = new re_detail::RegExData(); + SetExpression(c, icase); +} + +RegEx::RegEx(const std::string& s, bool icase) +{ + pdata = new re_detail::RegExData(); + SetExpression(s.c_str(), icase); +} + +RegEx& RegEx::operator=(const RegEx& o) +{ + *pdata = *(o.pdata); + return *this; +} + +RegEx& RegEx::operator=(const char* p) +{ + SetExpression(p, false); + return *this; +} + +unsigned int RegEx::SetExpression(const char* p, bool icase) +{ + boost::uint_fast32_t f = icase ? regex::normal | regex::icase : regex::normal; + return pdata->e.set_expression(p, f); +} + +unsigned int RegEx::error_code()const +{ + return pdata->e.error_code(); +} + + +std::string RegEx::Expression()const +{ + return pdata->e.expression(); +} + +// +// now matching operators: +// +bool RegEx::Match(const char* p, match_flag_type flags) +{ + pdata->t = re_detail::RegExData::type_pc; + pdata->pbase = p; + const char* end = p; + while(*end)++end; + + if(regex_match(p, end, pdata->m, pdata->e, flags)) + { + pdata->update(); + return true; + } + return false; +} + +bool RegEx::Search(const char* p, match_flag_type flags) +{ + pdata->t = re_detail::RegExData::type_pc; + pdata->pbase = p; + const char* end = p; + while(*end)++end; + + if(regex_search(p, end, pdata->m, pdata->e, flags)) + { + pdata->update(); + return true; + } + return false; +} +namespace re_detail{ +struct pred1 +{ + GrepCallback cb; + RegEx* pe; + pred1(GrepCallback c, RegEx* i) : cb(c), pe(i) {} + bool operator()(const cmatch& m) + { + pe->pdata->m = m; + return cb(*pe); + } +}; +} +unsigned int RegEx::Grep(GrepCallback cb, const char* p, match_flag_type flags) +{ + pdata->t = re_detail::RegExData::type_pc; + pdata->pbase = p; + const char* end = p; + while(*end)++end; + + unsigned int result = regex_grep(re_detail::pred1(cb, this), p, end, pdata->e, flags); + if(result) + pdata->update(); + return result; +} +namespace re_detail{ +struct pred2 +{ + std::vector<std::string>& v; + RegEx* pe; + pred2(std::vector<std::string>& o, RegEx* e) : v(o), pe(e) {} + bool operator()(const cmatch& m) + { + pe->pdata->m = m; + v.push_back(std::string(m[0].first, m[0].second)); + return true; + } +private: + pred2& operator=(const pred2&); +}; +} + +unsigned int RegEx::Grep(std::vector<std::string>& v, const char* p, match_flag_type flags) +{ + pdata->t = re_detail::RegExData::type_pc; + pdata->pbase = p; + const char* end = p; + while(*end)++end; + + unsigned int result = regex_grep(re_detail::pred2(v, this), p, end, pdata->e, flags); + if(result) + pdata->update(); + return result; +} +namespace re_detail{ +struct pred3 +{ + std::vector<std::size_t>& v; + const char* base; + RegEx* pe; + pred3(std::vector<std::size_t>& o, const char* pb, RegEx* p) : v(o), base(pb), pe(p) {} + bool operator()(const cmatch& m) + { + pe->pdata->m = m; + v.push_back(static_cast<std::size_t>(m[0].first - base)); + return true; + } +private: + pred3& operator=(const pred3&); +}; +} +unsigned int RegEx::Grep(std::vector<std::size_t>& v, const char* p, match_flag_type flags) +{ + pdata->t = re_detail::RegExData::type_pc; + pdata->pbase = p; + const char* end = p; + while(*end)++end; + + unsigned int result = regex_grep(re_detail::pred3(v, p, this), p, end, pdata->e, flags); + if(result) + pdata->update(); + return result; +} +#ifndef BOOST_REGEX_NO_FILEITER +namespace re_detail{ +struct pred4 +{ + GrepFileCallback cb; + RegEx* pe; + const char* file; + bool ok; + pred4(GrepFileCallback c, RegEx* i, const char* f) : cb(c), pe(i), file(f), ok(true) {} + bool operator()(const match_results<mapfile::iterator>& m) + { + pe->pdata->t = RegExData::type_pf; + pe->pdata->fm = m; + pe->pdata->update(); + ok = cb(file, *pe); + return ok; + } +}; +} +namespace{ +void BuildFileList(std::list<std::string>* pl, const char* files, bool recurse) +{ + file_iterator start(files); + file_iterator end; + if(recurse) + { + // go through sub directories: + char buf[MAX_PATH]; + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, start.root())); + if(*buf == 0) + { + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(buf, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator())); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*")); + } + else + { + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, directory_iterator::separator())); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(buf, MAX_PATH, "*")); + } + directory_iterator dstart(buf); + directory_iterator dend; + + // now get the file mask bit of "files": + const char* ptr = files; + while(*ptr) ++ptr; + while((ptr != files) && (*ptr != *directory_iterator::separator()) && (*ptr != '/'))--ptr; + if(ptr != files) ++ptr; + + while(dstart != dend) + { +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); +#else + (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); +#endif + BuildFileList(pl, buf, recurse); + ++dstart; + } + } + while(start != end) + { + pl->push_back(*start); + ++start; + } +} +} + +unsigned int RegEx::GrepFiles(GrepFileCallback cb, const char* files, bool recurse, match_flag_type flags) +{ + unsigned int result = 0; + std::list<std::string> file_list; + BuildFileList(&file_list, files, recurse); + std::list<std::string>::iterator start, end; + start = file_list.begin(); + end = file_list.end(); + + while(start != end) + { + mapfile map((*start).c_str()); + pdata->t = re_detail::RegExData::type_pf; + pdata->fbase = map.begin(); + re_detail::pred4 pred(cb, this, (*start).c_str()); + int r = regex_grep(pred, map.begin(), map.end(), pdata->e, flags); + result += r; + ++start; + pdata->clean(); + if(pred.ok == false) + return result; + } + + return result; +} + + +unsigned int RegEx::FindFiles(FindFilesCallback cb, const char* files, bool recurse, match_flag_type flags) +{ + unsigned int result = 0; + std::list<std::string> file_list; + BuildFileList(&file_list, files, recurse); + std::list<std::string>::iterator start, end; + start = file_list.begin(); + end = file_list.end(); + + while(start != end) + { + mapfile map((*start).c_str()); + pdata->t = re_detail::RegExData::type_pf; + pdata->fbase = map.begin(); + + if(regex_search(map.begin(), map.end(), pdata->fm, pdata->e, flags)) + { + ++result; + if(false == cb((*start).c_str())) + return result; + } + //pdata->update(); + ++start; + //pdata->clean(); + } + + return result; +} +#endif + +#ifdef BOOST_REGEX_V3 +#define regex_replace regex_merge +#endif + +std::string RegEx::Merge(const std::string& in, const std::string& fmt, + bool copy, match_flag_type flags) +{ + std::string result; + re_detail::string_out_iterator<std::string> i(result); + if(!copy) flags |= format_no_copy; + regex_replace(i, in.begin(), in.end(), pdata->e, fmt.c_str(), flags); + return result; +} + +std::string RegEx::Merge(const char* in, const char* fmt, + bool copy, match_flag_type flags) +{ + std::string result; + if(!copy) flags |= format_no_copy; + re_detail::string_out_iterator<std::string> i(result); + regex_replace(i, in, in + std::strlen(in), pdata->e, fmt, flags); + return result; +} + +std::size_t RegEx::Split(std::vector<std::string>& v, + std::string& s, + match_flag_type flags, + unsigned max_count) +{ + return regex_split(std::back_inserter(v), s, pdata->e, flags, max_count); +} + + + +// +// now operators for returning what matched in more detail: +// +std::size_t RegEx::Position(int i)const +{ + switch(pdata->t) + { + case re_detail::RegExData::type_pc: + return pdata->m[i].matched ? pdata->m[i].first - pdata->pbase : RegEx::npos; +#ifndef BOOST_REGEX_NO_FILEITER + case re_detail::RegExData::type_pf: + return pdata->fm[i].matched ? pdata->fm[i].first - pdata->fbase : RegEx::npos; +#endif + case re_detail::RegExData::type_copy: + { + std::map<int, std::ptrdiff_t, std::less<int> >::iterator pos = pdata->positions.find(i); + if(pos == pdata->positions.end()) + return RegEx::npos; + return (*pos).second; + } + } + return RegEx::npos; +} + +std::size_t RegEx::Marks()const +{ + return pdata->e.mark_count(); +} + + +std::size_t RegEx::Length(int i)const +{ + switch(pdata->t) + { + case re_detail::RegExData::type_pc: + return pdata->m[i].matched ? pdata->m[i].second - pdata->m[i].first : RegEx::npos; +#ifndef BOOST_REGEX_NO_FILEITER + case re_detail::RegExData::type_pf: + return pdata->fm[i].matched ? pdata->fm[i].second - pdata->fm[i].first : RegEx::npos; +#endif + case re_detail::RegExData::type_copy: + { + std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i); + if(pos == pdata->strings.end()) + return RegEx::npos; + return (*pos).second.size(); + } + } + return RegEx::npos; +} + +bool RegEx::Matched(int i)const +{ + switch(pdata->t) + { + case re_detail::RegExData::type_pc: + return pdata->m[i].matched; +#ifndef BOOST_REGEX_NO_FILEITER + case re_detail::RegExData::type_pf: + return pdata->fm[i].matched; +#endif + case re_detail::RegExData::type_copy: + { + std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i); + if(pos == pdata->strings.end()) + return false; + return true; + } + } + return false; +} + + +std::string RegEx::What(int i)const +{ + std::string result; + switch(pdata->t) + { + case re_detail::RegExData::type_pc: + if(pdata->m[i].matched) + result.assign(pdata->m[i].first, pdata->m[i].second); + break; + case re_detail::RegExData::type_pf: + if(pdata->m[i].matched) + result.assign(to_string(pdata->m[i].first, pdata->m[i].second)); + break; + case re_detail::RegExData::type_copy: + { + std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i); + if(pos != pdata->strings.end()) + result = (*pos).second; + break; + } + } + return result; +} + +#ifdef BOOST_HAS_LONG_LONG +const std::size_t RegEx::npos = static_cast<std::size_t>(~0ULL); +#else +const std::size_t RegEx::npos = static_cast<std::size_t>(~0UL); +#endif + +} // namespace boost + +#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x550) && (__BORLANDC__ <= 0x551) && !defined(_RWSTD_COMPILE_INSTANTIATE) +// +// this is an ugly hack to work around an ugly problem: +// by default this file will produce unresolved externals during +// linking unless _RWSTD_COMPILE_INSTANTIATE is defined (Borland bug). +// However if _RWSTD_COMPILE_INSTANTIATE is defined then we get separate +// copies of basic_string's static data in the RTL and this DLL, this messes +// with basic_string's memory management and results in run-time crashes, +// Oh sweet joy of Catch 22.... +// +namespace std{ +template<> template<> +basic_string<char>& BOOST_REGEX_DECL +basic_string<char>::replace<const char*>(char* f1, char* f2, const char* i1, const char* i2) +{ + unsigned insert_pos = f1 - begin(); + unsigned remove_len = f2 - f1; + unsigned insert_len = i2 - i1; + unsigned org_size = size(); + if(insert_len > remove_len) + { + append(insert_len-remove_len, ' '); + std::copy_backward(begin() + insert_pos + remove_len, begin() + org_size, end()); + std::copy(i1, i2, begin() + insert_pos); + } + else + { + std::copy(begin() + insert_pos + remove_len, begin() + org_size, begin() + insert_pos + insert_len); + std::copy(i1, i2, begin() + insert_pos); + erase(size() + insert_len - remove_len); + } + return *this; +} +template<> template<> +basic_string<wchar_t>& BOOST_REGEX_DECL +basic_string<wchar_t>::replace<const wchar_t*>(wchar_t* f1, wchar_t* f2, const wchar_t* i1, const wchar_t* i2) +{ + unsigned insert_pos = f1 - begin(); + unsigned remove_len = f2 - f1; + unsigned insert_len = i2 - i1; + unsigned org_size = size(); + if(insert_len > remove_len) + { + append(insert_len-remove_len, ' '); + std::copy_backward(begin() + insert_pos + remove_len, begin() + org_size, end()); + std::copy(i1, i2, begin() + insert_pos); + } + else + { + std::copy(begin() + insert_pos + remove_len, begin() + org_size, begin() + insert_pos + insert_len); + std::copy(i1, i2, begin() + insert_pos); + erase(size() + insert_len - remove_len); + } + return *this; +} +} // namespace std +#endif + +#endif + + + + + + + + + + + + + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/fileiter.cpp b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp new file mode 100644 index 0000000..7d9c7f8 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp @@ -0,0 +1,908 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: fileiter.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements file io primitives + directory searching for class boost::RegEx. + */ + + +#define BOOST_REGEX_SOURCE + +#include <climits> +#include <stdexcept> +#include <string> +#include <boost/throw_exception.hpp> +#include <boost/regex/v4/fileiter.hpp> +#include <boost/regex/v4/regex_workaround.hpp> +#include <boost/regex/pattern_except.hpp> + +#include <cstdio> +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; + using ::fseek; + using ::fread; + using ::ftell; + using ::fopen; + using ::fclose; + using ::FILE; + using ::strcpy; + using ::strcpy; + using ::strcat; + using ::strcmp; + using ::strlen; +} +#endif + + +#ifndef BOOST_REGEX_NO_FILEITER + +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +#include <sys/cygwin.h> +#endif + +#ifdef BOOST_MSVC +# pragma warning(disable: 4800) +#endif + +namespace boost{ + namespace re_detail{ +// start with the operating system specific stuff: + +#if (defined(__BORLANDC__) || defined(BOOST_REGEX_FI_WIN32_DIR) || defined(BOOST_MSVC)) && !defined(BOOST_RE_NO_WIN32) + +// platform is DOS or Windows +// directories are separated with '\\' +// and names are insensitive of case + +BOOST_REGEX_DECL const char* _fi_sep = "\\"; +const char* _fi_sep_alt = "/"; +#define BOOST_REGEX_FI_TRANSLATE(c) std::tolower(c) + +#else + +// platform is not DOS or Windows +// directories are separated with '/' +// and names are sensitive of case + +BOOST_REGEX_DECL const char* _fi_sep = "/"; +const char* _fi_sep_alt = _fi_sep; +#define BOOST_REGEX_FI_TRANSLATE(c) c + +#endif + +#ifdef BOOST_REGEX_FI_WIN32_MAP + +void mapfile::open(const char* file) +{ +#if defined(BOOST_NO_ANSI_APIS) + int filename_size = strlen(file); + LPWSTR wide_file = (LPWSTR)_alloca( (filename_size + 1) * sizeof(WCHAR) ); + if(::MultiByteToWideChar(CP_ACP, 0, file, filename_size, wide_file, filename_size + 1) == 0) + hfile = INVALID_HANDLE_VALUE; + else + hfile = CreateFileW(wide_file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); +#elif defined(__CYGWIN__)||defined(__CYGWIN32__) + char win32file[ MAX_PATH ]; + cygwin_conv_to_win32_path( file, win32file ); + hfile = CreateFileA(win32file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); +#else + hfile = CreateFileA(file, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); +#endif + if(hfile != INVALID_HANDLE_VALUE) + { + hmap = CreateFileMapping(hfile, 0, PAGE_READONLY, 0, 0, 0); + if((hmap == INVALID_HANDLE_VALUE) || (hmap == NULL)) + { + CloseHandle(hfile); + hmap = 0; + hfile = 0; + std::runtime_error err("Unable to create file mapping."); + boost::re_detail::raise_runtime_error(err); + } + _first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0)); + if(_first == 0) + { + CloseHandle(hmap); + CloseHandle(hfile); + hmap = 0; + hfile = 0; + std::runtime_error err("Unable to create file mapping."); + } + _last = _first + GetFileSize(hfile, 0); + } + else + { + hfile = 0; +#ifndef BOOST_NO_EXCEPTIONS + throw std::runtime_error("Unable to open file."); +#else + BOOST_REGEX_NOEH_ASSERT(hfile != INVALID_HANDLE_VALUE); +#endif + } +} + +void mapfile::close() +{ + if(hfile != INVALID_HANDLE_VALUE) + { + UnmapViewOfFile((void*)_first); + CloseHandle(hmap); + CloseHandle(hfile); + hmap = hfile = 0; + _first = _last = 0; + } +} + +#elif !defined(BOOST_RE_NO_STL) + +mapfile_iterator& mapfile_iterator::operator = (const mapfile_iterator& i) +{ + if(file && node) + file->unlock(node); + file = i.file; + node = i.node; + offset = i.offset; + if(file) + file->lock(node); + return *this; +} + +mapfile_iterator& mapfile_iterator::operator++ () +{ + if((++offset == mapfile::buf_size) && file) + { + ++node; + offset = 0; + file->lock(node); + file->unlock(node-1); + } + return *this; +} + +mapfile_iterator mapfile_iterator::operator++ (int) +{ + mapfile_iterator temp(*this); + if((++offset == mapfile::buf_size) && file) + { + ++node; + offset = 0; + file->lock(node); + file->unlock(node-1); + } + return temp; +} + +mapfile_iterator& mapfile_iterator::operator-- () +{ + if((offset == 0) && file) + { + --node; + offset = mapfile::buf_size - 1; + file->lock(node); + file->unlock(node + 1); + } + else + --offset; + return *this; +} + +mapfile_iterator mapfile_iterator::operator-- (int) +{ + mapfile_iterator temp(*this); + if((offset == 0) && file) + { + --node; + offset = mapfile::buf_size - 1; + file->lock(node); + file->unlock(node + 1); + } + else + --offset; + return temp; +} + +mapfile_iterator operator + (const mapfile_iterator& i, long off) +{ + mapfile_iterator temp(i); + temp += off; + return temp; +} + +mapfile_iterator operator - (const mapfile_iterator& i, long off) +{ + mapfile_iterator temp(i); + temp -= off; + return temp; +} + +mapfile::iterator mapfile::begin()const +{ + return mapfile_iterator(this, 0); +} + +mapfile::iterator mapfile::end()const +{ + return mapfile_iterator(this, _size); +} + +void mapfile::lock(pointer* node)const +{ + BOOST_ASSERT(node >= _first); + BOOST_ASSERT(node <= _last); + if(node < _last) + { + if(*node == 0) + { + if(condemed.empty()) + { + *node = new char[sizeof(int) + buf_size]; + *(reinterpret_cast<int*>(*node)) = 1; + } + else + { + pointer* p = condemed.front(); + condemed.pop_front(); + *node = *p; + *p = 0; + *(reinterpret_cast<int*>(*node)) = 1; + } + std::fseek(hfile, (node - _first) * buf_size, SEEK_SET); + if(node == _last - 1) + std::fread(*node + sizeof(int), _size % buf_size, 1, hfile); + else + std::fread(*node + sizeof(int), buf_size, 1, hfile); + } + else + { + if(*reinterpret_cast<int*>(*node) == 0) + { + *reinterpret_cast<int*>(*node) = 1; + condemed.remove(node); + } + else + ++(*reinterpret_cast<int*>(*node)); + } + } +} + +void mapfile::unlock(pointer* node)const +{ + BOOST_ASSERT(node >= _first); + BOOST_ASSERT(node <= _last); + if(node < _last) + { + if(--(*reinterpret_cast<int*>(*node)) == 0) + { + condemed.push_back(node); + } + } +} + +long int get_file_length(std::FILE* hfile) +{ + long int result; + std::fseek(hfile, 0, SEEK_END); + result = std::ftell(hfile); + std::fseek(hfile, 0, SEEK_SET); + return result; +} + + +void mapfile::open(const char* file) +{ + hfile = std::fopen(file, "rb"); +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + if(hfile != 0) + { + _size = get_file_length(hfile); + long cnodes = (_size + buf_size - 1) / buf_size; + + // check that number of nodes is not too high: + if(cnodes > (long)((INT_MAX) / sizeof(pointer*))) + { + std::fclose(hfile); + hfile = 0; + _size = 0; + return; + } + + _first = new pointer[(int)cnodes]; + _last = _first + cnodes; + std::memset(_first, 0, cnodes*sizeof(pointer)); + } + else + { + std::runtime_error err("Unable to open file."); + } +#ifndef BOOST_NO_EXCEPTIONS + }catch(...) + { close(); throw; } +#endif +} + +void mapfile::close() +{ + if(hfile != 0) + { + pointer* p = _first; + while(p != _last) + { + if(*p) + delete[] *p; + ++p; + } + delete[] _first; + _size = 0; + _first = _last = 0; + std::fclose(hfile); + hfile = 0; + condemed.erase(condemed.begin(), condemed.end()); + } +} + + +#endif + +inline _fi_find_handle find_first_file(const char* wild, _fi_find_data& data) +{ +#ifdef BOOST_NO_ANSI_APIS + std::size_t wild_size = std::strlen(wild); + LPWSTR wide_wild = (LPWSTR)_alloca( (wild_size + 1) * sizeof(WCHAR) ); + if (::MultiByteToWideChar(CP_ACP, 0, wild, wild_size, wide_wild, wild_size + 1) == 0) + return _fi_invalid_handle; + + return FindFirstFileW(wide_wild, &data); +#else + return FindFirstFileA(wild, &data); +#endif +} + +inline bool find_next_file(_fi_find_handle hf, _fi_find_data& data) +{ +#ifdef BOOST_NO_ANSI_APIS + return FindNextFileW(hf, &data); +#else + return FindNextFileA(hf, &data); +#endif +} + +inline void copy_find_file_result_with_overflow_check(const _fi_find_data& data, char* path, size_t max_size) +{ +#ifdef BOOST_NO_ANSI_APIS + if (::WideCharToMultiByte(CP_ACP, 0, data.cFileName, -1, path, max_size, NULL, NULL) == 0) + re_detail::overflow_error_if_not_zero(1); +#else + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(path, max_size, data.cFileName)); +#endif +} + +inline bool is_not_current_or_parent_path_string(const _fi_find_data& data) +{ +#ifdef BOOST_NO_ANSI_APIS + return (std::wcscmp(data.cFileName, L".") && std::wcscmp(data.cFileName, L"..")); +#else + return (std::strcmp(data.cFileName, ".") && std::strcmp(data.cFileName, "..")); +#endif +} + + +file_iterator::file_iterator() +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + ptr = _path; + *_path = 0; + *_root = 0; + ref = new file_iterator_ref(); + BOOST_REGEX_NOEH_ASSERT(ref) + ref->hf = _fi_invalid_handle; + ref->count = 1; +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + delete ref; + throw; + } +#endif +} + +file_iterator::file_iterator(const char* wild) +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild)); + ptr = _root; + while(*ptr)++ptr; + while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr; + if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) ) + { + _root[1]='\0'; + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); + } + else + { + *ptr = 0; + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); + if(*_path == 0) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep)); + } + ptr = _path + std::strlen(_path); + + ref = new file_iterator_ref(); + BOOST_REGEX_NOEH_ASSERT(ref) + ref->hf = find_first_file(wild, ref->_data); + ref->count = 1; + + if(ref->hf == _fi_invalid_handle) + { + *_path = 0; + ptr = _path; + } + else + { + copy_find_file_result_with_overflow_check(ref->_data, ptr, (MAX_PATH - (ptr - _path))); + if(ref->_data.dwFileAttributes & _fi_dir) + next(); + } +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + delete ref; + throw; + } +#endif +} + +file_iterator::file_iterator(const file_iterator& other) +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); + ptr = _path + (other.ptr - other._path); + ref = other.ref; +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + throw; + } +#endif + ++(ref->count); +} + +file_iterator& file_iterator::operator=(const file_iterator& other) +{ + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); + ptr = _path + (other.ptr - other._path); + if(--(ref->count) == 0) + { + if(ref->hf != _fi_invalid_handle) + FindClose(ref->hf); + delete ref; + } + ref = other.ref; + ++(ref->count); + return *this; +} + + +file_iterator::~file_iterator() +{ + delete[] _root; + delete[] _path; + if(--(ref->count) == 0) + { + if(ref->hf != _fi_invalid_handle) + FindClose(ref->hf); + delete ref; + } +} + +file_iterator file_iterator::operator++(int) +{ + file_iterator temp(*this); + next(); + return temp; +} + + +void file_iterator::next() +{ + if(ref->hf != _fi_invalid_handle) + { + bool cont = true; + while(cont) + { + cont = find_next_file(ref->hf, ref->_data); + if(cont && ((ref->_data.dwFileAttributes & _fi_dir) == 0)) + break; + } + if(!cont) + { + // end of sequence + FindClose(ref->hf); + ref->hf = _fi_invalid_handle; + *_path = 0; + ptr = _path; + } + else + copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path)); + } +} + + + +directory_iterator::directory_iterator() +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + ptr = _path; + *_path = 0; + *_root = 0; + ref = new file_iterator_ref(); + BOOST_REGEX_NOEH_ASSERT(ref) + ref->hf = _fi_invalid_handle; + ref->count = 1; +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + delete ref; + throw; + } +#endif +} + +directory_iterator::directory_iterator(const char* wild) +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, wild)); + ptr = _root; + while(*ptr)++ptr; + while((ptr > _root) && (*ptr != *_fi_sep) && (*ptr != *_fi_sep_alt))--ptr; + + if((ptr == _root) && ( (*ptr== *_fi_sep) || (*ptr==*_fi_sep_alt) ) ) + { + _root[1]='\0'; + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); + } + else + { + *ptr = 0; + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, _root)); + if(*_path == 0) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, ".")); + re_detail::overflow_error_if_not_zero(re_detail::strcat_s(_path, MAX_PATH, _fi_sep)); + } + ptr = _path + std::strlen(_path); + + ref = new file_iterator_ref(); + BOOST_REGEX_NOEH_ASSERT(ref) + ref->count = 1; + ref->hf = find_first_file(wild, ref->_data); + if(ref->hf == _fi_invalid_handle) + { + *_path = 0; + ptr = _path; + } + else + { + copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path)); + if(((ref->_data.dwFileAttributes & _fi_dir) == 0) || (std::strcmp(ptr, ".") == 0) || (std::strcmp(ptr, "..") == 0)) + next(); + } +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + delete ref; + throw; + } +#endif +} + +directory_iterator::~directory_iterator() +{ + delete[] _root; + delete[] _path; + if(--(ref->count) == 0) + { + if(ref->hf != _fi_invalid_handle) + FindClose(ref->hf); + delete ref; + } +} + +directory_iterator::directory_iterator(const directory_iterator& other) +{ + _root = _path = 0; + ref = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + _root = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_root) + _path = new char[MAX_PATH]; + BOOST_REGEX_NOEH_ASSERT(_path) + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); + ptr = _path + (other.ptr - other._path); + ref = other.ref; +#ifndef BOOST_NO_EXCEPTIONS + } + catch(...) + { + delete[] _root; + delete[] _path; + throw; + } +#endif + ++(ref->count); +} + +directory_iterator& directory_iterator::operator=(const directory_iterator& other) +{ + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_root, MAX_PATH, other._root)); + re_detail::overflow_error_if_not_zero(re_detail::strcpy_s(_path, MAX_PATH, other._path)); + ptr = _path + (other.ptr - other._path); + if(--(ref->count) == 0) + { + if(ref->hf != _fi_invalid_handle) + FindClose(ref->hf); + delete ref; + } + ref = other.ref; + ++(ref->count); + return *this; +} + +directory_iterator directory_iterator::operator++(int) +{ + directory_iterator temp(*this); + next(); + return temp; +} + +void directory_iterator::next() +{ + if(ref->hf != _fi_invalid_handle) + { + bool cont = true; + while(cont) + { + cont = find_next_file(ref->hf, ref->_data); + if(cont && (ref->_data.dwFileAttributes & _fi_dir)) + { + if(is_not_current_or_parent_path_string(ref->_data)) + break; + } + } + if(!cont) + { + // end of sequence + FindClose(ref->hf); + ref->hf = _fi_invalid_handle; + *_path = 0; + ptr = _path; + } + else + copy_find_file_result_with_overflow_check(ref->_data, ptr, MAX_PATH - (ptr - _path)); + } +} + + +#ifdef BOOST_REGEX_FI_POSIX_DIR + +struct _fi_priv_data +{ + char root[MAX_PATH]; + char* mask; + DIR* d; + _fi_priv_data(const char* p); +}; + +_fi_priv_data::_fi_priv_data(const char* p) +{ + std::strcpy(root, p); + mask = root; + while(*mask) ++mask; + while((mask > root) && (*mask != *_fi_sep) && (*mask != *_fi_sep_alt)) --mask; + if(mask == root && ((*mask== *_fi_sep) || (*mask == *_fi_sep_alt)) ) + { + root[1] = '\0'; + std::strcpy(root+2, p+1); + mask = root+2; + } + else if(mask == root) + { + root[0] = '.'; + root[1] = '\0'; + std::strcpy(root+2, p); + mask = root+2; + } + else + { + *mask = 0; + ++mask; + } +} + +bool iswild(const char* mask, const char* name) +{ + while(*mask && *name) + { + switch(*mask) + { + case '?': + ++name; + ++mask; + continue; + case '*': + ++mask; + if(*mask == 0) + return true; + while(*name) + { + if(iswild(mask, name)) + return true; + ++name; + } + return false; + case '.': + if(0 == *name) + { + ++mask; + continue; + } + // fall through: + default: + if(BOOST_REGEX_FI_TRANSLATE(*mask) != BOOST_REGEX_FI_TRANSLATE(*name)) + return false; + ++mask; + ++name; + continue; + } + } + if(*mask != *name) + return false; + return true; +} + +unsigned _fi_attributes(const char* root, const char* name) +{ + char buf[MAX_PATH]; + if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') ) + (std::sprintf)(buf, "%s%s", root, name); + else + (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); + DIR* d = opendir(buf); + if(d) + { + closedir(d); + return _fi_dir; + } + return 0; +} + +_fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindFileData) +{ + _fi_find_handle dat = new _fi_priv_data(lpFileName); + + DIR* h = opendir(dat->root); + dat->d = h; + if(h != 0) + { + if(_fi_FindNextFile(dat, lpFindFileData)) + return dat; + } + delete dat; + return 0; +} + +bool _fi_FindNextFile(_fi_find_handle dat, _fi_find_data* lpFindFileData) +{ + dirent* d; + do + { + d = readdir(dat->d); + } while(d && !iswild(dat->mask, d->d_name)); + + if(d) + { + std::strcpy(lpFindFileData->cFileName, d->d_name); + lpFindFileData->dwFileAttributes = _fi_attributes(dat->root, d->d_name); + return true; + } + return false; +} + +bool _fi_FindClose(_fi_find_handle dat) +{ + closedir(dat->d); + delete dat; + return true; +} + +#endif + +} // namespace re_detail +} // namspace boost + +#endif // BOOST_REGEX_NO_FILEITER + + + + + + + + + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/icu.cpp b/3rdParty/Boost/src/libs/regex/src/icu.cpp new file mode 100644 index 0000000..e06c317 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/icu.cpp @@ -0,0 +1,495 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE icu.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Unicode regular expressions on top of the ICU Library. + */ +#define BOOST_REGEX_SOURCE + +#include <boost/regex/config.hpp> +#ifdef BOOST_HAS_ICU +#define BOOST_REGEX_ICU_INSTANTIATE +#include <boost/regex/icu.hpp> + +namespace boost{ + +namespace re_detail{ + +icu_regex_traits_implementation::string_type icu_regex_traits_implementation::do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const +{ + // TODO make thread safe!!!! : + typedef u32_to_u16_iterator<const char_type*, ::UChar> itt; + itt i(p1), j(p2); +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + std::vector< ::UChar> t(i, j); +#else + std::vector< ::UChar> t; + while(i != j) + t.push_back(*i++); +#endif + ::uint8_t result[100]; + ::int32_t len; + if(t.size()) + len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), result, sizeof(result)); + else + len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), result, sizeof(result)); + if(std::size_t(len) > sizeof(result)) + { + scoped_array< ::uint8_t> presult(new ::uint8_t[len+1]); + if(t.size()) + len = pcoll->getSortKey(&*t.begin(), static_cast< ::int32_t>(t.size()), presult.get(), len+1); + else + len = pcoll->getSortKey(static_cast<UChar const*>(0), static_cast< ::int32_t>(0), presult.get(), len+1); + if((0 == presult[len-1]) && (len > 1)) + --len; +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + return string_type(presult.get(), presult.get()+len); +#else + string_type sresult; + ::uint8_t const* ia = presult.get(); + ::uint8_t const* ib = presult.get()+len; + while(ia != ib) + sresult.push_back(*ia++); + return sresult; +#endif + } + if((0 == result[len-1]) && (len > 1)) + --len; +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + return string_type(result, result+len); +#else + string_type sresult; + ::uint8_t const* ia = result; + ::uint8_t const* ib = result+len; + while(ia != ib) + sresult.push_back(*ia++); + return sresult; +#endif +} + +} + +icu_regex_traits::size_type icu_regex_traits::length(const char_type* p) +{ + size_type result = 0; + while(*p) + { + ++p; + ++result; + } + return result; +} + +// +// define our bitmasks: +// +const icu_regex_traits::char_class_type icu_regex_traits::mask_blank = icu_regex_traits::char_class_type(1) << offset_blank; +const icu_regex_traits::char_class_type icu_regex_traits::mask_space = icu_regex_traits::char_class_type(1) << offset_space; +const icu_regex_traits::char_class_type icu_regex_traits::mask_xdigit = icu_regex_traits::char_class_type(1) << offset_xdigit; +const icu_regex_traits::char_class_type icu_regex_traits::mask_underscore = icu_regex_traits::char_class_type(1) << offset_underscore; +const icu_regex_traits::char_class_type icu_regex_traits::mask_unicode = icu_regex_traits::char_class_type(1) << offset_unicode; +const icu_regex_traits::char_class_type icu_regex_traits::mask_any = icu_regex_traits::char_class_type(1) << offset_any; +const icu_regex_traits::char_class_type icu_regex_traits::mask_ascii = icu_regex_traits::char_class_type(1) << offset_ascii; + +icu_regex_traits::char_class_type icu_regex_traits::lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2) +{ + static const ::UChar32 prop_name_table[] = { + /* any */ 'a', 'n', 'y', + /* ascii */ 'a', 's', 'c', 'i', 'i', + /* assigned */ 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', + /* c* */ 'c', '*', + /* cc */ 'c', 'c', + /* cf */ 'c', 'f', + /* closepunctuation */ 'c', 'l', 'o', 's', 'e', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* cn */ 'c', 'n', + /* co */ 'c', 'o', + /* connectorpunctuation */ 'c', 'o', 'n', 'n', 'e', 'c', 't', 'o', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* control */ 'c', 'o', 'n', 't', 'r', 'o', 'l', + /* cs */ 'c', 's', + /* currencysymbol */ 'c', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 's', 'y', 'm', 'b', 'o', 'l', + /* dashpunctuation */ 'd', 'a', 's', 'h', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* decimaldigitnumber */ 'd', 'e', 'c', 'i', 'm', 'a', 'l', 'd', 'i', 'g', 'i', 't', 'n', 'u', 'm', 'b', 'e', 'r', + /* enclosingmark */ 'e', 'n', 'c', 'l', 'o', 's', 'i', 'n', 'g', 'm', 'a', 'r', 'k', + /* finalpunctuation */ 'f', 'i', 'n', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* format */ 'f', 'o', 'r', 'm', 'a', 't', + /* initialpunctuation */ 'i', 'n', 'i', 't', 'i', 'a', 'l', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* l* */ 'l', '*', + /* letter */ 'l', 'e', 't', 't', 'e', 'r', + /* letternumber */ 'l', 'e', 't', 't', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', + /* lineseparator */ 'l', 'i', 'n', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', + /* ll */ 'l', 'l', + /* lm */ 'l', 'm', + /* lo */ 'l', 'o', + /* lowercaseletter */ 'l', 'o', 'w', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', + /* lt */ 'l', 't', + /* lu */ 'l', 'u', + /* m* */ 'm', '*', + /* mark */ 'm', 'a', 'r', 'k', + /* mathsymbol */ 'm', 'a', 't', 'h', 's', 'y', 'm', 'b', 'o', 'l', + /* mc */ 'm', 'c', + /* me */ 'm', 'e', + /* mn */ 'm', 'n', + /* modifierletter */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', + /* modifiersymbol */ 'm', 'o', 'd', 'i', 'f', 'i', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', + /* n* */ 'n', '*', + /* nd */ 'n', 'd', + /* nl */ 'n', 'l', + /* no */ 'n', 'o', + /* nonspacingmark */ 'n', 'o', 'n', 's', 'p', 'a', 'c', 'i', 'n', 'g', 'm', 'a', 'r', 'k', + /* notassigned */ 'n', 'o', 't', 'a', 's', 's', 'i', 'g', 'n', 'e', 'd', + /* number */ 'n', 'u', 'm', 'b', 'e', 'r', + /* openpunctuation */ 'o', 'p', 'e', 'n', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* other */ 'o', 't', 'h', 'e', 'r', + /* otherletter */ 'o', 't', 'h', 'e', 'r', 'l', 'e', 't', 't', 'e', 'r', + /* othernumber */ 'o', 't', 'h', 'e', 'r', 'n', 'u', 'm', 'b', 'e', 'r', + /* otherpunctuation */ 'o', 't', 'h', 'e', 'r', 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* othersymbol */ 'o', 't', 'h', 'e', 'r', 's', 'y', 'm', 'b', 'o', 'l', + /* p* */ 'p', '*', + /* paragraphseparator */ 'p', 'a', 'r', 'a', 'g', 'r', 'a', 'p', 'h', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', + /* pc */ 'p', 'c', + /* pd */ 'p', 'd', + /* pe */ 'p', 'e', + /* pf */ 'p', 'f', + /* pi */ 'p', 'i', + /* po */ 'p', 'o', + /* privateuse */ 'p', 'r', 'i', 'v', 'a', 't', 'e', 'u', 's', 'e', + /* ps */ 'p', 's', + /* punctuation */ 'p', 'u', 'n', 'c', 't', 'u', 'a', 't', 'i', 'o', 'n', + /* s* */ 's', '*', + /* sc */ 's', 'c', + /* separator */ 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', + /* sk */ 's', 'k', + /* sm */ 's', 'm', + /* so */ 's', 'o', + /* spaceseparator */ 's', 'p', 'a', 'c', 'e', 's', 'e', 'p', 'a', 'r', 'a', 't', 'o', 'r', + /* spacingcombiningmark */ 's', 'p', 'a', 'c', 'i', 'n', 'g', 'c', 'o', 'm', 'b', 'i', 'n', 'i', 'n', 'g', 'm', 'a', 'r', 'k', + /* surrogate */ 's', 'u', 'r', 'r', 'o', 'g', 'a', 't', 'e', + /* symbol */ 's', 'y', 'm', 'b', 'o', 'l', + /* titlecase */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', + /* titlecaseletter */ 't', 'i', 't', 'l', 'e', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', + /* uppercaseletter */ 'u', 'p', 'p', 'e', 'r', 'c', 'a', 's', 'e', 'l', 'e', 't', 't', 'e', 'r', + /* z* */ 'z', '*', + /* zl */ 'z', 'l', + /* zp */ 'z', 'p', + /* zs */ 'z', 's', + }; + + static const re_detail::character_pointer_range< ::UChar32> range_data[] = { + { prop_name_table+0, prop_name_table+3, }, // any + { prop_name_table+3, prop_name_table+8, }, // ascii + { prop_name_table+8, prop_name_table+16, }, // assigned + { prop_name_table+16, prop_name_table+18, }, // c* + { prop_name_table+18, prop_name_table+20, }, // cc + { prop_name_table+20, prop_name_table+22, }, // cf + { prop_name_table+22, prop_name_table+38, }, // closepunctuation + { prop_name_table+38, prop_name_table+40, }, // cn + { prop_name_table+40, prop_name_table+42, }, // co + { prop_name_table+42, prop_name_table+62, }, // connectorpunctuation + { prop_name_table+62, prop_name_table+69, }, // control + { prop_name_table+69, prop_name_table+71, }, // cs + { prop_name_table+71, prop_name_table+85, }, // currencysymbol + { prop_name_table+85, prop_name_table+100, }, // dashpunctuation + { prop_name_table+100, prop_name_table+118, }, // decimaldigitnumber + { prop_name_table+118, prop_name_table+131, }, // enclosingmark + { prop_name_table+131, prop_name_table+147, }, // finalpunctuation + { prop_name_table+147, prop_name_table+153, }, // format + { prop_name_table+153, prop_name_table+171, }, // initialpunctuation + { prop_name_table+171, prop_name_table+173, }, // l* + { prop_name_table+173, prop_name_table+179, }, // letter + { prop_name_table+179, prop_name_table+191, }, // letternumber + { prop_name_table+191, prop_name_table+204, }, // lineseparator + { prop_name_table+204, prop_name_table+206, }, // ll + { prop_name_table+206, prop_name_table+208, }, // lm + { prop_name_table+208, prop_name_table+210, }, // lo + { prop_name_table+210, prop_name_table+225, }, // lowercaseletter + { prop_name_table+225, prop_name_table+227, }, // lt + { prop_name_table+227, prop_name_table+229, }, // lu + { prop_name_table+229, prop_name_table+231, }, // m* + { prop_name_table+231, prop_name_table+235, }, // mark + { prop_name_table+235, prop_name_table+245, }, // mathsymbol + { prop_name_table+245, prop_name_table+247, }, // mc + { prop_name_table+247, prop_name_table+249, }, // me + { prop_name_table+249, prop_name_table+251, }, // mn + { prop_name_table+251, prop_name_table+265, }, // modifierletter + { prop_name_table+265, prop_name_table+279, }, // modifiersymbol + { prop_name_table+279, prop_name_table+281, }, // n* + { prop_name_table+281, prop_name_table+283, }, // nd + { prop_name_table+283, prop_name_table+285, }, // nl + { prop_name_table+285, prop_name_table+287, }, // no + { prop_name_table+287, prop_name_table+301, }, // nonspacingmark + { prop_name_table+301, prop_name_table+312, }, // notassigned + { prop_name_table+312, prop_name_table+318, }, // number + { prop_name_table+318, prop_name_table+333, }, // openpunctuation + { prop_name_table+333, prop_name_table+338, }, // other + { prop_name_table+338, prop_name_table+349, }, // otherletter + { prop_name_table+349, prop_name_table+360, }, // othernumber + { prop_name_table+360, prop_name_table+376, }, // otherpunctuation + { prop_name_table+376, prop_name_table+387, }, // othersymbol + { prop_name_table+387, prop_name_table+389, }, // p* + { prop_name_table+389, prop_name_table+407, }, // paragraphseparator + { prop_name_table+407, prop_name_table+409, }, // pc + { prop_name_table+409, prop_name_table+411, }, // pd + { prop_name_table+411, prop_name_table+413, }, // pe + { prop_name_table+413, prop_name_table+415, }, // pf + { prop_name_table+415, prop_name_table+417, }, // pi + { prop_name_table+417, prop_name_table+419, }, // po + { prop_name_table+419, prop_name_table+429, }, // privateuse + { prop_name_table+429, prop_name_table+431, }, // ps + { prop_name_table+431, prop_name_table+442, }, // punctuation + { prop_name_table+442, prop_name_table+444, }, // s* + { prop_name_table+444, prop_name_table+446, }, // sc + { prop_name_table+446, prop_name_table+455, }, // separator + { prop_name_table+455, prop_name_table+457, }, // sk + { prop_name_table+457, prop_name_table+459, }, // sm + { prop_name_table+459, prop_name_table+461, }, // so + { prop_name_table+461, prop_name_table+475, }, // spaceseparator + { prop_name_table+475, prop_name_table+495, }, // spacingcombiningmark + { prop_name_table+495, prop_name_table+504, }, // surrogate + { prop_name_table+504, prop_name_table+510, }, // symbol + { prop_name_table+510, prop_name_table+519, }, // titlecase + { prop_name_table+519, prop_name_table+534, }, // titlecaseletter + { prop_name_table+534, prop_name_table+549, }, // uppercaseletter + { prop_name_table+549, prop_name_table+551, }, // z* + { prop_name_table+551, prop_name_table+553, }, // zl + { prop_name_table+553, prop_name_table+555, }, // zp + { prop_name_table+555, prop_name_table+557, }, // zs + }; + + static const icu_regex_traits::char_class_type icu_class_map[] = { + icu_regex_traits::mask_any, // any + icu_regex_traits::mask_ascii, // ascii + (0x3FFFFFFFu) & ~(U_GC_CN_MASK), // assigned + U_GC_C_MASK, // c* + U_GC_CC_MASK, // cc + U_GC_CF_MASK, // cf + U_GC_PE_MASK, // closepunctuation + U_GC_CN_MASK, // cn + U_GC_CO_MASK, // co + U_GC_PC_MASK, // connectorpunctuation + U_GC_CC_MASK, // control + U_GC_CS_MASK, // cs + U_GC_SC_MASK, // currencysymbol + U_GC_PD_MASK, // dashpunctuation + U_GC_ND_MASK, // decimaldigitnumber + U_GC_ME_MASK, // enclosingmark + U_GC_PF_MASK, // finalpunctuation + U_GC_CF_MASK, // format + U_GC_PI_MASK, // initialpunctuation + U_GC_L_MASK, // l* + U_GC_L_MASK, // letter + U_GC_NL_MASK, // letternumber + U_GC_ZL_MASK, // lineseparator + U_GC_LL_MASK, // ll + U_GC_LM_MASK, // lm + U_GC_LO_MASK, // lo + U_GC_LL_MASK, // lowercaseletter + U_GC_LT_MASK, // lt + U_GC_LU_MASK, // lu + U_GC_M_MASK, // m* + U_GC_M_MASK, // mark + U_GC_SM_MASK, // mathsymbol + U_GC_MC_MASK, // mc + U_GC_ME_MASK, // me + U_GC_MN_MASK, // mn + U_GC_LM_MASK, // modifierletter + U_GC_SK_MASK, // modifiersymbol + U_GC_N_MASK, // n* + U_GC_ND_MASK, // nd + U_GC_NL_MASK, // nl + U_GC_NO_MASK, // no + U_GC_MN_MASK, // nonspacingmark + U_GC_CN_MASK, // notassigned + U_GC_N_MASK, // number + U_GC_PS_MASK, // openpunctuation + U_GC_C_MASK, // other + U_GC_LO_MASK, // otherletter + U_GC_NO_MASK, // othernumber + U_GC_PO_MASK, // otherpunctuation + U_GC_SO_MASK, // othersymbol + U_GC_P_MASK, // p* + U_GC_ZP_MASK, // paragraphseparator + U_GC_PC_MASK, // pc + U_GC_PD_MASK, // pd + U_GC_PE_MASK, // pe + U_GC_PF_MASK, // pf + U_GC_PI_MASK, // pi + U_GC_PO_MASK, // po + U_GC_CO_MASK, // privateuse + U_GC_PS_MASK, // ps + U_GC_P_MASK, // punctuation + U_GC_S_MASK, // s* + U_GC_SC_MASK, // sc + U_GC_Z_MASK, // separator + U_GC_SK_MASK, // sk + U_GC_SM_MASK, // sm + U_GC_SO_MASK, // so + U_GC_ZS_MASK, // spaceseparator + U_GC_MC_MASK, // spacingcombiningmark + U_GC_CS_MASK, // surrogate + U_GC_S_MASK, // symbol + U_GC_LT_MASK, // titlecase + U_GC_LT_MASK, // titlecaseletter + U_GC_LU_MASK, // uppercaseletter + U_GC_Z_MASK, // z* + U_GC_ZL_MASK, // zl + U_GC_ZP_MASK, // zp + U_GC_ZS_MASK, // zs + }; + + + static const re_detail::character_pointer_range< ::UChar32>* ranges_begin = range_data; + static const re_detail::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data)/sizeof(range_data[0])); + + re_detail::character_pointer_range< ::UChar32> t = { p1, p2, }; + const re_detail::character_pointer_range< ::UChar32>* p = std::lower_bound(ranges_begin, ranges_end, t); + if((p != ranges_end) && (t == *p)) + return icu_class_map[p - ranges_begin]; + return 0; +} + +icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_type* p1, const char_type* p2) const +{ + static const char_class_type masks[] = + { + 0, + U_GC_L_MASK | U_GC_ND_MASK, + U_GC_L_MASK, + mask_blank, + U_GC_CC_MASK | U_GC_CF_MASK | U_GC_ZL_MASK | U_GC_ZP_MASK, + U_GC_ND_MASK, + U_GC_ND_MASK, + (0x3FFFFFFFu) & ~(U_GC_CC_MASK | U_GC_CF_MASK | U_GC_CS_MASK | U_GC_CN_MASK | U_GC_Z_MASK), + U_GC_LL_MASK, + U_GC_LL_MASK, + ~(U_GC_C_MASK), + U_GC_P_MASK, + char_class_type(U_GC_Z_MASK) | mask_space, + char_class_type(U_GC_Z_MASK) | mask_space, + U_GC_LU_MASK, + mask_unicode, + U_GC_LU_MASK, + char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, + char_class_type(U_GC_L_MASK | U_GC_ND_MASK | U_GC_MN_MASK) | mask_underscore, + char_class_type(U_GC_ND_MASK) | mask_xdigit, + }; + + int id = ::boost::re_detail::get_default_class_id(p1, p2); + if(id >= 0) + return masks[id+1]; + char_class_type result = lookup_icu_mask(p1, p2); + if(result != 0) + return result; + + if(id < 0) + { + string_type s(p1, p2); + string_type::size_type i = 0; + while(i < s.size()) + { + s[i] = static_cast<char>((::u_tolower)(s[i])); + if(::u_isspace(s[i]) || (s[i] == '-') || (s[i] == '_')) + s.erase(s.begin()+i, s.begin()+i+1); + else + { + s[i] = static_cast<char>((::u_tolower)(s[i])); + ++i; + } + } + if(s.size()) + id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); + if(id >= 0) + return masks[id+1]; + if(s.size()) + result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); + if(result != 0) + return result; + } + BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); + return masks[id+1]; +} + +icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const +{ + string_type result; + if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2) + { +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + std::string s(p1, p2); +#else + std::string s; + const char_type* p3 = p1; + while(p3 != p2) + s.append(1, *p3++); +#endif + // Try Unicode name: + UErrorCode err = U_ZERO_ERROR; + UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, s.c_str(), &err); + if(U_SUCCESS(err)) + { + result.push_back(c); + return result; + } + // Try Unicode-extended name: + err = U_ZERO_ERROR; + c = ::u_charFromName(U_EXTENDED_CHAR_NAME, s.c_str(), &err); + if(U_SUCCESS(err)) + { + result.push_back(c); + return result; + } + // try POSIX name: + s = ::boost::re_detail::lookup_default_collate_name(s); +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS + result.assign(s.begin(), s.end()); +#else + result.clear(); + std::string::const_iterator si, sj; + si = s.begin(); + sj = s.end(); + while(si != sj) + result.push_back(*si++); +#endif + } + if(result.empty() && (p2-p1 == 1)) + result.push_back(*p1); + return result; +} + +bool icu_regex_traits::isctype(char_type c, char_class_type f) const +{ + // check for standard catagories first: + char_class_type m = char_class_type(1u << u_charType(c)); + if((m & f) != 0) + return true; + // now check for special cases: + if(((f & mask_blank) != 0) && u_isblank(c)) + return true; + if(((f & mask_space) != 0) && u_isspace(c)) + return true; + if(((f & mask_xdigit) != 0) && (u_digit(c, 16) >= 0)) + return true; + if(((f & mask_unicode) != 0) && (c >= 0x100)) + return true; + if(((f & mask_underscore) != 0) && (c == '_')) + return true; + if(((f & mask_any) != 0) && (c <= 0x10FFFF)) + return true; + if(((f & mask_ascii) != 0) && (c <= 0x7F)) + return true; + return false; +} + +} + +#endif // BOOST_HAS_ICU diff --git a/3rdParty/Boost/src/libs/regex/src/instances.cpp b/3rdParty/Boost/src/libs/regex/src/instances.cpp new file mode 100644 index 0000000..69d72ad --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/instances.cpp @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: instances.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: regex narrow character template instances. + */ + +#define BOOST_REGEX_SOURCE + +#include <boost/regex/config.hpp> + +#if !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES) +#define BOOST_REGEX_NARROW_INSTANTIATE + +#ifdef __BORLANDC__ +#pragma hrdstop +#endif + +#include <boost/regex.hpp> + +#endif diff --git a/3rdParty/Boost/src/libs/regex/src/posix_api.cpp b/3rdParty/Boost/src/libs/regex/src/posix_api.cpp new file mode 100644 index 0000000..1564ced --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/posix_api.cpp @@ -0,0 +1,288 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: posix_api.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements the Posix API wrappers. + */ + +#define BOOST_REGEX_SOURCE + +#include <cstdio> +#include <boost/regex.hpp> +#include <boost/cregex.hpp> + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::sprintf; + using ::strcpy; + using ::strcmp; +} +#endif + + +namespace boost{ + +namespace{ + +unsigned int magic_value = 25631; + +const char* names[] = { + "REG_NOERROR", + "REG_NOMATCH", + "REG_BADPAT", + "REG_ECOLLATE", + "REG_ECTYPE", + "REG_EESCAPE", + "REG_ESUBREG", + "REG_EBRACK", + "REG_EPAREN", + "REG_EBRACE", + "REG_BADBR", + "REG_ERANGE", + "REG_ESPACE", + "REG_BADRPT", + "REG_EEND", + "REG_ESIZE", + "REG_ERPAREN", + "REG_EMPTY", + "REG_ECOMPLEXITY", + "REG_ESTACK", + "REG_E_UNKNOWN", +}; +} // namespace + +typedef boost::basic_regex<char, c_regex_traits<char> > c_regex_type; + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f) +{ + if(expression->re_magic != magic_value) + { + expression->guts = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + expression->guts = new c_regex_type(); +#ifndef BOOST_NO_EXCEPTIONS + } catch(...) + { + return REG_ESPACE; + } +#else + if(0 == expression->guts) + return REG_E_MEMORY; +#endif + } + // set default flags: + boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic); + expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; + // and translate those that are actually set: + + if(f & REG_NOCOLLATE) + { + flags |= regex::nocollate; +#ifndef BOOST_REGEX_V3 + flags &= ~regex::collate; +#endif + } + + if(f & REG_NOSUB) + { + //expression->eflags |= match_any; + flags |= regex::nosubs; + } + + if(f & REG_NOSPEC) + flags |= regex::literal; + if(f & REG_ICASE) + flags |= regex::icase; + if(f & REG_ESCAPE_IN_LISTS) + flags &= ~regex::no_escape_in_lists; + if(f & REG_NEWLINE_ALT) + flags |= regex::newline_alt; + + const char* p2; + if(f & REG_PEND) + p2 = expression->re_endp; + else p2 = ptr + std::strlen(ptr); + + int result; + +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + expression->re_magic = magic_value; + static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags); + expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1; + result = static_cast<c_regex_type*>(expression->guts)->error_code(); +#ifndef BOOST_NO_EXCEPTIONS + } + catch(const boost::regex_error& be) + { + result = be.code(); + } + catch(...) + { + result = REG_E_UNKNOWN; + } +#endif + if(result) + regfreeA(expression); + return result; + +} + +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* e, char* buf, regsize_t buf_size) +{ + std::size_t result = 0; + if(code & REG_ITOA) + { + code &= ~REG_ITOA; + if(code <= (int)REG_E_UNKNOWN) + { + result = std::strlen(names[code]) + 1; + if(buf_size >= result) + re_detail::strcpy_s(buf, buf_size, names[code]); + return result; + } + return result; + } + if(code == REG_ATOI) + { + char localbuf[5]; + if(e == 0) + return 0; + for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i) + { + if(std::strcmp(e->re_endp, names[i]) == 0) + { +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + (::sprintf_s)(localbuf, 5, "%d", i); +#else + (std::sprintf)(localbuf, "%d", i); +#endif + if(std::strlen(localbuf) < buf_size) + re_detail::strcpy_s(buf, buf_size, localbuf); + return std::strlen(localbuf) + 1; + } + } +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + (::sprintf_s)(localbuf, 5, "%d", 0); +#else + (std::sprintf)(localbuf, "%d", 0); +#endif + if(std::strlen(localbuf) < buf_size) + re_detail::strcpy_s(buf, buf_size, localbuf); + return std::strlen(localbuf) + 1; + } + if(code <= (int)REG_E_UNKNOWN) + { + std::string p; + if((e) && (e->re_magic == magic_value)) + p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code)); + else + { + p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code)); + } + std::size_t len = p.size(); + if(len < buf_size) + { + re_detail::strcpy_s(buf, buf_size, p.c_str()); + } + return len + 1; + } + if(buf_size) + *buf = 0; + return 0; +} + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, const char* buf, regsize_t n, regmatch_t* array, int eflags) +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif + bool result = false; + match_flag_type flags = match_default | expression->eflags; + const char* end; + const char* start; + cmatch m; + + if(eflags & REG_NOTBOL) + flags |= match_not_bol; + if(eflags & REG_NOTEOL) + flags |= match_not_eol; + if(eflags & REG_STARTEND) + { + start = buf + array[0].rm_so; + end = buf + array[0].rm_eo; + } + else + { + start = buf; + end = buf + std::strlen(buf); + } + +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + if(expression->re_magic == magic_value) + { + result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags); + } + else + return result; +#ifndef BOOST_NO_EXCEPTIONS + } catch(...) + { + return REG_E_UNKNOWN; + } +#endif + + if(result) + { + // extract what matched: + std::size_t i; + for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) + { + array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); + array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf); + } + // and set anything else to -1: + for(i = expression->re_nsub + 1; i < n; ++i) + { + array[i].rm_so = -1; + array[i].rm_eo = -1; + } + return 0; + } + return REG_NOMATCH; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression) +{ + if(expression->re_magic == magic_value) + { + delete static_cast<c_regex_type*>(expression->guts); + } + expression->re_magic = 0; +} + +} // namespace boost + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/regex.cpp b/3rdParty/Boost/src/libs/regex/src/regex.cpp new file mode 100644 index 0000000..0a50382 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/regex.cpp @@ -0,0 +1,239 @@ +/* + * + * Copyright (c) 1998-2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: regex.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Misc boost::regbase member funnctions. + */ + + +#define BOOST_REGEX_SOURCE + +#include <new> +#include <boost/regex.hpp> +#include <boost/throw_exception.hpp> + +#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300) +# include <malloc.h> +#endif +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +# define NOMINMAX +#endif +#define NOGDI +#define NOUSER +#include <windows.h> +#endif + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3) +#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 +#include <new> +#else +#include <boost/regex/v4/mem_block_cache.hpp> +#endif +#endif + + +namespace boost{ + +// +// fix: these are declared out of line here to ensure +// that dll builds contain the Virtual table for these +// types - this ensures that exceptions can be thrown +// from the dll and caught in an exe. +regex_error::regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos) + : std::runtime_error(s) + , m_error_code(err) + , m_position(pos) +{ +} + +regex_error::regex_error(regex_constants::error_type err) + : std::runtime_error(::boost::re_detail::get_default_error_string(err)) + , m_error_code(err) + , m_position(0) +{ +} + +regex_error::~regex_error() throw() +{ +} + +void regex_error::raise()const +{ +#ifndef BOOST_NO_EXCEPTIONS + ::boost::throw_exception(*this); +#endif +} + + + +namespace re_detail{ + +BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex) +{ + ::boost::throw_exception(ex); +} +// +// error checking API: +// +BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*ef*/, match_flag_type mf) +{ +#ifndef BOOST_REGEX_V3 + // + // can't mix match_extra with POSIX matching rules: + // + if((mf & match_extra) && (mf & match_posix)) + { + std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules"); + throw_exception(msg); + } +#endif +} + +#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD + +static void execute_eror() +{ + // we only get here after a stack overflow, + // this has to be a separate proceedure because we + // can't mix __try{}__except block with local objects + // that have destructors: + reset_stack_guard_page(); + std::runtime_error err("Out of stack space, while attempting to match a regular expression."); + raise_runtime_error(err); +} + +bool BOOST_REGEX_CALL abstract_protected_call::execute()const +{ + __try{ + return this->call(); + }__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) + { + execute_eror(); + } + // We never really get here at all: + return false; +} + +BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page() +{ +#if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && defined(_MSC_VER) && (_MSC_VER >= 1300) + _resetstkoflw(); +#else + // + // We need to locate the current page being used by the stack, + // move to the page below it and then deallocate and protect + // that page. Note that ideally we would protect only the lowest + // stack page that has been allocated: in practice there + // seems to be no easy way to locate this page, in any case as + // long as the next page is protected, then Windows will figure + // the rest out for us... + // + SYSTEM_INFO si; + GetSystemInfo(&si); + MEMORY_BASIC_INFORMATION mi; + DWORD previous_protection_status; + // + // this is an address in our stack space: + // + LPBYTE page = (LPBYTE)&page; + // + // Get the current memory page in use: + // + VirtualQuery(page, &mi, sizeof(mi)); + // + // Go to the page one below this: + // + page = (LPBYTE)(mi.BaseAddress)-si.dwPageSize; + // + // Free and protect everything from the start of the + // allocation range, to the end of the page below the + // one in use: + // + if (!VirtualFree(mi.AllocationBase, (LPBYTE)page - (LPBYTE)mi.AllocationBase, MEM_DECOMMIT) + || !VirtualProtect(page, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &previous_protection_status)) + { + throw std::bad_exception(); + } +#endif +} +#endif + +#if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_REGEX_V3) + +#if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 + +BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block() +{ + return ::operator new(BOOST_REGEX_BLOCKSIZE); +} + +BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p) +{ + ::operator delete(p); +} + +#else + +#ifdef BOOST_HAS_THREADS +mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, }; +#else +mem_block_cache block_cache = { 0, 0, }; +#endif + +BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block() +{ + return block_cache.get(); +} + +BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p) +{ + block_cache.put(p); +} + +#endif + +#endif + +} // namespace re_detail + + + +} // namespace boost + +#if defined(BOOST_RE_USE_VCL) && defined(BOOST_REGEX_DYN_LINK) + +int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*) +{ + return 1; +} +#endif + +#if defined(__IBMCPP__) && defined(BOOST_REGEX_DYN_LINK) +// +// Is this correct - linker complains without it ? +// +int main() +{ + return 0; +} + +#endif + + + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/regex_debug.cpp b/3rdParty/Boost/src/libs/regex/src/regex_debug.cpp new file mode 100644 index 0000000..9306a82 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/regex_debug.cpp @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 1998-2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: regex_debug.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Misc. debugging helpers. + */ + + +#define BOOST_REGEX_SOURCE + +#include <boost/regex/config.hpp> + + +// +// regex configuration information: this prints out the settings used +// when the library was built - include in debugging builds only: +// +#ifdef BOOST_REGEX_CONFIG_INFO + +#define print_macro regex_lib_print_macro +#define print_expression regex_lib_print_expression +#define print_byte_order regex_lib_print_byte_order +#define print_sign regex_lib_print_sign +#define print_compiler_macros regex_lib_print_compiler_macros +#define print_stdlib_macros regex_lib_print_stdlib_macros +#define print_platform_macros regex_lib_print_platform_macros +#define print_boost_macros regex_lib_print_boost_macros +#define print_separator regex_lib_print_separator +#define OLD_MAIN regex_lib_main +#define NEW_MAIN regex_lib_main2 +#define NO_RECURSE + +#include <libs/regex/test/config_info/regex_config_info.cpp> + +BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info() +{ + std::cout << "\n\n"; + print_separator(); + std::cout << "Regex library build configuration:\n\n"; + regex_lib_main2(); +} + +#endif + + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp b/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp new file mode 100644 index 0000000..7a8de80 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/regex_raw_buffer.cpp @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_raw_buffer.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Member functions for class raw_storage. + */ + + +#define BOOST_REGEX_SOURCE +#include <memory> +#include <cstring> +#include <boost/assert.hpp> +#include <boost/regex/v4/regex_raw_buffer.hpp> + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::memcpy; + using ::memmove; +} +#endif + + +namespace boost{ namespace re_detail{ + +void BOOST_REGEX_CALL raw_storage::resize(size_type n) +{ + register size_type newsize = start ? last - start : 1024; + while(newsize < n) + newsize *= 2; + register size_type datasize = end - start; + // extend newsize to WORD/DWORD boundary: + newsize = (newsize + padding_mask) & ~(padding_mask); + + // allocate and copy data: + register pointer ptr = static_cast<pointer>(::operator new(newsize)); + BOOST_REGEX_NOEH_ASSERT(ptr) + std::memcpy(ptr, start, datasize); + + // get rid of old buffer: + ::operator delete(start); + + // and set up pointers: + start = ptr; + end = ptr + datasize; + last = ptr + newsize; +} + +void* BOOST_REGEX_CALL raw_storage::insert(size_type pos, size_type n) +{ + BOOST_ASSERT(pos <= size_type(end - start)); + if(size_type(last - end) < n) + resize(n + (end - start)); + register void* result = start + pos; + std::memmove(start + pos + n, start + pos, (end - start) - pos); + end += n; + return result; +} + +}} // namespaces diff --git a/3rdParty/Boost/src/libs/regex/src/regex_traits_defaults.cpp b/3rdParty/Boost/src/libs/regex/src/regex_traits_defaults.cpp new file mode 100644 index 0000000..8f76c09 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/regex_traits_defaults.cpp @@ -0,0 +1,688 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_traits_defaults.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Declares API's for access to regex_traits default properties. + */ + +#define BOOST_REGEX_SOURCE +#include <boost/regex/regex_traits.hpp> + +#include <cctype> +#ifndef BOOST_NO_WREGEX +#include <cwctype> +#endif + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::tolower; + using ::toupper; +#ifndef BOOST_NO_WREGEX + using ::towlower; + using ::towupper; +#endif +} +#endif + + +namespace boost{ namespace re_detail{ + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n) +{ + // if the user hasn't supplied a message catalog, then this supplies + // default "messages" for us to load in the range 1-100. + const char* messages[] = { + "", + "(", + ")", + "$", + "^", + ".", + "*", + "+", + "?", + "[", + "]", + "|", + "\\", + "#", + "-", + "{", + "}", + "0123456789", + "b", + "B", + "<", + ">", + "", + "", + "A`", + "z'", + "\n", + ",", + "a", + "f", + "n", + "r", + "t", + "v", + "x", + "c", + ":", + "=", + "e", + "", + "", + "", + "", + "", + "", + "", + "", + "E", + "Q", + "X", + "C", + "Z", + "G", + "!", + "p", + "P", + "N", + }; + + return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]); +} + +BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n) +{ + static const char* const s_default_error_messages[] = { + "Success", /* REG_NOERROR */ + "No match", /* REG_NOMATCH */ + "Invalid regular expression", /* REG_BADPAT */ + "Invalid collation character", /* REG_ECOLLATE */ + "Invalid character class name", /* REG_ECTYPE */ + "Invalid or trailing backslash", /* REG_EESCAPE */ + "Invalid back reference", /* REG_ESUBREG */ + "Unmatched [ or [^", /* REG_EBRACK */ + "Unmatched ( or \\(", /* REG_EPAREN */ + "Unmatched { or \\{", /* REG_EBRACE */ + "Invalid content of repeat range", /* REG_BADBR */ + "Invalid range end", /* REG_ERANGE */ + "Memory exhausted", /* REG_ESPACE */ + "Invalid preceding regular expression", /* REG_BADRPT */ + "Premature end of regular expression", /* REG_EEND */ + "Regular expression too big", /* REG_ESIZE */ + "Unmatched ) or \\)", /* REG_ERPAREN */ + "Empty expression", /* REG_EMPTY */ + "Complexity requirements exceeded", /* REG_ECOMPLEXITY */ + "Out of stack space", /* REG_ESTACK */ + "Unknown error", /* REG_E_UNKNOWN */ + "", + "", + "", + }; + + return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[ ::boost::regex_constants::error_unknown] : s_default_error_messages[n]; +} + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c) +{ + const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361, + 0x0483, 0x0486, + 0x0903, 0x0903, + 0x093E, 0x0940, + 0x0949, 0x094C, + 0x0982, 0x0983, + 0x09BE, 0x09C0, + 0x09C7, 0x09CC, + 0x09D7, 0x09D7, + 0x0A3E, 0x0A40, + 0x0A83, 0x0A83, + 0x0ABE, 0x0AC0, + 0x0AC9, 0x0ACC, + 0x0B02, 0x0B03, + 0x0B3E, 0x0B3E, + 0x0B40, 0x0B40, + 0x0B47, 0x0B4C, + 0x0B57, 0x0B57, + 0x0B83, 0x0B83, + 0x0BBE, 0x0BBF, + 0x0BC1, 0x0BCC, + 0x0BD7, 0x0BD7, + 0x0C01, 0x0C03, + 0x0C41, 0x0C44, + 0x0C82, 0x0C83, + 0x0CBE, 0x0CBE, + 0x0CC0, 0x0CC4, + 0x0CC7, 0x0CCB, + 0x0CD5, 0x0CD6, + 0x0D02, 0x0D03, + 0x0D3E, 0x0D40, + 0x0D46, 0x0D4C, + 0x0D57, 0x0D57, + 0x0F7F, 0x0F7F, + 0x20D0, 0x20E1, + 0x3099, 0x309A, + 0xFE20, 0xFE23, + 0xffff, 0xffff, }; + + const boost::uint_least16_t* p = combining_ranges + 1; + while(*p < c) p += 2; + --p; + if((c >= *p) && (c <= *(p+1))) + return true; + return false; +} + +// +// these are the POSIX collating names: +// +BOOST_REGEX_DECL const char* def_coll_names[] = { +"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline", +"vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", +"SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark", +"quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe", +"left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen", +"period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", +"colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign", +"question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", +"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash", +"right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f", +"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket", +"vertical-line", "right-curly-bracket", "tilde", "DEL", "", +}; + +// these multi-character collating elements +// should keep most Western-European locales +// happy - we should really localise these a +// little more - but this will have to do for +// now: + +BOOST_REGEX_DECL const char* def_multi_coll[] = { + "ae", + "Ae", + "AE", + "ch", + "Ch", + "CH", + "ll", + "Ll", + "LL", + "ss", + "Ss", + "SS", + "nj", + "Nj", + "NJ", + "dz", + "Dz", + "DZ", + "lj", + "Lj", + "LJ", + "", +}; + + + +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name) +{ + unsigned int i = 0; + while(*def_coll_names[i]) + { + if(def_coll_names[i] == name) + { + return std::string(1, char(i)); + } + ++i; + } + i = 0; + while(*def_multi_coll[i]) + { + if(def_multi_coll[i] == name) + { + return def_multi_coll[i]; + } + ++i; + } + return std::string(); +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_lower(char c) +{ + return static_cast<char>((std::tolower)((unsigned char)c)); +} + +BOOST_REGEX_DECL char BOOST_REGEX_CALL do_global_upper(char c) +{ + return static_cast<char>((std::toupper)((unsigned char)c)); +} +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c) +{ + return (std::towlower)(c); +} + +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c) +{ + return (std::towupper)(c); +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_lower(unsigned short c) +{ + return (std::towlower)(c); +} + +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL do_global_upper(unsigned short c) +{ + return (std::towupper)(c); +} +#endif + +#endif + +BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c) +{ + // + // char_syntax determines how the compiler treats a given character + // in a regular expression. + // + static regex_constants::escape_syntax_type char_syntax[] = { + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /* */ // 32 + regex_constants::escape_type_identity, /*!*/ + regex_constants::escape_type_identity, /*"*/ + regex_constants::escape_type_identity, /*#*/ + regex_constants::escape_type_identity, /*$*/ + regex_constants::escape_type_identity, /*%*/ + regex_constants::escape_type_identity, /*&*/ + regex_constants::escape_type_end_buffer, /*'*/ + regex_constants::syntax_open_mark, /*(*/ + regex_constants::syntax_close_mark, /*)*/ + regex_constants::escape_type_identity, /***/ + regex_constants::syntax_plus, /*+*/ + regex_constants::escape_type_identity, /*,*/ + regex_constants::escape_type_identity, /*-*/ + regex_constants::escape_type_identity, /*.*/ + regex_constants::escape_type_identity, /*/*/ + regex_constants::escape_type_decimal, /*0*/ + regex_constants::escape_type_backref, /*1*/ + regex_constants::escape_type_backref, /*2*/ + regex_constants::escape_type_backref, /*3*/ + regex_constants::escape_type_backref, /*4*/ + regex_constants::escape_type_backref, /*5*/ + regex_constants::escape_type_backref, /*6*/ + regex_constants::escape_type_backref, /*7*/ + regex_constants::escape_type_backref, /*8*/ + regex_constants::escape_type_backref, /*9*/ + regex_constants::escape_type_identity, /*:*/ + regex_constants::escape_type_identity, /*;*/ + regex_constants::escape_type_left_word, /*<*/ + regex_constants::escape_type_identity, /*=*/ + regex_constants::escape_type_right_word, /*>*/ + regex_constants::syntax_question, /*?*/ + regex_constants::escape_type_identity, /*@*/ + regex_constants::escape_type_start_buffer, /*A*/ + regex_constants::escape_type_not_word_assert, /*B*/ + regex_constants::escape_type_C, /*C*/ + regex_constants::escape_type_not_class, /*D*/ + regex_constants::escape_type_E, /*E*/ + regex_constants::escape_type_not_class, /*F*/ + regex_constants::escape_type_G, /*G*/ + regex_constants::escape_type_not_class, /*H*/ + regex_constants::escape_type_not_class, /*I*/ + regex_constants::escape_type_not_class, /*J*/ + regex_constants::escape_type_not_class, /*K*/ + regex_constants::escape_type_not_class, /*L*/ + regex_constants::escape_type_not_class, /*M*/ + regex_constants::escape_type_named_char, /*N*/ + regex_constants::escape_type_not_class, /*O*/ + regex_constants::escape_type_not_property, /*P*/ + regex_constants::escape_type_Q, /*Q*/ + regex_constants::escape_type_not_class, /*R*/ + regex_constants::escape_type_not_class, /*S*/ + regex_constants::escape_type_not_class, /*T*/ + regex_constants::escape_type_not_class, /*U*/ + regex_constants::escape_type_not_class, /*V*/ + regex_constants::escape_type_not_class, /*W*/ + regex_constants::escape_type_X, /*X*/ + regex_constants::escape_type_not_class, /*Y*/ + regex_constants::escape_type_Z, /*Z*/ + regex_constants::escape_type_identity, /*[*/ + regex_constants::escape_type_identity, /*\*/ + regex_constants::escape_type_identity, /*]*/ + regex_constants::escape_type_identity, /*^*/ + regex_constants::escape_type_identity, /*_*/ + regex_constants::escape_type_start_buffer, /*`*/ + regex_constants::escape_type_control_a, /*a*/ + regex_constants::escape_type_word_assert, /*b*/ + regex_constants::escape_type_ascii_control, /*c*/ + regex_constants::escape_type_class, /*d*/ + regex_constants::escape_type_e, /*e*/ + regex_constants::escape_type_control_f, /*f*/ + regex_constants::escape_type_class, /*g*/ + regex_constants::escape_type_class, /*h*/ + regex_constants::escape_type_class, /*i*/ + regex_constants::escape_type_class, /*j*/ + regex_constants::escape_type_class, /*k*/ + regex_constants::escape_type_class, /*l*/ + regex_constants::escape_type_class, /*m*/ + regex_constants::escape_type_control_n, /*n*/ + regex_constants::escape_type_class, /*o*/ + regex_constants::escape_type_property, /*p*/ + regex_constants::escape_type_class, /*q*/ + regex_constants::escape_type_control_r, /*r*/ + regex_constants::escape_type_class, /*s*/ + regex_constants::escape_type_control_t, /*t*/ + regex_constants::escape_type_class, /*u*/ + regex_constants::escape_type_control_v, /*v*/ + regex_constants::escape_type_class, /*w*/ + regex_constants::escape_type_hex, /*x*/ + regex_constants::escape_type_class, /*y*/ + regex_constants::escape_type_end_buffer, /*z*/ + regex_constants::syntax_open_brace, /*{*/ + regex_constants::syntax_or, /*|*/ + regex_constants::syntax_close_brace, /*}*/ + regex_constants::escape_type_identity, /*~*/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + regex_constants::escape_type_identity, /**/ + }; + + return char_syntax[(unsigned char)c]; +} + +BOOST_REGEX_DECL regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c) +{ + // + // char_syntax determines how the compiler treats a given character + // in a regular expression. + // + static regex_constants::syntax_type char_syntax[] = { + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_newline, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /* */ // 32 + regex_constants::syntax_not, /*!*/ + regex_constants::syntax_char, /*"*/ + regex_constants::syntax_hash, /*#*/ + regex_constants::syntax_dollar, /*$*/ + regex_constants::syntax_char, /*%*/ + regex_constants::syntax_char, /*&*/ + regex_constants::syntax_char, /*'*/ + regex_constants::syntax_open_mark, /*(*/ + regex_constants::syntax_close_mark, /*)*/ + regex_constants::syntax_star, /***/ + regex_constants::syntax_plus, /*+*/ + regex_constants::syntax_comma, /*,*/ + regex_constants::syntax_dash, /*-*/ + regex_constants::syntax_dot, /*.*/ + regex_constants::syntax_char, /*/*/ + regex_constants::syntax_digit, /*0*/ + regex_constants::syntax_digit, /*1*/ + regex_constants::syntax_digit, /*2*/ + regex_constants::syntax_digit, /*3*/ + regex_constants::syntax_digit, /*4*/ + regex_constants::syntax_digit, /*5*/ + regex_constants::syntax_digit, /*6*/ + regex_constants::syntax_digit, /*7*/ + regex_constants::syntax_digit, /*8*/ + regex_constants::syntax_digit, /*9*/ + regex_constants::syntax_colon, /*:*/ + regex_constants::syntax_char, /*;*/ + regex_constants::escape_type_left_word, /*<*/ + regex_constants::syntax_equal, /*=*/ + regex_constants::escape_type_right_word, /*>*/ + regex_constants::syntax_question, /*?*/ + regex_constants::syntax_char, /*@*/ + regex_constants::syntax_char, /*A*/ + regex_constants::syntax_char, /*B*/ + regex_constants::syntax_char, /*C*/ + regex_constants::syntax_char, /*D*/ + regex_constants::syntax_char, /*E*/ + regex_constants::syntax_char, /*F*/ + regex_constants::syntax_char, /*G*/ + regex_constants::syntax_char, /*H*/ + regex_constants::syntax_char, /*I*/ + regex_constants::syntax_char, /*J*/ + regex_constants::syntax_char, /*K*/ + regex_constants::syntax_char, /*L*/ + regex_constants::syntax_char, /*M*/ + regex_constants::syntax_char, /*N*/ + regex_constants::syntax_char, /*O*/ + regex_constants::syntax_char, /*P*/ + regex_constants::syntax_char, /*Q*/ + regex_constants::syntax_char, /*R*/ + regex_constants::syntax_char, /*S*/ + regex_constants::syntax_char, /*T*/ + regex_constants::syntax_char, /*U*/ + regex_constants::syntax_char, /*V*/ + regex_constants::syntax_char, /*W*/ + regex_constants::syntax_char, /*X*/ + regex_constants::syntax_char, /*Y*/ + regex_constants::syntax_char, /*Z*/ + regex_constants::syntax_open_set, /*[*/ + regex_constants::syntax_escape, /*\*/ + regex_constants::syntax_close_set, /*]*/ + regex_constants::syntax_caret, /*^*/ + regex_constants::syntax_char, /*_*/ + regex_constants::syntax_char, /*`*/ + regex_constants::syntax_char, /*a*/ + regex_constants::syntax_char, /*b*/ + regex_constants::syntax_char, /*c*/ + regex_constants::syntax_char, /*d*/ + regex_constants::syntax_char, /*e*/ + regex_constants::syntax_char, /*f*/ + regex_constants::syntax_char, /*g*/ + regex_constants::syntax_char, /*h*/ + regex_constants::syntax_char, /*i*/ + regex_constants::syntax_char, /*j*/ + regex_constants::syntax_char, /*k*/ + regex_constants::syntax_char, /*l*/ + regex_constants::syntax_char, /*m*/ + regex_constants::syntax_char, /*n*/ + regex_constants::syntax_char, /*o*/ + regex_constants::syntax_char, /*p*/ + regex_constants::syntax_char, /*q*/ + regex_constants::syntax_char, /*r*/ + regex_constants::syntax_char, /*s*/ + regex_constants::syntax_char, /*t*/ + regex_constants::syntax_char, /*u*/ + regex_constants::syntax_char, /*v*/ + regex_constants::syntax_char, /*w*/ + regex_constants::syntax_char, /*x*/ + regex_constants::syntax_char, /*y*/ + regex_constants::syntax_char, /*z*/ + regex_constants::syntax_open_brace, /*{*/ + regex_constants::syntax_or, /*|*/ + regex_constants::syntax_close_brace, /*}*/ + regex_constants::syntax_char, /*~*/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + regex_constants::syntax_char, /**/ + }; + + return char_syntax[(unsigned char)c]; +} + + +} // re_detail +} // boost diff --git a/3rdParty/Boost/src/libs/regex/src/static_mutex.cpp b/3rdParty/Boost/src/libs/regex/src/static_mutex.cpp new file mode 100644 index 0000000..cef7678 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/static_mutex.cpp @@ -0,0 +1,179 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE static_mutex.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Declares static_mutex lock type. + */ + +#define BOOST_REGEX_SOURCE +#include <boost/config.hpp> + +#ifdef BOOST_HAS_THREADS + +#include <boost/regex/pending/static_mutex.hpp> + +#if defined(BOOST_HAS_WINTHREADS) +#ifndef NOMINMAX +# define NOMINMAX +#endif +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <boost/static_assert.hpp> +#endif + + +namespace boost{ + +#if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER) + +scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk) +: m_mutex(m), m_have_lock(false) +{ + if(lk) + lock(); +} + +scoped_static_mutex_lock::~scoped_static_mutex_lock() +{ + if(m_have_lock) + unlock(); +} + +void scoped_static_mutex_lock::lock() +{ + if(0 == m_have_lock) + { + pthread_mutex_lock(&(m_mutex.m_mutex)); + m_have_lock = true; + } +} + +void scoped_static_mutex_lock::unlock() +{ + if(m_have_lock) + { + pthread_mutex_unlock(&(m_mutex.m_mutex)); + m_have_lock = false; + } +} + +#elif defined(BOOST_HAS_WINTHREADS) + +BOOST_STATIC_ASSERT(sizeof(LONG) == sizeof(boost::int32_t)); + +scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& m, bool lk) +: m_mutex(m), m_have_lock(false) +{ + if(lk) + lock(); +} + +scoped_static_mutex_lock::~scoped_static_mutex_lock() +{ + if(m_have_lock) + unlock(); +} + +void scoped_static_mutex_lock::lock() +{ + if(0 == m_have_lock) + { +#if !defined(InterlockedCompareExchangePointer) + while(0 != InterlockedCompareExchange(reinterpret_cast<void**>((boost::uint_least16_t*)&(m_mutex.m_mutex)), (void*)1, 0)) +#else + while(0 != InterlockedCompareExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 1, 0)) +#endif + { + Sleep(0); + } + m_have_lock = true; + } +} + +void scoped_static_mutex_lock::unlock() +{ + if(m_have_lock) + { +#if !defined(InterlockedCompareExchangePointer) + InterlockedExchange((LONG*)&(m_mutex.m_mutex), 0); +#else + InterlockedExchange(reinterpret_cast<LONG*>(&(m_mutex.m_mutex)), 0); +#endif + m_have_lock = false; + } +} + +#else +// +// Portable version of a static mutex based on Boost.Thread library: +// +#include <stdlib.h> +#include <boost/assert.hpp> + +boost::recursive_mutex* static_mutex::m_pmutex = 0; +boost::once_flag static_mutex::m_once = BOOST_ONCE_INIT; + +extern "C" BOOST_REGEX_DECL void free_static_mutex() +{ + delete static_mutex::m_pmutex; + static_mutex::m_pmutex = 0; +} + +void static_mutex::init() +{ + m_pmutex = new boost::recursive_mutex(); + int r = atexit(free_static_mutex); + BOOST_ASSERT(0 == r); +} + +scoped_static_mutex_lock::scoped_static_mutex_lock(static_mutex& , bool lk) +: m_plock(0), m_have_lock(false) +{ + if(lk) + lock(); +} + +scoped_static_mutex_lock::~scoped_static_mutex_lock() +{ + if(m_have_lock) + unlock(); + delete m_plock; +} + +void scoped_static_mutex_lock::lock() +{ + if(0 == m_have_lock) + { + boost::call_once(static_mutex::m_once,&static_mutex::init); + if(0 == m_plock) + m_plock = new boost::recursive_mutex::scoped_lock(*static_mutex::m_pmutex, false); + m_plock->lock(); + m_have_lock = true; + } +} + +void scoped_static_mutex_lock::unlock() +{ + if(m_have_lock) + { + m_plock->unlock(); + m_have_lock = false; + } +} + +#endif + +} + +#endif // BOOST_HAS_THREADS diff --git a/3rdParty/Boost/src/libs/regex/src/usinstances.cpp b/3rdParty/Boost/src/libs/regex/src/usinstances.cpp new file mode 100644 index 0000000..5665366 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/usinstances.cpp @@ -0,0 +1,77 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: winstances.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: regex unsigned short template instances (MSVC only). + */ + +#define BOOST_REGEX_SOURCE + +#include <boost/detail/workaround.hpp> +#include <memory> +#include <string> + +#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)) +// +// This is a horrible workaround, but without declaring these symbols extern we get +// duplicate symbol errors when linking if the application is built without +// /Zc:wchar_t +// +#ifdef _CRTIMP2_PURE +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE +#else +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2 +#endif + +namespace std{ + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>; +template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >; +template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >; +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) +template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*); +#endif + +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const unsigned short *, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const unsigned short *); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +} +#endif + +#include <boost/regex/config.hpp> + +#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES) +#define BOOST_REGEX_US_INSTANTIATE + +#include <boost/regex.hpp> + +#endif + + diff --git a/3rdParty/Boost/src/libs/regex/src/w32_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/w32_regex_traits.cpp new file mode 100644 index 0000000..365fccc --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/w32_regex_traits.cpp @@ -0,0 +1,650 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE w32_regex_traits.cpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Implements w32_regex_traits<char> (and associated helper classes). + */ + +#define BOOST_REGEX_SOURCE +#include <boost/regex/config.hpp> + +#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) +#include <boost/regex/regex_traits.hpp> +#include <boost/regex/pattern_except.hpp> + +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +# define NOMINMAX +#endif +#define NOGDI +#include <windows.h> + +#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(UNDER_CE) +#pragma comment(lib, "user32.lib") +#endif + +#ifdef BOOST_NO_STDC_NAMESPACE +namespace std{ + using ::memset; +} +#endif + +namespace boost{ namespace re_detail{ + +#ifdef BOOST_NO_ANSI_APIS +UINT get_code_page_for_locale_id(lcid_type id) +{ + WCHAR code_page_string[7]; + if (::GetLocaleInfoW(id, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0) + return 0; + + return static_cast<UINT>(_wtol(code_page_string)); +} +#endif + + +void w32_regex_traits_char_layer<char>::init() +{ + // we need to start by initialising our syntax map so we know which + // character is used for which purpose: + std::memset(m_char_map, 0, sizeof(m_char_map)); + cat_type cat; + std::string cat_name(w32_regex_traits<char>::get_catalog_name()); + if(cat_name.size()) + { + cat = ::boost::re_detail::w32_cat_open(cat_name); + if(!cat) + { + std::string m("Unable to open message catalog: "); + std::runtime_error err(m + cat_name); + ::boost::re_detail::raise_runtime_error(err); + } + } + // + // if we have a valid catalog then load our messages: + // + if(cat) + { + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + string_type mss = ::boost::re_detail::w32_cat_get(cat, this->m_locale, i, get_default_syntax(i)); + for(string_type::size_type j = 0; j < mss.size(); ++j) + { + m_char_map[static_cast<unsigned char>(mss[j])] = i; + } + } + } + else + { + for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i) + { + const char* ptr = get_default_syntax(i); + while(ptr && *ptr) + { + m_char_map[static_cast<unsigned char>(*ptr)] = i; + ++ptr; + } + } + } + // + // finish off by calculating our escape types: + // + unsigned char i = 'A'; + do + { + if(m_char_map[i] == 0) + { + if(::boost::re_detail::w32_is(this->m_locale, 0x0002u, (char)i)) + m_char_map[i] = regex_constants::escape_type_class; + else if(::boost::re_detail::w32_is(this->m_locale, 0x0001u, (char)i)) + m_char_map[i] = regex_constants::escape_type_not_class; + } + }while(0xFF != i++); + + // + // fill in lower case map: + // + char char_map[1 << CHAR_BIT]; + for(int ii = 0; ii < (1 << CHAR_BIT); ++ii) + char_map[ii] = static_cast<char>(ii); +#ifndef BOOST_NO_ANSI_APIS + int r = ::LCMapStringA(this->m_locale, LCMAP_LOWERCASE, char_map, 1 << CHAR_BIT, this->m_lower_map, 1 << CHAR_BIT); + BOOST_ASSERT(r != 0); +#else + UINT code_page = get_code_page_for_locale_id(this->m_locale); + BOOST_ASSERT(code_page != 0); + + WCHAR wide_char_map[1 << CHAR_BIT]; + int conv_r = ::MultiByteToWideChar(code_page, 0, char_map, 1 << CHAR_BIT, wide_char_map, 1 << CHAR_BIT); + BOOST_ASSERT(conv_r != 0); + + WCHAR wide_lower_map[1 << CHAR_BIT]; + int r = ::LCMapStringW(this->m_locale, LCMAP_LOWERCASE, wide_char_map, 1 << CHAR_BIT, wide_lower_map, 1 << CHAR_BIT); + BOOST_ASSERT(r != 0); + + conv_r = ::WideCharToMultiByte(code_page, 0, wide_lower_map, r, this->m_lower_map, 1 << CHAR_BIT, NULL, NULL); + BOOST_ASSERT(conv_r != 0); +#endif + if(r < (1 << CHAR_BIT)) + { + // if we have multibyte characters then not all may have been given + // a lower case mapping: + for(int jj = r; jj < (1 << CHAR_BIT); ++jj) + this->m_lower_map[jj] = static_cast<char>(jj); + } + +#ifndef BOOST_NO_ANSI_APIS + r = ::GetStringTypeExA(this->m_locale, CT_CTYPE1, char_map, 1 << CHAR_BIT, this->m_type_map); +#else + r = ::GetStringTypeExW(this->m_locale, CT_CTYPE1, wide_char_map, 1 << CHAR_BIT, this->m_type_map); +#endif + BOOST_ASSERT(0 != r); +} + +BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale() +{ + return ::GetUserDefaultLCID(); +} + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id) +{ +#ifndef BOOST_NO_ANSI_APIS + WORD mask; + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +#else + UINT code_page = get_code_page_for_locale_id(id); + if (code_page == 0) + return false; + + WCHAR wide_c; + if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) + return false; + + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +#endif +} + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type id) +{ + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id) +{ + WORD mask; + wchar_t c = ca; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) + return true; + return false; +} +#endif + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type id) +{ +#ifndef BOOST_NO_ANSI_APIS + WORD mask; + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +#else + UINT code_page = get_code_page_for_locale_id(id); + if (code_page == 0) + return false; + + WCHAR wide_c; + if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) + return false; + + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +#endif +} + +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type id) +{ + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type id) +{ + WORD mask; + wchar_t c = ca; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) + return true; + return false; +} +#endif + +void free_module(void* mod) +{ + ::FreeLibrary(static_cast<HMODULE>(mod)); +} + +BOOST_REGEX_DECL cat_type BOOST_REGEX_CALL w32_cat_open(const std::string& name) +{ +#ifndef BOOST_NO_ANSI_APIS + cat_type result(::LoadLibraryA(name.c_str()), &free_module); + return result; +#else + LPWSTR wide_name = (LPWSTR)_alloca( (name.size() + 1) * sizeof(WCHAR) ); + if (::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.size(), wide_name, name.size() + 1) == 0) + return cat_type(); + + cat_type result(::LoadLibraryW(wide_name), &free_module); + return result; +#endif +} + +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::string& def) +{ +#ifndef BOOST_NO_ANSI_APIS + char buf[256]; + if(0 == ::LoadStringA( + static_cast<HMODULE>(cat.get()), + i, + buf, + 256 + )) + { + return def; + } +#else + WCHAR wbuf[256]; + int r = ::LoadStringW( + static_cast<HMODULE>(cat.get()), + i, + wbuf, + 256 + ); + if (r == 0) + return def; + + LPSTR buf = (LPSTR)_alloca( (r + 1) * 2 ); + if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, (r + 1) * 2, NULL, NULL) == 0) + return def; +#endif + return std::string(buf); +} + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::wstring& def) +{ + wchar_t buf[256]; + if(0 == ::LoadStringW( + static_cast<HMODULE>(cat.get()), + i, + buf, + 256 + )) + { + return def; + } + return std::wstring(buf); +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, lcid_type, int i, const std::basic_string<unsigned short>& def) +{ + unsigned short buf[256]; + if(0 == ::LoadStringW( + static_cast<HMODULE>(cat.get()), + i, + (LPWSTR)buf, + 256 + )) + { + return def; + } + return std::basic_string<unsigned short>(buf); +} +#endif +#endif +BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2) +{ +#ifndef BOOST_NO_ANSI_APIS + int bytes = ::LCMapStringA( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringA( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + &*result.begin(), // destination buffer + bytes // size of destination buffer + ); +#else + UINT code_page = get_code_page_for_locale_id(id); + if(code_page == 0) + return std::string(p1, p2); + + int src_len = static_cast<int>(p2 - p1); + LPWSTR wide_p1 = (LPWSTR)_alloca( (src_len + 1) * 2 ); + if(::MultiByteToWideChar(code_page, 0, p1, src_len, wide_p1, src_len + 1) == 0) + return std::string(p1, p2); + + int bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + wide_p1, // source string + src_len, // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::string(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + wide_p1, // source string + src_len, // number of characters in source string + (LPWSTR)&*result.begin(), // destination buffer + bytes // size of destination buffer + ); +#endif + if(bytes > static_cast<int>(result.size())) + return std::string(p1, p2); + while(result.size() && result[result.size()-1] == '\0') + { + result.erase(result.size()-1); + } + return result; +} + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const wchar_t* p1, const wchar_t* p2) +{ + int bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::wstring(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + reinterpret_cast<wchar_t*>(&*result.begin()), // destination buffer *of bytes* + bytes // size of destination buffer + ); + if(bytes > static_cast<int>(result.size())) + return std::wstring(p1, p2); + while(result.size() && result[result.size()-1] == L'\0') + { + result.erase(result.size()-1); + } + std::wstring r2; + for(std::string::size_type i = 0; i < result.size(); ++i) + r2.append(1, static_cast<wchar_t>(static_cast<unsigned char>(result[i]))); + return r2; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type id, const unsigned short* p1, const unsigned short* p2) +{ + int bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + 0, // destination buffer + 0 // size of destination buffer + ); + if(!bytes) + return std::basic_string<unsigned short>(p1, p2); + std::string result(++bytes, '\0'); + bytes = ::LCMapStringW( + id, // locale identifier + LCMAP_SORTKEY, // mapping transformation type + (LPCWSTR)p1, // source string + static_cast<int>(p2 - p1), // number of characters in source string + reinterpret_cast<wchar_t*>(&*result.begin()), // destination buffer *of bytes* + bytes // size of destination buffer + ); + if(bytes > static_cast<int>(result.size())) + return std::basic_string<unsigned short>(p1, p2); + while(result.size() && result[result.size()-1] == L'\0') + { + result.erase(result.size()-1); + } + std::basic_string<unsigned short> r2; + for(std::string::size_type i = 0; i < result.size(); ++i) + r2.append(1, static_cast<unsigned short>(static_cast<unsigned char>(result[i]))); + return r2; +} +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id) +{ + char result[2]; +#ifndef BOOST_NO_ANSI_APIS + int b = ::LCMapStringA( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; +#else + UINT code_page = get_code_page_for_locale_id(id); + if (code_page == 0) + return c; + + WCHAR wide_c; + if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) + return c; + + WCHAR wide_result; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &wide_c, // source string + 1, // number of characters in source string + &wide_result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + + if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) + return c; +#endif + return result[0]; +} + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_LOWERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#endif +#endif +BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id) +{ + char result[2]; +#ifndef BOOST_NO_ANSI_APIS + int b = ::LCMapStringA( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; +#else + UINT code_page = get_code_page_for_locale_id(id); + if(code_page == 0) + return c; + + WCHAR wide_c; + if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) + return c; + + WCHAR wide_result; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &wide_c, // source string + 1, // number of characters in source string + &wide_result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + + if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) + return c; +#endif + return result[0]; +} + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + &c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type id) +{ + wchar_t result[2]; + int b = ::LCMapStringW( + id, // locale identifier + LCMAP_UPPERCASE, // mapping transformation type + (wchar_t const*)&c, // source string + 1, // number of characters in source string + result, // destination buffer + 1); // size of destination buffer + if(b == 0) + return c; + return result[0]; +} +#endif +#endif +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, char c) +{ + WORD mask; +#ifndef BOOST_NO_ANSI_APIS + if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base)) + return true; +#else + UINT code_page = get_code_page_for_locale_id(id); + if(code_page == 0) + return false; + + WCHAR wide_c; + if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) + return false; + + if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base)) + return true; +#endif + if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_')) + return true; + return false; +} + +#ifndef BOOST_NO_WREGEX +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, wchar_t c) +{ + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base)) + return true; + if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_')) + return true; + if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff)) + return true; + return false; +} +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, unsigned short c) +{ + WORD mask; + if(::GetStringTypeExW(id, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base)) + return true; + if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_')) + return true; + if((m & w32_regex_traits_implementation<wchar_t>::mask_unicode) && (c > 0xff)) + return true; + return false; +} +#endif +#endif + +} // re_detail +} // boost + +#endif + diff --git a/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp b/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp new file mode 100644 index 0000000..3640f29 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/wc_regex_traits.cpp @@ -0,0 +1,313 @@ +/* + * + * Copyright (c) 2004 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: wc_regex_traits.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements out of line members for c_regex_traits<wchar_t> + */ + + +#define BOOST_REGEX_SOURCE + +#include <boost/detail/workaround.hpp> +#include <memory> +#include <string> + +#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \ + && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)) +// +// This is a horrible workaround, but without declaring these symbols extern we get +// duplicate symbol errors when linking if the application is built without +// /Zc:wchar_t +// +#ifdef _CRTIMP2_PURE +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE +#else +# define BOOST_REGEX_STDLIB_DECL _CRTIMP2 +#endif + +namespace std{ + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>; +template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >; +template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >; +#endif + +#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) +template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*); +#endif + +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const unsigned short *, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const unsigned short *); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>( + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&, + const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&); +} +#endif + +#include <boost/regex/config.hpp> +#include <boost/detail/workaround.hpp> + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) + +#include <boost/regex/v4/c_regex_traits.hpp> +#ifndef BOOST_NO_WREGEX +#include <boost/regex/v4/primary_transform.hpp> +#include <boost/regex/v4/regex_traits_defaults.hpp> + +#if defined(BOOST_NO_STDC_NAMESPACE) +namespace std{ + using ::wcstol; +} +#endif + +namespace boost{ + +c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(const wchar_t* p1, const wchar_t* p2) +{ + std::size_t r; + std::size_t s = 10; + std::wstring src(p1, p2); + std::wstring result(s, L' '); + while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s))) + { + result.append(r - s + 3, L' '); + s = result.size(); + } + result.erase(r); + return result; +} + +c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(const wchar_t* p1, const wchar_t* p2) +{ + static wchar_t s_delim; + static const int s_collate_type = ::boost::re_detail::find_sort_syntax(static_cast<const c_regex_traits<wchar_t>*>(0), &s_delim); + std::wstring result; + // + // What we do here depends upon the format of the sort key returned by + // sort key returned by this->transform: + // + switch(s_collate_type) + { + case ::boost::re_detail::sort_C: + case ::boost::re_detail::sort_unknown: + // the best we can do is translate to lower case, then get a regular sort key: + { + result.assign(p1, p2); + for(std::wstring::size_type i = 0; i < result.size(); ++i) + result[i] = (std::towlower)(result[i]); + result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size()); + break; + } + case ::boost::re_detail::sort_fixed: + { + // get a regular sort key, and then truncate it: + result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size()); + result.erase(s_delim); + break; + } + case ::boost::re_detail::sort_delim: + // get a regular sort key, and then truncate everything after the delim: + result = c_regex_traits<wchar_t>::transform(&*result.begin(), &*result.begin() + result.size()); + if(result.size() && (result[0] == s_delim)) + break; + std::size_t i; + for(i = 0; i < result.size(); ++i) + { + if(result[i] == s_delim) + break; + } + result.erase(i); + break; + } + if(result.empty()) + result = std::wstring(1, char(0)); + return result; +} + +enum +{ + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11 +}; + +c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2) +{ + static const char_class_type masks[] = + { + 0, + char_class_alnum, + char_class_alpha, + char_class_blank, + char_class_cntrl, + char_class_digit, + char_class_digit, + char_class_graph, + char_class_lower, + char_class_lower, + char_class_print, + char_class_punct, + char_class_space, + char_class_space, + char_class_upper, + char_class_unicode, + char_class_upper, + char_class_alnum | char_class_word, + char_class_alnum | char_class_word, + char_class_xdigit, + }; + + int id = ::boost::re_detail::get_default_class_id(p1, p2); + if(id < 0) + { + std::wstring s(p1, p2); + for(std::wstring::size_type i = 0; i < s.size(); ++i) + s[i] = (std::towlower)(s[i]); + id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); + } + BOOST_ASSERT(id+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0]))); + return masks[id+1]; +} + +bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask) +{ + return + ((mask & char_class_space) && (std::iswspace)(c)) + || ((mask & char_class_print) && (std::iswprint)(c)) + || ((mask & char_class_cntrl) && (std::iswcntrl)(c)) + || ((mask & char_class_upper) && (std::iswupper)(c)) + || ((mask & char_class_lower) && (std::iswlower)(c)) + || ((mask & char_class_alpha) && (std::iswalpha)(c)) + || ((mask & char_class_digit) && (std::iswdigit)(c)) + || ((mask & char_class_punct) && (std::iswpunct)(c)) + || ((mask & char_class_xdigit) && (std::iswxdigit)(c)) + || ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::re_detail::is_separator(c)) + || ((mask & char_class_word) && (c == '_')) + || ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff))); +} + +c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2) +{ +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + std::string name(p1, p2); +#else + std::string name; + const wchar_t* p0 = p1; + while(p0 != p2) + name.append(1, char(*p0++)); +#endif + name = ::boost::re_detail::lookup_default_collate_name(name); +#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\ + && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)\ + && !BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) + if(name.size()) + return string_type(name.begin(), name.end()); +#else + if(name.size()) + { + string_type result; + typedef std::string::const_iterator iter; + iter b = name.begin(); + iter e = name.end(); + while(b != e) + result.append(1, wchar_t(*b++)); + return result; + } +#endif + if(p2 - p1 == 1) + return string_type(1, *p1); + return string_type(); +} + +int BOOST_REGEX_CALL c_regex_traits<wchar_t>::value(wchar_t c, int radix) +{ +#ifdef __BORLANDC__ + // workaround for broken wcstol: + if((std::iswxdigit)(c) == 0) + return -1; +#endif + wchar_t b[2] = { c, '\0', }; + wchar_t* ep; + int result = std::wcstol(b, &ep, radix); + if(ep == b) + return -1; + return result; +} + +#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T +c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform(const unsigned short* p1, const unsigned short* p2) +{ + std::wstring result = c_regex_traits<wchar_t>::transform((const wchar_t*)p1, (const wchar_t*)p2); + return string_type(result.begin(), result.end()); +} + +c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::transform_primary(const unsigned short* p1, const unsigned short* p2) +{ + std::wstring result = c_regex_traits<wchar_t>::transform_primary((const wchar_t*)p1, (const wchar_t*)p2); + return string_type(result.begin(), result.end()); +} + +c_regex_traits<unsigned short>::char_class_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_classname(const unsigned short* p1, const unsigned short* p2) +{ + return c_regex_traits<wchar_t>::lookup_classname((const wchar_t*)p1, (const wchar_t*)p2); +} + +c_regex_traits<unsigned short>::string_type BOOST_REGEX_CALL c_regex_traits<unsigned short>::lookup_collatename(const unsigned short* p1, const unsigned short* p2) +{ + std::wstring result = c_regex_traits<wchar_t>::lookup_collatename((const wchar_t*)p1, (const wchar_t*)p2); + return string_type(result.begin(), result.end()); +} + +bool BOOST_REGEX_CALL c_regex_traits<unsigned short>::isctype(unsigned short c, char_class_type m) +{ + return c_regex_traits<wchar_t>::isctype(c, m); +} + +int BOOST_REGEX_CALL c_regex_traits<unsigned short>::value(unsigned short c, int radix) +{ + return c_regex_traits<wchar_t>::value(c, radix); +} + +#endif + +} + +#endif // BOOST_NO_WREGEX + +#endif // __BORLANDC__ + diff --git a/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp b/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp new file mode 100644 index 0000000..c8a9190 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/wide_posix_api.cpp @@ -0,0 +1,310 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: wide_posix_api.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: Implements the wide character POSIX API wrappers. + */ + +#define BOOST_REGEX_SOURCE + +#include <boost/regex/config.hpp> + +#ifndef BOOST_NO_WREGEX + +#include <boost/regex.hpp> +#include <boost/cregex.hpp> + +#include <cwchar> +#include <cstring> +#include <cstdio> + +#if defined(BOOST_NO_STDC_NAMESPACE) || defined(__NetBSD__) +namespace std{ +# ifndef BOOST_NO_SWPRINTF + using ::swprintf; +# endif +} +#endif + + +namespace boost{ + +namespace { + +unsigned int wmagic_value = 28631; + +const wchar_t* wnames[] = { + L"REG_NOERROR", + L"REG_NOMATCH", + L"REG_BADPAT", + L"REG_ECOLLATE", + L"REG_ECTYPE", + L"REG_EESCAPE", + L"REG_ESUBREG", + L"REG_EBRACK", + L"REG_EPAREN", + L"REG_EBRACE", + L"REG_BADBR", + L"REG_ERANGE", + L"REG_ESPACE", + L"REG_BADRPT", + L"REG_EEND", + L"REG_ESIZE", + L"REG_ERPAREN", + L"REG_EMPTY", + L"REG_ECOMPLEXITY", + L"REG_ESTACK", + L"REG_E_UNKNOWN", +}; +} + +typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > c_regex_type; + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f) +{ + if(expression->re_magic != wmagic_value) + { + expression->guts = 0; +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + expression->guts = new c_regex_type(); +#ifndef BOOST_NO_EXCEPTIONS + } catch(...) + { + return REG_ESPACE; + } +#else + if(0 == expression->guts) + return REG_E_MEMORY; +#endif + } + // set default flags: + boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic); + expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default; + + // and translate those that are actually set: + if(f & REG_NOCOLLATE) + { + flags |= wregex::nocollate; +#ifndef BOOST_REGEX_V3 + flags &= ~wregex::collate; +#endif + } + + if(f & REG_NOSUB) + { + //expression->eflags |= match_any; + flags |= wregex::nosubs; + } + + if(f & REG_NOSPEC) + flags |= wregex::literal; + if(f & REG_ICASE) + flags |= wregex::icase; + if(f & REG_ESCAPE_IN_LISTS) + flags &= ~wregex::no_escape_in_lists; + if(f & REG_NEWLINE_ALT) + flags |= wregex::newline_alt; + + const wchar_t* p2; + if(f & REG_PEND) + p2 = expression->re_endp; + else p2 = ptr + std::wcslen(ptr); + + int result; + +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + expression->re_magic = wmagic_value; + static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags); + expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1; + result = static_cast<c_regex_type*>(expression->guts)->error_code(); +#ifndef BOOST_NO_EXCEPTIONS + } + catch(const boost::regex_error& be) + { + result = be.code(); + } + catch(...) + { + result = REG_E_UNKNOWN; + } +#endif + if(result) + regfreeW(expression); + return result; + +} + +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* e, wchar_t* buf, regsize_t buf_size) +{ + std::size_t result = 0; + if(code & REG_ITOA) + { + code &= ~REG_ITOA; + if((code <= (int)REG_E_UNKNOWN) && (code >= 0)) + { + result = std::wcslen(wnames[code]) + 1; + if(buf_size >= result) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + ::wcscpy_s(buf, buf_size, wnames[code]); +#else + std::wcscpy(buf, wnames[code]); +#endif + return result; + } + return result; + } +#if !defined(BOOST_NO_SWPRINTF) + if(code == REG_ATOI) + { + wchar_t localbuf[5]; + if(e == 0) + return 0; + for(int i = 0; i <= (int)REG_E_UNKNOWN; ++i) + { + if(std::wcscmp(e->re_endp, wnames[i]) == 0) + { +#if defined(_WIN32_WCE) && !defined(UNDER_CE) + (std::swprintf)(localbuf, L"%d", i); +#else + (std::swprintf)(localbuf, 5, L"%d", i); +#endif + if(std::wcslen(localbuf) < buf_size) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + ::wcscpy_s(buf, buf_size, localbuf); +#else + std::wcscpy(buf, localbuf); +#endif + return std::wcslen(localbuf) + 1; + } + } +#if defined(_WIN32_WCE) && !defined(UNDER_CE) + (std::swprintf)(localbuf, L"%d", 0); +#else + (std::swprintf)(localbuf, 5, L"%d", 0); +#endif + if(std::wcslen(localbuf) < buf_size) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) + ::wcscpy_s(buf, buf_size, localbuf); +#else + std::wcscpy(buf, localbuf); +#endif + return std::wcslen(localbuf) + 1; + } +#endif + if(code <= (int)REG_E_UNKNOWN) + { + std::string p; + if((e) && (e->re_magic == wmagic_value)) + p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code)); + else + { + p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code)); + } + std::size_t len = p.size(); + if(len < buf_size) + { + re_detail::copy(p.c_str(), p.c_str() + p.size() + 1, buf); + } + return len + 1; + } + if(buf_size) + *buf = 0; + return 0; +} + +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, const wchar_t* buf, regsize_t n, regmatch_t* array, int eflags) +{ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4267) +#endif + bool result = false; + match_flag_type flags = match_default | expression->eflags; + const wchar_t* end; + const wchar_t* start; + wcmatch m; + + if(eflags & REG_NOTBOL) + flags |= match_not_bol; + if(eflags & REG_NOTEOL) + flags |= match_not_eol; + if(eflags & REG_STARTEND) + { + start = buf + array[0].rm_so; + end = buf + array[0].rm_eo; + } + else + { + start = buf; + end = buf + std::wcslen(buf); + } + +#ifndef BOOST_NO_EXCEPTIONS + try{ +#endif + if(expression->re_magic == wmagic_value) + { + result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags); + } + else + return result; +#ifndef BOOST_NO_EXCEPTIONS + } catch(...) + { + return REG_E_UNKNOWN; + } +#endif + if(result) + { + // extract what matched: + std::size_t i; + for(i = 0; (i < n) && (i < expression->re_nsub + 1); ++i) + { + array[i].rm_so = (m[i].matched == false) ? -1 : (m[i].first - buf); + array[i].rm_eo = (m[i].matched == false) ? -1 : (m[i].second - buf); + } + // and set anything else to -1: + for(i = expression->re_nsub + 1; i < n; ++i) + { + array[i].rm_so = -1; + array[i].rm_eo = -1; + } + return 0; + } + return REG_NOMATCH; +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif +} + +BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression) +{ + if(expression->re_magic == wmagic_value) + { + delete static_cast<c_regex_type*>(expression->guts); + } + expression->re_magic = 0; +} + +} // namespace boost; + +#endif + + + + diff --git a/3rdParty/Boost/src/libs/regex/src/winstances.cpp b/3rdParty/Boost/src/libs/regex/src/winstances.cpp new file mode 100644 index 0000000..1e0b859 --- /dev/null +++ b/3rdParty/Boost/src/libs/regex/src/winstances.cpp @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * 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) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE: winstances.cpp + * VERSION: see <boost/version.hpp> + * DESCRIPTION: regex wide character template instances. + */ + +#define BOOST_REGEX_SOURCE + +#include <boost/regex/config.hpp> + +#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_REGEX_NO_EXTERNAL_TEMPLATES) +#define BOOST_REGEX_WIDE_INSTANTIATE + +#ifdef __BORLANDC__ +#pragma hrdstop +#endif + +#include <boost/regex.hpp> + +#endif + + + diff --git a/3rdParty/Boost/src/libs/signals/src/connection.cpp b/3rdParty/Boost/src/libs/signals/src/connection.cpp new file mode 100644 index 0000000..b4ed8b4 --- /dev/null +++ b/3rdParty/Boost/src/libs/signals/src/connection.cpp @@ -0,0 +1,155 @@ +// Boost.Signals library + +// Copyright Douglas Gregor 2001-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) + +// For more information, see http://www.boost.org + +#define BOOST_SIGNALS_SOURCE + +#include <boost/signals/connection.hpp> +#include <cassert> + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + + connection::connection(const connection& other) : + con(other.con), controlling_connection(other.controlling_connection) + { + } + + connection::~connection() + { + if (controlling_connection) { + disconnect(); + } + } + + void + connection::reset(BOOST_SIGNALS_NAMESPACE::detail::basic_connection* new_con) + { + con.reset(new_con); + } + + bool connection::operator==(const connection& other) const + { + return con.get() == other.con.get(); + } + + bool connection::operator<(const connection& other) const + { + return con.get() < other.con.get(); + } + + connection& connection::operator=(const connection& other) + { + connection(other).swap(*this); + return *this; + } + + void connection::swap(connection& other) + { + this->con.swap(other.con); + std::swap(this->controlling_connection, other.controlling_connection); + } + + void swap(connection& c1, connection& c2) + { + c1.swap(c2); + } + + scoped_connection::scoped_connection(const connection& other) : + connection(other), + released(false) + { + } + + scoped_connection::scoped_connection(const scoped_connection& other) : + connection(other), + released(other.released) + { + } + + scoped_connection::~scoped_connection() + { + if (!released) { + this->disconnect(); + } + } + + connection scoped_connection::release() + { + released = true; + return *this; + } + + void scoped_connection::swap(scoped_connection& other) + { + this->connection::swap(other); + bool other_released = other.released; + other.released = this->released; + this->released = other_released; + } + + void swap(scoped_connection& c1, scoped_connection& c2) + { + c1.swap(c2); + } + + scoped_connection& + scoped_connection::operator=(const connection& other) + { + scoped_connection(other).swap(*this); + return *this; + } + + scoped_connection& + scoped_connection::operator=(const scoped_connection& other) + { + scoped_connection(other).swap(*this); + return *this; + } + + void + connection::add_bound_object(const BOOST_SIGNALS_NAMESPACE::detail::bound_object& b) + { + assert(con.get() != 0); + con->bound_objects.push_back(b); + } + + + void connection::disconnect() const + { + if (this->connected()) { + // Make sure we have a reference to the basic_connection object, + // because 'this' may disappear + shared_ptr<detail::basic_connection> local_con = con; + + void (*signal_disconnect)(void*, void*) = local_con->signal_disconnect; + + // Note that this connection no longer exists + // Order is important here: we could get into an infinite loop if this + // isn't cleared before we try the disconnect. + local_con->signal_disconnect = 0; + + // Disconnect signal + signal_disconnect(local_con->signal, local_con->signal_data); + + // Disconnect all bound objects + typedef std::list<BOOST_SIGNALS_NAMESPACE::detail::bound_object>::iterator iterator; + for (iterator i = local_con->bound_objects.begin(); + i != local_con->bound_objects.end(); ++i) { + assert(i->disconnect != 0); + i->disconnect(i->obj, i->data); + } + } + } + } // end namespace boost +} // end namespace boost + +#ifndef BOOST_MSVC +// Explicit instantiations to keep everything in the library +template class std::list<boost::BOOST_SIGNALS_NAMESPACE::detail::bound_object>; +#endif diff --git a/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp b/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp new file mode 100644 index 0000000..85a4bda --- /dev/null +++ b/3rdParty/Boost/src/libs/signals/src/named_slot_map.cpp @@ -0,0 +1,134 @@ +// Boost.Signals library + +// Copyright Douglas Gregor 2001-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) + +// For more information, see http://www.boost.org + +#define BOOST_SIGNALS_SOURCE + +#include <boost/signals/detail/named_slot_map.hpp> +#include <cassert> +#include <map> +#include <list> +#include <typeinfo> + +namespace boost { namespace BOOST_SIGNALS_NAMESPACE { namespace detail { + +typedef std::list<connection_slot_pair> group_list; +typedef group_list::iterator slot_pair_iterator; +typedef std::map<stored_group, group_list, compare_type> slot_container_type; +typedef slot_container_type::iterator group_iterator; +typedef slot_container_type::const_iterator const_group_iterator; + + +#if BOOST_WORKAROUND(_MSC_VER, <= 1500) +void named_slot_map_iterator::decrement() { assert(false); } +void named_slot_map_iterator::advance(difference_type) { assert(false); } +#endif + +named_slot_map::named_slot_map(const compare_type& compare) : groups(compare) +{ + clear(); +} + +void named_slot_map::clear() +{ + groups.clear(); + groups[stored_group(stored_group::sk_front)]; + groups[stored_group(stored_group::sk_back)]; + back = groups.end(); + --back; +} + +named_slot_map::iterator named_slot_map::begin() +{ + return named_slot_map::iterator(groups.begin(), groups.end()); +} + +named_slot_map::iterator named_slot_map::end() +{ + return named_slot_map::iterator(groups.end(), groups.end()); +} + +named_slot_map::iterator +named_slot_map::insert(const stored_group& name, const connection& con, + const any& slot, connect_position at) +{ + group_iterator group; + if (name.empty()) { + switch (at) { + case at_front: group = groups.begin(); break; + case at_back: group = back; break; + } + } else { + group = groups.find(name); + if (group == groups.end()) { + slot_container_type::value_type v(name, group_list()); + group = groups.insert(v).first; + } + } + iterator it; + it.group = group; + it.last_group = groups.end(); + + switch (at) { + case at_back: + group->second.push_back(connection_slot_pair(con, slot)); + it.slot_ = group->second.end(); + it.slot_assigned = true; + --(it.slot_); + break; + + case at_front: + group->second.push_front(connection_slot_pair(con, slot)); + it.slot_ = group->second.begin(); + it.slot_assigned = true; + break; + } + return it; +} + +void named_slot_map::disconnect(const stored_group& name) +{ + group_iterator group = groups.find(name); + if (group != groups.end()) { + slot_pair_iterator i = group->second.begin(); + while (i != group->second.end()) { + slot_pair_iterator next = i; + ++next; + i->first.disconnect(); + i = next; + } + groups.erase(group); + } +} + +void named_slot_map::erase(iterator pos) +{ + // Erase the slot + pos.slot_->first.disconnect(); + pos.group->second.erase(pos.slot_); +} + +void named_slot_map::remove_disconnected_slots() +{ + // Remove any disconnected slots + group_iterator g = groups.begin(); + while (g != groups.end()) { + slot_pair_iterator s = g->second.begin(); + while (s != g->second.end()) { + if (s->first.connected()) ++s; + else g->second.erase(s++); + } + + // Clear out empty groups + if (empty(g)) groups.erase(g++); + else ++g; + } +} + + +} } } diff --git a/3rdParty/Boost/src/libs/signals/src/signal_base.cpp b/3rdParty/Boost/src/libs/signals/src/signal_base.cpp new file mode 100644 index 0000000..759672d --- /dev/null +++ b/3rdParty/Boost/src/libs/signals/src/signal_base.cpp @@ -0,0 +1,189 @@ +// Boost.Signals library + +// Copyright Douglas Gregor 2001-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) + +// For more information, see http://www.boost.org + +#define BOOST_SIGNALS_SOURCE + +#include <boost/signals/detail/signal_base.hpp> +#include <cassert> + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + namespace detail { + signal_base_impl::signal_base_impl(const compare_type& comp, + const any& combiner) + : call_depth(0), + slots_(comp), + combiner_(combiner) + { + flags.delayed_disconnect = false; + flags.clearing = false; + } + + signal_base_impl::~signal_base_impl() + { + // Set the "clearing" flag to ignore extraneous disconnect requests, + // because all slots will be disconnected on destruction anyway. + flags.clearing = true; + } + + void signal_base_impl::disconnect_all_slots() + { + // Do nothing if we're already clearing the slot list + if (flags.clearing) + return; + + if (call_depth == 0) { + // Clearing the slot list will disconnect all slots automatically + temporarily_set_clearing set_clearing(this); + slots_.clear(); + } + else { + // We can't actually remove elements from the slot list because there + // are still iterators into the slot list that must not be + // invalidated by this operation. So just disconnect each slot + // without removing it from the slot list. When the call depth does + // reach zero, the call list will be cleared. + flags.delayed_disconnect = true; + temporarily_set_clearing set_clearing(this); + for (iterator i = slots_.begin(); i != slots_.end(); ++i) { + i->first.disconnect(); + } + } + } + + connection + signal_base_impl:: + connect_slot(const any& slot_, + const stored_group& name, + shared_ptr<slot_base::data_t> data, + connect_position at) + { + // Transfer the burden of ownership to a local, scoped + // connection. + data->watch_bound_objects.set_controlling(false); + scoped_connection safe_connection(data->watch_bound_objects); + + // Allocate storage for an iterator that will hold the point of + // insertion of the slot into the list. This is used to later remove + // the slot when it is disconnected. + std::auto_ptr<iterator> saved_iter(new iterator); + + // Add the slot to the list. + iterator pos = + slots_.insert(name, data->watch_bound_objects, slot_, at); + + // The assignment operation here absolutely must not throw, which + // intuitively makes sense (because any container's insert method + // becomes impossible to use in an exception-safe manner without this + // assumption), but doesn't appear to be mentioned in the standard. + *saved_iter = pos; + + // Fill out the connection object appropriately. None of these + // operations can throw + data->watch_bound_objects.get_connection()->signal = this; + data->watch_bound_objects.get_connection()->signal_data = + saved_iter.release(); + data->watch_bound_objects.get_connection()->signal_disconnect = + &signal_base_impl::slot_disconnected; + + // Make the copy of the connection in the list disconnect when it is + // destroyed. The local, scoped connection is then released + // because ownership has been transferred. + pos->first.set_controlling(); + return safe_connection.release(); + } + + bool signal_base_impl::empty() const + { + // Disconnected slots may still be in the list of slots if + // a) this is called while slots are being invoked (call_depth > 0) + // b) an exception was thrown in remove_disconnected_slots + for (iterator i = slots_.begin(); i != slots_.end(); ++i) { + if (i->first.connected()) + return false; + } + + return true; + } + + std::size_t signal_base_impl::num_slots() const + { + // Disconnected slots may still be in the list of slots if + // a) this is called while slots are being invoked (call_depth > 0) + // b) an exception was thrown in remove_disconnected_slots + std::size_t count = 0; + for (iterator i = slots_.begin(); i != slots_.end(); ++i) { + if (i->first.connected()) + ++count; + } + return count; + } + + void signal_base_impl::disconnect(const stored_group& group) + { slots_.disconnect(group); } + + void signal_base_impl::slot_disconnected(void* obj, void* data) + { + signal_base_impl* self = reinterpret_cast<signal_base_impl*>(obj); + + // We won't need the slot iterator after this + std::auto_ptr<iterator> slot(reinterpret_cast<iterator*>(data)); + + // If we're flags.clearing, we don't bother updating the list of slots + if (!self->flags.clearing) { + // If we're in a call, note the fact that a slot has been deleted so + // we can come back later to remove the iterator + if (self->call_depth > 0) { + self->flags.delayed_disconnect = true; + } + else { + // Just remove the slot now, it's safe + self->slots_.erase(*slot); + } + } + } + + void signal_base_impl::remove_disconnected_slots() const + { slots_.remove_disconnected_slots(); } + + call_notification:: + call_notification(const shared_ptr<signal_base_impl>& b) : + impl(b) + { + // A call will be made, so increment the call depth as a notification + impl->call_depth++; + } + + call_notification::~call_notification() + { + impl->call_depth--; + + // If the call depth is zero and we have some slots that have been + // disconnected during the calls, remove those slots from the list + if (impl->call_depth == 0 && + impl->flags.delayed_disconnect) { + impl->remove_disconnected_slots(); + impl->flags.delayed_disconnect = false; + } + } + + signal_base::signal_base(const compare_type& comp, const any& combiner) + : impl() + { + impl.reset(new signal_base_impl(comp, combiner)); + } + + signal_base::~signal_base() + { + } + + } // namespace detail + } // namespace BOOST_SIGNALS_NAMESPACE +} // namespace boost + diff --git a/3rdParty/Boost/src/libs/signals/src/slot.cpp b/3rdParty/Boost/src/libs/signals/src/slot.cpp new file mode 100644 index 0000000..7c296d6 --- /dev/null +++ b/3rdParty/Boost/src/libs/signals/src/slot.cpp @@ -0,0 +1,71 @@ +// Boost.Signals library + +// Copyright Douglas Gregor 2001-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) + +// For more information, see http://www.boost.org + +#define BOOST_SIGNALS_SOURCE + +#include <boost/signals/slot.hpp> + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + namespace detail { + void slot_base::create_connection() + { + // Create a new connection object + basic_connection* con = new basic_connection(); + + /* nothrow */ { + // The signal portion isn't really necessary, except that we need a + // signal for the connection to be connected. + con->signal = static_cast<void*>(this); + con->signal_data = 0; + con->blocked_ = false ; + con->signal_disconnect = &bound_object_destructed; + } + + // This connection watches for destruction of bound objects. Note + // that the reset routine will delete con if an allocation throws + data->watch_bound_objects.reset(con); + + // We create a scoped connection, so that exceptions thrown while + // adding bound objects will cause a cleanup of the bound objects + // already connected. + scoped_connection safe_connection(data->watch_bound_objects); + + // Now notify each of the bound objects that they are connected to this + // slot. + for(std::vector<const trackable*>::iterator i = + data->bound_objects.begin(); + i != data->bound_objects.end(); ++i) { + // Notify the object that the slot is connecting to it + BOOST_SIGNALS_NAMESPACE::detail::bound_object binding; + (*i)->signal_connected(data->watch_bound_objects, binding); + + // This will notify the bound object that the connection just made + // should be disconnected if an exception is thrown before the + // end of this iteration + BOOST_SIGNALS_NAMESPACE::detail::auto_disconnect_bound_object + disconnector(binding); + + // Add the binding to the list of bindings for the connection + con->bound_objects.push_back(binding); + + // The connection object now knows about the bound object, so if an + // exception is thrown later the connection object will notify the + // bound object of the disconnection automatically + disconnector.release(); + } + + // No exceptions will be thrown past this point. + safe_connection.release(); + + data->watch_bound_objects.set_controlling(true); + } + } // end namespace detail + } // end namespace BOOST_SIGNALS_NAMESPACE +} // end namespace boost diff --git a/3rdParty/Boost/src/libs/signals/src/trackable.cpp b/3rdParty/Boost/src/libs/signals/src/trackable.cpp new file mode 100644 index 0000000..4f63586 --- /dev/null +++ b/3rdParty/Boost/src/libs/signals/src/trackable.cpp @@ -0,0 +1,59 @@ +// Boost.Signals library + +// Copyright Douglas Gregor 2001-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) + +// For more information, see http://www.boost.org + +#define BOOST_SIGNALS_SOURCE + +#include <boost/signals/trackable.hpp> +#include <algorithm> + +namespace boost { + namespace BOOST_SIGNALS_NAMESPACE { + void trackable::signal_disconnected(void* obj, void* data) + { + trackable* self = reinterpret_cast<trackable*>(obj); + connection_iterator* signal = + reinterpret_cast<connection_iterator*>(data); + + // If we're dying, don't bother erasing the connection from the list; + // it'll be gone anyway + if (!self->dying) { + self->connected_signals.erase(*signal); + } + + // This iterator pointer won't ever be used again + delete signal; + } + + void + trackable::signal_connected(connection c, + BOOST_SIGNALS_NAMESPACE::detail::bound_object& binding) const + { + // Insert the connection + connection_iterator pos = + connected_signals.insert(connected_signals.end(), c); + + // Make this copy of the object disconnect when destroyed + pos->set_controlling(); + + binding.obj = const_cast<void*>(reinterpret_cast<const void*>(this)); + binding.data = reinterpret_cast<void*>(new connection_iterator(pos)); + binding.disconnect = &signal_disconnected; + } + + trackable::~trackable() + { + dying = true; + } + } // end namespace BOOST_SIGNALS_NAMESPACE +} + +#ifndef BOOST_MSVC +// Explicit instantiations to keep in the library +template class std::list<boost::BOOST_SIGNALS_NAMESPACE::connection>; +#endif diff --git a/3rdParty/Boost/src/libs/system/src/error_code.cpp b/3rdParty/Boost/src/libs/system/src/error_code.cpp new file mode 100644 index 0000000..030ab70 --- /dev/null +++ b/3rdParty/Boost/src/libs/system/src/error_code.cpp @@ -0,0 +1,433 @@ +// error_code support implementation file ----------------------------------// + +// Copyright Beman Dawes 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 library home page at http://www.boost.org/libs/system + +//----------------------------------------------------------------------------// + +#include <boost/config/warning_disable.hpp> + +// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_SYSTEM_SOURCE + +#include <boost/system/config.hpp> +#include <boost/system/error_code.hpp> +#include <boost/cerrno.hpp> +#include <vector> +#include <cstdlib> +#include <cassert> + +using namespace boost::system; +using namespace boost::system::posix_error; + +#include <cstring> // for strerror/strerror_r + +# if defined( BOOST_WINDOWS_API ) +# include <windows.h> +# ifndef ERROR_INCORRECT_SIZE +# define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS +# endif +# endif + +//----------------------------------------------------------------------------// + +namespace +{ + // standard error categories ---------------------------------------------// + + class generic_error_category : public error_category + { + public: + generic_error_category(){} + const char * name() const; + std::string message( int ev ) const; + }; + + class system_error_category : public error_category + { + public: + system_error_category(){} + const char * name() const; + std::string message( int ev ) const; + error_condition default_error_condition( int ev ) const; + }; + + // generic_error_category implementation ---------------------------------// + + const char * generic_error_category::name() const + { + return "generic"; + } + + std::string generic_error_category::message( int ev ) const + { + static std::string unknown_err( "Unknown error" ); + // strerror_r is preferred because it is always thread safe, + // however, we fallback to strerror in certain cases because: + // -- Windows doesn't provide strerror_r. + // -- HP and Sundo provide strerror_r on newer systems, but there is + // no way to tell if is available at runtime and in any case their + // versions of strerror are thread safe anyhow. + // -- Linux only sometimes provides strerror_r. + // -- Tru64 provides strerror_r only when compiled -pthread. + // -- VMS doesn't provide strerror_r, but on this platform, strerror is + // thread safe. + # if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ + || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\ + || (defined(__osf__) && !defined(_REENTRANT))\ + || (defined(__vms))\ + || (defined(__QNXNTO__)) + const char * c_str = std::strerror( ev ); + return c_str + ? std::string( c_str ) + : unknown_err; + # else // use strerror_r + char buf[64]; + char * bp = buf; + std::size_t sz = sizeof(buf); + # if defined(__CYGWIN__) || defined(__USE_GNU) + // Oddball version of strerror_r + const char * c_str = strerror_r( ev, bp, sz ); + return c_str + ? std::string( c_str ) + : unknown_err; + # else + // POSIX version of strerror_r + int result; + for (;;) + { + // strerror_r returns 0 on success, otherwise ERANGE if buffer too small, + // invalid_argument if ev not a valid error number + # if defined (__sgi) + const char * c_str = strerror( ev ); + result = 0; + return c_str + ? std::string( c_str ) + : unknown_err; + # else + result = strerror_r( ev, bp, sz ); + # endif + if (result == 0 ) + break; + else + { + # if defined(__linux) + // Linux strerror_r returns -1 on error, with error number in errno + result = errno; + # endif + if ( result != ERANGE ) break; + if ( sz > sizeof(buf) ) std::free( bp ); + sz *= 2; + if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 ) + return std::string( "ENOMEM" ); + } + } + std::string msg; + try + { + msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); + } + +# ifndef BOOST_NO_EXCEPTIONS + // See ticket #2098 + catch(...) + { + // just eat the exception + } +# endif + + if ( sz > sizeof(buf) ) std::free( bp ); + sz = 0; + return msg; + # endif // else POSIX version of strerror_r + # endif // else use strerror_r + } + // system_error_category implementation --------------------------------// + + const char * system_error_category::name() const + { + return "system"; + } + + error_condition system_error_category::default_error_condition( int ev ) const + { + switch ( ev ) + { + case 0: return make_error_condition( success ); + # if defined(BOOST_POSIX_API) + // POSIX-like O/S -> posix_errno decode table ---------------------------// + case E2BIG: return make_error_condition( argument_list_too_long ); + case EACCES: return make_error_condition( permission_denied ); + case EADDRINUSE: return make_error_condition( address_in_use ); + case EADDRNOTAVAIL: return make_error_condition( address_not_available ); + case EAFNOSUPPORT: return make_error_condition( address_family_not_supported ); + case EAGAIN: return make_error_condition( resource_unavailable_try_again ); +# if EALREADY != EBUSY // EALREADY and EBUSY are the same on QNX Neutrino + case EALREADY: return make_error_condition( connection_already_in_progress ); +# endif + case EBADF: return make_error_condition( bad_file_descriptor ); + case EBADMSG: return make_error_condition( bad_message ); + case EBUSY: return make_error_condition( device_or_resource_busy ); + case ECANCELED: return make_error_condition( operation_canceled ); + case ECHILD: return make_error_condition( no_child_process ); + case ECONNABORTED: return make_error_condition( connection_aborted ); + case ECONNREFUSED: return make_error_condition( connection_refused ); + case ECONNRESET: return make_error_condition( connection_reset ); + case EDEADLK: return make_error_condition( resource_deadlock_would_occur ); + case EDESTADDRREQ: return make_error_condition( destination_address_required ); + case EDOM: return make_error_condition( argument_out_of_domain ); + case EEXIST: return make_error_condition( file_exists ); + case EFAULT: return make_error_condition( bad_address ); + case EFBIG: return make_error_condition( file_too_large ); + case EHOSTUNREACH: return make_error_condition( host_unreachable ); + case EIDRM: return make_error_condition( identifier_removed ); + case EILSEQ: return make_error_condition( illegal_byte_sequence ); + case EINPROGRESS: return make_error_condition( operation_in_progress ); + case EINTR: return make_error_condition( interrupted ); + case EINVAL: return make_error_condition( invalid_argument ); + case EIO: return make_error_condition( io_error ); + case EISCONN: return make_error_condition( already_connected ); + case EISDIR: return make_error_condition( is_a_directory ); + case ELOOP: return make_error_condition( too_many_synbolic_link_levels ); + case EMFILE: return make_error_condition( too_many_files_open ); + case EMLINK: return make_error_condition( too_many_links ); + case EMSGSIZE: return make_error_condition( message_size ); + case ENAMETOOLONG: return make_error_condition( filename_too_long ); + case ENETDOWN: return make_error_condition( network_down ); + case ENETRESET: return make_error_condition( network_reset ); + case ENETUNREACH: return make_error_condition( network_unreachable ); + case ENFILE: return make_error_condition( too_many_files_open_in_system ); + case ENOBUFS: return make_error_condition( no_buffer_space ); + case ENODATA: return make_error_condition( no_message_available ); + case ENODEV: return make_error_condition( no_such_device ); + case ENOENT: return make_error_condition( no_such_file_or_directory ); + case ENOEXEC: return make_error_condition( executable_format_error ); + case ENOLCK: return make_error_condition( no_lock_available ); + case ENOLINK: return make_error_condition( no_link ); + case ENOMEM: return make_error_condition( not_enough_memory ); + case ENOMSG: return make_error_condition( no_message ); + case ENOPROTOOPT: return make_error_condition( no_protocol_option ); + case ENOSPC: return make_error_condition( no_space_on_device ); + case ENOSR: return make_error_condition( no_stream_resources ); + case ENOSTR: return make_error_condition( not_a_stream ); + case ENOSYS: return make_error_condition( function_not_supported ); + case ENOTCONN: return make_error_condition( not_connected ); + case ENOTDIR: return make_error_condition( not_a_directory ); + # if ENOTEMPTY != EEXIST // AIX treats ENOTEMPTY and EEXIST as the same value + case ENOTEMPTY: return make_error_condition( directory_not_empty ); + # endif // ENOTEMPTY != EEXIST + case ENOTRECOVERABLE: return make_error_condition( state_not_recoverable ); + case ENOTSOCK: return make_error_condition( not_a_socket ); + case ENOTSUP: return make_error_condition( not_supported ); + case ENOTTY: return make_error_condition( inappropriate_io_control_operation ); + case ENXIO: return make_error_condition( no_such_device_or_address ); + # if EOPNOTSUPP != ENOTSUP + case EOPNOTSUPP: return make_error_condition( operation_not_supported ); + # endif // EOPNOTSUPP != ENOTSUP + case EOVERFLOW: return make_error_condition( value_too_large ); + case EOWNERDEAD: return make_error_condition( owner_dead ); + case EPERM: return make_error_condition( operation_not_permitted ); + case EPIPE: return make_error_condition( broken_pipe ); + case EPROTO: return make_error_condition( protocol_error ); + case EPROTONOSUPPORT: return make_error_condition( protocol_not_supported ); + case EPROTOTYPE: return make_error_condition( wrong_protocol_type ); + case ERANGE: return make_error_condition( result_out_of_range ); + case EROFS: return make_error_condition( read_only_file_system ); + case ESPIPE: return make_error_condition( invalid_seek ); + case ESRCH: return make_error_condition( no_such_process ); + case ETIME: return make_error_condition( stream_timeout ); + case ETIMEDOUT: return make_error_condition( timed_out ); + case ETXTBSY: return make_error_condition( text_file_busy ); + # if EAGAIN != EWOULDBLOCK + case EWOULDBLOCK: return make_error_condition( operation_would_block ); + # endif // EAGAIN != EWOULDBLOCK + case EXDEV: return make_error_condition( cross_device_link ); + #else + // Windows system -> posix_errno decode table ---------------------------// + // see WinError.h comments for descriptions of errors + case ERROR_ACCESS_DENIED: return make_error_condition( permission_denied ); + case ERROR_ALREADY_EXISTS: return make_error_condition( file_exists ); + case ERROR_BAD_UNIT: return make_error_condition( no_such_device ); + case ERROR_BUFFER_OVERFLOW: return make_error_condition( filename_too_long ); + case ERROR_BUSY: return make_error_condition( device_or_resource_busy ); + case ERROR_BUSY_DRIVE: return make_error_condition( device_or_resource_busy ); + case ERROR_CANNOT_MAKE: return make_error_condition( permission_denied ); + case ERROR_CANTOPEN: return make_error_condition( io_error ); + case ERROR_CANTREAD: return make_error_condition( io_error ); + case ERROR_CANTWRITE: return make_error_condition( io_error ); + case ERROR_CURRENT_DIRECTORY: return make_error_condition( permission_denied ); + case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); + case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); + case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); + case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid" + case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); + case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); + case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); + case ERROR_HANDLE_DISK_FULL: return make_error_condition( no_space_on_device ); + case ERROR_INVALID_ACCESS: return make_error_condition( permission_denied ); + case ERROR_INVALID_DRIVE: return make_error_condition( no_such_device ); + case ERROR_INVALID_FUNCTION: return make_error_condition( function_not_supported ); + case ERROR_INVALID_HANDLE: return make_error_condition( invalid_argument ); + case ERROR_INVALID_NAME: return make_error_condition( invalid_argument ); + case ERROR_LOCK_VIOLATION: return make_error_condition( no_lock_available ); + case ERROR_LOCKED: return make_error_condition( no_lock_available ); + case ERROR_NEGATIVE_SEEK: return make_error_condition( invalid_argument ); + case ERROR_NOACCESS: return make_error_condition( permission_denied ); + case ERROR_NOT_ENOUGH_MEMORY: return make_error_condition( not_enough_memory ); + case ERROR_NOT_READY: return make_error_condition( resource_unavailable_try_again ); + case ERROR_NOT_SAME_DEVICE: return make_error_condition( cross_device_link ); + case ERROR_OPEN_FAILED: return make_error_condition( io_error ); + case ERROR_OPEN_FILES: return make_error_condition( device_or_resource_busy ); + case ERROR_OPERATION_ABORTED: return make_error_condition( operation_canceled ); + case ERROR_OUTOFMEMORY: return make_error_condition( not_enough_memory ); + case ERROR_PATH_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); + case ERROR_READ_FAULT: return make_error_condition( io_error ); + case ERROR_RETRY: return make_error_condition( resource_unavailable_try_again ); + case ERROR_SEEK: return make_error_condition( io_error ); + case ERROR_SHARING_VIOLATION: return make_error_condition( permission_denied ); + case ERROR_TOO_MANY_OPEN_FILES: return make_error_condition( too_many_files_open ); + case ERROR_WRITE_FAULT: return make_error_condition( io_error ); + case ERROR_WRITE_PROTECT: return make_error_condition( permission_denied ); + case WSAEACCES: return make_error_condition( permission_denied ); + case WSAEADDRINUSE: return make_error_condition( address_in_use ); + case WSAEADDRNOTAVAIL: return make_error_condition( address_not_available ); + case WSAEAFNOSUPPORT: return make_error_condition( address_family_not_supported ); + case WSAEALREADY: return make_error_condition( connection_already_in_progress ); + case WSAEBADF: return make_error_condition( bad_file_descriptor ); + case WSAECONNABORTED: return make_error_condition( connection_aborted ); + case WSAECONNREFUSED: return make_error_condition( connection_refused ); + case WSAECONNRESET: return make_error_condition( connection_reset ); + case WSAEDESTADDRREQ: return make_error_condition( destination_address_required ); + case WSAEFAULT: return make_error_condition( bad_address ); + case WSAEHOSTUNREACH: return make_error_condition( host_unreachable ); + case WSAEINPROGRESS: return make_error_condition( operation_in_progress ); + case WSAEINTR: return make_error_condition( interrupted ); + case WSAEINVAL: return make_error_condition( invalid_argument ); + case WSAEISCONN: return make_error_condition( already_connected ); + case WSAEMFILE: return make_error_condition( too_many_files_open ); + case WSAEMSGSIZE: return make_error_condition( message_size ); + case WSAENAMETOOLONG: return make_error_condition( filename_too_long ); + case WSAENETDOWN: return make_error_condition( network_down ); + case WSAENETRESET: return make_error_condition( network_reset ); + case WSAENETUNREACH: return make_error_condition( network_unreachable ); + case WSAENOBUFS: return make_error_condition( no_buffer_space ); + case WSAENOPROTOOPT: return make_error_condition( no_protocol_option ); + case WSAENOTCONN: return make_error_condition( not_connected ); + case WSAENOTSOCK: return make_error_condition( not_a_socket ); + case WSAEOPNOTSUPP: return make_error_condition( operation_not_supported ); + case WSAEPROTONOSUPPORT: return make_error_condition( protocol_not_supported ); + case WSAEPROTOTYPE: return make_error_condition( wrong_protocol_type ); + case WSAETIMEDOUT: return make_error_condition( timed_out ); + case WSAEWOULDBLOCK: return make_error_condition( operation_would_block ); + #endif + default: return error_condition( ev, system_category ); + } + } + +# if !defined( BOOST_WINDOWS_API ) + + std::string system_error_category::message( int ev ) const + { + return generic_category.message( ev ); + } +# else +// TODO: + +//Some quick notes on the implementation (sorry for the noise if +//someone has already mentioned them): +// +//- The ::LocalFree() usage isn't exception safe. +// +//See: +// +//<http://boost.cvs.sourceforge.net/boost/boost/boost/asio/system_exception.hpp?revision=1.1&view=markup> +// +//in the implementation of what() for an example. +// +//Cheers, +//Chris + std::string system_error_category::message( int ev ) const + { +# ifndef BOOST_NO_ANSI_APIS + LPVOID lpMsgBuf; + DWORD retval = ::FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ev, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPSTR) &lpMsgBuf, + 0, + NULL + ); + if (retval == 0) + return std::string("Unknown error"); + + std::string str( static_cast<LPCSTR>(lpMsgBuf) ); + ::LocalFree( lpMsgBuf ); // free the buffer +# else // WinCE workaround + LPVOID lpMsgBuf; + DWORD retval = ::FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ev, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPWSTR) &lpMsgBuf, + 0, + NULL + ); + if (retval == 0) + return std::string("Unknown error"); + + int num_chars = (wcslen( static_cast<LPCWSTR>(lpMsgBuf) ) + 1) * 2; + LPSTR narrow_buffer = (LPSTR)_alloca( num_chars ); + if (::WideCharToMultiByte(CP_ACP, 0, static_cast<LPCWSTR>(lpMsgBuf), -1, narrow_buffer, num_chars, NULL, NULL) == 0) + return std::string("Unknown error"); + + std::string str( narrow_buffer ); + ::LocalFree( lpMsgBuf ); // free the buffer +# endif + while ( str.size() + && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) + str.erase( str.size()-1 ); + if ( str.size() && str[str.size()-1] == '.' ) + { str.erase( str.size()-1 ); } + return str; + } +# endif + +} // unnamed namespace + +namespace boost +{ + namespace system + { + + BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; + // note that it doesn't matter if this + // isn't initialized before use since + // the only use is to take its + // address for comparison purposes + + BOOST_SYSTEM_DECL const error_category & get_system_category() + { + static const system_error_category system_category_const; + return system_category_const; + } + + BOOST_SYSTEM_DECL const error_category & get_generic_category() + { + static const generic_error_category generic_category_const; + return generic_category_const; + } + + } // namespace system +} // namespace boost diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/exceptions.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/exceptions.cpp new file mode 100644 index 0000000..8881303 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/pthread/exceptions.cpp @@ -0,0 +1,124 @@ +// Copyright (C) 2001-2003 +// William E. Kempf +// +// Distributed under the 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/thread/detail/config.hpp> + +#include <boost/thread/exceptions.hpp> +#include <cstring> +#include <string> + +namespace boost { + +thread_exception::thread_exception() + : m_sys_err(0) +{ +} + +thread_exception::thread_exception(int sys_err_code) + : m_sys_err(sys_err_code) +{ +} + +thread_exception::~thread_exception() throw() +{ +} + +int thread_exception::native_error() const +{ + return m_sys_err; +} + +lock_error::lock_error() +{ +} + +lock_error::lock_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +lock_error::~lock_error() throw() +{ +} + +const char* lock_error::what() const throw() +{ + return "boost::lock_error"; +} + +thread_resource_error::thread_resource_error() +{ +} + +thread_resource_error::thread_resource_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +thread_resource_error::~thread_resource_error() throw() +{ +} + +const char* thread_resource_error::what() const throw() +{ + return "boost::thread_resource_error"; +} + +unsupported_thread_option::unsupported_thread_option() +{ +} + +unsupported_thread_option::unsupported_thread_option(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +unsupported_thread_option::~unsupported_thread_option() throw() +{ +} + +const char* unsupported_thread_option::what() const throw() +{ + return "boost::unsupported_thread_option"; +} + +invalid_thread_argument::invalid_thread_argument() +{ +} + +invalid_thread_argument::invalid_thread_argument(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +invalid_thread_argument::~invalid_thread_argument() throw() +{ +} + +const char* invalid_thread_argument::what() const throw() +{ + return "boost::invalid_thread_argument"; +} + +thread_permission_error::thread_permission_error() +{ +} + +thread_permission_error::thread_permission_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +thread_permission_error::~thread_permission_error() throw() +{ +} + +const char* thread_permission_error::what() const throw() +{ + return "boost::thread_permission_error"; +} + +} // namespace boost diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp new file mode 100644 index 0000000..6e3722a --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/pthread/once.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2007 Anthony Williams +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#define __STDC_CONSTANT_MACROS +#include <boost/thread/once.hpp> +#include <boost/assert.hpp> +#include <pthread.h> +#include <stdlib.h> + +namespace boost +{ + namespace detail + { + BOOST_THREAD_DECL boost::uintmax_t once_global_epoch=UINTMAX_C(~0); + BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER; + BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER; + + namespace + { + pthread_key_t epoch_tss_key; + pthread_once_t epoch_tss_key_flag=PTHREAD_ONCE_INIT; + + extern "C" void delete_epoch_tss_data(void* data) + { + free(data); + } + + extern "C" void create_epoch_tss_key() + { + BOOST_VERIFY(!pthread_key_create(&epoch_tss_key,delete_epoch_tss_data)); + } + + } + + boost::uintmax_t& get_once_per_thread_epoch() + { + BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key)); + void* data=pthread_getspecific(epoch_tss_key); + if(!data) + { + data=malloc(sizeof(boost::uintmax_t)); + BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data)); + *static_cast<boost::uintmax_t*>(data)=UINTMAX_C(~0); + } + return *static_cast<boost::uintmax_t*>(data); + } + } + +} diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp new file mode 100644 index 0000000..cc71d97 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp @@ -0,0 +1,678 @@ +// Copyright (C) 2001-2003 +// William E. Kempf +// Copyright (C) 2007-8 Anthony Williams +// +// Distributed under the 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/thread/detail/config.hpp> + +#include <boost/thread/thread.hpp> +#include <boost/thread/xtime.hpp> +#include <boost/thread/condition.hpp> +#include <boost/thread/locks.hpp> +#include <boost/thread/once.hpp> +#include <boost/thread/tss.hpp> +#ifdef __linux__ +#include <sys/sysinfo.h> +#elif defined(__APPLE__) || defined(__FreeBSD__) +#include <sys/types.h> +#include <sys/sysctl.h> +#elif defined BOOST_HAS_UNISTD_H +#include <unistd.h> +#endif + +#include "timeconv.inl" + +namespace boost +{ + namespace detail + { + thread_data_base::~thread_data_base() + {} + + struct thread_exit_callback_node + { + boost::detail::thread_exit_function_base* func; + thread_exit_callback_node* next; + + thread_exit_callback_node(boost::detail::thread_exit_function_base* func_, + thread_exit_callback_node* next_): + func(func_),next(next_) + {} + }; + + struct tss_data_node + { + void const* key; + boost::shared_ptr<boost::detail::tss_cleanup_function> func; + void* value; + tss_data_node* next; + + tss_data_node(void const* key_,boost::shared_ptr<boost::detail::tss_cleanup_function> func_,void* value_, + tss_data_node* next_): + key(key_),func(func_),value(value_),next(next_) + {} + }; + + namespace + { + boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; + pthread_key_t current_thread_tls_key; + + extern "C" + { + void tls_destructor(void* data) + { + boost::detail::thread_data_base* thread_info=static_cast<boost::detail::thread_data_base*>(data); + if(thread_info) + { + while(thread_info->tss_data || thread_info->thread_exit_callbacks) + { + while(thread_info->thread_exit_callbacks) + { + detail::thread_exit_callback_node* const current_node=thread_info->thread_exit_callbacks; + thread_info->thread_exit_callbacks=current_node->next; + if(current_node->func) + { + (*current_node->func)(); + delete current_node->func; + } + delete current_node; + } + while(thread_info->tss_data) + { + detail::tss_data_node* const current_node=thread_info->tss_data; + thread_info->tss_data=current_node->next; + if(current_node->func) + { + (*current_node->func)(current_node->value); + } + delete current_node; + } + } + thread_info->self.reset(); + } + } + } + + + void create_current_thread_tls_key() + { + BOOST_VERIFY(!pthread_key_create(¤t_thread_tls_key,&tls_destructor)); + } + } + + boost::detail::thread_data_base* get_current_thread_data() + { + boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); + return (boost::detail::thread_data_base*)pthread_getspecific(current_thread_tls_key); + } + + void set_current_thread_data(detail::thread_data_base* new_data) + { + boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); + BOOST_VERIFY(!pthread_setspecific(current_thread_tls_key,new_data)); + } + } + + namespace + { + extern "C" + { + void* thread_proxy(void* param) + { + boost::detail::thread_data_ptr thread_info = static_cast<boost::detail::thread_data_base*>(param)->self; + thread_info->self.reset(); + detail::set_current_thread_data(thread_info.get()); + try + { + thread_info->run(); + } + catch(thread_interrupted const&) + { + } +// Removed as it stops the debugger identifying the cause of the exception +// Unhandled exceptions still cause the application to terminate +// catch(...) +// { +// std::terminate(); +// } + + detail::tls_destructor(thread_info.get()); + detail::set_current_thread_data(0); + boost::lock_guard<boost::mutex> lock(thread_info->data_mutex); + thread_info->done=true; + thread_info->done_condition.notify_all(); + return 0; + } + } + + struct externally_launched_thread: + detail::thread_data_base + { + externally_launched_thread() + { + interrupt_enabled=false; + } + + void run() + {} + + private: + externally_launched_thread(externally_launched_thread&); + void operator=(externally_launched_thread&); + }; + + detail::thread_data_base* make_external_thread_data() + { + detail::thread_data_base* const me(new externally_launched_thread()); + me->self.reset(me); + set_current_thread_data(me); + return me; + } + + + detail::thread_data_base* get_or_make_current_thread_data() + { + detail::thread_data_base* current_thread_data(detail::get_current_thread_data()); + if(!current_thread_data) + { + current_thread_data=make_external_thread_data(); + } + return current_thread_data; + } + + } + + + thread::thread() + {} + + void thread::start_thread() + { + thread_info->self=thread_info; + int const res = pthread_create(&thread_info->thread_handle, 0, &thread_proxy, thread_info.get()); + if (res != 0) + { + thread_info->self.reset(); + throw thread_resource_error(); + } + } + + thread::~thread() + { + detach(); + } + + detail::thread_data_ptr thread::get_thread_info() const + { + lock_guard<mutex> l(thread_info_mutex); + return thread_info; + } + + void thread::join() + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + bool do_join=false; + + { + unique_lock<mutex> lock(local_thread_info->data_mutex); + while(!local_thread_info->done) + { + local_thread_info->done_condition.wait(lock); + } + do_join=!local_thread_info->join_started; + + if(do_join) + { + local_thread_info->join_started=true; + } + else + { + while(!local_thread_info->joined) + { + local_thread_info->done_condition.wait(lock); + } + } + } + if(do_join) + { + void* result=0; + BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result)); + lock_guard<mutex> lock(local_thread_info->data_mutex); + local_thread_info->joined=true; + local_thread_info->done_condition.notify_all(); + } + + lock_guard<mutex> l1(thread_info_mutex); + if(thread_info==local_thread_info) + { + thread_info.reset(); + } + } + } + + bool thread::timed_join(system_time const& wait_until) + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + bool do_join=false; + + { + unique_lock<mutex> lock(local_thread_info->data_mutex); + while(!local_thread_info->done) + { + if(!local_thread_info->done_condition.timed_wait(lock,wait_until)) + { + return false; + } + } + do_join=!local_thread_info->join_started; + + if(do_join) + { + local_thread_info->join_started=true; + } + else + { + while(!local_thread_info->joined) + { + local_thread_info->done_condition.wait(lock); + } + } + } + if(do_join) + { + void* result=0; + BOOST_VERIFY(!pthread_join(local_thread_info->thread_handle,&result)); + lock_guard<mutex> lock(local_thread_info->data_mutex); + local_thread_info->joined=true; + local_thread_info->done_condition.notify_all(); + } + + lock_guard<mutex> l1(thread_info_mutex); + if(thread_info==local_thread_info) + { + thread_info.reset(); + } + } + return true; + } + + bool thread::joinable() const + { + return get_thread_info(); + } + + + void thread::detach() + { + detail::thread_data_ptr local_thread_info; + { + lock_guard<mutex> l1(thread_info_mutex); + thread_info.swap(local_thread_info); + } + + if(local_thread_info) + { + lock_guard<mutex> lock(local_thread_info->data_mutex); + if(!local_thread_info->join_started) + { + BOOST_VERIFY(!pthread_detach(local_thread_info->thread_handle)); + local_thread_info->join_started=true; + local_thread_info->joined=true; + } + } + } + + namespace this_thread + { + + void sleep(const system_time& st) + { + detail::thread_data_base* const thread_info=detail::get_current_thread_data(); + + if(thread_info) + { + unique_lock<mutex> lk(thread_info->sleep_mutex); + while(thread_info->sleep_condition.timed_wait(lk,st)); + } + else + { + xtime const xt=get_xtime(st); + + for (int foo=0; foo < 5; ++foo) + { +# if defined(BOOST_HAS_PTHREAD_DELAY_NP) + timespec ts; + to_timespec_duration(xt, ts); + BOOST_VERIFY(!pthread_delay_np(&ts)); +# elif defined(BOOST_HAS_NANOSLEEP) + timespec ts; + to_timespec_duration(xt, ts); + + // nanosleep takes a timespec that is an offset, not + // an absolute time. + nanosleep(&ts, 0); +# else + mutex mx; + mutex::scoped_lock lock(mx); + condition cond; + cond.timed_wait(lock, xt); +# endif + xtime cur; + xtime_get(&cur, TIME_UTC); + if (xtime_cmp(xt, cur) <= 0) + return; + } + } + } + + void yield() + { +# if defined(BOOST_HAS_SCHED_YIELD) + BOOST_VERIFY(!sched_yield()); +# elif defined(BOOST_HAS_PTHREAD_YIELD) + BOOST_VERIFY(!pthread_yield()); +# else + xtime xt; + xtime_get(&xt, TIME_UTC); + sleep(xt); +# endif + } + } + + unsigned thread::hardware_concurrency() + { +#if defined(PTW32_VERSION) || defined(__hpux) + return pthread_num_processors_np(); +#elif defined(__linux__) + return get_nprocs(); +#elif defined(__APPLE__) || defined(__FreeBSD__) + int count; + size_t size=sizeof(count); + return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count; +#elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) + int const count=sysconf(_SC_NPROCESSORS_ONLN); + return (count>0)?count:0; +#else + return 0; +#endif + } + + thread::id thread::get_id() const + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + return id(local_thread_info); + } + else + { + return id(); + } + } + + void thread::interrupt() + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + lock_guard<mutex> lk(local_thread_info->data_mutex); + local_thread_info->interrupt_requested=true; + if(local_thread_info->current_cond) + { + BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond)); + } + } + } + + bool thread::interruption_requested() const + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + lock_guard<mutex> lk(local_thread_info->data_mutex); + return local_thread_info->interrupt_requested; + } + else + { + return false; + } + } + + thread::native_handle_type thread::native_handle() + { + detail::thread_data_ptr const local_thread_info=get_thread_info(); + if(local_thread_info) + { + lock_guard<mutex> lk(local_thread_info->data_mutex); + return local_thread_info->thread_handle; + } + else + { + return pthread_t(); + } + } + + + + namespace this_thread + { + thread::id get_id() + { + boost::detail::thread_data_base* const thread_info=get_or_make_current_thread_data(); + return thread::id(thread_info?thread_info->shared_from_this():detail::thread_data_ptr()); + } + + void interruption_point() + { + boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); + if(thread_info && thread_info->interrupt_enabled) + { + lock_guard<mutex> lg(thread_info->data_mutex); + if(thread_info->interrupt_requested) + { + thread_info->interrupt_requested=false; + throw thread_interrupted(); + } + } + } + + bool interruption_enabled() + { + boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); + return thread_info && thread_info->interrupt_enabled; + } + + bool interruption_requested() + { + boost::detail::thread_data_base* const thread_info=detail::get_current_thread_data(); + if(!thread_info) + { + return false; + } + else + { + lock_guard<mutex> lg(thread_info->data_mutex); + return thread_info->interrupt_requested; + } + } + + disable_interruption::disable_interruption(): + interruption_was_enabled(interruption_enabled()) + { + if(interruption_was_enabled) + { + detail::get_current_thread_data()->interrupt_enabled=false; + } + } + + disable_interruption::~disable_interruption() + { + if(detail::get_current_thread_data()) + { + detail::get_current_thread_data()->interrupt_enabled=interruption_was_enabled; + } + } + + restore_interruption::restore_interruption(disable_interruption& d) + { + if(d.interruption_was_enabled) + { + detail::get_current_thread_data()->interrupt_enabled=true; + } + } + + restore_interruption::~restore_interruption() + { + if(detail::get_current_thread_data()) + { + detail::get_current_thread_data()->interrupt_enabled=false; + } + } + } + + namespace detail + { + void add_thread_exit_function(thread_exit_function_base* func) + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + thread_exit_callback_node* const new_node= + new thread_exit_callback_node(func,current_thread_data->thread_exit_callbacks); + current_thread_data->thread_exit_callbacks=new_node; + } + + tss_data_node* find_tss_data(void const* key) + { + detail::thread_data_base* const current_thread_data(get_current_thread_data()); + if(current_thread_data) + { + detail::tss_data_node* current_node=current_thread_data->tss_data; + while(current_node) + { + if(current_node->key==key) + { + return current_node; + } + current_node=current_node->next; + } + } + return NULL; + } + + void* get_tss_data(void const* key) + { + if(tss_data_node* const current_node=find_tss_data(key)) + { + return current_node->value; + } + return NULL; + } + + void set_tss_data(void const* key,boost::shared_ptr<tss_cleanup_function> func,void* tss_data,bool cleanup_existing) + { + if(tss_data_node* const current_node=find_tss_data(key)) + { + if(cleanup_existing && current_node->func) + { + (*current_node->func)(current_node->value); + } + current_node->func=func; + current_node->value=tss_data; + } + else + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + tss_data_node* const new_node=new tss_data_node(key,func,tss_data,current_thread_data->tss_data); + current_thread_data->tss_data=new_node; + } + } + } + +// thread_group::thread_group() +// { +// } + +// thread_group::~thread_group() +// { +// // We shouldn't have to scoped_lock here, since referencing this object +// // from another thread while we're deleting it in the current thread is +// // going to lead to undefined behavior any way. +// for (std::list<thread*>::iterator it = m_threads.begin(); +// it != m_threads.end(); ++it) +// { +// delete (*it); +// } +// } + +// thread* thread_group::create_thread(const function0<void>& threadfunc) +// { +// // No scoped_lock required here since the only "shared data" that's +// // modified here occurs inside add_thread which does scoped_lock. +// std::auto_ptr<thread> thrd(new thread(threadfunc)); +// add_thread(thrd.get()); +// return thrd.release(); +// } + +// void thread_group::add_thread(thread* thrd) +// { +// mutex::scoped_lock scoped_lock(m_mutex); + +// // For now we'll simply ignore requests to add a thread object multiple +// // times. Should we consider this an error and either throw or return an +// // error value? +// std::list<thread*>::iterator it = std::find(m_threads.begin(), +// m_threads.end(), thrd); +// BOOST_ASSERT(it == m_threads.end()); +// if (it == m_threads.end()) +// m_threads.push_back(thrd); +// } + +// void thread_group::remove_thread(thread* thrd) +// { +// mutex::scoped_lock scoped_lock(m_mutex); + +// // For now we'll simply ignore requests to remove a thread object that's +// // not in the group. Should we consider this an error and either throw or +// // return an error value? +// std::list<thread*>::iterator it = std::find(m_threads.begin(), +// m_threads.end(), thrd); +// BOOST_ASSERT(it != m_threads.end()); +// if (it != m_threads.end()) +// m_threads.erase(it); +// } + +// void thread_group::join_all() +// { +// mutex::scoped_lock scoped_lock(m_mutex); +// for (std::list<thread*>::iterator it = m_threads.begin(); +// it != m_threads.end(); ++it) +// { +// (*it)->join(); +// } +// } + +// void thread_group::interrupt_all() +// { +// boost::lock_guard<mutex> guard(m_mutex); + +// for(std::list<thread*>::iterator it=m_threads.begin(),end=m_threads.end(); +// it!=end; +// ++it) +// { +// (*it)->interrupt(); +// } +// } + + +// size_t thread_group::size() const +// { +// return m_threads.size(); +// } + +} diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl b/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl new file mode 100644 index 0000000..5ec3b17 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/pthread/timeconv.inl @@ -0,0 +1,130 @@ +// Copyright (C) 2001-2003 +// William E. Kempf +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// boostinspect:nounnamed + +namespace { +const int MILLISECONDS_PER_SECOND = 1000; +const int NANOSECONDS_PER_SECOND = 1000000000; +const int NANOSECONDS_PER_MILLISECOND = 1000000; + +const int MICROSECONDS_PER_SECOND = 1000000; +const int NANOSECONDS_PER_MICROSECOND = 1000; + +inline void to_time(int milliseconds, boost::xtime& xt) +{ + int res = 0; + res = boost::xtime_get(&xt, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + xt.sec += (milliseconds / MILLISECONDS_PER_SECOND); + xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) * + NANOSECONDS_PER_MILLISECOND); + + if (xt.nsec >= NANOSECONDS_PER_SECOND) + { + ++xt.sec; + xt.nsec -= NANOSECONDS_PER_SECOND; + } +} + +#if defined(BOOST_HAS_PTHREADS) +inline void to_timespec(const boost::xtime& xt, timespec& ts) +{ + ts.tv_sec = static_cast<int>(xt.sec); + ts.tv_nsec = static_cast<int>(xt.nsec); + if(ts.tv_nsec >= NANOSECONDS_PER_SECOND) + { + ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND; + ts.tv_nsec %= NANOSECONDS_PER_SECOND; + } +} + +inline void to_time(int milliseconds, timespec& ts) +{ + boost::xtime xt; + to_time(milliseconds, xt); + to_timespec(xt, ts); +} + +inline void to_timespec_duration(const boost::xtime& xt, timespec& ts) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + { + ts.tv_sec = 0; + ts.tv_nsec = 0; + } + else + { + ts.tv_sec = xt.sec - cur.sec; + ts.tv_nsec = xt.nsec - cur.nsec; + + if( ts.tv_nsec < 0 ) + { + ts.tv_sec -= 1; + ts.tv_nsec += NANOSECONDS_PER_SECOND; + } + if(ts.tv_nsec >= NANOSECONDS_PER_SECOND) + { + ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND; + ts.tv_nsec %= NANOSECONDS_PER_SECOND; + } + } +} +#endif + +inline void to_duration(boost::xtime xt, int& milliseconds) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + milliseconds = 0; + else + { + if (cur.nsec > xt.nsec) + { + xt.nsec += NANOSECONDS_PER_SECOND; + --xt.sec; + } + milliseconds = (int)((xt.sec - cur.sec) * MILLISECONDS_PER_SECOND) + + (((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MILLISECOND/2)) / + NANOSECONDS_PER_MILLISECOND); + } +} + +inline void to_microduration(boost::xtime xt, int& microseconds) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + microseconds = 0; + else + { + if (cur.nsec > xt.nsec) + { + xt.nsec += NANOSECONDS_PER_SECOND; + --xt.sec; + } + microseconds = (int)((xt.sec - cur.sec) * MICROSECONDS_PER_SECOND) + + (((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MICROSECOND/2)) / + NANOSECONDS_PER_MICROSECOND); + } +} +} + +// Change Log: +// 1 Jun 01 Initial creation. diff --git a/3rdParty/Boost/src/libs/thread/src/tss_null.cpp b/3rdParty/Boost/src/libs/thread/src/tss_null.cpp new file mode 100644 index 0000000..ff13b30 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/tss_null.cpp @@ -0,0 +1,34 @@ +// (C) Copyright Michael Glassford 2004. +// (C) Copyright 2007 Anthony Williams +// 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) + +#include <boost/thread/detail/config.hpp> + +#if defined(BOOST_HAS_WINTHREADS) && (defined(BOOST_THREAD_BUILD_LIB) || defined(BOOST_THREAD_TEST) || defined(UNDER_CE)) && (!defined(_MSC_VER) || defined(UNDER_CE)) + + /* + This file is a "null" implementation of tss cleanup; it's + purpose is to to eliminate link errors in cases + where it is known that tss cleanup is not needed. + */ + + extern "C" void tss_cleanup_implemented(void) + { + /* + This function's sole purpose is to cause a link error in cases where + automatic tss cleanup is not implemented by Boost.Threads as a + reminder that user code is responsible for calling the necessary + functions at the appropriate times (and for implementing an a + tss_cleanup_implemented() function to eliminate the linker's + missing symbol error). + + If Boost.Threads later implements automatic tss cleanup in cases + where it currently doesn't (which is the plan), the duplicate + symbol error will warn the user that their custom solution is no + longer needed and can be removed. + */ + } + +#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) && !defined(_MSC_VER) diff --git a/3rdParty/Boost/src/libs/thread/src/win32/exceptions.cpp b/3rdParty/Boost/src/libs/thread/src/win32/exceptions.cpp new file mode 100644 index 0000000..8881303 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/win32/exceptions.cpp @@ -0,0 +1,124 @@ +// Copyright (C) 2001-2003 +// William E. Kempf +// +// Distributed under the 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/thread/detail/config.hpp> + +#include <boost/thread/exceptions.hpp> +#include <cstring> +#include <string> + +namespace boost { + +thread_exception::thread_exception() + : m_sys_err(0) +{ +} + +thread_exception::thread_exception(int sys_err_code) + : m_sys_err(sys_err_code) +{ +} + +thread_exception::~thread_exception() throw() +{ +} + +int thread_exception::native_error() const +{ + return m_sys_err; +} + +lock_error::lock_error() +{ +} + +lock_error::lock_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +lock_error::~lock_error() throw() +{ +} + +const char* lock_error::what() const throw() +{ + return "boost::lock_error"; +} + +thread_resource_error::thread_resource_error() +{ +} + +thread_resource_error::thread_resource_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +thread_resource_error::~thread_resource_error() throw() +{ +} + +const char* thread_resource_error::what() const throw() +{ + return "boost::thread_resource_error"; +} + +unsupported_thread_option::unsupported_thread_option() +{ +} + +unsupported_thread_option::unsupported_thread_option(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +unsupported_thread_option::~unsupported_thread_option() throw() +{ +} + +const char* unsupported_thread_option::what() const throw() +{ + return "boost::unsupported_thread_option"; +} + +invalid_thread_argument::invalid_thread_argument() +{ +} + +invalid_thread_argument::invalid_thread_argument(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +invalid_thread_argument::~invalid_thread_argument() throw() +{ +} + +const char* invalid_thread_argument::what() const throw() +{ + return "boost::invalid_thread_argument"; +} + +thread_permission_error::thread_permission_error() +{ +} + +thread_permission_error::thread_permission_error(int sys_err_code) + : thread_exception(sys_err_code) +{ +} + +thread_permission_error::~thread_permission_error() throw() +{ +} + +const char* thread_permission_error::what() const throw() +{ + return "boost::thread_permission_error"; +} + +} // namespace boost diff --git a/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp new file mode 100644 index 0000000..a72f053 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp @@ -0,0 +1,597 @@ +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// (C) Copyright 2007 Anthony Williams +// (C) Copyright 2007 David Deakins + +#define _WIN32_WINNT 0x400 +#define WINVER 0x400 + +#include <boost/thread/thread.hpp> +#include <algorithm> +#include <windows.h> +#ifndef UNDER_CE +#include <process.h> +#endif +#include <stdio.h> +#include <boost/thread/once.hpp> +#include <boost/thread/tss.hpp> +#include <boost/assert.hpp> +#include <boost/thread/detail/tss_hooks.hpp> +#include <boost/date_time/posix_time/conversion.hpp> + +namespace boost +{ + namespace + { + boost::once_flag current_thread_tls_init_flag=BOOST_ONCE_INIT; + DWORD current_thread_tls_key=0; + + void create_current_thread_tls_key() + { + tss_cleanup_implemented(); // if anyone uses TSS, we need the cleanup linked in + current_thread_tls_key=TlsAlloc(); + BOOST_ASSERT(current_thread_tls_key!=TLS_OUT_OF_INDEXES); + } + + void cleanup_tls_key() + { + if(current_thread_tls_key) + { + TlsFree(current_thread_tls_key); + current_thread_tls_key=0; + } + } + + detail::thread_data_base* get_current_thread_data() + { + if(!current_thread_tls_key) + { + return 0; + } + return (detail::thread_data_base*)TlsGetValue(current_thread_tls_key); + } + + void set_current_thread_data(detail::thread_data_base* new_data) + { + boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); + BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); + } + +#ifdef BOOST_NO_THREADEX +// Windows CE doesn't define _beginthreadex + + struct ThreadProxyData + { + typedef unsigned (__stdcall* func)(void*); + func start_address_; + void* arglist_; + ThreadProxyData(func start_address,void* arglist) : start_address_(start_address), arglist_(arglist) {} + }; + + DWORD WINAPI ThreadProxy(LPVOID args) + { + ThreadProxyData* data=reinterpret_cast<ThreadProxyData*>(args); + DWORD ret=data->start_address_(data->arglist_); + delete data; + return ret; + } + + typedef void* uintptr_t; + + inline uintptr_t const _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*), + void* arglist, unsigned initflag, unsigned* thrdaddr) + { + DWORD threadID; + HANDLE hthread=CreateThread(static_cast<LPSECURITY_ATTRIBUTES>(security),stack_size,ThreadProxy, + new ThreadProxyData(start_address,arglist),initflag,&threadID); + if (hthread!=0) + *thrdaddr=threadID; + return reinterpret_cast<uintptr_t const>(hthread); + } + +#endif + + } + + namespace detail + { + struct thread_exit_callback_node + { + boost::detail::thread_exit_function_base* func; + thread_exit_callback_node* next; + + thread_exit_callback_node(boost::detail::thread_exit_function_base* func_, + thread_exit_callback_node* next_): + func(func_),next(next_) + {} + }; + + struct tss_data_node + { + void const* key; + boost::shared_ptr<boost::detail::tss_cleanup_function> func; + void* value; + tss_data_node* next; + + tss_data_node(void const* key_,boost::shared_ptr<boost::detail::tss_cleanup_function> func_,void* value_, + tss_data_node* next_): + key(key_),func(func_),value(value_),next(next_) + {} + }; + + } + + namespace + { + void run_thread_exit_callbacks() + { + detail::thread_data_ptr current_thread_data(get_current_thread_data(),false); + if(current_thread_data) + { + while(current_thread_data->tss_data || current_thread_data->thread_exit_callbacks) + { + while(current_thread_data->thread_exit_callbacks) + { + detail::thread_exit_callback_node* const current_node=current_thread_data->thread_exit_callbacks; + current_thread_data->thread_exit_callbacks=current_node->next; + if(current_node->func) + { + (*current_node->func)(); + boost::detail::heap_delete(current_node->func); + } + boost::detail::heap_delete(current_node); + } + while(current_thread_data->tss_data) + { + detail::tss_data_node* const current_node=current_thread_data->tss_data; + current_thread_data->tss_data=current_node->next; + if(current_node->func) + { + (*current_node->func)(current_node->value); + } + boost::detail::heap_delete(current_node); + } + } + + set_current_thread_data(0); + } + } + + unsigned __stdcall thread_start_function(void* param) + { + detail::thread_data_base* const thread_info(reinterpret_cast<detail::thread_data_base*>(param)); + set_current_thread_data(thread_info); + try + { + thread_info->run(); + } + catch(thread_interrupted const&) + { + } +// Removed as it stops the debugger identifying the cause of the exception +// Unhandled exceptions still cause the application to terminate +// catch(...) +// { +// std::terminate(); +// } + run_thread_exit_callbacks(); + return 0; + } + } + + thread::thread() + {} + + void thread::start_thread() + { + uintptr_t const new_thread=_beginthreadex(0,0,&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id); + if(!new_thread) + { + throw thread_resource_error(); + } + intrusive_ptr_add_ref(thread_info.get()); + thread_info->thread_handle=(detail::win32::handle)(new_thread); + ResumeThread(thread_info->thread_handle); + } + + thread::thread(detail::thread_data_ptr data): + thread_info(data) + {} + + namespace + { + struct externally_launched_thread: + detail::thread_data_base + { + externally_launched_thread() + { + ++count; + interruption_enabled=false; + } + + void run() + {} + private: + externally_launched_thread(externally_launched_thread&); + void operator=(externally_launched_thread&); + }; + + void make_external_thread_data() + { + externally_launched_thread* me=detail::heap_new<externally_launched_thread>(); + set_current_thread_data(me); + } + + detail::thread_data_base* get_or_make_current_thread_data() + { + detail::thread_data_base* current_thread_data(get_current_thread_data()); + if(!current_thread_data) + { + make_external_thread_data(); + current_thread_data=get_current_thread_data(); + } + return current_thread_data; + } + + } + + thread::~thread() + { + detach(); + } + + thread::id thread::get_id() const + { + return thread::id(get_thread_info()); + } + + bool thread::joinable() const + { + return get_thread_info(); + } + + void thread::join() + { + detail::thread_data_ptr local_thread_info=get_thread_info(); + if(local_thread_info) + { + this_thread::interruptible_wait(local_thread_info->thread_handle,detail::timeout::sentinel()); + release_handle(); + } + } + + bool thread::timed_join(boost::system_time const& wait_until) + { + detail::thread_data_ptr local_thread_info=get_thread_info(); + if(local_thread_info) + { + if(!this_thread::interruptible_wait(local_thread_info->thread_handle,get_milliseconds_until(wait_until))) + { + return false; + } + release_handle(); + } + return true; + } + + void thread::detach() + { + release_handle(); + } + + void thread::release_handle() + { + lock_guard<mutex> l1(thread_info_mutex); + thread_info=0; + } + + void thread::interrupt() + { + detail::thread_data_ptr local_thread_info=get_thread_info(); + if(local_thread_info) + { + local_thread_info->interrupt(); + } + } + + bool thread::interruption_requested() const + { + detail::thread_data_ptr local_thread_info=get_thread_info(); + return local_thread_info.get() && (detail::win32::WaitForSingleObject(local_thread_info->interruption_handle,0)==0); + } + + unsigned thread::hardware_concurrency() + { + SYSTEM_INFO info={0}; + GetSystemInfo(&info); + return info.dwNumberOfProcessors; + } + + thread::native_handle_type thread::native_handle() + { + detail::thread_data_ptr local_thread_info=get_thread_info(); + return local_thread_info?(detail::win32::handle)local_thread_info->thread_handle:detail::win32::invalid_handle_value; + } + + detail::thread_data_ptr thread::get_thread_info() const + { + boost::mutex::scoped_lock l(thread_info_mutex); + return thread_info; + } + + namespace this_thread + { + namespace + { + LARGE_INTEGER get_due_time(detail::timeout const& target_time) + { + LARGE_INTEGER due_time={0}; + if(target_time.relative) + { + unsigned long const elapsed_milliseconds=GetTickCount()-target_time.start; + LONGLONG const remaining_milliseconds=(target_time.milliseconds-elapsed_milliseconds); + LONGLONG const hundred_nanoseconds_in_one_millisecond=10000; + + if(remaining_milliseconds>0) + { + due_time.QuadPart=-(remaining_milliseconds*hundred_nanoseconds_in_one_millisecond); + } + } + else + { + SYSTEMTIME target_system_time={0}; + target_system_time.wYear=target_time.abs_time.date().year(); + target_system_time.wMonth=target_time.abs_time.date().month(); + target_system_time.wDay=target_time.abs_time.date().day(); + target_system_time.wHour=(WORD)target_time.abs_time.time_of_day().hours(); + target_system_time.wMinute=(WORD)target_time.abs_time.time_of_day().minutes(); + target_system_time.wSecond=(WORD)target_time.abs_time.time_of_day().seconds(); + + if(!SystemTimeToFileTime(&target_system_time,((FILETIME*)&due_time))) + { + due_time.QuadPart=0; + } + else + { + long const hundred_nanoseconds_in_one_second=10000000; + due_time.QuadPart+=target_time.abs_time.time_of_day().fractional_seconds()*(hundred_nanoseconds_in_one_second/target_time.abs_time.time_of_day().ticks_per_second()); + } + } + return due_time; + } + } + + + bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time) + { + detail::win32::handle handles[3]={0}; + unsigned handle_count=0; + unsigned wait_handle_index=~0U; + unsigned interruption_index=~0U; + unsigned timeout_index=~0U; + if(handle_to_wait_for!=detail::win32::invalid_handle_value) + { + wait_handle_index=handle_count; + handles[handle_count++]=handle_to_wait_for; + } + if(get_current_thread_data() && get_current_thread_data()->interruption_enabled) + { + interruption_index=handle_count; + handles[handle_count++]=get_current_thread_data()->interruption_handle; + } + + detail::win32::handle_manager timer_handle; + +#ifndef UNDER_CE + unsigned const min_timer_wait_period=20; + + if(!target_time.is_sentinel()) + { + detail::timeout::remaining_time const time_left=target_time.remaining_milliseconds(); + if(time_left.milliseconds > min_timer_wait_period) + { + // for a long-enough timeout, use a waitable timer (which tracks clock changes) + timer_handle=CreateWaitableTimer(NULL,false,NULL); + if(timer_handle!=0) + { + LARGE_INTEGER due_time=get_due_time(target_time); + + bool const set_time_succeeded=SetWaitableTimer(timer_handle,&due_time,0,0,0,false)!=0; + if(set_time_succeeded) + { + timeout_index=handle_count; + handles[handle_count++]=timer_handle; + } + } + } + else if(!target_time.relative) + { + // convert short absolute-time timeouts into relative ones, so we don't race against clock changes + target_time=detail::timeout(time_left.milliseconds); + } + } +#endif + + bool const using_timer=timeout_index!=~0u; + detail::timeout::remaining_time time_left(0); + + do + { + if(!using_timer) + { + time_left=target_time.remaining_milliseconds(); + } + + if(handle_count) + { + unsigned long const notified_index=detail::win32::WaitForMultipleObjects(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds); + if(notified_index<handle_count) + { + if(notified_index==wait_handle_index) + { + return true; + } + else if(notified_index==interruption_index) + { + detail::win32::ResetEvent(get_current_thread_data()->interruption_handle); + throw thread_interrupted(); + } + else if(notified_index==timeout_index) + { + return false; + } + } + } + else + { + detail::win32::Sleep(time_left.milliseconds); + } + if(target_time.relative) + { + target_time.milliseconds-=detail::timeout::max_non_infinite_wait; + } + } + while(time_left.more); + return false; + } + + thread::id get_id() + { + return thread::id(get_or_make_current_thread_data()); + } + + void interruption_point() + { + if(interruption_enabled() && interruption_requested()) + { + detail::win32::ResetEvent(get_current_thread_data()->interruption_handle); + throw thread_interrupted(); + } + } + + bool interruption_enabled() + { + return get_current_thread_data() && get_current_thread_data()->interruption_enabled; + } + + bool interruption_requested() + { + return get_current_thread_data() && (detail::win32::WaitForSingleObject(get_current_thread_data()->interruption_handle,0)==0); + } + + void yield() + { + detail::win32::Sleep(0); + } + + disable_interruption::disable_interruption(): + interruption_was_enabled(interruption_enabled()) + { + if(interruption_was_enabled) + { + get_current_thread_data()->interruption_enabled=false; + } + } + + disable_interruption::~disable_interruption() + { + if(get_current_thread_data()) + { + get_current_thread_data()->interruption_enabled=interruption_was_enabled; + } + } + + restore_interruption::restore_interruption(disable_interruption& d) + { + if(d.interruption_was_enabled) + { + get_current_thread_data()->interruption_enabled=true; + } + } + + restore_interruption::~restore_interruption() + { + if(get_current_thread_data()) + { + get_current_thread_data()->interruption_enabled=false; + } + } + } + + namespace detail + { + void add_thread_exit_function(thread_exit_function_base* func) + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + thread_exit_callback_node* const new_node= + heap_new<thread_exit_callback_node>(func, + current_thread_data->thread_exit_callbacks); + current_thread_data->thread_exit_callbacks=new_node; + } + + tss_data_node* find_tss_data(void const* key) + { + detail::thread_data_base* const current_thread_data(get_current_thread_data()); + if(current_thread_data) + { + detail::tss_data_node* current_node=current_thread_data->tss_data; + while(current_node) + { + if(current_node->key==key) + { + return current_node; + } + current_node=current_node->next; + } + } + return NULL; + } + + void* get_tss_data(void const* key) + { + if(tss_data_node* const current_node=find_tss_data(key)) + { + return current_node->value; + } + return NULL; + } + + void set_tss_data(void const* key,boost::shared_ptr<tss_cleanup_function> func,void* tss_data,bool cleanup_existing) + { + if(tss_data_node* const current_node=find_tss_data(key)) + { + if(cleanup_existing && current_node->func.get()) + { + (*current_node->func)(current_node->value); + } + current_node->func=func; + current_node->value=tss_data; + } + else + { + detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); + tss_data_node* const new_node=heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data); + current_thread_data->tss_data=new_node; + } + } + } +} + + +extern "C" BOOST_THREAD_DECL void on_process_enter() +{} + +extern "C" BOOST_THREAD_DECL void on_thread_enter() +{} + +extern "C" BOOST_THREAD_DECL void on_process_exit() +{ + boost::cleanup_tls_key(); +} + +extern "C" BOOST_THREAD_DECL void on_thread_exit() +{ + boost::run_thread_exit_callbacks(); +} + diff --git a/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl b/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl new file mode 100644 index 0000000..5ec3b17 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/win32/timeconv.inl @@ -0,0 +1,130 @@ +// Copyright (C) 2001-2003 +// William E. Kempf +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// boostinspect:nounnamed + +namespace { +const int MILLISECONDS_PER_SECOND = 1000; +const int NANOSECONDS_PER_SECOND = 1000000000; +const int NANOSECONDS_PER_MILLISECOND = 1000000; + +const int MICROSECONDS_PER_SECOND = 1000000; +const int NANOSECONDS_PER_MICROSECOND = 1000; + +inline void to_time(int milliseconds, boost::xtime& xt) +{ + int res = 0; + res = boost::xtime_get(&xt, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + xt.sec += (milliseconds / MILLISECONDS_PER_SECOND); + xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) * + NANOSECONDS_PER_MILLISECOND); + + if (xt.nsec >= NANOSECONDS_PER_SECOND) + { + ++xt.sec; + xt.nsec -= NANOSECONDS_PER_SECOND; + } +} + +#if defined(BOOST_HAS_PTHREADS) +inline void to_timespec(const boost::xtime& xt, timespec& ts) +{ + ts.tv_sec = static_cast<int>(xt.sec); + ts.tv_nsec = static_cast<int>(xt.nsec); + if(ts.tv_nsec >= NANOSECONDS_PER_SECOND) + { + ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND; + ts.tv_nsec %= NANOSECONDS_PER_SECOND; + } +} + +inline void to_time(int milliseconds, timespec& ts) +{ + boost::xtime xt; + to_time(milliseconds, xt); + to_timespec(xt, ts); +} + +inline void to_timespec_duration(const boost::xtime& xt, timespec& ts) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + { + ts.tv_sec = 0; + ts.tv_nsec = 0; + } + else + { + ts.tv_sec = xt.sec - cur.sec; + ts.tv_nsec = xt.nsec - cur.nsec; + + if( ts.tv_nsec < 0 ) + { + ts.tv_sec -= 1; + ts.tv_nsec += NANOSECONDS_PER_SECOND; + } + if(ts.tv_nsec >= NANOSECONDS_PER_SECOND) + { + ts.tv_sec += ts.tv_nsec / NANOSECONDS_PER_SECOND; + ts.tv_nsec %= NANOSECONDS_PER_SECOND; + } + } +} +#endif + +inline void to_duration(boost::xtime xt, int& milliseconds) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + milliseconds = 0; + else + { + if (cur.nsec > xt.nsec) + { + xt.nsec += NANOSECONDS_PER_SECOND; + --xt.sec; + } + milliseconds = (int)((xt.sec - cur.sec) * MILLISECONDS_PER_SECOND) + + (((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MILLISECOND/2)) / + NANOSECONDS_PER_MILLISECOND); + } +} + +inline void to_microduration(boost::xtime xt, int& microseconds) +{ + boost::xtime cur; + int res = 0; + res = boost::xtime_get(&cur, boost::TIME_UTC); + assert(res == boost::TIME_UTC); + + if (boost::xtime_cmp(xt, cur) <= 0) + microseconds = 0; + else + { + if (cur.nsec > xt.nsec) + { + xt.nsec += NANOSECONDS_PER_SECOND; + --xt.sec; + } + microseconds = (int)((xt.sec - cur.sec) * MICROSECONDS_PER_SECOND) + + (((xt.nsec - cur.nsec) + (NANOSECONDS_PER_MICROSECOND/2)) / + NANOSECONDS_PER_MICROSECOND); + } +} +} + +// Change Log: +// 1 Jun 01 Initial creation. diff --git a/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp b/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp new file mode 100644 index 0000000..0522a12 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/win32/tss_dll.cpp @@ -0,0 +1,72 @@ +// (C) Copyright Michael Glassford 2004. +// 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) + +#include <boost/thread/detail/config.hpp> + +#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) + + #include <boost/thread/detail/tss_hooks.hpp> + + #define WIN32_LEAN_AND_MEAN + #include <windows.h> + + #if defined(__BORLANDC__) + extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) + #elif defined(_WIN32_WCE) + extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) + #else + extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) + #endif + { + switch(dwReason) + { + case DLL_PROCESS_ATTACH: + { + on_process_enter(); + on_thread_enter(); + break; + } + + case DLL_THREAD_ATTACH: + { + on_thread_enter(); + break; + } + + case DLL_THREAD_DETACH: + { + on_thread_exit(); + break; + } + + case DLL_PROCESS_DETACH: + { + on_thread_exit(); + on_process_exit(); + break; + } + } + + return TRUE; + } + + extern "C" void tss_cleanup_implemented(void) + { + /* + This function's sole purpose is to cause a link error in cases where + automatic tss cleanup is not implemented by Boost.Threads as a + reminder that user code is responsible for calling the necessary + functions at the appropriate times (and for implementing an a + tss_cleanup_implemented() function to eliminate the linker's + missing symbol error). + + If Boost.Threads later implements automatic tss cleanup in cases + where it currently doesn't (which is the plan), the duplicate + symbol error will warn the user that their custom solution is no + longer needed and can be removed. + */ + } + +#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) diff --git a/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp b/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp new file mode 100644 index 0000000..ae89bc4 --- /dev/null +++ b/3rdParty/Boost/src/libs/thread/src/win32/tss_pe.cpp @@ -0,0 +1,287 @@ +// $Id: tss_pe.cpp 49324 2008-10-13 20:30:13Z anthonyw $ +// (C) Copyright Aaron W. LaFramboise, Roland Schwarz, Michael Glassford 2004. +// (C) Copyright 2007 Roland Schwarz +// (C) Copyright 2007 Anthony Williams +// (C) Copyright 2007 David Deakins +// 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) + +#include <boost/thread/detail/config.hpp> + +#if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) + +#if defined(__MINGW32__) && !defined(_WIN64) + +#include <boost/thread/detail/tss_hooks.hpp> + +#include <windows.h> + +#include <cstdlib> + +extern "C" void tss_cleanup_implemented(void) {} + +namespace { + void NTAPI on_tls_callback(void* h, DWORD dwReason, PVOID pv) + { + switch (dwReason) + { + case DLL_THREAD_DETACH: + { + on_thread_exit(); + break; + } + } + } + + void on_after_ctors(void) + { + on_process_enter(); + } + + void on_before_dtors(void) + { + on_thread_exit(); + } + + void on_after_dtors(void) + { + on_process_exit(); + } +} + +extern "C" { + + void (* after_ctors )(void) __attribute__((section(".ctors"))) = on_after_ctors; + void (* before_dtors)(void) __attribute__((section(".dtors"))) = on_before_dtors; + void (* after_dtors )(void) __attribute__((section(".dtors.zzz"))) = on_after_dtors; + + ULONG __tls_index__ = 0; + char __tls_end__ __attribute__((section(".tls$zzz"))) = 0; + char __tls_start__ __attribute__((section(".tls"))) = 0; + + + PIMAGE_TLS_CALLBACK __crt_xl_start__ __attribute__ ((section(".CRT$XLA"))) = 0; + PIMAGE_TLS_CALLBACK __crt_xl_tls_callback__ __attribute__ ((section(".CRT$XLB"))) = on_tls_callback; + PIMAGE_TLS_CALLBACK __crt_xl_end__ __attribute__ ((section(".CRT$XLZ"))) = 0; +} + +extern "C" const IMAGE_TLS_DIRECTORY32 _tls_used __attribute__ ((section(".rdata$T"))) = +{ + (DWORD) &__tls_start__, + (DWORD) &__tls_end__, + (DWORD) &__tls_index__, + (DWORD) (&__crt_xl_start__+1), + (DWORD) 0, + (DWORD) 0 +}; + + +#elif defined(_MSC_VER) && !defined(UNDER_CE) + + #include <boost/thread/detail/tss_hooks.hpp> + + #include <stdlib.h> + + #define WIN32_LEAN_AND_MEAN + #include <windows.h> + + //Definitions required by implementation + + #if (_MSC_VER < 1300) // 1300 == VC++ 7.0 + typedef void (__cdecl *_PVFV)(void); + #define INIRETSUCCESS + #define PVAPI void + #else + typedef int (__cdecl *_PVFV)(void); + #define INIRETSUCCESS 0 + #define PVAPI int + #endif + + typedef void (NTAPI* _TLSCB)(HINSTANCE, DWORD, PVOID); + + //Symbols for connection to the runtime environment + + extern "C" + { + extern DWORD _tls_used; //the tls directory (located in .rdata segment) + extern _TLSCB __xl_a[], __xl_z[]; //tls initializers */ + } + + namespace + { + //Forward declarations + + static PVAPI on_tls_prepare(void); + static PVAPI on_process_init(void); + static PVAPI on_process_term(void); + static void NTAPI on_tls_callback(HINSTANCE, DWORD, PVOID); + + //The .CRT$Xxx information is taken from Codeguru: + //http://www.codeguru.com/Cpp/misc/misc/threadsprocesses/article.php/c6945__2/ + +#if (_MSC_VER >= 1400) +#pragma section(".CRT$XIU",long,read) +#pragma section(".CRT$XCU",long,read) +#pragma section(".CRT$XTU",long,read) +#pragma section(".CRT$XLC",long,read) + __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback; + __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare; + __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init; + __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term; +#else + #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 + # pragma data_seg(push, old_seg) + #endif + //Callback to run tls glue code first. + //I don't think it is necessary to run it + //at .CRT$XIB level, since we are only + //interested in thread detachement. But + //this could be changed easily if required. + + #pragma data_seg(".CRT$XIU") + static _PVFV p_tls_prepare = on_tls_prepare; + #pragma data_seg() + + //Callback after all global ctors. + + #pragma data_seg(".CRT$XCU") + static _PVFV p_process_init = on_process_init; + #pragma data_seg() + + //Callback for tls notifications. + + #pragma data_seg(".CRT$XLB") + _TLSCB p_thread_callback = on_tls_callback; + #pragma data_seg() + //Callback for termination. + + #pragma data_seg(".CRT$XTU") + static _PVFV p_process_term = on_process_term; + #pragma data_seg() + #if (_MSC_VER >= 1300) // 1300 == VC++ 7.0 + # pragma data_seg(pop, old_seg) + #endif +#endif + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4189) +#endif + + PVAPI on_tls_prepare(void) + { + //The following line has an important side effect: + //if the TLS directory is not already there, it will + //be created by the linker. In other words, it forces a tls + //directory to be generated by the linker even when static tls + //(i.e. __declspec(thread)) is not used. + //The volatile should prevent the optimizer + //from removing the reference. + + DWORD volatile dw = _tls_used; + + #if (_MSC_VER < 1300) // 1300 == VC++ 7.0 + _TLSCB* pfbegin = __xl_a; + _TLSCB* pfend = __xl_z; + _TLSCB* pfdst = pfbegin; + //pfdst = (_TLSCB*)_tls_used.AddressOfCallBacks; + + //The following loop will merge the address pointers + //into a contiguous area, since the tlssup code seems + //to require this (at least on MSVC 6) + + while (pfbegin < pfend) + { + if (*pfbegin != 0) + { + *pfdst = *pfbegin; + ++pfdst; + } + ++pfbegin; + } + + *pfdst = 0; + #endif + + return INIRETSUCCESS; + } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + + PVAPI on_process_init(void) + { + //Schedule on_thread_exit() to be called for the main + //thread before destructors of global objects have been + //called. + + //It will not be run when 'quick' exiting the + //library; however, this is the standard behaviour + //for destructors of global objects, so that + //shouldn't be a problem. + + atexit(on_thread_exit); + + //Call Boost process entry callback here + + on_process_enter(); + + return INIRETSUCCESS; + } + + PVAPI on_process_term(void) + { + on_process_exit(); + return INIRETSUCCESS; + } + + void NTAPI on_tls_callback(HINSTANCE /*h*/, DWORD dwReason, PVOID /*pv*/) + { + switch (dwReason) + { + case DLL_THREAD_DETACH: + on_thread_exit(); + break; + } + } + + BOOL WINAPI dll_callback(HANDLE, DWORD dwReason, LPVOID) + { + switch (dwReason) + { + case DLL_THREAD_DETACH: + on_thread_exit(); + break; + case DLL_PROCESS_DETACH: + on_process_exit(); + break; + } + return true; + } + } //namespace + +extern "C" +{ + extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback; +} + + extern "C" void tss_cleanup_implemented(void) + { + /* + This function's sole purpose is to cause a link error in cases where + automatic tss cleanup is not implemented by Boost.Threads as a + reminder that user code is responsible for calling the necessary + functions at the appropriate times (and for implementing an a + tss_cleanup_implemented() function to eliminate the linker's + missing symbol error). + + If Boost.Threads later implements automatic tss cleanup in cases + where it currently doesn't (which is the plan), the duplicate + symbol error will warn the user that their custom solution is no + longer needed and can be removed. + */ + } +#endif //defined(_MSC_VER) && !defined(UNDER_CE) + +#endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) |