stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,548 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/date_time.hpp
* \author Andrey Semashev
* \date 07.11.2012
*
* This header enables Boost.DateTime support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_DATE_TIME_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_DATE_TIME_HPP_INCLUDED_
#include <ctime>
#include <string>
#include <locale>
#include <ostream>
#include <iterator>
#include <boost/cstdint.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/date_time/time.hpp>
#include <boost/date_time/date.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/local_time/local_time_types.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/detail/date_time_format_parser.hpp>
#include <boost/log/detail/light_function.hpp>
#include <boost/log/detail/decomposed_time.hpp>
#include <boost/log/detail/date_time_fmt_gen_traits_fwd.hpp>
#include <boost/log/utility/formatting_ostream.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace expressions {
namespace aux {
namespace date_time_support {
template< typename DateT, typename ValueT >
inline void decompose_date(DateT const& d, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
typedef typename DateT::ymd_type ymd_type;
ymd_type ymd = d.year_month_day();
v.year = ymd.year;
v.month = ymd.month;
v.day = ymd.day;
}
template< typename TimeDurationT, typename ValueT >
inline void decompose_time_of_day(TimeDurationT const& tod, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
v.hours = tod.hours();
v.minutes = tod.minutes();
v.seconds = tod.seconds();
typedef typename TimeDurationT::traits_type traits_type;
enum
{
adjustment_ratio = (traits_type::ticks_per_second > boost::log::aux::decomposed_time::subseconds_per_second ?
traits_type::ticks_per_second / boost::log::aux::decomposed_time::subseconds_per_second :
boost::log::aux::decomposed_time::subseconds_per_second / traits_type::ticks_per_second)
};
uint64_t frac = tod.fractional_seconds();
v.subseconds = static_cast< uint32_t >(traits_type::ticks_per_second > boost::log::aux::decomposed_time::subseconds_per_second ? frac / adjustment_ratio : frac * adjustment_ratio);
}
template< typename TimeDurationT, typename ValueT >
inline void decompose_time_duration(TimeDurationT const& dur, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
if (dur.is_negative())
{
v.negative = true;
(decompose_time_of_day)(-dur, v);
}
else
(decompose_time_of_day)(dur, v);
}
template< typename DateDurationT, typename ValueT >
inline void decompose_date_duration(DateDurationT const& dur, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
if (dur.is_negative())
{
v.negative = true;
v.day = (-dur).days();
}
else
v.day = dur.days();
}
template< typename TimeT, typename ValueT >
inline void decompose_time(TimeT const& t, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
(decompose_date)(t.date(), v);
(decompose_time_of_day)(t.time_of_day(), v);
}
} // namespace date_time_support
template< typename TimeT, typename CharT >
struct date_time_formatter_generator_traits_impl
{
//! Character type
typedef CharT char_type;
//! String type
typedef std::basic_string< char_type > string_type;
//! Formatting stream type
typedef basic_formatting_ostream< char_type > stream_type;
//! Value type
typedef TimeT value_type;
//! Formatter function
typedef boost::log::aux::light_function< void (stream_type&, value_type const&) > formatter_function_type;
//! Formatter implementation
class formatter :
public boost::log::aux::date_time_formatter< boost::log::aux::decomposed_time_wrapper< value_type >, char_type >
{
BOOST_COPYABLE_AND_MOVABLE_ALT(formatter)
private:
// Do not change this typedef, copy-pasting the inherited class from above will break compilation with MSVC 2012 because it incorrectly binds value_type.
typedef typename formatter::date_time_formatter_ base_type;
public:
typedef typename base_type::result_type result_type;
// This typedef is needed to work around MSVC 2012 crappy name lookup. Otherwise base_type::value_type is bound instead.
typedef typename date_time_formatter_generator_traits_impl< TimeT, CharT >::value_type value_type;
public:
BOOST_DEFAULTED_FUNCTION(formatter(), {})
formatter(formatter const& that) : base_type(static_cast< base_type const& >(that)) {}
formatter(BOOST_RV_REF(formatter) that) { this->swap(that); }
formatter& operator= (formatter that)
{
this->swap(that);
return *this;
}
result_type operator() (stream_type& strm, value_type const& value) const
{
if (value.is_not_a_date_time())
strm << "not-a-date-time";
else if (value.is_pos_infinity())
strm << "+infinity";
else if (value.is_neg_infinity())
strm << "-infinity";
else
{
boost::log::aux::decomposed_time_wrapper< value_type > val(value);
date_time_support::decompose_time(value, val);
base_type::operator() (strm, val);
}
}
};
//! The function parses format string and constructs formatter function
static formatter_function_type parse(string_type const& format)
{
formatter fmt;
boost::log::aux::decomposed_time_formatter_builder< formatter, char_type > builder(fmt);
boost::log::aux::parse_date_time_format(format, builder);
return formatter_function_type(boost::move(fmt));
}
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< posix_time::ptime, CharT, VoidT > :
public date_time_formatter_generator_traits_impl< posix_time::ptime, CharT >
{
};
template< typename TimeT, typename TimeZoneT, typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< local_time::local_date_time_base< TimeT, TimeZoneT >, CharT, VoidT >
{
//! Character type
typedef CharT char_type;
//! String type
typedef std::basic_string< char_type > string_type;
//! Formatting stream type
typedef basic_formatting_ostream< char_type > stream_type;
//! Value type
typedef local_time::local_date_time_base< TimeT, TimeZoneT > value_type;
//! Formatter function
typedef boost::log::aux::light_function< void (stream_type&, value_type const&) > formatter_function_type;
//! Formatter implementation
class formatter :
public boost::log::aux::date_time_formatter< boost::log::aux::decomposed_time_wrapper< value_type >, char_type >
{
BOOST_COPYABLE_AND_MOVABLE_ALT(formatter)
private:
// Do not change this typedef, copy-pasting the inherited class from above will break compilation with MSVC 2012 because it incorrectly binds value_type.
typedef typename formatter::date_time_formatter_ base_type;
public:
typedef typename base_type::result_type result_type;
typedef typename base_type::context context;
// This typedef is needed to work around MSVC 2012 crappy name lookup. Otherwise base_type::value_type is bound instead.
typedef typename date_time_formatter_generator_traits< local_time::local_date_time_base< TimeT, TimeZoneT >, CharT, VoidT >::value_type value_type;
public:
BOOST_DEFAULTED_FUNCTION(formatter(), {})
formatter(formatter const& that) : base_type(static_cast< base_type const& >(that)) {}
formatter(BOOST_RV_REF(formatter) that) { this->swap(that); }
formatter& operator= (formatter that)
{
this->swap(that);
return *this;
}
result_type operator() (stream_type& strm, value_type const& value) const
{
if (value.is_not_a_date_time())
strm << "not-a-date-time";
else if (value.is_pos_infinity())
strm << "+infinity";
else if (value.is_neg_infinity())
strm << "-infinity";
else
{
boost::log::aux::decomposed_time_wrapper< value_type > val(value);
date_time_support::decompose_time(value.local_time(), val);
base_type::operator() (strm, val);
}
}
public:
static void format_iso_time_zone(context& ctx)
{
ctx.strm << ctx.value.m_time.zone_abbrev(true);
ctx.strm.flush();
}
static void format_extended_iso_time_zone(context& ctx)
{
ctx.strm << ctx.value.m_time.zone_name(true);
ctx.strm.flush();
}
};
class formatter_builder :
public boost::log::aux::decomposed_time_formatter_builder< formatter, char_type >
{
private:
typedef boost::log::aux::decomposed_time_formatter_builder< formatter, char_type > base_type;
public:
explicit formatter_builder(formatter& fmt) : base_type(fmt)
{
}
void on_iso_time_zone()
{
this->m_formatter.add_formatter(&formatter::format_iso_time_zone);
}
void on_extended_iso_time_zone()
{
this->m_formatter.add_formatter(&formatter::format_extended_iso_time_zone);
}
};
//! The function parses format string and constructs formatter function
static formatter_function_type parse(string_type const& format)
{
formatter fmt;
formatter_builder builder(fmt);
boost::log::aux::parse_date_time_format(format, builder);
return formatter_function_type(boost::move(fmt));
}
};
template< typename DateT, typename CharT >
struct date_formatter_generator_traits_impl
{
//! Character type
typedef CharT char_type;
//! String type
typedef std::basic_string< char_type > string_type;
//! Formatting stream type
typedef basic_formatting_ostream< char_type > stream_type;
//! Value type
typedef DateT value_type;
//! Formatter function
typedef boost::log::aux::light_function< void (stream_type&, value_type const&) > formatter_function_type;
//! Formatter implementation
class formatter :
public boost::log::aux::date_time_formatter< boost::log::aux::decomposed_time_wrapper< value_type >, char_type >
{
BOOST_COPYABLE_AND_MOVABLE_ALT(formatter)
private:
// Do not change this typedef, copy-pasting the inherited class from above will break compilation with MSVC 2012 because it incorrectly binds value_type.
typedef typename formatter::date_time_formatter_ base_type;
public:
typedef typename base_type::result_type result_type;
// This typedef is needed to work around MSVC 2012 crappy name lookup. Otherwise base_type::value_type is bound instead.
typedef typename date_formatter_generator_traits_impl< DateT, CharT >::value_type value_type;
public:
BOOST_DEFAULTED_FUNCTION(formatter(), {})
formatter(formatter const& that) : base_type(static_cast< base_type const& >(that)) {}
formatter(BOOST_RV_REF(formatter) that) { this->swap(that); }
formatter& operator= (formatter that)
{
this->swap(that);
return *this;
}
result_type operator() (stream_type& strm, value_type const& value) const
{
if (value.is_not_a_date())
strm << "not-a-date-time";
else if (value.is_pos_infinity())
strm << "+infinity";
else if (value.is_neg_infinity())
strm << "-infinity";
else
{
boost::log::aux::decomposed_time_wrapper< value_type > val(value);
date_time_support::decompose_date(value, val);
base_type::operator() (strm, val);
}
}
};
//! The function parses format string and constructs formatter function
static formatter_function_type parse(string_type const& format)
{
formatter fmt;
boost::log::aux::decomposed_time_formatter_builder< formatter, char_type > builder(fmt);
boost::log::aux::parse_date_format(format, builder);
return formatter_function_type(boost::move(fmt));
}
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< gregorian::date, CharT, VoidT > :
public date_formatter_generator_traits_impl< gregorian::date, CharT >
{
};
template< typename TimeDurationT, typename CharT >
struct time_duration_formatter_generator_traits_impl
{
//! Character type
typedef CharT char_type;
//! String type
typedef std::basic_string< char_type > string_type;
//! Formatting stream type
typedef basic_formatting_ostream< char_type > stream_type;
//! Value type
typedef TimeDurationT value_type;
//! Formatter function
typedef boost::log::aux::light_function< void (stream_type&, value_type const&) > formatter_function_type;
//! Formatter implementation
class formatter :
public boost::log::aux::date_time_formatter< boost::log::aux::decomposed_time_wrapper< value_type >, char_type >
{
BOOST_COPYABLE_AND_MOVABLE_ALT(formatter)
private:
// Do not change this typedef, copy-pasting the inherited class from above will break compilation with MSVC 2012 because it incorrectly binds value_type.
typedef typename formatter::date_time_formatter_ base_type;
public:
typedef typename base_type::result_type result_type;
// This typedef is needed to work around MSVC 2012 crappy name lookup. Otherwise base_type::value_type is bound instead.
typedef typename time_duration_formatter_generator_traits_impl< TimeDurationT, CharT >::value_type value_type;
public:
BOOST_DEFAULTED_FUNCTION(formatter(), {})
formatter(formatter const& that) : base_type(static_cast< base_type const& >(that)) {}
formatter(BOOST_RV_REF(formatter) that) { this->swap(that); }
formatter& operator= (formatter that)
{
this->swap(that);
return *this;
}
result_type operator() (stream_type& strm, value_type const& value) const
{
if (value.is_not_a_date_time())
strm << "not-a-date-time";
else if (value.is_pos_infinity())
strm << "+infinity";
else if (value.is_neg_infinity())
strm << "-infinity";
else
{
boost::log::aux::decomposed_time_wrapper< value_type > val(value);
date_time_support::decompose_time_duration(value, val);
base_type::operator() (strm, val);
}
}
};
//! The function parses format string and constructs formatter function
static formatter_function_type parse(string_type const& format)
{
formatter fmt;
boost::log::aux::decomposed_time_formatter_builder< formatter, char_type > builder(fmt);
boost::log::aux::parse_time_format(format, builder);
return formatter_function_type(boost::move(fmt));
}
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< posix_time::time_duration, CharT, VoidT > :
public time_duration_formatter_generator_traits_impl< posix_time::time_duration, CharT >
{
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< posix_time::hours, CharT, VoidT > :
public time_duration_formatter_generator_traits_impl< posix_time::hours, CharT >
{
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< posix_time::minutes, CharT, VoidT > :
public time_duration_formatter_generator_traits_impl< posix_time::minutes, CharT >
{
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< posix_time::seconds, CharT, VoidT > :
public time_duration_formatter_generator_traits_impl< posix_time::seconds, CharT >
{
};
template< typename BaseDurationT, uint64_t FracOfSecondV, typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< date_time::subsecond_duration< BaseDurationT, FracOfSecondV >, CharT, VoidT > :
public time_duration_formatter_generator_traits_impl< date_time::subsecond_duration< BaseDurationT, FracOfSecondV >, CharT >
{
};
template< typename DateDurationT, typename CharT >
struct date_duration_formatter_generator_traits_impl
{
//! Character type
typedef CharT char_type;
//! String type
typedef std::basic_string< char_type > string_type;
//! Formatting stream type
typedef basic_formatting_ostream< char_type > stream_type;
//! Value type
typedef DateDurationT value_type;
//! Formatter function
typedef boost::log::aux::light_function< void (stream_type&, value_type const&) > formatter_function_type;
//! Formatter implementation
class formatter :
public boost::log::aux::date_time_formatter< boost::log::aux::decomposed_time_wrapper< value_type >, char_type >
{
BOOST_COPYABLE_AND_MOVABLE_ALT(formatter)
private:
// Do not change this typedef, copy-pasting the inherited class from above will break compilation with MSVC 2012 because it incorrectly binds value_type.
typedef typename formatter::date_time_formatter_ base_type;
public:
typedef typename base_type::result_type result_type;
// This typedef is needed to work around MSVC 2012 crappy name lookup. Otherwise base_type::value_type is bound instead.
typedef typename date_duration_formatter_generator_traits_impl< DateDurationT, CharT >::value_type value_type;
public:
BOOST_DEFAULTED_FUNCTION(formatter(), {})
formatter(formatter const& that) : base_type(static_cast< base_type const& >(that)) {}
formatter(BOOST_RV_REF(formatter) that) { this->swap(that); }
formatter& operator= (formatter that)
{
this->swap(that);
return *this;
}
result_type operator() (stream_type& strm, value_type const& value) const
{
if (value.is_not_a_date())
strm << "not-a-date-time";
else if (value.is_pos_infinity())
strm << "+infinity";
else if (value.is_neg_infinity())
strm << "-infinity";
else
{
boost::log::aux::decomposed_time_wrapper< value_type > val(value);
date_time_support::decompose_date_duration(value, val);
base_type::operator() (strm, val);
}
}
};
//! The function parses format string and constructs formatter function
static formatter_function_type parse(string_type const& format)
{
formatter fmt;
boost::log::aux::decomposed_time_formatter_builder< formatter, char_type > builder(fmt);
boost::log::aux::parse_date_format(format, builder);
return formatter_function_type(boost::move(fmt));
}
};
template< typename CharT, typename VoidT >
struct date_time_formatter_generator_traits< gregorian::date_duration, CharT, VoidT > :
public date_formatter_generator_traits_impl< gregorian::date_duration, CharT >
{
};
} // namespace aux
} // namespace expressions
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_DATE_TIME_HPP_INCLUDED_
@@ -0,0 +1,84 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/exception.hpp
* \author Andrey Semashev
* \date 18.07.2009
*
* This header enables Boost.Exception support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
#include <string>
#include <boost/type_index.hpp>
#include <boost/exception/info.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/attributes/attribute_name.hpp>
#include <boost/log/attributes/named_scope.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
/*!
* Attribute name exception information
*/
typedef error_info< struct attribute_name_info_tag, attribute_name > attribute_name_info;
/*!
* Type info exception information
*/
typedef error_info< struct type_info_info_tag, typeindex::type_index > type_info_info;
/*!
* Parse position exception information
*/
typedef error_info< struct position_info_tag, unsigned int > position_info;
/*!
* Current scope exception information
*/
typedef error_info< struct current_scope_info_tag, attributes::named_scope_list > current_scope_info;
/*!
* The function returns an error information object that contains current stack of scopes.
* This information can then be attached to an exception and extracted at the catch site.
* The extracted scope list won't be affected by any scope changes that may happen during
* the exception propagation.
*
* \note See the \c named_scope attribute documentation on how to maintain scope list.
*/
inline current_scope_info current_scope()
{
return current_scope_info(attributes::named_scope::get_scopes());
}
namespace ipc {
class object_name;
/*!
* System resource name
*/
typedef error_info< struct object_name_tag, object_name > object_name_info;
} // namespace ipc
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_EXCEPTION_HPP_INCLUDED_
@@ -0,0 +1,76 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/regex.hpp
* \author Andrey Semashev
* \date 18.07.2009
*
* This header enables Boost.Regex support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_
#include <string>
#include <boost/regex.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/utility/functional/matches.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
//! This tag type is used if an expression is recognized as a Boost.Regex expression
struct boost_regex_expression_tag;
//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
template< typename CharT, typename TraitsT >
struct matching_expression_kind< boost::basic_regex< CharT, TraitsT > >
{
typedef boost_regex_expression_tag type;
};
//! The matching function implementation
template< typename ExpressionT >
struct match_traits< ExpressionT, boost_regex_expression_tag >
{
typedef ExpressionT compiled_type;
static compiled_type compile(ExpressionT const& expr) { return expr; }
template< typename StringT, typename CharT, typename TraitsT >
static bool matches(StringT const& str, boost::basic_regex< CharT, TraitsT > const& expr, boost::regex_constants::match_flag_type flags = boost::regex_constants::match_default)
{
return boost::regex_match(str.begin(), str.end(), expr, flags);
}
template< typename CharT, typename StringTraitsT, typename AllocatorT, typename ReTraitsT >
static bool matches(
std::basic_string< CharT, StringTraitsT, AllocatorT > const& str,
boost::basic_regex< CharT, ReTraitsT > const& expr,
boost::regex_constants::match_flag_type flags = boost::regex_constants::match_default)
{
const CharT* p = str.c_str();
return boost::regex_match(p, p + str.size(), expr, flags);
}
};
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_
@@ -0,0 +1,112 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/spirit_classic.hpp
* \author Andrey Semashev
* \date 19.07.2009
*
* This header enables Boost.Spirit (classic) support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
#include <boost/mpl/bool.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/utility/functional/matches.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_SPIRIT_THREADSAFE) && !defined(BOOST_LOG_DOXYGEN_PASS)
/*
* As Boost.Log filters may be called in multiple threads concurrently,
* this may lead to using Boost.Spirit parsers in a multithreaded context.
* In order to protect parsers properly, BOOST_SPIRIT_THREADSAFE macro should
* be defined.
*
* If we got here, it means that the user did not define that macro and we
* have to define it ourselves. However, it may also lead to ODR violations
* or even total ignorance of this macro, if the user has included Boost.Spirit
* headers before including this header, or uses Boost.Spirit without the macro
* in other translation units. The only reliable way to settle this problem is to
* define the macro for the whole project (i.e. all translation units).
*/
#if defined(__GNUC__)
#pragma message "Boost.Log: Boost.Spirit requires BOOST_SPIRIT_THREADSAFE macro to be defined if parsers are used in a multithreaded context. It is strongly recommended to define this macro project-wide."
#elif defined(_MSC_VER)
#pragma message("Boost.Log: Boost.Spirit requires BOOST_SPIRIT_THREADSAFE macro to be defined if parsers are used in a multithreaded context. It is strongly recommended to define this macro project-wide.")
#endif
#define BOOST_SPIRIT_THREADSAFE 1
#endif // !defined(BOOST_LOG_NO_THREADS) && !defined(BOOST_SPIRIT_THREADSAFE)
#include <boost/spirit/include/classic_parser.hpp>
#include <boost/log/detail/header.hpp>
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
//! This tag type is used if an expression is recognized as a Boost.Spirit.Classic expression
struct boost_spirit_classic_expression_tag;
//! The trait verifies if the type can be converted to a Boost.Spirit (classic) parser
template< typename T >
struct is_spirit_classic_parser
{
private:
typedef char yes_type;
struct no_type { char dummy[2]; };
template< typename U >
static yes_type check_spirit_classic_parser(spirit::classic::parser< U > const&);
static no_type check_spirit_classic_parser(...);
static T& get_T();
public:
enum { value = sizeof(check_spirit_classic_parser(get_T())) == sizeof(yes_type) };
typedef mpl::bool_< value > type;
};
//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
template< typename ExpressionT >
struct matching_expression_kind< ExpressionT, typename boost::enable_if_c< is_spirit_classic_parser< ExpressionT >::value >::type >
{
typedef boost_spirit_classic_expression_tag type;
};
//! The matching function implementation
template< typename ExpressionT >
struct match_traits< ExpressionT, boost_spirit_classic_expression_tag >
{
typedef ExpressionT compiled_type;
static compiled_type compile(ExpressionT const& expr) { return expr; }
template< typename StringT >
static bool matches(StringT const& str, ExpressionT const& expr)
{
typedef typename StringT::const_iterator const_iterator;
spirit::classic::parse_info< const_iterator > info =
spirit::classic::parse(str.begin(), str.end(), expr);
return info.full;
}
};
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_SPIRIT_CLASSIC_HPP_INCLUDED_
@@ -0,0 +1,92 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/spirit_qi.hpp
* \author Andrey Semashev
* \date 19.07.2009
*
* This header enables Boost.Spirit.Qi support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
#include <boost/core/enable_if.hpp>
#include <boost/spirit/include/qi_parse.hpp>
#include <boost/spirit/include/qi_domain.hpp>
#include <boost/spirit/include/support_unused.hpp>
#include <boost/spirit/home/support/meta_compiler.hpp> // spirit::compile()
#include <boost/spirit/home/qi/nonterminal/nonterminal_fwd.hpp> // rule forward declaration
#include <boost/log/detail/config.hpp>
#include <boost/log/utility/functional/matches.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
//! This tag type is used if an expression is recognized as a Boost.Spirit.Qi expression
struct boost_spirit_qi_expression_tag;
//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
template< typename ExpressionT >
struct matching_expression_kind< ExpressionT, typename boost::enable_if_c< spirit::traits::matches< spirit::qi::domain, ExpressionT >::value >::type >
{
typedef boost_spirit_qi_expression_tag type;
};
//! The matching function implementation
template< typename ExpressionT >
struct match_traits< ExpressionT, boost_spirit_qi_expression_tag >
{
typedef typename spirit::result_of::compile< spirit::qi::domain, ExpressionT, spirit::unused_type >::type compiled_type;
static compiled_type compile(ExpressionT const& expr)
{
return spirit::compile< spirit::qi::domain >(expr);
}
template< typename StringT >
static bool matches(StringT const& str, ExpressionT const& expr)
{
typedef typename StringT::const_iterator const_iterator;
const_iterator it = str.begin(), end = str.end();
return (spirit::qi::parse(it, end, expr) && it == end);
}
};
//! The matching function implementation
template< typename IteratorT, typename T1, typename T2, typename T3, typename T4 >
struct match_traits< spirit::qi::rule< IteratorT, T1, T2, T3, T4 >, boost_spirit_qi_expression_tag >
{
typedef spirit::qi::rule< IteratorT, T1, T2, T3, T4 > compiled_type;
static compiled_type compile(compiled_type const& expr) { return expr; }
template< typename StringT >
static bool matches(StringT const& str, compiled_type const& expr)
{
typedef typename StringT::const_iterator const_iterator;
const_iterator it = str.begin(), end = str.end();
return (spirit::qi::parse(it, end, expr) && it == end);
}
};
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_SPIRIT_QI_HPP_INCLUDED_
@@ -0,0 +1,86 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/std_regex.hpp
* \author Andrey Semashev
* \date 19.03.2014
*
* This header enables \c std::regex support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_
#include <boost/log/detail/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if defined(BOOST_NO_CXX11_HDR_REGEX)
#if defined(__GNUC__)
#pragma message "Boost.Log: This header requires support for std::regex in the standard library."
#elif defined(_MSC_VER)
#pragma message("Boost.Log: This header requires support for std::regex in the standard library.")
#endif
#else // defined(BOOST_NO_CXX11_HDR_REGEX)
#include <regex>
#include <string>
#include <boost/log/utility/functional/matches.hpp>
#include <boost/log/detail/header.hpp>
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
//! This tag type is used if an expression is recognized as \c std::regex
struct std_regex_expression_tag;
//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
template< typename CharT, typename ReTraitsT >
struct matching_expression_kind< std::basic_regex< CharT, ReTraitsT > >
{
typedef std_regex_expression_tag type;
};
//! The matching function implementation
template< typename ExpressionT >
struct match_traits< ExpressionT, std_regex_expression_tag >
{
typedef ExpressionT compiled_type;
static compiled_type compile(ExpressionT const& expr) { return expr; }
template< typename StringT, typename CharT, typename ReTraitsT >
static bool matches(StringT const& str, std::basic_regex< CharT, ReTraitsT > const& expr, std::regex_constants::match_flag_type flags = std::regex_constants::match_default)
{
return std::regex_match(str.begin(), str.end(), expr, flags);
}
template< typename CharT, typename StringTraitsT, typename AllocatorT, typename ReTraitsT >
static bool matches(std::basic_string< CharT, StringTraitsT, AllocatorT > const& str, std::basic_regex< CharT, ReTraitsT > const& expr, std::regex_constants::match_flag_type flags = std::regex_constants::match_default)
{
const CharT* p = str.c_str();
return std::regex_match(p, p + str.size(), expr, flags);
}
};
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // defined(BOOST_NO_CXX11_HDR_REGEX)
#endif // BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_
@@ -0,0 +1,75 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file support/xpressive.hpp
* \author Andrey Semashev
* \date 18.07.2009
*
* This header enables Boost.Xpressive support for Boost.Log.
*/
#ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
#define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
#include <string>
#include <boost/xpressive/basic_regex.hpp>
#include <boost/xpressive/regex_constants.hpp>
#include <boost/xpressive/regex_algorithms.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/utility/functional/matches.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
//! This tag type is used if an expression is recognized as a Boost.Xpressive expression
struct boost_xpressive_expression_tag;
//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
template< typename T >
struct matching_expression_kind< xpressive::basic_regex< T > >
{
typedef boost_xpressive_expression_tag type;
};
//! The matching function implementation
template< typename ExpressionT >
struct match_traits< ExpressionT, boost_xpressive_expression_tag >
{
typedef ExpressionT compiled_type;
static compiled_type compile(ExpressionT const& expr) { return expr; }
template< typename StringT, typename T >
static bool matches(StringT const& str, xpressive::basic_regex< T > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
{
return xpressive::regex_match(str, expr, flags);
}
template< typename CharT, typename TraitsT, typename AllocatorT >
static bool matches(std::basic_string< CharT, TraitsT, AllocatorT > const& str, xpressive::basic_regex< const CharT* > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
{
const CharT* p = str.c_str();
return xpressive::regex_match(p, p + str.size(), expr, flags);
}
};
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_