Initial commit (I really need to remove Boost)

This commit is contained in:
wheremyfoodat 2022-09-15 04:47:14 +03:00
commit b5371dc66c
3226 changed files with 668081 additions and 0 deletions

View file

@ -0,0 +1,15 @@
// chrono.cpp --------------------------------------------------------------//
// Copyright Beman Dawes 2008
// Copyright Vicente J. Botet Escriba 2009-2010
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// define BOOST_CHRONO_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_CHRONO_SOURCE
#include <boost/chrono/detail/inlined/chrono.hpp>

View file

@ -0,0 +1,18 @@
// boost process_cpu_clocks.cpp -----------------------------------------------------------//
// Copyright 2009-2010 Vicente J. Botet Escriba
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See http://www.boost.org/libs/chrono for documentation.
//--------------------------------------------------------------------------------------//
// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_CHRONO_SOURCE
#include <boost/chrono/detail/inlined/process_cpu_clocks.hpp>

View file

@ -0,0 +1,19 @@
// boost thread_clock.cpp -----------------------------------------------------------//
// Copyright 2010 Vicente J. Botet Escriba
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See http://www.boost.org/libs/chrono for documentation.
//--------------------------------------------------------------------------------------//
// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_CHRONO_SOURCE
#include <boost/chrono/detail/inlined/thread_clock.hpp>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,72 @@
/* Copyright (c) 2001-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$
*/
/*! @mainpage Boost Date-Time Library Reference Documentation
*
*
*@section intro Introduction
*
* The Boost Date-Time Library (originally the Generic Date-Time Library or GDTL)
* is a set of C++ date-time libraries based on the concepts of generic programming.
* This is an online reference guide generated from the source code
* that provides a handy way to learn about the details of the
* library. If you are a user you should start with the
* <a href="../user_docs/index.html">User Documentation</a>.
*
*@section using Using This Documentation
*
* The online documentation provides extensive information about the details
* of the library including:
* - <A href="inherits.html">Class hierarchy</A>
* - <A href="namespaces.html">Namespace Documentation</A>
* - List of <A href="files.html">source files</A>
* - Annotated list of classes and structs
* <A href="annotated.html">(Compound List)</A>
*
* For example, suppose you wanted to learn more about the
* gregorian::greg_month class.
* You could alternatively browse the
* - <A href="classboost_1_1gregorian_1_1greg__month.html">Class documentation page</A>
* - Include dependencies for greg_month.hpp
* - Hyperlinked and colorized source files: <A href="greg__month_8hpp-source.html">[hpp file]</A> <A href="greg__month_8cpp-source.html">[cpp file]</A>
*
* The main navigation bar at the top provides that access to many
* different modes of naviation through the library.
*
*/
//! Overall boost namespace -- library does not put any symbols here
namespace boost {
//! Namespace for basic templates and components used to construct date-time systems
/*!
This namespace encapsulates various types of templates and classes used
to construct coherent date-time systems including date, time, etc. These
components should be considered helper components to be utilized in the
construction of specific date-time system implementations. See namespace
gregorian for one such example.
*/
namespace date_time {}
}
/*! Namespace for the c++ standard library. Library does not define any symbols in the namespace, but uses some classes from this namespace.
*/
namespace std {}
/*!\class std::out_of_range
\brief Exception class defined in c++ standard library.
A derivative of std::logic_error and std::exception and base class for
many exceptions in the library. See also:
<a href="http://docs.mandragor.org/files/Programming_languages/Cpp/libstdcpp_v3_Source_Documentation/classstd_1_1out__of__range.html">Mandragor docs for libstdcpp_v3 std::out_of_range</a>
*/

View file

@ -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$
*/
#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

View file

@ -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$
*/
#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

View file

@ -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$
*/
#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___

View file

@ -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$
*/
#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

View file

@ -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$
*/
/** @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.
*/

View file

@ -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$
*/
//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.
*/

View file

@ -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>
#include "internals.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)))
{
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if(r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<char>(0));
return result;
}
#endif
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::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::sort_fixed:
{
// get a regular sort key, and then truncate it:
result = transform(p1, p2);
result.erase(s_delim);
break;
}
case ::boost::BOOST_REGEX_DETAIL_NS::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;
}
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_horizontal,
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_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if(idx < 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])));
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_ASSERT(std::size_t(idx+1) < sizeof(masks) / sizeof(masks[0]));
return masks[idx+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::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == '\v')))
|| ((mask & char_class_horizontal) && (std::isspace)(static_cast<unsigned char>(c)) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != '\v'));
}
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::BOOST_REGEX_DETAIL_NS::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

View file

@ -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 BOOST_REGEX_DETAIL_NS{
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() && (m_pmessages != 0))
{
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::BOOST_REGEX_DETAIL_NS::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++);
}
} // BOOST_REGEX_DETAIL_NS
} // boost
#endif

View file

@ -0,0 +1,660 @@
/*
*
* 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
#ifdef BOOST_INTEL
#pragma warning(disable:981 383)
#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 BOOST_REGEX_DETAIL_NS{
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 BOOST_REGEX_DETAIL_NS::RegExData();
}
RegEx::RegEx(const RegEx& o)
{
pdata = new BOOST_REGEX_DETAIL_NS::RegExData(*(o.pdata));
}
RegEx::~RegEx()
{
delete pdata;
}
RegEx::RegEx(const char* c, bool icase)
{
pdata = new BOOST_REGEX_DETAIL_NS::RegExData();
SetExpression(c, icase);
}
RegEx::RegEx(const std::string& s, bool icase)
{
pdata = new BOOST_REGEX_DETAIL_NS::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 = BOOST_REGEX_DETAIL_NS::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 = BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS{
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 = BOOST_REGEX_DETAIL_NS::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(BOOST_REGEX_DETAIL_NS::pred1(cb, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
namespace BOOST_REGEX_DETAIL_NS{
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 = BOOST_REGEX_DETAIL_NS::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(BOOST_REGEX_DETAIL_NS::pred2(v, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
namespace BOOST_REGEX_DETAIL_NS{
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 = BOOST_REGEX_DETAIL_NS::RegExData::type_pc;
pdata->pbase = p;
const char* end = p;
while(*end)++end;
unsigned int result = regex_grep(BOOST_REGEX_DETAIL_NS::pred3(v, p, this), p, end, pdata->e, flags);
if(result)
pdata->update();
return result;
}
#ifndef BOOST_REGEX_NO_FILEITER
namespace BOOST_REGEX_DETAIL_NS{
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];
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(buf, MAX_PATH, start.root()));
if(*buf == 0)
{
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(buf, MAX_PATH, "."));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcat_s(buf, MAX_PATH, directory_iterator::separator()));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcat_s(buf, MAX_PATH, "*"));
}
else
{
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcat_s(buf, MAX_PATH, directory_iterator::separator()));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
{
// Verify that sprintf will not overflow:
if(std::strlen(dstart.path()) + std::strlen(directory_iterator::separator()) + std::strlen(ptr) >= MAX_PATH)
{
// Oops overflow, skip this item:
++dstart;
continue;
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
int r = (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#else
int r = (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
#endif
if(r < 0)
{
// sprintf failed, skip this item:
++dstart;
continue;
}
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 = BOOST_REGEX_DETAIL_NS::RegExData::type_pf;
pdata->fbase = map.begin();
BOOST_REGEX_DETAIL_NS::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 = BOOST_REGEX_DETAIL_NS::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;
BOOST_REGEX_DETAIL_NS::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;
BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS::RegExData::type_pc:
return pdata->m[i].matched ? pdata->m[i].first - pdata->pbase : RegEx::npos;
case BOOST_REGEX_DETAIL_NS::RegExData::type_pf:
#ifndef BOOST_REGEX_NO_FILEITER
return pdata->fm[i].matched ? pdata->fm[i].first - pdata->fbase : RegEx::npos;
#endif
case BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS::RegExData::type_pc:
return pdata->m[i].matched ? pdata->m[i].second - pdata->m[i].first : RegEx::npos;
case BOOST_REGEX_DETAIL_NS::RegExData::type_pf:
#ifndef BOOST_REGEX_NO_FILEITER
return pdata->fm[i].matched ? pdata->fm[i].second - pdata->fm[i].first : RegEx::npos;
#endif
case BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS::RegExData::type_pc:
return pdata->m[i].matched;
case BOOST_REGEX_DETAIL_NS::RegExData::type_pf:
#ifndef BOOST_REGEX_NO_FILEITER
return pdata->fm[i].matched;
#endif
case BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS::RegExData::type_pc:
if(pdata->m[i].matched)
result.assign(pdata->m[i].first, pdata->m[i].second);
break;
case BOOST_REGEX_DETAIL_NS::RegExData::type_pf:
if(pdata->m[i].matched)
result.assign(to_string(pdata->m[i].first, pdata->m[i].second));
break;
case BOOST_REGEX_DETAIL_NS::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;
}
const std::size_t RegEx::npos = ~static_cast<std::size_t>(0);
} // 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

View file

@ -0,0 +1,928 @@
/*
*
* 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 <boost/config.hpp>
#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 BOOST_REGEX_DETAIL_NS{
// 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::BOOST_REGEX_DETAIL_NS::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::size_t read_size = 0;
int read_pos = std::fseek(hfile, (node - _first) * buf_size, SEEK_SET);
if(0 == read_pos && node == _last - 1)
read_size = std::fread(*node + sizeof(int), _size % buf_size, 1, hfile);
else
read_size = std::fread(*node + sizeof(int), buf_size, 1, hfile);
if((read_size == 0) || (std::ferror(hfile)))
{
#ifndef BOOST_NO_EXCEPTIONS
unlock(node);
throw std::runtime_error("Unable to read file.");
#else
BOOST_REGEX_NOEH_ASSERT((0 == std::ferror(hfile)) && (read_size != 0));
#endif
}
}
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)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(1);
#else
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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';
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
}
else
{
*ptr = 0;
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
if(*_path == 0)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, "."));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
{
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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';
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
}
else
{
*ptr = 0;
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, _root));
if(*_path == 0)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_path, MAX_PATH, "."));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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)
{
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::strcpy_s(_root, MAX_PATH, other._root));
BOOST_REGEX_DETAIL_NS::overflow_error_if_not_zero(BOOST_REGEX_DETAIL_NS::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];
// verify that we can not overflow:
if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH)
return 0;
int r;
if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') )
r = (std::sprintf)(buf, "%s%s", root, name);
else
r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name);
if(r < 0)
return 0; // sprintf failed
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;
closedir(h);
}
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 BOOST_REGEX_DETAIL_NS
} // namspace boost
#endif // BOOST_REGEX_NO_FILEITER

511
third_party/boost/libs/regex/src/icu.cpp vendored Normal file
View file

@ -0,0 +1,511 @@
/*
*
* 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>
#ifdef BOOST_INTEL
#pragma warning(disable:981 2259 383)
#endif
namespace boost{
namespace BOOST_REGEX_DETAIL_NS{
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;
const icu_regex_traits::char_class_type icu_regex_traits::mask_horizontal = icu_regex_traits::char_class_type(1) << offset_horizontal;
const icu_regex_traits::char_class_type icu_regex_traits::mask_vertical = icu_regex_traits::char_class_type(1) << offset_vertical;
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 BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_begin = range_data;
static const BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32>* ranges_end = range_data + (sizeof(range_data)/sizeof(range_data[0]));
BOOST_REGEX_DETAIL_NS::character_pointer_range< ::UChar32> t = { p1, p2, };
const BOOST_REGEX_DETAIL_NS::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),
mask_horizontal,
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,
mask_vertical,
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 idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if(idx >= 0)
return masks[idx+1];
char_class_type result = lookup_icu_mask(p1, p2);
if(result != 0)
return result;
if(idx < 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())
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
if(idx >= 0)
return masks[idx+1];
if(s.size())
result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size());
if(result != 0)
return result;
}
BOOST_ASSERT(std::size_t(idx+1) < sizeof(masks) / sizeof(masks[0]));
return masks[idx+1];
}
icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const
{
string_type result;
#ifdef BOOST_NO_CXX98_BINDERS
if(std::find_if(p1, p2, std::bind(std::greater< ::UChar32>(), std::placeholders::_1, 0x7f)) == p2)
#else
if(std::find_if(p1, p2, std::bind2nd(std::greater< ::UChar32>(), 0x7f)) == p2)
#endif
{
#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::BOOST_REGEX_DETAIL_NS::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(static_cast<char_class_type>(1) << 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;
if(((f & mask_vertical) != 0) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == static_cast<char_type>('\v')) || (m == U_GC_ZL_MASK) || (m == U_GC_ZP_MASK)))
return true;
if(((f & mask_horizontal) != 0) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && u_isspace(c) && (c != static_cast<char_type>('\v')))
return true;
return false;
}
}
#endif // BOOST_HAS_ICU

View file

@ -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

View file

@ -0,0 +1,35 @@
/*
*
* Copyright (c) 2011
* 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)
*
*/
#ifndef BOOST_REGEX_SRC_INTERNALS_HPP
#define BOOST_REGEX_SRC_INTERNALS_HPP
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,
char_class_horizontal=1<<12,
char_class_vertical=1<<13
};
#endif // BOOST_REGEX_SRC_INTERNALS_HPP

View file

@ -0,0 +1,295 @@
/*
*
* 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 <boost/config.hpp>
#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_PERL",
"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)
{
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->guts = new c_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
expression->guts = 0;
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();
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)
BOOST_REGEX_DETAIL_NS::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)
{
//
// We're converting an integer i to a string, and since i <= REG_E_UNKNOWN
// a five character string is *always* large enough:
//
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
int r = (::sprintf_s)(localbuf, 5, "%d", i);
#else
int r = (std::sprintf)(localbuf, "%d", i);
#endif
if(r < 0)
return 0; // sprintf failed
if(std::strlen(localbuf) < buf_size)
BOOST_REGEX_DETAIL_NS::strcpy_s(buf, buf_size, localbuf);
return std::strlen(localbuf) + 1;
}
}
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
int r = (::sprintf_s)(localbuf, 5, "%d", 0);
#else
int r = (std::sprintf)(localbuf, "%d", 0);
#endif
if(r < 0)
return 0; // sprintf failed
if(std::strlen(localbuf) < buf_size)
BOOST_REGEX_DETAIL_NS::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 = BOOST_REGEX_DETAIL_NS::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
}
std::size_t len = p.size();
if(len < buf_size)
{
BOOST_REGEX_DETAIL_NS::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

View file

@ -0,0 +1,231 @@
/*
*
* 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 <boost/config.hpp>
#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
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#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
#ifdef BOOST_INTEL
#pragma warning(disable:383)
#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::BOOST_REGEX_DETAIL_NS::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 BOOST_REGEX_DETAIL_NS{
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
#if defined(BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE)
mem_block_cache block_cache = { { {nullptr} } } ;
#elif defined(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 BOOST_REGEX_DETAIL_NS
} // namespace boost
#if defined(BOOST_RE_USE_VCL) && defined(BOOST_REGEX_DYN_LINK)
int WINAPI DllEntryPoint(HINSTANCE , unsigned long , void*)
{
return 1;
}
#endif

View file

@ -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

View file

@ -0,0 +1,72 @@
/*
*
* 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 <boost/config.hpp>
#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 BOOST_REGEX_DETAIL_NS{
void BOOST_REGEX_CALL raw_storage::resize(size_type n)
{
size_type newsize = start ? last - start : 1024;
while(newsize < n)
newsize *= 2;
size_type datasize = end - start;
// extend newsize to WORD/DWORD boundary:
newsize = (newsize + padding_mask) & ~(padding_mask);
// allocate and copy data:
pointer ptr = static_cast<pointer>(::operator new(newsize));
BOOST_REGEX_NOEH_ASSERT(ptr)
if(start)
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));
void* result = start + pos;
std::memmove(start + pos + n, start + pos, (end - start) - pos);
end += n;
return result;
}
}} // namespaces

View file

@ -0,0 +1,692 @@
/*
*
* 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 BOOST_REGEX_DETAIL_NS{
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",
"gk",
"K",
"R",
};
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 0 error_ok */
"No match", /* REG_NOMATCH 1 error_no_match */
"Invalid regular expression.", /* REG_BADPAT 2 error_bad_pattern */
"Invalid collation character.", /* REG_ECOLLATE 3 error_collate */
"Invalid character class name, collating name, or character range.", /* REG_ECTYPE 4 error_ctype */
"Invalid or unterminated escape sequence.", /* REG_EESCAPE 5 error_escape */
"Invalid back reference: specified capturing group does not exist.", /* REG_ESUBREG 6 error_backref */
"Unmatched [ or [^ in character class declaration.", /* REG_EBRACK 7 error_brack */
"Unmatched marking parenthesis ( or \\(.", /* REG_EPAREN 8 error_paren */
"Unmatched quantified repeat operator { or \\{.", /* REG_EBRACE 9 error_brace */
"Invalid content of repeat range.", /* REG_BADBR 10 error_badbrace */
"Invalid range end in character class", /* REG_ERANGE 11 error_range */
"Out of memory.", /* REG_ESPACE 12 error_space NOT USED */
"Invalid preceding regular expression prior to repetition operator.", /* REG_BADRPT 13 error_badrepeat */
"Premature end of regular expression", /* REG_EEND 14 error_end NOT USED */
"Regular expression is too large.", /* REG_ESIZE 15 error_size NOT USED */
"Unmatched ) or \\)", /* REG_ERPAREN 16 error_right_paren NOT USED */
"Empty regular expression.", /* REG_EMPTY 17 error_empty */
"The complexity of matching the regular expression exceeded predefined bounds. "
"Try refactoring the regular expression to make each choice made by the state machine unambiguous. "
"This exception is thrown to prevent \"eternal\" matches that take an "
"indefinite period time to locate.", /* REG_ECOMPLEXITY 18 error_complexity */
"Ran out of stack space trying to match the regular expression.", /* REG_ESTACK 19 error_stack */
"Invalid or unterminated Perl (?...) sequence.", /* REG_E_PERL 20 error_perl */
"Unknown error.", /* REG_E_UNKNOWN 21 error_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_reset_start_mark, /*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_line_ending, /*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_extended_backref, /*g*/
regex_constants::escape_type_class, /*h*/
regex_constants::escape_type_class, /*i*/
regex_constants::escape_type_class, /*j*/
regex_constants::escape_type_extended_backref, /*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::escape_type_end_buffer, /*'*/
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];
}
} // BOOST_REGEX_DETAIL_NS
} // boost

View file

@ -0,0 +1,185 @@
/*
*
* 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>
#include <boost/assert.hpp>
#ifdef BOOST_HAS_THREADS
#include <boost/regex/pending/static_mutex.hpp>
#if defined(BOOST_HAS_WINTHREADS)
#ifndef NOMINMAX
# define NOMINMAX
#endif
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#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)
{
// Client code will throw if this fails:
m_have_lock = (pthread_mutex_lock(&(m_mutex.m_mutex)) == 0);
}
}
void scoped_static_mutex_lock::unlock()
{
if(m_have_lock)
{
// If this fails there's nothing we can do except assert,
// exceptions are out of the question as this code is called
// from the lock's destructor:
BOOST_VERIFY(pthread_mutex_unlock(&(m_mutex.m_mutex)) == 0);
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 boost_regex_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(boost_regex_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::unique_lock<boost::recursive_mutex>(*static_mutex::m_pmutex, boost::defer_lock);
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

View file

@ -0,0 +1,81 @@
/*
*
* 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
#ifdef _MSC_VER
#pragma warning(disable:4506) // 'no definition for inline function'
#endif
#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))\
&& BOOST_WORKAROUND(BOOST_MSVC, <1600)
//
// 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

View file

@ -0,0 +1,654 @@
/*
*
* 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) && !defined(BOOST_REGEX_NO_WIN32_LOCALE)
#include <boost/regex/regex_traits.hpp>
#include <boost/regex/pattern_except.hpp>
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#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 BOOST_REGEX_DETAIL_NS{
#ifdef BOOST_NO_ANSI_APIS
UINT get_code_page_for_locale_id(lcid_type idx)
{
WCHAR code_page_string[7];
if (::GetLocaleInfoW(idx, 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::BOOST_REGEX_DETAIL_NS::w32_cat_open(cat_name);
if(!cat)
{
std::string m("Unable to open message catalog: ");
std::runtime_error err(m + cat_name);
::boost::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::w32_is(this->m_locale, 0x0002u, (char)i))
m_char_map[i] = regex_constants::escape_type_class;
else if(::boost::BOOST_REGEX_DETAIL_NS::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 idx)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(idx);
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(idx, 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 idx)
{
WORD mask;
if(::GetStringTypeExW(idx, 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 idx)
{
WORD mask;
wchar_t c = ca;
if(::GetStringTypeExW(idx, 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 idx)
{
#ifndef BOOST_NO_ANSI_APIS
WORD mask;
if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true;
return false;
#else
UINT code_page = get_code_page_for_locale_id(idx);
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(idx, 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 idx)
{
WORD mask;
if(::GetStringTypeExW(idx, 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 idx)
{
WORD mask;
wchar_t c = ca;
if(::GetStringTypeExW(idx, 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;
int buf_size = 1 + ::WideCharToMultiByte(CP_ACP, 0, wbuf, r, NULL, 0, NULL, NULL);
LPSTR buf = (LPSTR)_alloca(buf_size);
if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, buf_size, NULL, NULL) == 0)
return def; // failed conversion.
#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 idx, const char* p1, const char* p2)
{
#ifndef BOOST_NO_ANSI_APIS
int bytes = ::LCMapStringA(
idx, // 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(
idx, // 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(idx);
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(
idx, // 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(
idx, // 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 idx, const wchar_t* p1, const wchar_t* p2)
{
int bytes = ::LCMapStringW(
idx, // 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(
idx, // 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 idx, const unsigned short* p1, const unsigned short* p2)
{
int bytes = ::LCMapStringW(
idx, // 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(
idx, // 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 idx)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
idx, // 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(idx);
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(
idx, // 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; // No single byte lower case equivalent available
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // 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 idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // 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 idx)
{
char result[2];
#ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA(
idx, // 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(idx);
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(
idx, // 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; // No single byte upper case equivalent available.
#endif
return result[0];
}
#ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // 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 idx)
{
wchar_t result[2];
int b = ::LCMapStringW(
idx, // 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 idx, boost::uint32_t m, char c)
{
WORD mask;
#ifndef BOOST_NO_ANSI_APIS
if(::GetStringTypeExA(idx, 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(idx);
if(code_page == 0)
return false;
WCHAR wide_c;
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false;
if(::GetStringTypeExW(idx, 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 idx, boost::uint32_t m, wchar_t c)
{
WORD mask;
if(::GetStringTypeExW(idx, 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 idx, boost::uint32_t m, unsigned short c)
{
WORD mask;
if(::GetStringTypeExW(idx, 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
} // BOOST_REGEX_DETAIL_NS
} // boost
#endif

View file

@ -0,0 +1,314 @@
/*
*
* 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>
#include "internals.hpp"
#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))\
&& BOOST_WORKAROUND(BOOST_MSVC, <1600)
//
// 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)))
{
#if defined(_CPPLIB_VER)
//
// A bug in VC11 and 12 causes the program to hang if we pass a null-string
// to std::strxfrm, but only for certain locales :-(
// Probably effects Intel and Clang or any compiler using the VC std library (Dinkumware).
//
if(r == INT_MAX)
{
result.erase();
result.insert(result.begin(), static_cast<wchar_t>(0));
return result;
}
#endif
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::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::sort_C:
case ::boost::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::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::BOOST_REGEX_DETAIL_NS::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;
}
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_horizontal,
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_vertical,
char_class_alnum | char_class_word,
char_class_alnum | char_class_word,
char_class_xdigit,
};
int idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(p1, p2);
if(idx < 0)
{
std::wstring s(p1, p2);
for(std::wstring::size_type i = 0; i < s.size(); ++i)
s[i] = (std::towlower)(s[i]);
idx = ::boost::BOOST_REGEX_DETAIL_NS::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
}
BOOST_ASSERT(idx+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
return masks[idx+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::BOOST_REGEX_DETAIL_NS::is_separator(c))
|| ((mask & char_class_word) && (c == '_'))
|| ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
|| ((mask & char_class_vertical) && (::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) || (c == L'\v')))
|| ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::BOOST_REGEX_DETAIL_NS::is_separator(c) && (c != L'\v'));
}
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::BOOST_REGEX_DETAIL_NS::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__

View file

@ -0,0 +1,312 @@
/*
*
* 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>
#ifdef BOOST_INTEL
#pragma warning(disable:981)
#endif
#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_PERL",
L"REG_E_UNKNOWN",
};
}
typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > wc_regex_type;
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
{
#ifndef BOOST_NO_EXCEPTIONS
try{
#endif
expression->guts = new wc_regex_type();
#ifndef BOOST_NO_EXCEPTIONS
} catch(...)
{
expression->guts = 0;
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<wc_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
expression->re_nsub = static_cast<wc_regex_type*>(expression->guts)->mark_count();
result = static_cast<wc_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<wc_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
else
{
p = BOOST_REGEX_DETAIL_NS::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
}
std::size_t len = p.size();
if(len < buf_size)
{
BOOST_REGEX_DETAIL_NS::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<wc_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<wc_regex_type*>(expression->guts);
}
expression->re_magic = 0;
}
} // namespace boost;
#endif

View file

@ -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

View file

@ -0,0 +1,73 @@
/*
*
* Copyright (c) 2003
* 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)
*
*/
//
// This program extends config_info to print out regex library
// configuration information. We do this by redfining the main
// provided by config_info, our real main will call it later:
//
#ifndef OLD_MAIN
# define OLD_MAIN info_main
#endif
#define main OLD_MAIN
#include <libs/config/test/config_info.cpp>
#undef main
#ifndef NEW_MAIN
# define NEW_MAIN main
#endif
#include <boost/regex.hpp>
int NEW_MAIN()
{
OLD_MAIN();
print_separator();
PRINT_MACRO(BOOST_REGEX_USER_CONFIG);
PRINT_MACRO(BOOST_REGEX_USE_C_LOCALE);
PRINT_MACRO(BOOST_REGEX_USE_CPP_LOCALE);
PRINT_MACRO(BOOST_REGEX_HAS_DLL_RUNTIME);
PRINT_MACRO(BOOST_REGEX_DYN_LINK);
PRINT_MACRO(BOOST_REGEX_NO_LIB);
PRINT_MACRO(BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE);
PRINT_MACRO(BOOST_REGEX_NO_W32);
PRINT_MACRO(BOOST_REGEX_NO_BOOL);
PRINT_MACRO(BOOST_REGEX_NO_EXTERNAL_TEMPLATES);
PRINT_MACRO(BOOST_REGEX_NO_FWD);
PRINT_MACRO(BOOST_REGEX_V3);
PRINT_MACRO(BOOST_REGEX_HAS_MS_STACK_GUARD);
PRINT_MACRO(BOOST_REGEX_RECURSIVE);
PRINT_MACRO(BOOST_REGEX_NON_RECURSIVE);
PRINT_MACRO(BOOST_REGEX_BLOCKSIZE);
PRINT_MACRO(BOOST_REGEX_MAX_BLOCKS);
PRINT_MACRO(BOOST_REGEX_MAX_CACHE_BLOCKS);
PRINT_MACRO(BOOST_NO_WREGEX);
PRINT_MACRO(BOOST_REGEX_NO_FILEITER);
PRINT_MACRO(BOOST_REGEX_STATIC_LINK);
PRINT_MACRO(BOOST_REGEX_DYN_LINK);
PRINT_MACRO(BOOST_REGEX_DECL);
PRINT_MACRO(BOOST_REGEX_CALL);
PRINT_MACRO(BOOST_REGEX_CCALL);
PRINT_MACRO(BOOST_REGEX_MAX_STATE_COUNT);
PRINT_MACRO(BOOST_REGEX_BUGGY_CTYPE_FACET);
PRINT_MACRO(BOOST_REGEX_MATCH_EXTRA);
PRINT_MACRO(BOOST_HAS_ICU);
PRINT_MACRO(BOOST_REGEX_HAS_OTHER_WCHAR_T);
#if defined(BOOST_REGEX_CONFIG_INFO) && !defined(NO_RECURSE)
print_regex_library_info();
#endif
return 0;
}

View file

@ -0,0 +1,154 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// archive_exception.cpp:
// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <exception>
#include <string>
#include <cstring>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/archive_exception.hpp>
namespace boost {
namespace archive {
BOOST_ARCHIVE_DECL
unsigned int
archive_exception::append(unsigned int l, const char * a){
while(l < (sizeof(m_buffer) - 1)){
char c = *a++;
if('\0' == c)
break;
m_buffer[l++] = c;
}
m_buffer[l] = '\0';
return l;
}
BOOST_ARCHIVE_DECL
archive_exception::archive_exception(
exception_code c,
const char * e1,
const char * e2
) BOOST_NOEXCEPT :
code(c)
{
unsigned int length = 0;
switch(code){
case no_exception:
length = append(length, "uninitialized exception");
break;
case unregistered_class:
length = append(length, "unregistered class");
if(NULL != e1){
length = append(length, " - ");
length = append(length, e1);
}
break;
case invalid_signature:
length = append(length, "invalid signature");
break;
case unsupported_version:
length = append(length, "unsupported version");
break;
case pointer_conflict:
length = append(length, "pointer conflict");
break;
case incompatible_native_format:
length = append(length, "incompatible native format");
if(NULL != e1){
length = append(length, " - ");
length = append(length, e1);
}
break;
case array_size_too_short:
length = append(length, "array size too short");
break;
case input_stream_error:
length = append(length, "input stream error");
if(NULL != e1){
length = append(length, "-");
length = append(length, e1);
}
if(NULL != e2){
length = append(length, "-");
length = append(length, e2);
}
break;
case invalid_class_name:
length = append(length, "class name too long");
break;
case unregistered_cast:
length = append(length, "unregistered void cast ");
length = append(length, (NULL != e1) ? e1 : "?");
length = append(length, "<-");
length = append(length, (NULL != e2) ? e2 : "?");
break;
case unsupported_class_version:
length = append(length, "class version ");
length = append(length, (NULL != e1) ? e1 : "<unknown class>");
break;
case other_exception:
// if get here - it indicates a derived exception
// was sliced by passing by value in catch
length = append(length, "unknown derived exception");
break;
case multiple_code_instantiation:
length = append(length, "code instantiated in more than one module");
if(NULL != e1){
length = append(length, " - ");
length = append(length, e1);
}
break;
case output_stream_error:
length = append(length, "output stream error");
if(NULL != e1){
length = append(length, "-");
length = append(length, e1);
}
if(NULL != e2){
length = append(length, "-");
length = append(length, e2);
}
break;
default:
BOOST_ASSERT(false);
length = append(length, "programming error");
break;
}
}
BOOST_ARCHIVE_DECL
archive_exception::archive_exception(archive_exception const & oth) BOOST_NOEXCEPT :
std::exception(oth),
code(oth.code)
{
std::memcpy(m_buffer,oth.m_buffer,sizeof m_buffer);
}
BOOST_ARCHIVE_DECL
archive_exception::~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW {}
BOOST_ARCHIVE_DECL const char *
archive_exception::what() const BOOST_NOEXCEPT_OR_NOTHROW {
return m_buffer;
}
BOOST_ARCHIVE_DECL
archive_exception::archive_exception() BOOST_NOEXCEPT :
code(no_exception)
{}
} // archive
} // boost

View file

@ -0,0 +1,90 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_archive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
//////////////////////////////////////////////////////////////////////
//
// objects are stored as
//
// class_id* // -1 for a null pointer
// if a new class id
// [
// exported key - class name*
// tracking level - always/never
// class version
// ]
//
// if tracking
// [
// object_id
// ]
//
// [ // if a new object id
// data...
// ]
//
// * required only for pointers - optional for objects
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/basic_archive.hpp>
namespace boost {
namespace archive {
///////////////////////////////////////////////////////////////////////
// constants used in archive signature
//This should never ever change. note that is not an std::string
// string.
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_SIGNATURE(){
return "serialization::archive";
}
// this should change if the capabilities are added to the library
// such that archives can be created which can't be read by previous
// versions of this library
// 1 - initial version
// 2 - made address tracking optional
// 3 - numerous changes - can't guarentee compatibility with previous versions
// 4 - Boost 1.34
// added item_version to properly support versioning for collections
// 5 - Boost 1.36
// changed serialization of collections: adding version even for primitive
// types caused backwards compatibility breaking change in 1.35
// 6 - Boost 1.41 17 Nov 2009
// serializing collection sizes as std::size_t
// 7 Boost 1.42 2 Feb 2010
// error - changed binary version to 16 bits w/o changing library version #
// That is - binary archives are recorded with #6 even though they are
// different from the previous versions. This means that binary archives
// created with versions 1.42 and 1.43 will have to be fixed with a special
// program which fixes the library version # in the header
// Boost 1.43 6 May 2010
// no change
// 8 - Boost 1.44
// separated version_type into library_version_type and class_version_type
// changed version_type to be stored as 8 bits.
// 10- fixed base64 output/input.
// 11- not changes
// 12- improved serialization of collections
// 13- simplified visibility, removed Borland, removed pfto
// 14- improved visibility, refactor map/set
// 15- corrections to optional and collection loading
// 16- eliminated dependency on <codecvt> which is buggy in some libraries
// and now officially deprecated in the standard
// 17- Boost 1.68 August 2018
BOOST_SYMBOL_VISIBLE library_version_type
BOOST_ARCHIVE_VERSION(){
return library_version_type(17);
}
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,599 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_archive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings
#include <boost/assert.hpp>
#include <set>
#include <list>
#include <vector>
#include <cstddef> // size_t, NULL
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{
using ::size_t;
} // namespace std
#endif
#include <boost/integer_traits.hpp>
#define BOOST_ARCHIVE_SOURCE
// include this to prevent linker errors when the
// same modules are marked export and import.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/state_saver.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/decl.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/basic_iserializer.hpp>
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
using namespace boost::serialization;
namespace boost {
namespace archive {
namespace detail {
class basic_iarchive_impl {
friend class basic_iarchive;
library_version_type m_archive_library_version;
unsigned int m_flags;
//////////////////////////////////////////////////////////////////////
// information about each serialized object loaded
// indexed on object_id
struct aobject
{
void * address;
bool loaded_as_pointer;
class_id_type class_id;
aobject(
void *a,
class_id_type class_id_
) :
address(a),
loaded_as_pointer(false),
class_id(class_id_)
{}
aobject() :
address(NULL),
loaded_as_pointer(false),
class_id(-2)
{}
};
typedef std::vector<aobject> object_id_vector_type;
object_id_vector_type object_id_vector;
//////////////////////////////////////////////////////////////////////
// used to implement the reset_object_address operation.
struct moveable_objects {
object_id_type start;
object_id_type end;
object_id_type recent;
bool is_pointer;
moveable_objects() :
start(0),
end(0),
recent(0),
is_pointer(false)
{}
} m_moveable_objects;
void reset_object_address(
const void * new_address,
const void *old_address
);
//////////////////////////////////////////////////////////////////////
// used by load object to look up class id given basic_serializer
struct cobject_type
{
const basic_iserializer * m_bis;
const class_id_type m_class_id;
cobject_type(
std::size_t class_id,
const basic_iserializer & bis
) :
m_bis(& bis),
m_class_id(class_id)
{}
cobject_type(const cobject_type & rhs) :
m_bis(rhs.m_bis),
m_class_id(rhs.m_class_id)
{}
// the following cannot be defined because of the const
// member. This will generate a link error if an attempt
// is made to assign. This should never be necessary
cobject_type & operator=(const cobject_type & rhs);
bool operator<(const cobject_type &rhs) const
{
return *m_bis < *(rhs.m_bis);
}
};
typedef std::set<cobject_type> cobject_info_set_type;
cobject_info_set_type cobject_info_set;
//////////////////////////////////////////////////////////////////////
// information about each serialized class indexed on class_id
class cobject_id
{
public:
cobject_id & operator=(const cobject_id & rhs){
bis_ptr = rhs.bis_ptr;
bpis_ptr = rhs.bpis_ptr;
file_version = rhs.file_version;
tracking_level = rhs.tracking_level;
initialized = rhs.initialized;
return *this;
}
const basic_iserializer * bis_ptr;
const basic_pointer_iserializer * bpis_ptr;
version_type file_version;
tracking_type tracking_level;
bool initialized;
cobject_id(const basic_iserializer & bis_) :
bis_ptr(& bis_),
bpis_ptr(NULL),
file_version(0),
tracking_level(track_never),
initialized(false)
{}
cobject_id(const cobject_id &rhs):
bis_ptr(rhs.bis_ptr),
bpis_ptr(rhs.bpis_ptr),
file_version(rhs.file_version),
tracking_level(rhs.tracking_level),
initialized(rhs.initialized)
{}
};
typedef std::vector<cobject_id> cobject_id_vector_type;
cobject_id_vector_type cobject_id_vector;
//////////////////////////////////////////////////////////////////////
// address of the most recent object serialized as a poiner
// whose data itself is now pending serialization
struct pending {
void * object;
const basic_iserializer * bis;
version_type version;
pending() :
object(NULL),
bis(NULL),
version(0)
{}
} m_pending;
basic_iarchive_impl(unsigned int flags) :
m_archive_library_version(BOOST_ARCHIVE_VERSION()),
m_flags(flags)
{}
void set_library_version(library_version_type archive_library_version){
m_archive_library_version = archive_library_version;
}
bool
track(
basic_iarchive & ar,
void * & t
);
void
load_preamble(
basic_iarchive & ar,
cobject_id & co
);
class_id_type register_type(
const basic_iserializer & bis
);
// redirect through virtual functions to load functions for this archive
template<class T>
void load(basic_iarchive & ar, T & t){
ar.vload(t);
}
//public:
void
next_object_pointer(void * t){
m_pending.object = t;
}
void delete_created_pointers();
class_id_type register_type(
const basic_pointer_iserializer & bpis
);
void load_object(
basic_iarchive & ar,
void * t,
const basic_iserializer & bis
);
const basic_pointer_iserializer * load_pointer(
basic_iarchive & ar,
void * & t,
const basic_pointer_iserializer * bpis,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type
)
);
};
inline void
basic_iarchive_impl::reset_object_address(
void const * const new_address,
void const * const old_address
){
if(m_moveable_objects.is_pointer)
return;
// this code handles a couple of situations.
// a) where reset_object_address is applied to an untracked object.
// In such a case the call is really superfluous and its really an
// an error. But we don't have access to the types here so we can't
// know that. However, this code will effectively turn this situation
// into a no-op and every thing will work fine - albeat with a small
// execution time penalty.
// b) where the call to reset_object_address doesn't immediatly follow
// the << operator to which it corresponds. This would be a bad idea
// but the code may work anyway. Naturally, a bad practice on the part
// of the programmer but we can't detect it - as above. So maybe we
// can save a few more people from themselves as above.
object_id_type i = m_moveable_objects.recent;
for(; i < m_moveable_objects.end; ++i){
if(old_address == object_id_vector[i].address)
break;
}
for(; i < m_moveable_objects.end; ++i){
void const * const this_address = object_id_vector[i].address;
// calculate displacement from this level
// warning - pointer arithmetic on void * is in herently non-portable
// but expected to work on all platforms in current usage
if(this_address > old_address){
std::size_t member_displacement
= reinterpret_cast<std::size_t>(this_address)
- reinterpret_cast<std::size_t>(old_address);
object_id_vector[i].address = reinterpret_cast<void *>(
reinterpret_cast<std::size_t>(new_address) + member_displacement
);
}
else{
std::size_t member_displacement
= reinterpret_cast<std::size_t>(old_address)
- reinterpret_cast<std::size_t>(this_address);
object_id_vector[i].address = reinterpret_cast<void *>(
reinterpret_cast<std::size_t>(new_address) - member_displacement
);
}
}
}
inline void
basic_iarchive_impl::delete_created_pointers()
{
object_id_vector_type::iterator i;
for(
i = object_id_vector.begin();
i != object_id_vector.end();
++i
){
if(i->loaded_as_pointer){
// borland complains without this minor hack
const int j = i->class_id;
const cobject_id & co = cobject_id_vector[j];
//const cobject_id & co = cobject_id_vector[i->class_id];
// with the appropriate input serializer,
// delete the indicated object
co.bis_ptr->destroy(i->address);
}
}
}
inline class_id_type
basic_iarchive_impl::register_type(
const basic_iserializer & bis
){
class_id_type cid(cobject_info_set.size());
cobject_type co(cid, bis);
std::pair<cobject_info_set_type::const_iterator, bool>
result = cobject_info_set.insert(co);
if(result.second){
cobject_id_vector.push_back(cobject_id(bis));
BOOST_ASSERT(cobject_info_set.size() == cobject_id_vector.size());
}
cid = result.first->m_class_id;
// borland complains without this minor hack
const int tid = cid;
cobject_id & coid = cobject_id_vector[tid];
coid.bpis_ptr = bis.get_bpis_ptr();
return cid;
}
void
basic_iarchive_impl::load_preamble(
basic_iarchive & ar,
cobject_id & co
){
if(! co.initialized){
if(co.bis_ptr->class_info()){
class_id_optional_type cid(class_id_type(0));
load(ar, cid); // to be thrown away
load(ar, co.tracking_level);
load(ar, co.file_version);
}
else{
// override tracking with indicator from class information
co.tracking_level = co.bis_ptr->tracking(m_flags);
co.file_version = version_type(
co.bis_ptr->version()
);
}
co.initialized = true;
}
}
bool
basic_iarchive_impl::track(
basic_iarchive & ar,
void * & t
){
object_id_type oid;
load(ar, oid);
// if its a reference to a old object
if(object_id_type(object_id_vector.size()) > oid){
// we're done
t = object_id_vector[oid].address;
return false;
}
return true;
}
inline void
basic_iarchive_impl::load_object(
basic_iarchive & ar,
void * t,
const basic_iserializer & bis
){
m_moveable_objects.is_pointer = false;
serialization::state_saver<bool> ss_is_pointer(m_moveable_objects.is_pointer);
// if its been serialized through a pointer and the preamble's been done
if(t == m_pending.object && & bis == m_pending.bis){
// read data
(bis.load_object_data)(ar, t, m_pending.version);
return;
}
const class_id_type cid = register_type(bis);
const int i = cid;
cobject_id & co = cobject_id_vector[i];
load_preamble(ar, co);
// save the current move stack position in case we want to truncate it
boost::serialization::state_saver<object_id_type> ss_start(m_moveable_objects.start);
// note: extra line used to evade borland issue
const bool tracking = co.tracking_level;
object_id_type this_id;
m_moveable_objects.start =
this_id = object_id_type(object_id_vector.size());
// if we tracked this object when the archive was saved
if(tracking){
// if it was already read
if(!track(ar, t))
// we're done
return;
// add a new enty into the tracking list
object_id_vector.push_back(aobject(t, cid));
// and add an entry for this object
m_moveable_objects.end = object_id_type(object_id_vector.size());
}
// read data
(bis.load_object_data)(ar, t, co.file_version);
m_moveable_objects.recent = this_id;
}
inline const basic_pointer_iserializer *
basic_iarchive_impl::load_pointer(
basic_iarchive &ar,
void * & t,
const basic_pointer_iserializer * bpis_ptr,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type_
)
){
m_moveable_objects.is_pointer = true;
serialization::state_saver<bool> w(m_moveable_objects.is_pointer);
class_id_type cid;
load(ar, cid);
if(NULL_POINTER_TAG == cid){
t = NULL;
return bpis_ptr;
}
// if its a new class type - i.e. never been registered
if(class_id_type(cobject_info_set.size()) <= cid){
// if its either abstract
if(NULL == bpis_ptr
// or polymorphic
|| bpis_ptr->get_basic_serializer().is_polymorphic()){
// is must have been exported
char key[BOOST_SERIALIZATION_MAX_KEY_SIZE];
class_name_type class_name(key);
load(ar, class_name);
// if it has a class name
const serialization::extended_type_info *eti = NULL;
if(0 != key[0])
eti = serialization::extended_type_info::find(key);
if(NULL == eti)
boost::serialization::throw_exception(
archive_exception(archive_exception::unregistered_class)
);
bpis_ptr = (*finder)(*eti);
}
BOOST_ASSERT(NULL != bpis_ptr);
// class_id_type new_cid = register_type(bpis_ptr->get_basic_serializer());
BOOST_VERIFY(register_type(bpis_ptr->get_basic_serializer()) == cid);
int i = cid;
cobject_id_vector[i].bpis_ptr = bpis_ptr;
}
int i = cid;
cobject_id & co = cobject_id_vector[i];
bpis_ptr = co.bpis_ptr;
if (bpis_ptr == NULL) {
boost::serialization::throw_exception(
archive_exception(archive_exception::unregistered_class)
);
}
load_preamble(ar, co);
// extra line to evade borland issue
const bool tracking = co.tracking_level;
// if we're tracking and the pointer has already been read
if(tracking && ! track(ar, t))
// we're done
return bpis_ptr;
// save state
serialization::state_saver<object_id_type> w_start(m_moveable_objects.start);
// allocate space on the heap for the object - to be constructed later
t = bpis_ptr->heap_allocation();
BOOST_ASSERT(NULL != t);
if(! tracking){
bpis_ptr->load_object_ptr(ar, t, co.file_version);
}
else{
serialization::state_saver<void *> x(m_pending.object);
serialization::state_saver<const basic_iserializer *> y(m_pending.bis);
serialization::state_saver<version_type> z(m_pending.version);
m_pending.bis = & bpis_ptr->get_basic_serializer();
m_pending.version = co.file_version;
// predict next object id to be created
const size_t ui = object_id_vector.size();
serialization::state_saver<object_id_type> w_end(m_moveable_objects.end);
// add to list of serialized objects so that we can properly handle
// cyclic strucures
object_id_vector.push_back(aobject(t, cid));
// remember that that the address of these elements could change
// when we make another call so don't use the address
bpis_ptr->load_object_ptr(
ar,
t,
m_pending.version
);
object_id_vector[ui].loaded_as_pointer = true;
}
return bpis_ptr;
}
} // namespace detail
} // namespace archive
} // namespace boost
//////////////////////////////////////////////////////////////////////
// implementation of basic_iarchive functions
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL void
basic_iarchive::next_object_pointer(void *t){
pimpl->next_object_pointer(t);
}
BOOST_ARCHIVE_DECL
basic_iarchive::basic_iarchive(unsigned int flags) :
pimpl(new basic_iarchive_impl(flags))
{}
BOOST_ARCHIVE_DECL
basic_iarchive::~basic_iarchive()
{}
BOOST_ARCHIVE_DECL void
basic_iarchive::set_library_version(library_version_type archive_library_version){
pimpl->set_library_version(archive_library_version);
}
BOOST_ARCHIVE_DECL void
basic_iarchive::reset_object_address(
const void * new_address,
const void * old_address
){
pimpl->reset_object_address(new_address, old_address);
}
BOOST_ARCHIVE_DECL void
basic_iarchive::load_object(
void *t,
const basic_iserializer & bis
){
pimpl->load_object(*this, t, bis);
}
// load a pointer object
BOOST_ARCHIVE_DECL const basic_pointer_iserializer *
basic_iarchive::load_pointer(
void * &t,
const basic_pointer_iserializer * bpis_ptr,
const basic_pointer_iserializer * (*finder)(
const boost::serialization::extended_type_info & type_
)
){
return pimpl->load_pointer(*this, t, bpis_ptr, finder);
}
BOOST_ARCHIVE_DECL void
basic_iarchive::register_basic_serializer(const basic_iserializer & bis){
pimpl->register_type(bis);
}
BOOST_ARCHIVE_DECL void
basic_iarchive::delete_created_pointers()
{
pimpl->delete_created_pointers();
}
BOOST_ARCHIVE_DECL boost::archive::library_version_type
basic_iarchive::get_library_version() const{
return pimpl->m_archive_library_version;
}
BOOST_ARCHIVE_DECL unsigned int
basic_iarchive::get_flags() const{
return pimpl->m_flags;
}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,34 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_iserializer.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <cstddef> // NULL
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/basic_iserializer.hpp>
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL
basic_iserializer::basic_iserializer(
const boost::serialization::extended_type_info & eti
) :
basic_serializer(eti),
m_bpis(NULL)
{}
BOOST_ARCHIVE_DECL
basic_iserializer::~basic_iserializer(){}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,470 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_oarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp> // msvc 6.0 needs this for warning suppression
#include <boost/assert.hpp>
#include <set>
#include <cstddef> // NULL
#include <boost/limits.hpp>
// including this here to work around an ICC in intel 7.0
// normally this would be part of basic_oarchive.hpp below.
#define BOOST_ARCHIVE_SOURCE
// include this to prevent linker errors when the
// same modules are marked export and import.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/state_saver.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/serialization/extended_type_info.hpp>
#include <boost/archive/detail/decl.hpp>
#include <boost/archive/basic_archive.hpp>
#include <boost/archive/detail/basic_oserializer.hpp>
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
#include <boost/archive/detail/basic_oarchive.hpp>
#include <boost/archive/archive_exception.hpp>
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4251 4231 4660 4275)
#endif
using namespace boost::serialization;
namespace boost {
namespace archive {
namespace detail {
class basic_oarchive_impl {
friend class basic_oarchive;
unsigned int m_flags;
//////////////////////////////////////////////////////////////////////
// information about each serialized object saved
// keyed on address, class_id
struct aobject
{
const void * address;
class_id_type class_id;
object_id_type object_id;
bool operator<(const aobject &rhs) const
{
BOOST_ASSERT(NULL != address);
BOOST_ASSERT(NULL != rhs.address);
if( address < rhs.address )
return true;
if( address > rhs.address )
return false;
return class_id < rhs.class_id;
}
aobject & operator=(const aobject & rhs)
{
address = rhs.address;
class_id = rhs.class_id;
object_id = rhs.object_id;
return *this;
}
aobject(
const void *a,
class_id_type class_id_,
object_id_type object_id_
) :
address(a),
class_id(class_id_),
object_id(object_id_)
{}
aobject() : address(NULL){}
};
// keyed on class_id, address
typedef std::set<aobject> object_set_type;
object_set_type object_set;
//////////////////////////////////////////////////////////////////////
// information about each serialized class saved
// keyed on type_info
struct cobject_type
{
const basic_oserializer * m_bos_ptr;
const class_id_type m_class_id;
bool m_initialized;
cobject_type(
std::size_t class_id,
const basic_oserializer & bos
) :
m_bos_ptr(& bos),
m_class_id(class_id),
m_initialized(false)
{}
cobject_type(const basic_oserializer & bos) :
m_bos_ptr(& bos),
m_initialized(false)
{}
cobject_type(
const cobject_type & rhs
) :
m_bos_ptr(rhs.m_bos_ptr),
m_class_id(rhs.m_class_id),
m_initialized(rhs.m_initialized)
{}
// the following cannot be defined because of the const
// member. This will generate a link error if an attempt
// is made to assign. This should never be necessary
// use this only for lookup argument
cobject_type & operator=(const cobject_type &rhs);
bool operator<(const cobject_type &rhs) const {
return *m_bos_ptr < *(rhs.m_bos_ptr);
}
};
// keyed on type_info
typedef std::set<cobject_type> cobject_info_set_type;
cobject_info_set_type cobject_info_set;
// list of objects initially stored as pointers - used to detect errors
// keyed on object id
std::set<object_id_type> stored_pointers;
// address of the most recent object serialized as a poiner
// whose data itself is now pending serialization
const void * pending_object;
const basic_oserializer * pending_bos;
basic_oarchive_impl(unsigned int flags) :
m_flags(flags),
pending_object(NULL),
pending_bos(NULL)
{}
const cobject_type &
find(const basic_oserializer & bos);
const basic_oserializer *
find(const serialization::extended_type_info &ti) const;
//public:
const cobject_type &
register_type(const basic_oserializer & bos);
void save_object(
basic_oarchive & ar,
const void *t,
const basic_oserializer & bos
);
void save_pointer(
basic_oarchive & ar,
const void * t,
const basic_pointer_oserializer * bpos
);
};
//////////////////////////////////////////////////////////////////////
// basic_oarchive implementation functions
// given a type_info - find its bos
// return NULL if not found
inline const basic_oserializer *
basic_oarchive_impl::find(const serialization::extended_type_info & ti) const {
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
class bosarg :
public basic_oserializer
{
bool class_info() const {
BOOST_ASSERT(false);
return false;
}
// returns true if objects should be tracked
bool tracking(const unsigned int) const {
BOOST_ASSERT(false);
return false;
}
// returns class version
version_type version() const {
BOOST_ASSERT(false);
return version_type(0);
}
// returns true if this class is polymorphic
bool is_polymorphic() const{
BOOST_ASSERT(false);
return false;
}
void save_object_data(
basic_oarchive & /*ar*/, const void * /*x*/
) const {
BOOST_ASSERT(false);
}
public:
bosarg(const serialization::extended_type_info & eti) :
boost::archive::detail::basic_oserializer(eti)
{}
};
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
bosarg bos(ti);
cobject_info_set_type::const_iterator cit
= cobject_info_set.find(cobject_type(bos));
// it should already have been "registered" - see below
if(cit == cobject_info_set.end()){
// if an entry is not found in the table it is because a pointer
// of a derived class has been serialized through its base class
// but the derived class hasn't been "registered"
return NULL;
}
// return pointer to the real class
return cit->m_bos_ptr;
}
inline const basic_oarchive_impl::cobject_type &
basic_oarchive_impl::find(const basic_oserializer & bos)
{
std::pair<cobject_info_set_type::iterator, bool> cresult =
cobject_info_set.insert(cobject_type(cobject_info_set.size(), bos));
return *(cresult.first);
}
inline const basic_oarchive_impl::cobject_type &
basic_oarchive_impl::register_type(
const basic_oserializer & bos
){
cobject_type co(cobject_info_set.size(), bos);
std::pair<cobject_info_set_type::const_iterator, bool>
result = cobject_info_set.insert(co);
return *(result.first);
}
inline void
basic_oarchive_impl::save_object(
basic_oarchive & ar,
const void *t,
const basic_oserializer & bos
){
// if its been serialized through a pointer and the preamble's been done
if(t == pending_object && pending_bos == & bos){
// just save the object data
ar.end_preamble();
(bos.save_object_data)(ar, t);
return;
}
// get class information for this object
const cobject_type & co = register_type(bos);
if(bos.class_info()){
if( ! co.m_initialized){
ar.vsave(class_id_optional_type(co.m_class_id));
ar.vsave(tracking_type(bos.tracking(m_flags)));
ar.vsave(version_type(bos.version()));
(const_cast<cobject_type &>(co)).m_initialized = true;
}
}
// we're not tracking this type of object
if(! bos.tracking(m_flags)){
// just windup the preamble - no object id to write
ar.end_preamble();
// and save the data
(bos.save_object_data)(ar, t);
return;
}
// look for an existing object id
object_id_type oid(object_set.size());
// lookup to see if this object has already been written to the archive
basic_oarchive_impl::aobject ao(t, co.m_class_id, oid);
std::pair<basic_oarchive_impl::object_set_type::const_iterator, bool>
aresult = object_set.insert(ao);
oid = aresult.first->object_id;
// if its a new object
if(aresult.second){
// write out the object id
ar.vsave(oid);
ar.end_preamble();
// and data
(bos.save_object_data)(ar, t);
return;
}
// check that it wasn't originally stored through a pointer
if(stored_pointers.end() != stored_pointers.find(oid)){
// this has to be a user error. loading such an archive
// would create duplicate objects
boost::serialization::throw_exception(
archive_exception(archive_exception::pointer_conflict)
);
}
// just save the object id
ar.vsave(object_reference_type(oid));
ar.end_preamble();
return;
}
// save a pointer to an object instance
inline void
basic_oarchive_impl::save_pointer(
basic_oarchive & ar,
const void * t,
const basic_pointer_oserializer * bpos_ptr
){
const basic_oserializer & bos = bpos_ptr->get_basic_serializer();
std::size_t original_count = cobject_info_set.size();
const cobject_type & co = register_type(bos);
if(! co.m_initialized){
ar.vsave(co.m_class_id);
// if its a previously unregistered class
if((cobject_info_set.size() > original_count)){
if(bos.is_polymorphic()){
const serialization::extended_type_info *eti = & bos.get_eti();
const char * key = NULL;
if(NULL != eti)
key = eti->get_key();
if(NULL != key){
// the following is required by IBM C++ compiler which
// makes a copy when passing a non-const to a const. This
// is permitted by the standard but rarely seen in practice
const class_name_type cn(key);
if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
boost::serialization::throw_exception(
boost::archive::archive_exception(
boost::archive::archive_exception::
invalid_class_name)
);
// write out the external class identifier
ar.vsave(cn);
}
else
// without an external class name
// we won't be able to de-serialize it so bail now
boost::serialization::throw_exception(
archive_exception(archive_exception::unregistered_class)
);
}
}
if(bos.class_info()){
ar.vsave(tracking_type(bos.tracking(m_flags)));
ar.vsave(version_type(bos.version()));
}
(const_cast<cobject_type &>(co)).m_initialized = true;
}
else{
ar.vsave(class_id_reference_type(co.m_class_id));
}
// if we're not tracking
if(! bos.tracking(m_flags)){
// just save the data itself
ar.end_preamble();
serialization::state_saver<const void *> x(pending_object);
serialization::state_saver<const basic_oserializer *> y(pending_bos);
pending_object = t;
pending_bos = & bpos_ptr->get_basic_serializer();
bpos_ptr->save_object_ptr(ar, t);
return;
}
object_id_type oid(object_set.size());
// lookup to see if this object has already been written to the archive
basic_oarchive_impl::aobject ao(t, co.m_class_id, oid);
std::pair<basic_oarchive_impl::object_set_type::const_iterator, bool>
aresult = object_set.insert(ao);
oid = aresult.first->object_id;
// if the saved object already exists
if(! aresult.second){
// append the object id to he preamble
ar.vsave(object_reference_type(oid));
// and windup.
ar.end_preamble();
return;
}
// append id of this object to preamble
ar.vsave(oid);
ar.end_preamble();
// and save the object itself
serialization::state_saver<const void *> x(pending_object);
serialization::state_saver<const basic_oserializer *> y(pending_bos);
pending_object = t;
pending_bos = & bpos_ptr->get_basic_serializer();
bpos_ptr->save_object_ptr(ar, t);
// add to the set of object initially stored through pointers
stored_pointers.insert(oid);
}
} // namespace detail
} // namespace archive
} // namespace boost
//////////////////////////////////////////////////////////////////////
// implementation of basic_oarchive functions
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL
basic_oarchive::basic_oarchive(unsigned int flags)
: pimpl(new basic_oarchive_impl(flags))
{}
BOOST_ARCHIVE_DECL
basic_oarchive::~basic_oarchive()
{}
BOOST_ARCHIVE_DECL void
basic_oarchive::save_object(
const void *x,
const basic_oserializer & bos
){
pimpl->save_object(*this, x, bos);
}
BOOST_ARCHIVE_DECL void
basic_oarchive::save_pointer(
const void * t,
const basic_pointer_oserializer * bpos_ptr
){
pimpl->save_pointer(*this, t, bpos_ptr);
}
BOOST_ARCHIVE_DECL void
basic_oarchive::register_basic_serializer(const basic_oserializer & bos){
pimpl->register_type(bos);
}
BOOST_ARCHIVE_DECL library_version_type
basic_oarchive::get_library_version() const{
return BOOST_ARCHIVE_VERSION();
}
BOOST_ARCHIVE_DECL unsigned int
basic_oarchive::get_flags() const{
return pimpl->m_flags;
}
BOOST_ARCHIVE_DECL void
basic_oarchive::end_preamble(){
}
BOOST_ARCHIVE_DECL helper_collection &
basic_oarchive::get_helper_collection(){
return *this;
}
} // namespace detail
} // namespace archive
} // namespace boost
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif

View file

@ -0,0 +1,34 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_oserializer.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <cstddef> // NULL
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/basic_oserializer.hpp>
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL
basic_oserializer::basic_oserializer(
const boost::serialization::extended_type_info & eti
) :
basic_serializer(eti),
m_bpos(NULL)
{}
BOOST_ARCHIVE_DECL
basic_oserializer::~basic_oserializer(){}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,31 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_pointer_iserializer.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL
basic_pointer_iserializer::basic_pointer_iserializer(
const boost::serialization::extended_type_info & eti
) :
basic_serializer(eti)
{}
BOOST_ARCHIVE_DECL
basic_pointer_iserializer::~basic_pointer_iserializer() {}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,31 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_pointer_oserializer.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
namespace boost {
namespace archive {
namespace detail {
BOOST_ARCHIVE_DECL
basic_pointer_oserializer::basic_pointer_oserializer(
const boost::serialization::extended_type_info & eti
) :
basic_serializer(eti)
{}
BOOST_ARCHIVE_DECL
basic_pointer_oserializer::~basic_pointer_oserializer() {}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,112 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// serializer_map.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <set>
#include <utility>
#define BOOST_ARCHIVE_SOURCE
// include this to prevent linker errors when the
// same modules are marked export and import.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/archive_exception.hpp>
#include <boost/archive/detail/basic_serializer.hpp>
#include <boost/archive/detail/basic_serializer_map.hpp>
namespace boost {
namespace serialization {
class extended_type_info;
}
namespace archive {
namespace detail {
bool
basic_serializer_map::type_info_pointer_compare::operator()(
const basic_serializer * lhs, const basic_serializer * rhs
) const {
return *lhs < *rhs;
}
BOOST_ARCHIVE_DECL bool
basic_serializer_map::insert(const basic_serializer * bs){
// attempt to insert serializer into it's map
// the following is commented out - rather than being just
// deleted as a reminder not to try this.
// const std::pair<map_type::iterator, bool> result =
m_map.insert(bs);
// At first it seemed like a good idea. It enforced the
// idea that a type be exported from at most one code module
// (DLL or mainline). This would enforce a "one definition rule"
// across code modules. This seems a good idea to me.
// But it seems that it's just too hard for many users to implement.
// Ideally, I would like to make this exception a warning -
// but there isn't anyway to do that.
// if this fails, it's because it's been instantiated
// in multiple modules - DLLS - a recipe for problems.
// So trap this here
// if(!result.second){
// boost::serialization::throw_exception(
// archive_exception(
// archive_exception::multiple_code_instantiation,
// bs->get_debug_info()
// )
// );
// }
return true;
}
BOOST_ARCHIVE_DECL void
basic_serializer_map::erase(const basic_serializer * bs){
map_type::iterator it = m_map.begin();
map_type::iterator it_end = m_map.end();
while(it != it_end){
// note item 9 from Effective STL !!! it++
if(*it == bs)
m_map.erase(it++);
else
it++;
}
// note: we can't do this since some of the eti records
// we're pointing to might be expired and the comparison
// won't work. Leave this as a reminder not to "optimize" this.
//it = m_map.find(bs);
//assert(it != m_map.end());
//if(*it == bs)
// m_map.erase(it);
}
BOOST_ARCHIVE_DECL const basic_serializer *
basic_serializer_map::find(
const boost::serialization::extended_type_info & eti
) const {
const basic_serializer_arg bs(eti);
map_type::const_iterator it;
it = m_map.find(& bs);
if(it == m_map.end()){
BOOST_ASSERT(false);
return 0;
}
return *it;
}
} // namespace detail
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,29 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_iprimitive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <istream>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/impl/basic_text_iprimitive.ipp>
namespace boost {
namespace archive {
// explicitly instantiate for this type of text stream
template class basic_text_iprimitive<std::istream> ;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,29 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_oprimitive.cpp:
// (C) Copyright 2004 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <ostream>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/auto_link_archive.hpp>
#include <boost/archive/impl/basic_text_oprimitive.ipp>
namespace boost {
namespace archive {
// explicitly instantiate for this type of text stream
template class basic_text_oprimitive<std::ostream> ;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,36 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_wiprimitive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/auto_link_warchive.hpp>
#include <boost/archive/impl/basic_text_iprimitive.ipp>
namespace boost {
namespace archive {
template class basic_text_iprimitive<std::wistream> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,36 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_text_woprimitive.cpp:
// (C) Copyright 2004 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/auto_link_warchive.hpp>
#include <boost/archive/impl/basic_text_oprimitive.ipp>
namespace boost {
namespace archive {
template class basic_text_oprimitive<std::wostream> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,52 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_archive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/basic_xml_archive.hpp>
namespace boost {
namespace archive {
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_OBJECT_ID(){
return "object_id";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_OBJECT_REFERENCE(){
return "object_id_reference";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_CLASS_ID(){
return "class_id";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_CLASS_ID_REFERENCE(){
return "class_id_reference";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_CLASS_NAME(){
return "class_name";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_TRACKING(){
return "tracking_level";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_VERSION(){
return "version";
}
BOOST_SYMBOL_VISIBLE const char *
BOOST_ARCHIVE_XML_SIGNATURE(){
return "signature";
}
}// namespace archive
}// namespace boost

View file

@ -0,0 +1,468 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// basic_xml_grammar.ipp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <istream>
#include <algorithm>
#include <boost/config.hpp> // typename
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4244 4511 4512)
#endif
#include <cerrno> // errno
#include <cstring> // strerror(errno)
// spirit stuff
#include <boost/spirit/include/classic_operators.hpp>
#include <boost/spirit/include/classic_actions.hpp>
#include <boost/spirit/include/classic_numerics.hpp>
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
// for head_iterator test
#include <boost/function.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/serialization/throw_exception.hpp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
#include <boost/archive/xml_archive_exception.hpp>
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/iterators/xml_unescape.hpp>
using namespace boost::spirit::classic;
namespace boost {
namespace archive {
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// template code for basic_xml_grammar of both wchar_t and char types
namespace xml { // anonymous
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
template<class T>
struct assign_impl {
T & t;
void operator()(const T t_) const {
t = t_;
}
assign_impl(T & t_)
: t(t_)
{}
};
template<>
struct assign_impl<std::string> {
std::string & t;
void operator()(
std::string::const_iterator b,
std::string::const_iterator e
) const {
t.resize(0);
while(b != e){
t += * b;
++b;
}
}
assign_impl<std::string> & operator=(
assign_impl<std::string> & rhs
);
assign_impl(std::string & t_)
: t(t_)
{}
};
#ifndef BOOST_NO_STD_WSTRING
template<>
struct assign_impl<std::wstring> {
std::wstring & t;
void operator()(
std::wstring::const_iterator b,
std::wstring::const_iterator e
) const {
t.resize(0);
while(b != e){
t += * b;
++b;
}
}
assign_impl(std::wstring & t_)
: t(t_)
{}
};
#endif
template<class T>
assign_impl<T> assign_object(T &t){
return assign_impl<T>(t);
}
struct assign_level {
tracking_type & tracking_level;
void operator()(const unsigned int tracking_level_) const {
tracking_level = (0 == tracking_level_) ? false : true;
}
assign_level(tracking_type & tracking_level_)
: tracking_level(tracking_level_)
{}
};
template<class String, class Iterator>
struct append_string {
String & contents;
void operator()(Iterator start, Iterator end) const {
#if 0
typedef boost::archive::iterators::xml_unescape<Iterator> translator;
contents.append(
translator(BOOST_MAKE_PFTO_WRAPPER(start)),
translator(BOOST_MAKE_PFTO_WRAPPER(end))
);
#endif
contents.append(start, end);
}
append_string(String & contents_)
: contents(contents_)
{}
};
template<class String>
struct append_char {
String & contents;
void operator()(const unsigned int char_value) const {
contents += static_cast<typename String::value_type>(char_value);
}
append_char(String & contents_)
: contents(contents_)
{}
};
template<class String, unsigned int c>
struct append_lit {
String & contents;
template<class X, class Y>
void operator()(const X & /*x*/, const Y & /*y*/) const {
const typename String::value_type z = c;
contents += z;
}
append_lit(String & contents_)
: contents(contents_)
{}
};
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
} // namespace anonymous
template<class CharType>
bool basic_xml_grammar<CharType>::my_parse(
typename basic_xml_grammar<CharType>::IStream & is,
const rule_t & rule_,
CharType delimiter
) const {
if(is.fail()){
return false;
}
is >> std::noskipws;
std::basic_string<CharType> arg;
for(;;){
CharType result;
is.get(result);
if(is.fail()){
boost::serialization::throw_exception(
boost::archive::archive_exception(
archive_exception::input_stream_error,
std::strerror(errno)
)
);
}
if(is.eof())
return false;
arg += result;
if(result == delimiter)
break;
}
// read just one more character. This will be the newline after the tag
// this is so that the next operation will return fail if the archive
// is terminated. This will permit the archive to be used for debug
// and transaction data logging in the standard way.
parse_info<typename std::basic_string<CharType>::iterator>
result = boost::spirit::classic::parse(arg.begin(), arg.end(), rule_);
return result.hit;
}
template<class CharType>
bool basic_xml_grammar<CharType>::parse_start_tag(
typename basic_xml_grammar<CharType>::IStream & is
){
rv.class_name.resize(0);
return my_parse(is, STag);
}
template<class CharType>
bool basic_xml_grammar<CharType>::parse_end_tag(IStream & is) const {
return my_parse(is, ETag);
}
template<class CharType>
bool basic_xml_grammar<CharType>::parse_string(IStream & is, StringType & s){
rv.contents.resize(0);
bool result = my_parse(is, content, '<');
// note: unget caused a problem with dinkumware. replace with
// is.unget();
// putback another delimiter instead
is.putback('<');
if(result)
s = rv.contents;
return result;
}
template<class CharType>
basic_xml_grammar<CharType>::basic_xml_grammar(){
init_chset();
S =
+(Sch)
;
// refactoring to workaround template depth on darwin
NameHead = (Letter | '_' | ':');
NameTail = *NameChar ;
Name =
NameHead >> NameTail
;
Eq =
!S >> '=' >> !S
;
AttributeList =
*(S >> Attribute)
;
STag =
!S
>> '<'
>> Name [xml::assign_object(rv.object_name)]
>> AttributeList
>> !S
>> '>'
;
ETag =
!S
>> "</"
>> Name [xml::assign_object(rv.object_name)]
>> !S
>> '>'
;
// refactoring to workaround template depth on darwin
CharDataChars = +(anychar_p - chset_p(L"&<"));
CharData =
CharDataChars [
xml::append_string<
StringType,
typename std::basic_string<CharType>::const_iterator
>(rv.contents)
]
;
// slight factoring works around ICE in msvc 6.0
CharRef1 =
str_p(L"&#") >> uint_p [xml::append_char<StringType>(rv.contents)] >> L';'
;
CharRef2 =
str_p(L"&#x") >> hex_p [xml::append_char<StringType>(rv.contents)] >> L';'
;
CharRef = CharRef1 | CharRef2 ;
AmpRef = str_p(L"&amp;")[xml::append_lit<StringType, L'&'>(rv.contents)];
LTRef = str_p(L"&lt;")[xml::append_lit<StringType, L'<'>(rv.contents)];
GTRef = str_p(L"&gt;")[xml::append_lit<StringType, L'>'>(rv.contents)];
AposRef = str_p(L"&apos;")[xml::append_lit<StringType, L'\''>(rv.contents)];
QuoteRef = str_p(L"&quot;")[xml::append_lit<StringType, L'"'>(rv.contents)];
Reference =
AmpRef
| LTRef
| GTRef
| AposRef
| QuoteRef
| CharRef
;
content =
L"<" // should be end_p
| +(Reference | CharData) >> L"<"
;
ClassIDAttribute =
str_p(BOOST_ARCHIVE_XML_CLASS_ID()) >> NameTail
>> Eq
>> L'"'
>> int_p [xml::assign_object(rv.class_id)]
>> L'"'
;
ObjectIDAttribute = (
str_p(BOOST_ARCHIVE_XML_OBJECT_ID())
|
str_p(BOOST_ARCHIVE_XML_OBJECT_REFERENCE())
)
>> NameTail
>> Eq
>> L'"'
>> L'_'
>> uint_p [xml::assign_object(rv.object_id)]
>> L'"'
;
AmpName = str_p(L"&amp;")[xml::append_lit<StringType, L'&'>(rv.class_name)];
LTName = str_p(L"&lt;")[xml::append_lit<StringType, L'<'>(rv.class_name)];
GTName = str_p(L"&gt;")[xml::append_lit<StringType, L'>'>(rv.class_name)];
ClassNameChar =
AmpName
| LTName
| GTName
| (anychar_p - chset_p(L"\"")) [xml::append_char<StringType>(rv.class_name)]
;
ClassName =
* ClassNameChar
;
ClassNameAttribute =
str_p(BOOST_ARCHIVE_XML_CLASS_NAME())
>> Eq
>> L'"'
>> ClassName
>> L'"'
;
TrackingAttribute =
str_p(BOOST_ARCHIVE_XML_TRACKING())
>> Eq
>> L'"'
>> uint_p [xml::assign_level(rv.tracking_level)]
>> L'"'
;
VersionAttribute =
str_p(BOOST_ARCHIVE_XML_VERSION())
>> Eq
>> L'"'
>> uint_p [xml::assign_object(rv.version)]
>> L'"'
;
UnusedAttribute =
Name
>> Eq
>> L'"'
>> !CharData
>> L'"'
;
Attribute =
ClassIDAttribute
| ObjectIDAttribute
| ClassNameAttribute
| TrackingAttribute
| VersionAttribute
| UnusedAttribute
;
XMLDeclChars = *(anychar_p - chset_p(L"?>"));
XMLDecl =
!S
>> str_p(L"<?xml")
>> S
>> str_p(L"version")
>> Eq
>> str_p(L"\"1.0\"")
>> XMLDeclChars
>> !S
>> str_p(L"?>")
;
DocTypeDeclChars = *(anychar_p - chset_p(L">"));
DocTypeDecl =
!S
>> str_p(L"<!DOCTYPE")
>> DocTypeDeclChars
>> L'>'
;
SignatureAttribute =
str_p(L"signature")
>> Eq
>> L'"'
>> Name [xml::assign_object(rv.class_name)]
>> L'"'
;
SerializationWrapper =
!S
>> str_p(L"<boost_serialization")
>> S
>> ( (SignatureAttribute >> S >> VersionAttribute)
| (VersionAttribute >> S >> SignatureAttribute)
)
>> !S
>> L'>'
;
}
template<class CharType>
void basic_xml_grammar<CharType>::init(IStream & is){
init_chset();
if(! my_parse(is, XMLDecl))
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
if(! my_parse(is, DocTypeDecl))
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
if(! my_parse(is, SerializationWrapper))
boost::serialization::throw_exception(
xml_archive_exception(xml_archive_exception::xml_archive_parsing_error)
);
if(! std::equal(rv.class_name.begin(), rv.class_name.end(), BOOST_ARCHIVE_SIGNATURE()))
boost::serialization::throw_exception(
archive_exception(archive_exception::invalid_signature)
);
}
template<class CharType>
bool basic_xml_grammar<CharType>::windup(IStream & is) {
return my_parse(is, ETag);
}
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,40 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// binary_iarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <istream>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
namespace boost {
namespace archive {
// explicitly instantiate for this type of stream
template class detail::archive_serializer_map<binary_iarchive>;
template class basic_binary_iprimitive<
binary_iarchive,
std::istream::char_type,
std::istream::traits_type
>;
template class basic_binary_iarchive<binary_iarchive> ;
template class binary_iarchive_impl<
binary_iarchive,
std::istream::char_type,
std::istream::traits_type
>;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,40 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// binary_oarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <ostream>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of binary stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<binary_oarchive>;
template class basic_binary_oprimitive<
binary_oarchive,
std::ostream::char_type,
std::ostream::traits_type
>;
template class basic_binary_oarchive<binary_oarchive> ;
template class binary_oarchive_impl<
binary_oarchive,
std::ostream::char_type,
std::ostream::traits_type
>;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,47 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// binary_wiarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/archive/binary_wiarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_binary_iprimitive.ipp>
#include <boost/archive/impl/basic_binary_iarchive.ipp>
namespace boost {
namespace archive {
// explicitly instantiate for this type of text stream
template class detail::archive_serializer_map<binary_wiarchive>;
template class basic_binary_iprimitive<
binary_wiarchive,
wchar_t,
std::char_traits<wchar_t>
>;
template class basic_binary_iarchive<binary_wiarchive> ;
template class binary_iarchive_impl<
binary_wiarchive,
wchar_t,
std::char_traits<wchar_t>
>;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,44 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// binary_woarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/archive/binary_woarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_binary_oprimitive.ipp>
#include <boost/archive/impl/basic_binary_oarchive.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<binary_woarchive>;
template class basic_binary_oprimitive<
binary_woarchive,
wchar_t,
std::char_traits<wchar_t>
>;
template class basic_binary_oarchive<binary_woarchive> ;
template class binary_oarchive_impl<
binary_woarchive,
wchar_t,
std::char_traits<wchar_t>
>;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,84 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// codecvt_null.cpp
// Copyright (c) 2004 Robert Ramey, 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)
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/codecvt_null.hpp>
// codecvt implementation for passing wchar_t objects to char output
// without any translation whatever. Used to implement binary output
// of wchar_t objects.
namespace boost {
namespace archive {
std::codecvt_base::result
codecvt_null<wchar_t>::do_out(
std::mbstate_t & /*state*/,
const wchar_t * first1,
const wchar_t * last1,
const wchar_t * & next1,
char * first2,
char * last2,
char * & next2
) const {
while(first1 != last1){
// Per std::22.2.1.5.2/2, we can store no more that
// last2-first2 characters. If we need to more encode
// next internal char type, return 'partial'.
if(static_cast<int>(sizeof(wchar_t)) > (last2 - first2)){
next1 = first1;
next2 = first2;
return std::codecvt_base::partial;
}
* reinterpret_cast<wchar_t *>(first2) = * first1++;
first2 += sizeof(wchar_t);
}
next1 = first1;
next2 = first2;
return std::codecvt_base::ok;
}
std::codecvt_base::result
codecvt_null<wchar_t>::do_in(
std::mbstate_t & /*state*/,
const char * first1,
const char * last1,
const char * & next1,
wchar_t * first2,
wchar_t * last2,
wchar_t * & next2
) const {
// Process input characters until we've run of them,
// or the number of remaining characters is not
// enough to construct another output character,
// or we've run out of place for output characters.
while(first2 != last2){
// Have we converted all input characters?
// Return with 'ok', if so.
if (first1 == last1)
break;
// Do we have less input characters than needed
// for a single output character?
if(static_cast<int>(sizeof(wchar_t)) > (last1 - first1)){
next1 = first1;
next2 = first2;
return std::codecvt_base::partial;
}
*first2++ = * reinterpret_cast<const wchar_t *>(first1);
first1 += sizeof(wchar_t);
}
next1 = first1;
next2 = first2;
return std::codecvt_base::ok;
}
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,196 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// extended_type_info.cpp: implementation for portable version of type_info
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <algorithm>
#include <set>
#include <utility>
#include <boost/assert.hpp>
#include <cstddef> // NULL
#include <cstring>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::strcmp; }
#endif
#include <boost/config.hpp> // msvc needs this to suppress warning
#include <boost/core/no_exceptions_support.hpp>
// it marks our code with proper attributes as being exported when
// we're compiling it while marking it import when just the headers
// is being included.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/force_include.hpp>
#include <boost/serialization/extended_type_info.hpp>
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
namespace boost {
namespace serialization {
namespace detail {
struct key_compare
{
bool
operator()(
const extended_type_info * lhs,
const extended_type_info * rhs
) const {
// performance shortcut
if(lhs == rhs)
return false;
const char * l = lhs->get_key();
BOOST_ASSERT(NULL != l);
const char * r = rhs->get_key();
BOOST_ASSERT(NULL != r);
// performance shortcut
// shortcut to exploit string pooling
if(l == r)
return false;
// for exported types, use the string key so that
// multiple instances in different translation units
// can be matched up
return std::strcmp(l, r) < 0;
}
};
typedef std::multiset<const extended_type_info *, key_compare> ktmap;
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
class extended_type_info_arg : public extended_type_info
{
virtual bool
is_less_than(const extended_type_info & /*rhs*/) const {
BOOST_ASSERT(false);
return false;
};
virtual bool
is_equal(const extended_type_info & /*rhs*/) const {
BOOST_ASSERT(false);
return false;
};
virtual const char * get_debug_info() const {
return get_key();
}
virtual void * construct(unsigned int /*count*/, ...) const{
BOOST_ASSERT(false);
return NULL;
}
virtual void destroy(void const * const /*p*/) const {
BOOST_ASSERT(false);
}
public:
extended_type_info_arg(const char * key) :
extended_type_info(0, key)
{}
~extended_type_info_arg(){
}
};
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
} // namespace detail
BOOST_SERIALIZATION_DECL void
extended_type_info::key_register() const{
if(NULL == get_key())
return;
singleton<detail::ktmap>::get_mutable_instance().insert(this);
}
BOOST_SERIALIZATION_DECL void
extended_type_info::key_unregister() const{
if(NULL == get_key())
return;
// note: it's been discovered that at least one platform is not guaranteed
// to destroy singletons reverse order of construction. So we can't
// use a runtime assert here. Leave this in a reminder not to do this!
// BOOST_ASSERT(! singleton<detail::ktmap>::is_destroyed());
if(! singleton<detail::ktmap>::is_destroyed()){
detail::ktmap & x = singleton<detail::ktmap>::get_mutable_instance();
detail::ktmap::iterator start = x.lower_bound(this);
detail::ktmap::iterator end = x.upper_bound(this);
// remove entry in map which corresponds to this type
for(;start != end; ++start){
if(this == *start){
x.erase(start);
break;
}
}
}
}
BOOST_SERIALIZATION_DECL const extended_type_info *
extended_type_info::find(const char *key) {
BOOST_ASSERT(NULL != key);
const detail::ktmap & k = singleton<detail::ktmap>::get_const_instance();
const detail::extended_type_info_arg eti_key(key);
const detail::ktmap::const_iterator it = k.find(& eti_key);
if(k.end() == it)
return NULL;
return *(it);
}
BOOST_SERIALIZATION_DECL
extended_type_info::extended_type_info(
const unsigned int type_info_key,
const char * key
) :
m_type_info_key(type_info_key),
m_key(key)
{
}
BOOST_SERIALIZATION_DECL
extended_type_info::~extended_type_info(){
}
BOOST_SERIALIZATION_DECL bool
extended_type_info::operator<(const extended_type_info &rhs) const {
// short cut for a common cases
if(this == & rhs)
return false;
if(m_type_info_key == rhs.m_type_info_key){
return is_less_than(rhs);
}
if(m_type_info_key < rhs.m_type_info_key)
return true;
return false;
}
BOOST_SERIALIZATION_DECL bool
extended_type_info::operator==(const extended_type_info &rhs) const {
// short cut for a common cases
if(this == & rhs)
return true;
if(m_type_info_key != rhs.m_type_info_key){
return false;
}
return is_equal(rhs);
}
} // namespace serialization
} // namespace boost

View file

@ -0,0 +1,89 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// extended_type_info_no_rtti.cpp: specific implementation of type info
// that is NOT based on typeid
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <cstring>
#include <cstddef> // NULL
#include <boost/assert.hpp>
#include <boost/config.hpp>
#if defined(BOOST_NO_STDC_NAMESPACE)
namespace std{ using ::strcmp; }
#endif
// it marks our code with proper attributes as being exported when
// we're compiling it while marking it import when just the headers
// is being included.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/extended_type_info_no_rtti.hpp>
#define EXTENDED_TYPE_INFO_NO_RTTI_KEY 2
namespace boost {
namespace serialization {
namespace no_rtti_system {
BOOST_SERIALIZATION_DECL
extended_type_info_no_rtti_0::extended_type_info_no_rtti_0(
const char * key
) :
extended_type_info(EXTENDED_TYPE_INFO_NO_RTTI_KEY, key)
{}
BOOST_SERIALIZATION_DECL bool
extended_type_info_no_rtti_0::is_less_than(
const boost::serialization::extended_type_info &rhs) const
{
// shortcut for common case
if(this == & rhs)
return false;
const char * l = get_key();
const char * r = rhs.get_key();
// if this assertion is triggered, it could mean one of the following
// a) This class was never exported - make sure all calls which use
// this method of type id are in fact exported.
// b) This class was used (e.g. serialized through a pointer) before
// it was exported. Make sure that classes which use this method
// of type id are NOT "automatically" registered by serializating
// through a pointer to the to most derived class. OR make sure
// that the BOOST_CLASS_EXPORT is included in every file
// which does this.
BOOST_ASSERT(NULL != l);
BOOST_ASSERT(NULL != r);
return std::strcmp(l, r) < 0;
}
BOOST_SERIALIZATION_DECL bool
extended_type_info_no_rtti_0::is_equal(
const boost::serialization::extended_type_info &rhs) const
{
// shortcut for common case
if(this == & rhs)
return true;
// null keys don't match with anything
const char * l = get_key();
BOOST_ASSERT(NULL != l);
if(NULL == l)
return false;
const char * r = rhs.get_key();
BOOST_ASSERT(NULL != r);
if(NULL == r)
return false;
return 0 == std::strcmp(l, r);
}
BOOST_SERIALIZATION_DECL
extended_type_info_no_rtti_0::~extended_type_info_no_rtti_0()
{}
} // namespece detail
} // namespace serialization
} // namespace boost

View file

@ -0,0 +1,167 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// extended_type_info_typeid.cpp: specific implementation of type info
// that is based on typeid
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <algorithm>
#include <set>
#include <boost/assert.hpp>
#include <typeinfo>
#include <cstddef> // NULL
#include <boost/core/no_exceptions_support.hpp>
// it marks our code with proper attributes as being exported when
// we're compiling it while marking it import when just the headers
// is being included.
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/extended_type_info_typeid.hpp>
namespace boost {
namespace serialization {
namespace typeid_system {
#define EXTENDED_TYPE_INFO_TYPE_KEY 1
struct type_compare
{
bool
operator()(
const extended_type_info_typeid_0 * lhs,
const extended_type_info_typeid_0 * rhs
) const {
return lhs->is_less_than(*rhs);
}
};
typedef std::multiset<
const extended_type_info_typeid_0 *,
type_compare
> tkmap;
BOOST_SERIALIZATION_DECL bool
extended_type_info_typeid_0::is_less_than(
const boost::serialization::extended_type_info & rhs
) const {
// shortcut for common case
if(this == & rhs)
return false;
return 0 != m_ti->before(
*(static_cast<const extended_type_info_typeid_0 &>(rhs).m_ti)
);
}
BOOST_SERIALIZATION_DECL bool
extended_type_info_typeid_0::is_equal(
const boost::serialization::extended_type_info & rhs
) const {
return
// note: std::type_info == operator returns an int !!!
// the following permits conversion to bool without a warning.
! (
* m_ti
!= *(static_cast<const extended_type_info_typeid_0 &>(rhs).m_ti)
)
;
}
BOOST_SERIALIZATION_DECL
extended_type_info_typeid_0::extended_type_info_typeid_0(
const char * key
) :
extended_type_info(EXTENDED_TYPE_INFO_TYPE_KEY, key),
m_ti(NULL)
{}
BOOST_SERIALIZATION_DECL
extended_type_info_typeid_0::~extended_type_info_typeid_0()
{}
BOOST_SERIALIZATION_DECL void
extended_type_info_typeid_0::type_register(const std::type_info & ti){
m_ti = & ti;
singleton<tkmap>::get_mutable_instance().insert(this);
}
BOOST_SERIALIZATION_DECL void
extended_type_info_typeid_0::type_unregister()
{
if(NULL != m_ti){
// note: previously this conditional was a runtime assertion with
// BOOST_ASSERT. We've changed it because we've discovered that at
// least one platform is not guaranteed to destroy singletons in
// reverse order of distruction.
// BOOST_ASSERT(! singleton<tkmap>::is_destroyed());
if(! singleton<tkmap>::is_destroyed()){
tkmap & x = singleton<tkmap>::get_mutable_instance();
// remove all entries in map which corresponds to this type
// make sure that we don't use any invalidated iterators
for(;;){
const tkmap::iterator & it = x.find(this);
if(it == x.end())
break;
x.erase(it);
};
}
}
m_ti = NULL;
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
// this derivation is used for creating search arguments
class extended_type_info_typeid_arg :
public extended_type_info_typeid_0
{
virtual void * construct(unsigned int /*count*/, ...) const{
BOOST_ASSERT(false);
return NULL;
}
virtual void destroy(void const * const /*p*/) const {
BOOST_ASSERT(false);
}
public:
extended_type_info_typeid_arg(const std::type_info & ti) :
extended_type_info_typeid_0(NULL)
{
// note absense of self register and key as this is used only as
// search argument given a type_info reference and is not to
// be added to the map.
m_ti = & ti;
}
~extended_type_info_typeid_arg(){
m_ti = NULL;
}
};
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
BOOST_SERIALIZATION_DECL const extended_type_info *
extended_type_info_typeid_0::get_extended_type_info(
const std::type_info & ti
) const {
typeid_system::extended_type_info_typeid_arg etia(ti);
const tkmap & t = singleton<tkmap>::get_const_instance();
const tkmap::const_iterator it = t.find(& etia);
if(t.end() == it)
return NULL;
return *(it);
}
} // namespace detail
} // namespace serialization
} // namespace boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_binary_iarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_binary_iarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_binary_iarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_binary_oarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_binary_oarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class detail::archive_serializer_map<polymorphic_binary_oarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_iarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/polymorphic_iarchive.hpp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_iarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_oarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/polymorphic_oarchive.hpp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_oarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_text_iarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_text_iarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_text_iarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_text_oarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_text_oarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class detail::archive_serializer_map<polymorphic_text_oarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_text_wiarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_text_wiarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_text_wiarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_text_woarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_text_woarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class detail::archive_serializer_map<polymorphic_text_woarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_xml_iarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_xml_iarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_xml_iarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_xml_oarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_xml_oarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class detail::archive_serializer_map<polymorphic_xml_oarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_xml_wiarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_xml_wiarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class archive_serializer_map<polymorphic_xml_wiarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,30 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// polymorphic_xml_woarchive.cpp:
// (C) Copyright 2018 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/polymorphic_xml_woarchive.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
namespace boost {
namespace archive {
namespace detail {
template class detail::archive_serializer_map<polymorphic_xml_woarchive>;
} // detail
} // archive
} // boost

View file

@ -0,0 +1,42 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// stl_port.cpp: implementation of run-time casting of void pointers
// (C) Copyright 2005 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
// this befuddles the msvc 6 compiler so we can't use it
#if ! ((defined _MSC_VER) && (_MSC_VER <= 1300))
#include <boost/config.hpp>
#if defined(__SGI_STL_PORT) && (__SGI_STL_PORT < 0x500)
#include <boost/archive/codecvt_null.hpp>
// explicit instantiation
namespace std {
template
locale::locale(
const locale& __loc, boost::archive::codecvt_null<char> * __f
);
template
locale::locale(
const locale& __loc, boost::archive::codecvt_null<wchar_t> * __f
);
} // namespace std
#endif
#endif

View file

@ -0,0 +1,33 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_iarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_text_iarchive.ipp>
#include <boost/archive/impl/text_iarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<text_iarchive>;
template class basic_text_iarchive<text_iarchive> ;
template class text_iarchive_impl<text_iarchive> ;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,34 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_oarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_text_oarchive.ipp>
#include <boost/archive/impl/text_oarchive_impl.ipp>
namespace boost {
namespace archive {
//template class basic_text_oprimitive<std::ostream> ;
template class detail::archive_serializer_map<text_oarchive>;
template class basic_text_oarchive<text_oarchive> ;
template class text_oarchive_impl<text_oarchive> ;
} // namespace serialization
} // namespace boost

View file

@ -0,0 +1,38 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_wiarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/text_wiarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_text_iarchive.ipp>
#include <boost/archive/impl/text_wiarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<text_wiarchive>;
template class basic_text_iarchive<text_wiarchive> ;
template class text_wiarchive_impl<text_wiarchive> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,36 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// text_woarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/text_woarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_text_oarchive.ipp>
#include <boost/archive/impl/text_woarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<text_woarchive>;
template class basic_text_oarchive<text_woarchive> ;
template class text_woarchive_impl<text_woarchive> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,22 @@
// 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)
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#endif
// include boost implementation of utf8 codecvt facet
# define BOOST_ARCHIVE_SOURCE
#include <boost/archive/detail/decl.hpp>
#define BOOST_UTF8_BEGIN_NAMESPACE \
namespace boost { namespace archive { namespace detail {
#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL
#define BOOST_UTF8_END_NAMESPACE }}}
#include <boost/detail/utf8_codecvt_facet.ipp>
#undef BOOST_UTF8_END_NAMESPACE
#undef BOOST_UTF8_DECL
#undef BOOST_UTF8_BEGIN_NAMESPACE

View file

@ -0,0 +1,382 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// void_cast.cpp: implementation of run-time casting of void pointers
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// <gennadiy.rozental@tfn.com>
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
// STL
#include <set>
#include <functional>
#include <algorithm>
#include <cstddef> // NULL
#ifdef BOOST_SERIALIZATION_LOG
#include <iostream>
#endif
// BOOST
#include <boost/config.hpp>
#include <boost/assert.hpp>
#define BOOST_SERIALIZATION_SOURCE
#include <boost/serialization/config.hpp>
// it marks our code with proper attributes as being exported when
// we're compiling it while marking it import when just the headers
// is being included.
#include <boost/serialization/singleton.hpp>
#include <boost/serialization/extended_type_info.hpp>
#include <boost/serialization/void_cast.hpp>
namespace boost {
namespace serialization {
namespace void_cast_detail {
// note that void_casters are keyed on value of
// member extended type info records - NOT their
// addresses. This is necessary in order for the
// void cast operations to work across dll and exe
// module boundries.
bool void_caster::operator<(const void_caster & rhs) const {
// include short cut to save time and eliminate
// problems when when base class aren't virtual
if(m_derived != rhs.m_derived){
if(*m_derived < *rhs.m_derived)
return true;
if(*rhs.m_derived < *m_derived)
return false;
}
// m_derived == rhs.m_derived
if(m_base != rhs.m_base)
return *m_base < *rhs.m_base;
else
return false;
}
struct void_caster_compare {
bool operator()(const void_caster * lhs, const void_caster * rhs) const {
return *lhs < *rhs;
}
};
typedef std::set<const void_caster *, void_caster_compare> set_type;
typedef boost::serialization::singleton<set_type> void_caster_registry;
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
// implementation of shortcut void caster
class void_caster_shortcut : public void_caster
{
bool m_includes_virtual_base;
void const *
vbc_upcast(
void const * const t
) const;
void const *
vbc_downcast(
void const * const t
) const;
virtual void const *
upcast(void const * const t) const{
if(m_includes_virtual_base)
return vbc_upcast(t);
return static_cast<const char *> ( t ) - m_difference;
}
virtual void const *
downcast(void const * const t) const{
if(m_includes_virtual_base)
return vbc_downcast(t);
return static_cast<const char *> ( t ) + m_difference;
}
virtual bool is_shortcut() const {
return true;
}
virtual bool has_virtual_base() const {
return m_includes_virtual_base;
}
public:
void_caster_shortcut(
extended_type_info const * derived,
extended_type_info const * base,
std::ptrdiff_t difference,
bool includes_virtual_base,
void_caster const * const parent
) :
void_caster(derived, base, difference, parent),
m_includes_virtual_base(includes_virtual_base)
{
recursive_register(includes_virtual_base);
}
virtual ~void_caster_shortcut(){
recursive_unregister();
}
};
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
void const *
void_caster_shortcut::vbc_downcast(
void const * const t
) const {
// try to find a chain that gives us what we want
const void_cast_detail::set_type & s
= void_cast_detail::void_caster_registry::get_const_instance();
void_cast_detail::set_type::const_iterator it;
for(it = s.begin(); it != s.end(); ++it){
// if the current candidate casts to the desired target type
if ((*it)->m_derived == m_derived){
// and if it's not us
if ((*it)->m_base != m_base){
// try to cast from the candidate base to our base
const void * t_new;
t_new = void_downcast(*(*it)->m_base, *m_base, t);
// if we were successful
if(NULL != t_new){
// recast to our derived
const void_caster * vc = *it;
return vc->downcast(t_new);
}
}
}
}
return NULL;
}
void const *
void_caster_shortcut::vbc_upcast(
void const * const t
) const {
// try to find a chain that gives us what we want
const void_cast_detail::set_type & s
= void_cast_detail::void_caster_registry::get_const_instance();
void_cast_detail::set_type::const_iterator it;
for(it = s.begin(); it != s.end(); ++it){
// if the current candidate casts from the desired base type
if((*it)->m_base == m_base){
// and if it's not us
if ((*it)->m_derived != m_derived){
// try to cast from the candidate derived to our our derived
const void * t_new;
t_new = void_upcast(*m_derived, *(*it)->m_derived, t);
if(NULL != t_new)
return (*it)->upcast(t_new);
}
}
}
return NULL;
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable : 4511 4512)
#endif
// just used as a search key
class void_caster_argument : public void_caster
{
virtual void const *
upcast(void const * const /*t*/) const {
BOOST_ASSERT(false);
return NULL;
}
virtual void const *
downcast( void const * const /*t*/) const {
BOOST_ASSERT(false);
return NULL;
}
virtual bool has_virtual_base() const {
BOOST_ASSERT(false);
return false;
}
public:
void_caster_argument(
extended_type_info const * derived,
extended_type_info const * base
) :
void_caster(derived, base)
{}
virtual ~void_caster_argument(){};
};
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
// implementation of void caster base class
BOOST_SERIALIZATION_DECL void
void_caster::recursive_register(bool includes_virtual_base) const {
void_cast_detail::set_type & s
= void_cast_detail::void_caster_registry::get_mutable_instance();
#ifdef BOOST_SERIALIZATION_LOG
std::clog << "recursive_register\n";
std::clog << m_derived->get_debug_info();
std::clog << "<-";
std::clog << m_base->get_debug_info();
std::clog << "\n";
#endif
std::pair<void_cast_detail::set_type::const_iterator, bool> result;
// comment this out for now.
result = s.insert(this);
//assert(result.second);
// generate all implied void_casts.
void_cast_detail::set_type::const_iterator it;
for(it = s.begin(); it != s.end(); ++it){
if(* m_derived == * (*it)->m_base){
const void_caster_argument vca(
(*it)->m_derived,
m_base
);
void_cast_detail::set_type::const_iterator i;
i = s.find(& vca);
if(i == s.end()){
new void_caster_shortcut(
(*it)->m_derived,
m_base,
m_difference + (*it)->m_difference,
(*it)->has_virtual_base() || includes_virtual_base,
this
);
}
}
if(* (*it)->m_derived == * m_base){
const void_caster_argument vca(
m_derived,
(*it)->m_base
);
void_cast_detail::set_type::const_iterator i;
i = s.find(& vca);
if(i == s.end()){
new void_caster_shortcut(
m_derived,
(*it)->m_base,
m_difference + (*it)->m_difference,
(*it)->has_virtual_base() || includes_virtual_base,
this
);
}
}
}
}
BOOST_SERIALIZATION_DECL void
void_caster::recursive_unregister() const {
// note: it's been discovered that at least one platform is not guaranteed
// to destroy singletons reverse order of construction. So we can't
// use a runtime assert here. Leave this in a reminder not to do this!
// BOOST_ASSERT(! void_caster_registry::is_destroyed());
if(void_caster_registry::is_destroyed())
return;
#ifdef BOOST_SERIALIZATION_LOG
std::clog << "recursive_unregister\n";
std::clog << m_derived->get_debug_info();
std::clog << "<-";
std::clog << m_base->get_debug_info();
std::clog << "\n";
#endif
void_cast_detail::set_type & s
= void_caster_registry::get_mutable_instance();
// delete all shortcuts which use this primitive
void_cast_detail::set_type::iterator it;
for(it = s.begin(); it != s.end();){
const void_caster * vc = *it;
if(vc == this){
s.erase(it++);
}
else
if(vc->m_parent == this){
s.erase(it);
delete vc;
it = s.begin();
}
else
it++;
}
}
} // namespace void_cast_detail
BOOST_SYMBOL_VISIBLE void const *
void_upcast(
extended_type_info const & derived,
extended_type_info const & base,
void const * const t
);
// Given a void *, assume that it really points to an instance of one type
// and alter it so that it would point to an instance of a related type.
// Return the altered pointer. If there exists no sequence of casts that
// can transform from_type to to_type, return a NULL.
BOOST_SERIALIZATION_DECL void const *
void_upcast(
extended_type_info const & derived,
extended_type_info const & base,
void const * const t
){
// same types - trivial case
if (derived == base)
return t;
// check to see if base/derived pair is found in the registry
const void_cast_detail::set_type & s
= void_cast_detail::void_caster_registry::get_const_instance();
const void_cast_detail::void_caster_argument ca(& derived, & base);
void_cast_detail::set_type::const_iterator it;
it = s.find(& ca);
if (s.end() != it)
return (*it)->upcast(t);
return NULL;
}
BOOST_SYMBOL_VISIBLE void const *
void_downcast(
extended_type_info const & derived,
extended_type_info const & base,
void const * const t
);
BOOST_SERIALIZATION_DECL void const *
void_downcast(
extended_type_info const & derived,
extended_type_info const & base,
void const * const t
){
// same types - trivial case
if (derived == base)
return t;
// check to see if base/derived pair is found in the registry
const void_cast_detail::set_type & s
= void_cast_detail::void_caster_registry::get_const_instance();
const void_cast_detail::void_caster_argument ca(& derived, & base);
void_cast_detail::set_type::const_iterator it;
it = s.find(&ca);
if (s.end() != it)
return(*it)->downcast(t);
return NULL;
}
} // namespace serialization
} // namespace boost

View file

@ -0,0 +1,68 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_archive_exception.cpp:
// (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <exception>
#include <string>
#include <boost/assert.hpp>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/xml_archive_exception.hpp>
namespace boost {
namespace archive {
BOOST_ARCHIVE_DECL
xml_archive_exception::xml_archive_exception(
exception_code c,
const char * e1,
const char * e2
) :
archive_exception(other_exception, e1, e2)
{
switch(c){
case xml_archive_parsing_error:
archive_exception::append(0, "unrecognized XML syntax");
break;
case xml_archive_tag_mismatch:{
unsigned int l;
l = archive_exception::append(0, "XML start/end tag mismatch");
if(NULL != e1){
l = archive_exception::append(l, " - ");
archive_exception::append(l, e1);
}
break;
}
case xml_archive_tag_name_error:
archive_exception::append(0, "Invalid XML tag name");
break;
default:
BOOST_ASSERT(false);
archive_exception::append(0, "programming error");
break;
}
}
BOOST_ARCHIVE_DECL
xml_archive_exception::xml_archive_exception(xml_archive_exception const & oth) :
archive_exception(oth)
{
}
BOOST_ARCHIVE_DECL xml_archive_exception::~xml_archive_exception() BOOST_NOEXCEPT_OR_NOTHROW {}
} // archive
} // boost

View file

@ -0,0 +1,74 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_grammar.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <boost/config.hpp>
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
using namespace boost::spirit::classic;
// fixup for borland
// The following code will be put into Boost.Config in a later revision
#if ! defined(__SGI_STL_PORT) \
&& defined(BOOST_RWSTD_VER) && BOOST_RWSTD_VER<=0x020101
#include <string>
namespace std {
template<>
inline string &
string::replace (
char * first1,
char * last1,
const char * first2,
const char * last2
){
replace(first1-begin(),last1-first1,first2,last2-first2,0,last2-first2);
return *this;
}
} // namespace std
#endif
namespace boost {
namespace archive {
typedef basic_xml_grammar<char> xml_grammar;
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// specific definitions for char based XML
template<>
void xml_grammar::init_chset(){
Char = chset_t("\x9\xA\xD\x20-\x7f\x80\x81-\xFF");
Letter = chset_t("\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF");
Digit = chset_t("0-9");
Extender = chset_t('\xB7');
Sch = chset_t("\x20\x9\xD\xA");
NameChar = Letter | Digit | chset_p("._:-") | Extender ;
}
} // namespace archive
} // namespace boost
#include "basic_xml_grammar.ipp"
namespace boost {
namespace archive {
// explicit instantiation of xml for 8 bit characters
template class basic_xml_grammar<char>;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,33 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_iarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of xml stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/impl/xml_iarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<xml_iarchive>;
template class basic_xml_iarchive<xml_iarchive> ;
template class xml_iarchive_impl<xml_iarchive> ;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,33 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_oarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#define BOOST_ARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of xml stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/xml_oarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<xml_oarchive>;
template class basic_xml_oarchive<xml_oarchive> ;
template class xml_oarchive_impl<xml_oarchive> ;
} // namespace archive
} // namespace boost

View file

@ -0,0 +1,157 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_wgrammar.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/impl/basic_xml_grammar.hpp>
using namespace boost::spirit::classic;
// fixup for RogueWave
#if ! defined(__SGI_STL_PORT) \
&& defined(BOOST_RWSTD_VER) && BOOST_RWSTD_VER<=0x020101
#include <string>
namespace std {
template<>
inline wstring &
wstring::replace (
wchar_t * first1,
wchar_t * last1,
const wchar_t * first2,
const wchar_t * last2
){
replace(first1-begin(),last1-first1,first2,last2-first2,0,last2-first2);
return *this;
}
} // namespace std
#endif
namespace boost {
namespace archive {
typedef basic_xml_grammar<wchar_t> xml_wgrammar;
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// specific definitions for wchar_t based XML
template<>
void xml_wgrammar::init_chset(){
Char = chset_t(
#if defined(__GNUC__) && defined(linux)
L"\x9\xA\xD\x20-\xD7FF\xE000-\xFFFD\x10000-\x10FFFF"
#else
L"\x9\xA\xD\x20-\xD7FF\xE000-\xFFFD"
#endif
);
Sch = chset_t(L"\x20\x9\xD\xA");
BaseChar = chset_t(
L"\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF\x100-\x131\x134-\x13E"
L"\x141-\x148\x14A-\x17E\x180-\x1C3\x1CD-\x1F0\x1F4-\x1F5\x1FA-\x217"
L"\x250-\x2A8\x2BB-\x2C1\x386\x388-\x38A\x38C\x38E-\x3A1\x3A3-\x3CE"
L"\x3D0-\x3D6\x3DA\x3DC\x3DE\x3E0\x3E2-\x3F3\x401-\x40C\x40E-\x44F"
L"\x451-\x45C\x45E-\x481\x490-\x4C4\x4C7-\x4C8\x4CB-\x4CC\x4D0-\x4EB"
L"\x4EE-\x4F5\x4F8-\x4F9\x531-\x556\x559\x561-\x586\x5D0-\x5EA"
L"\x5F0-\x5F2\x621-\x63A\x641-\x64A\x671-\x6B7\x6BA-\x6BE\x6C0-\x6CE"
L"\x6D0-\x6D3\x6D5\x6E5-\x6E6\x905-\x939\x93D\x958-\x961\x985-\x98C"
L"\x98F-\x990\x993-\x9A8\x9AA-\x9B0\x9B2\x9B6-\x9B9\x9DC-\x9DD"
L"\x9DF-\x9E1\x9F0-\x9F1\xA05-\xA0A\xA0F-\xA10\xA13-\xA28\xA2A-\xA30"
L"\xA32-\xA33\xA35-\xA36\xA38-\xA39\xA59-\xA5C\xA5E\xA72-\xA74"
L"\xA85-\xA8B\xA8D\xA8F-\xA91\xA93-\xAA8\xAAA-\xAB0\xAB2-\xAB3"
L"\xAB5-\xAB9\xABD\xAE0\xB05-\xB0C\xB0F-\xB10\xB13-\xB28\xB2A-\xB30"
L"\xB32-\xB33\xB36-\xB39\xB3D\xB5C-\xB5D\xB5F-\xB61\xB85-\xB8A"
L"\xB8E-\xB90\xB92-\xB95\xB99-\xB9A\xB9C\xB9E-\xB9F\xBA3-\xBA4"
L"\xBA8-\xBAA\xBAE-\xBB5\xBB7-\xBB9\xC05-\xC0C\xC0E-\xC10\xC12-\xC28"
L"\xC2A-\xC33\xC35-\xC39\xC60-\xC61\xC85-\xC8C\xC8E-\xC90\xC92-\xCA8"
L"\xCAA-\xCB3\xCB5-\xCB9\xCDE\xCE0-\xCE1\xD05-\xD0C\xD0E-\xD10"
L"\xD12-\xD28\xD2A-\xD39\xD60-\xD61\xE01-\xE2E\xE30\xE32-\xE33"
L"\xE40-\xE45\xE81-\xE82\xE84\xE87-\xE88\xE8A\xE8D\xE94-\xE97"
L"\xE99-\xE9F\xEA1-\xEA3\xEA5\xEA7\xEAA-\xEAB\xEAD-\xEAE\xEB0"
L"\xEB2-\xEB3\xEBD\xEC0-\xEC4\xF40-\xF47\xF49-\xF69\x10A0-\x10C5"
L"\x10D0-\x10F6\x1100\x1102-\x1103\x1105-\x1107\x1109\x110B-\x110C"
L"\x110E-\x1112\x113C\x113E\x1140\x114C\x114E\x1150\x1154-\x1155"
L"\x1159\x115F-\x1161\x1163\x1165\x1167\x1169\x116D-\x116E"
L"\x1172-\x1173\x1175\x119E\x11A8\x11AB\x11AE-\x11AF\x11B7-\x11B8"
L"\x11BA\x11BC-\x11C2\x11EB\x11F0\x11F9\x1E00-\x1E9B\x1EA0-\x1EF9"
L"\x1F00-\x1F15\x1F18-\x1F1D\x1F20-\x1F45\x1F48-\x1F4D\x1F50-\x1F57"
L"\x1F59\x1F5B\x1F5D\x1F5F-\x1F7D\x1F80-\x1FB4\x1FB6-\x1FBC\x1FBE"
L"\x1FC2-\x1FC4\x1FC6-\x1FCC\x1FD0-\x1FD3\x1FD6-\x1FDB\x1FE0-\x1FEC"
L"\x1FF2-\x1FF4\x1FF6-\x1FFC\x2126\x212A-\x212B\x212E\x2180-\x2182"
L"\x3041-\x3094\x30A1-\x30FA\x3105-\x312C\xAC00-\xD7A3"
);
Ideographic = chset_t(L"\x4E00-\x9FA5\x3007\x3021-\x3029");
Letter = BaseChar | Ideographic;
CombiningChar = chset_t(
L"\x0300-\x0345\x0360-\x0361\x0483-\x0486\x0591-\x05A1\x05A3-\x05B9"
L"\x05BB-\x05BD\x05BF\x05C1-\x05C2\x05C4\x064B-\x0652\x0670"
L"\x06D6-\x06DC\x06DD-\x06DF\x06E0-\x06E4\x06E7-\x06E8\x06EA-\x06ED"
L"\x0901-\x0903\x093C\x093E-\x094C\x094D\x0951-\x0954\x0962-\x0963"
L"\x0981-\x0983\x09BC\x09BE\x09BF\x09C0-\x09C4\x09C7-\x09C8"
L"\x09CB-\x09CD\x09D7\x09E2-\x09E3\x0A02\x0A3C\x0A3E\x0A3F"
L"\x0A40-\x0A42\x0A47-\x0A48\x0A4B-\x0A4D\x0A70-\x0A71\x0A81-\x0A83"
L"\x0ABC\x0ABE-\x0AC5\x0AC7-\x0AC9\x0ACB-\x0ACD\x0B01-\x0B03\x0B3C"
L"\x0B3E-\x0B43\x0B47-\x0B48\x0B4B-\x0B4D\x0B56-\x0B57\x0B82-\x0B83"
L"\x0BBE-\x0BC2\x0BC6-\x0BC8\x0BCA-\x0BCD\x0BD7\x0C01-\x0C03"
L"\x0C3E-\x0C44\x0C46-\x0C48\x0C4A-\x0C4D\x0C55-\x0C56\x0C82-\x0C83"
L"\x0CBE-\x0CC4\x0CC6-\x0CC8\x0CCA-\x0CCD\x0CD5-\x0CD6\x0D02-\x0D03"
L"\x0D3E-\x0D43\x0D46-\x0D48\x0D4A-\x0D4D\x0D57\x0E31\x0E34-\x0E3A"
L"\x0E47-\x0E4E\x0EB1\x0EB4-\x0EB9\x0EBB-\x0EBC\x0EC8-\x0ECD"
L"\x0F18-\x0F19\x0F35\x0F37\x0F39\x0F3E\x0F3F\x0F71-\x0F84"
L"\x0F86-\x0F8B\x0F90-\x0F95\x0F97\x0F99-\x0FAD\x0FB1-\x0FB7\x0FB9"
L"\x20D0-\x20DC\x20E1\x302A-\x302F\x3099\x309A"
);
Digit = chset_t(
L"\x0030-\x0039\x0660-\x0669\x06F0-\x06F9\x0966-\x096F\x09E6-\x09EF"
L"\x0A66-\x0A6F\x0AE6-\x0AEF\x0B66-\x0B6F\x0BE7-\x0BEF\x0C66-\x0C6F"
L"\x0CE6-\x0CEF\x0D66-\x0D6F\x0E50-\x0E59\x0ED0-\x0ED9\x0F20-\x0F29"
);
Extender = chset_t(
L"\x00B7\x02D0\x02D1\x0387\x0640\x0E46\x0EC6\x3005\x3031-\x3035"
L"\x309D-\x309E\x30FC-\x30FE"
);
NameChar =
Letter
| Digit
| L'.'
| L'-'
| L'_'
| L':'
| CombiningChar
| Extender
;
}
} // namespace archive
} // namespace boost
#include "basic_xml_grammar.ipp"
namespace boost {
namespace archive {
// explicit instantiation of xml for wide characters
template class basic_xml_grammar<wchar_t>;
} // namespace archive
} // namespace boost
#endif

View file

@ -0,0 +1,40 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_wiarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/xml_wiarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of xml stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_xml_iarchive.ipp>
#include <boost/archive/impl/xml_wiarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<xml_wiarchive>;
template class basic_xml_iarchive<xml_wiarchive> ;
template class xml_wiarchive_impl<xml_wiarchive> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,40 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// xml_woarchive.cpp:
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#if (defined _MSC_VER) && (_MSC_VER == 1200)
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_STD_WSTREAMBUF
#error "wide char i/o not supported on this platform"
#else
#define BOOST_WARCHIVE_SOURCE
#include <boost/serialization/config.hpp>
#include <boost/archive/xml_woarchive.hpp>
#include <boost/archive/detail/archive_serializer_map.hpp>
// explicitly instantiate for this type of text stream
#include <boost/archive/impl/archive_serializer_map.ipp>
#include <boost/archive/impl/basic_xml_oarchive.ipp>
#include <boost/archive/impl/xml_woarchive_impl.ipp>
namespace boost {
namespace archive {
template class detail::archive_serializer_map<xml_woarchive>;
template class basic_xml_oarchive<xml_woarchive> ;
template class xml_woarchive_impl<xml_woarchive> ;
} // namespace archive
} // namespace boost
#endif // BOOST_NO_STD_WSTREAMBUF

View file

@ -0,0 +1,31 @@
// error_code stub implementation, for compatibility only
// Copyright Beman Dawes 2002, 2006
// Copyright Peter Dimov 2018
// Distributed under the 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
//----------------------------------------------------------------------------//
// 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>
namespace boost
{
namespace system
{
BOOST_SYSTEM_DECL void dummy_exported_function()
{
}
} // namespace system
} // namespace boost