|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85202 - in trunk/libs/log: build src
From: andrey.semashev_at_[hidden]
Date: 2013-08-03 14:41:53
Author: andysem
Date: 2013-08-03 14:41:53 EDT (Sat, 03 Aug 2013)
New Revision: 85202
URL: http://svn.boost.org/trac/boost/changeset/85202
Log:
Extracted Boost.Xpressive use to a separate translation unit in attempt to work around MinGW 64 bit compiler limitation on the number of sections in the object file. Made some changes to reduce binary size. Refs #8786, #8773.
Added:
trunk/libs/log/src/matches_relation_factory.cpp (contents, props changed)
Text files modified:
trunk/libs/log/build/Jamfile.v2 | 1
trunk/libs/log/src/default_filter_factory.cpp | 151 ++++---------------------------------
trunk/libs/log/src/default_filter_factory.hpp | 45 ++++++++---
trunk/libs/log/src/matches_relation_factory.cpp | 160 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 210 insertions(+), 147 deletions(-)
Modified: trunk/libs/log/build/Jamfile.v2
==============================================================================
--- trunk/libs/log/build/Jamfile.v2 Sat Aug 3 12:47:58 2013 (r85201)
+++ trunk/libs/log/build/Jamfile.v2 2013-08-03 14:41:53 EDT (Sat, 03 Aug 2013) (r85202)
@@ -344,6 +344,7 @@
filter_parser.cpp
formatter_parser.cpp
default_filter_factory.cpp
+ matches_relation_factory.cpp
default_formatter_factory.cpp
;
Modified: trunk/libs/log/src/default_filter_factory.cpp
==============================================================================
--- trunk/libs/log/src/default_filter_factory.cpp Sat Aug 3 12:47:58 2013 (r85201)
+++ trunk/libs/log/src/default_filter_factory.cpp 2013-08-03 14:41:53 EDT (Sat, 03 Aug 2013) (r85202)
@@ -22,7 +22,6 @@
#include <boost/spirit/include/qi_eoi.hpp>
#include <boost/spirit/include/qi_as.hpp>
#include <boost/log/exceptions.hpp>
-#include <boost/log/attributes/value_visitation.hpp>
#include <boost/log/expressions/predicates/has_attr.hpp>
#include <boost/log/utility/type_dispatch/standard_types.hpp>
#include <boost/log/utility/string_literal.hpp>
@@ -30,13 +29,9 @@
#include <boost/log/utility/functional/begins_with.hpp>
#include <boost/log/utility/functional/ends_with.hpp>
#include <boost/log/utility/functional/contains.hpp>
-#include <boost/log/utility/functional/matches.hpp>
#include <boost/log/utility/functional/bind.hpp>
#include <boost/log/utility/functional/as_action.hpp>
-#include <boost/log/utility/functional/save_result.hpp>
#include <boost/log/detail/code_conversion.hpp>
-#include <boost/log/support/xpressive.hpp>
-#include <boost/xpressive/xpressive_dynamic.hpp>
#if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
#include <boost/fusion/container/set.hpp>
#include <boost/fusion/sequence/intrinsic/at_key.hpp>
@@ -55,32 +50,10 @@
namespace aux {
-template< typename CharT >
-template< typename ValueT, typename PredicateT >
-struct default_filter_factory< CharT >::predicate_wrapper
-{
- typedef typename PredicateT::result_type result_type;
-
- explicit predicate_wrapper(attribute_name const& name, PredicateT const& pred) : m_name(name), m_visitor(pred)
- {
- }
-
- template< typename T >
- result_type operator() (T const& arg) const
- {
- bool res = false;
- boost::log::visit< ValueT >(m_name, arg, save_result_wrapper< PredicateT const&, bool >(m_visitor, res));
- return res;
- }
-
-private:
- attribute_name m_name;
- const PredicateT m_visitor;
-};
+BOOST_LOG_ANONYMOUS_NAMESPACE {
-template< typename CharT >
template< typename RelationT >
-struct default_filter_factory< CharT >::on_integral_argument
+struct on_integral_argument
{
typedef void result_type;
@@ -99,9 +72,8 @@
filter& m_filter;
};
-template< typename CharT >
template< typename RelationT >
-struct default_filter_factory< CharT >::on_fp_argument
+struct on_fp_argument
{
typedef void result_type;
@@ -120,9 +92,8 @@
filter& m_filter;
};
-template< typename CharT >
template< typename RelationT >
-struct default_filter_factory< CharT >::on_string_argument
+struct on_string_argument
{
typedef void result_type;
@@ -131,11 +102,12 @@
struct predicate :
public RelationT
{
+ template< typename StringT >
struct initializer
{
typedef void result_type;
- explicit initializer(string_type const& val) : m_initializer(val)
+ explicit initializer(StringT const& val) : m_initializer(val)
{
}
@@ -153,14 +125,15 @@
}
private:
- string_type const& m_initializer;
+ StringT const& m_initializer;
};
typedef typename RelationT::result_type result_type;
- explicit predicate(RelationT const& rel, string_type const& operand) : RelationT(rel)
+ template< typename StringT >
+ predicate(RelationT const& rel, StringT const& operand) : RelationT(rel)
{
- fusion::for_each(m_operands, initializer(operand));
+ fusion::for_each(m_operands, initializer< StringT >(operand));
}
template< typename T >
@@ -173,111 +146,18 @@
private:
fusion::set< std::string, std::wstring > m_operands;
};
-#else
- typedef binder2nd< RelationT, string_type > predicate;
#endif
on_string_argument(attribute_name const& name, filter& f) : m_name(name), m_filter(f)
{
}
- result_type operator() (string_type const& val) const
- {
- m_filter = predicate_wrapper< log::string_types::type, predicate >(m_name, predicate(RelationT(), val));
- }
-
-private:
- attribute_name m_name;
- filter& m_filter;
-};
-
-template< typename CharT >
-template< typename RelationT >
-struct default_filter_factory< CharT >::on_regex_argument
-{
- typedef void result_type;
-
-#if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
- //! A special filtering predicate that adopts the string operand to the attribute value character type
- struct predicate :
- public RelationT
+ template< typename StringT >
+ result_type operator() (StringT const& val) const
{
- struct initializer
- {
- typedef void result_type;
-
- explicit initializer(string_type const& val) : m_initializer(val)
- {
- }
-
- template< typename T >
- result_type operator() (T& val) const
- {
- try
- {
- typedef typename T::char_type char_type;
- std::basic_string< char_type > str;
- log::aux::code_convert(m_initializer, str);
- val = T::compile(str.c_str(), str.size(), T::ECMAScript | T::optimize);
- }
- catch (...)
- {
- }
- }
-
- private:
- string_type const& m_initializer;
- };
-
- typedef typename RelationT::result_type result_type;
-
- explicit predicate(RelationT const& rel, string_type const& operand) : RelationT(rel)
- {
- fusion::for_each(m_operands, initializer(operand));
- }
-
- template< typename T >
- result_type operator() (T const& val) const
- {
- typedef typename T::value_type char_type;
- typedef xpressive::basic_regex< const char_type* > regex_type;
- return RelationT::operator() (val, fusion::at_key< regex_type >(m_operands));
- }
-
- private:
- fusion::set< xpressive::cregex, xpressive::wcregex > m_operands;
- };
-#else
- //! A special filtering predicate that adopts the string operand to the attribute value character type
- struct predicate :
- public RelationT
- {
- typedef typename RelationT::result_type result_type;
- typedef xpressive::basic_regex< typename string_type::value_type const* > regex_type;
-
- explicit predicate(RelationT const& rel, string_type const& operand) :
- RelationT(rel),
- m_operand(regex_type::compile(operand.c_str(), operand.size(), regex_type::ECMAScript | regex_type::optimize))
- {
- }
-
- template< typename T >
- result_type operator() (T const& val) const
- {
- return RelationT::operator() (val, m_operand);
- }
-
- private:
- regex_type m_operand;
- };
+#if !defined(BOOST_LOG_USE_CHAR) || !defined(BOOST_LOG_USE_WCHAR_T)
+ typedef binder2nd< RelationT, StringT > predicate;
#endif
-
- on_regex_argument(attribute_name const& name, filter& f) : m_name(name), m_filter(f)
- {
- }
-
- result_type operator() (string_type const& val) const
- {
m_filter = predicate_wrapper< log::string_types::type, predicate >(m_name, predicate(RelationT(), val));
}
@@ -286,6 +166,7 @@
filter& m_filter;
};
+} // namespace
//! The callback for equality relation filter
template< typename CharT >
@@ -343,7 +224,7 @@
else if (rel == constants::contains_keyword())
on_string_argument< contains_fun >(name, f)(arg);
else if (rel == constants::matches_keyword())
- on_regex_argument< matches_fun >(name, f)(arg);
+ f = parse_matches_relation(name, arg);
else
{
BOOST_LOG_THROW_DESCR(parse_error, "The custom attribute relation \"" + log::aux::to_narrow(rel) + "\" is not supported");
Modified: trunk/libs/log/src/default_filter_factory.hpp
==============================================================================
--- trunk/libs/log/src/default_filter_factory.hpp Sat Aug 3 12:47:58 2013 (r85201)
+++ trunk/libs/log/src/default_filter_factory.hpp 2013-08-03 14:41:53 EDT (Sat, 03 Aug 2013) (r85202)
@@ -16,7 +16,11 @@
#ifndef BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
#define BOOST_DEFAULT_FILTER_FACTORY_HPP_INCLUDED_
+#include <cstddef>
+#include <boost/log/attributes/attribute_name.hpp>
+#include <boost/log/attributes/value_visitation.hpp>
#include <boost/log/utility/setup/filter_parser.hpp>
+#include <boost/log/utility/functional/save_result.hpp>
#include <boost/log/detail/header.hpp>
namespace boost {
@@ -25,28 +29,40 @@
namespace aux {
+//! Relation predicate wrapper
+template< typename ValueT, typename PredicateT >
+struct predicate_wrapper
+{
+ typedef typename PredicateT::result_type result_type;
+
+ explicit predicate_wrapper(attribute_name const& name, PredicateT const& pred) : m_name(name), m_visitor(pred)
+ {
+ }
+
+ template< typename T >
+ result_type operator() (T const& arg) const
+ {
+ bool res = false;
+ boost::log::visit< ValueT >(m_name, arg, save_result_wrapper< PredicateT const&, bool >(m_visitor, res));
+ return res;
+ }
+
+private:
+ attribute_name m_name;
+ const PredicateT m_visitor;
+};
+
//! The default filter factory that supports creating filters for the standard types (see utility/type_dispatch/standard_types.hpp)
template< typename CharT >
class default_filter_factory :
public filter_factory< CharT >
{
+private:
//! Base type
typedef filter_factory< CharT > base_type;
//! Self type
typedef default_filter_factory< CharT > this_type;
- template< typename ValueT, typename PredicateT >
- struct predicate_wrapper;
-
- template< typename RelationT >
- struct on_integral_argument;
- template< typename RelationT >
- struct on_fp_argument;
- template< typename RelationT >
- struct on_string_argument;
- template< typename RelationT >
- struct on_regex_argument;
-
public:
// Type imports
typedef typename base_type::char_type char_type;
@@ -68,11 +84,16 @@
//! The callback for custom relation filter
virtual filter on_custom_relation(attribute_name const& name, string_type const& rel, string_type const& arg);
+private:
//! The function parses the argument value for a binary relation and constructs the corresponding filter
template< typename RelationT >
static filter parse_argument(attribute_name const& name, string_type const& arg);
};
+//! The function parses the "matches" relation
+template< typename CharT >
+filter parse_matches_relation(attribute_name const& name, std::basic_string< CharT > const& operand);
+
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
Added: trunk/libs/log/src/matches_relation_factory.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/libs/log/src/matches_relation_factory.cpp 2013-08-03 14:41:53 EDT (Sat, 03 Aug 2013) (r85202)
@@ -0,0 +1,160 @@
+/*
+ * Copyright Andrey Semashev 2007 - 2013.
+ * Distributed under the 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 matches_relation_factory.hpp
+ * \author Andrey Semashev
+ * \date 03.08.2013
+ *
+ * \brief This header is the Boost.Log library implementation, see the library documentation
+ * at http://www.boost.org/libs/log/doc/log.html.
+ */
+
+#if !defined(BOOST_LOG_WITHOUT_SETTINGS_PARSERS) && !defined(BOOST_LOG_WITHOUT_DEFAULT_FACTORIES)
+
+#include <string>
+#include <boost/move/core.hpp>
+#include <boost/move/utility.hpp>
+#include <boost/log/exceptions.hpp>
+#include <boost/log/utility/functional/matches.hpp>
+#include <boost/log/utility/type_dispatch/standard_types.hpp>
+#include <boost/log/utility/string_literal.hpp>
+#include <boost/log/detail/code_conversion.hpp>
+#include <boost/log/support/xpressive.hpp>
+#include <boost/xpressive/xpressive_dynamic.hpp>
+#if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
+#include <boost/fusion/container/set.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#endif
+#include "default_filter_factory.hpp"
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+BOOST_LOG_ANONYMOUS_NAMESPACE {
+
+#if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
+
+//! A special filtering predicate that adopts the string operand to the attribute value character type
+struct matches_predicate :
+ public matches_fun
+{
+ template< typename CharT >
+ struct initializer
+ {
+ typedef void result_type;
+ typedef CharT char_type;
+ typedef std::basic_string< char_type > string_type;
+
+ explicit initializer(string_type const& val) : m_initializer(val)
+ {
+ }
+
+ template< typename T >
+ result_type operator() (T& val) const
+ {
+ try
+ {
+ typedef typename T::char_type target_char_type;
+ std::basic_string< target_char_type > str;
+ log::aux::code_convert(m_initializer, str);
+ val = T::compile(str.c_str(), str.size(), T::ECMAScript | T::optimize);
+ }
+ catch (...)
+ {
+ }
+ }
+
+ private:
+ string_type const& m_initializer;
+ };
+
+ typedef matches_fun::result_type result_type;
+
+ template< typename CharT >
+ explicit matches_predicate(std::basic_string< CharT > const& operand)
+ {
+ fusion::for_each(m_operands, initializer< CharT >(operand));
+ }
+
+ template< typename T >
+ result_type operator() (T const& val) const
+ {
+ typedef typename T::value_type char_type;
+ typedef xpressive::basic_regex< const char_type* > regex_type;
+ return matches_fun::operator() (val, fusion::at_key< regex_type >(m_operands));
+ }
+
+private:
+ fusion::set< xpressive::cregex, xpressive::wcregex > m_operands;
+};
+
+#else
+
+//! A special filtering predicate that adopts the string operand to the attribute value character type
+template< typename CharT >
+struct matches_predicate :
+ public matches_fun
+{
+ typedef typename matches_fun::result_type result_type;
+ typedef CharT char_type;
+ typedef std::basic_string< char_type > string_type;
+ typedef xpressive::basic_regex< const char_type* > regex_type;
+
+ explicit matches_predicate(string_type const& operand) :
+ m_operand(regex_type::compile(operand.c_str(), operand.size(), regex_type::ECMAScript | regex_type::optimize))
+ {
+ }
+
+ template< typename T >
+ result_type operator() (T const& val) const
+ {
+ return matches_fun::operator() (val, m_operand);
+ }
+
+private:
+ regex_type m_operand;
+};
+
+#endif
+
+} // namespace
+
+//! The function parses the "matches" relation
+template< typename CharT >
+filter parse_matches_relation(attribute_name const& name, std::basic_string< CharT > const& operand)
+{
+#if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
+ return predicate_wrapper< log::string_types::type, matches_predicate >(name, matches_predicate(operand));
+#else
+ return predicate_wrapper< std::basic_string< CharT >, matches_predicate< CharT > >(name, matches_predicate< CharT >(operand));
+#endif
+}
+
+// Explicitly instantiate factory implementation
+#ifdef BOOST_LOG_USE_CHAR
+template
+filter parse_matches_relation< char >(attribute_name const& name, std::basic_string< char > const& operand);
+#endif
+#ifdef BOOST_LOG_USE_WCHAR_T
+template
+filter parse_matches_relation< wchar_t >(attribute_name const& name, std::basic_string< wchar_t > const& operand);
+#endif
+
+} // namespace aux
+
+BOOST_LOG_CLOSE_NAMESPACE // namespace log
+
+} // namespace boost
+
+#include <boost/log/detail/footer.hpp>
+
+#endif // !defined(BOOST_LOG_WITHOUT_SETTINGS_PARSERS) && !defined(BOOST_LOG_WITHOUT_DEFAULT_FACTORIES)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk