Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70139 - sandbox/local/boost/detail/preprocessor/keyword/_facility
From: lorcaminiti_at_[hidden]
Date: 2011-03-18 17:39:28


Author: lcaminiti
Date: 2011-03-18 17:39:26 EDT (Fri, 18 Mar 2011)
New Revision: 70139
URL: http://svn.boost.org/trac/boost/changeset/70139

Log:
Updating docs.
Added:
   sandbox/local/boost/detail/preprocessor/keyword/_facility/
   sandbox/local/boost/detail/preprocessor/keyword/_facility/add.hpp (contents, props changed)
   sandbox/local/boost/detail/preprocessor/keyword/_facility/is.hpp (contents, props changed)
   sandbox/local/boost/detail/preprocessor/keyword/_facility/remove.hpp (contents, props changed)

Added: sandbox/local/boost/detail/preprocessor/keyword/_facility/add.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/_facility/add.hpp 2011-03-18 17:39:26 EDT (Fri, 18 Mar 2011)
@@ -0,0 +1,25 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_FACILITY_ADD_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_ADD_HPP_
+
+#include <boost/preprocessor/control/expr_iif.hpp>
+#include <boost/preprocessor/logical/not.hpp>
+
+// `is_front_macro(tokens)` is 1 iff `tokens` start with `keyword` to add.
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_ADD_FRONT( \
+ tokens, is_front_macro, keyword) \
+ BOOST_PP_EXPR_IIF(BOOST_PP_NOT(is_front_macro(tokens)), keyword) tokens
+
+// `is_back_macro(tokens)` is 1 iff `tokens` end with `keyword` to add.
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_ADD_BACK(tokens, \
+ is_back_macro, keyword) \
+ tokens BOOST_PP_EXPR_IIF(BOOST_PP_NOT(is_back_macro(tokens)), keyword)
+
+#endif // #include guard
+

Added: sandbox/local/boost/detail/preprocessor/keyword/_facility/is.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/_facility/is.hpp 2011-03-18 17:39:26 EDT (Fri, 18 Mar 2011)
@@ -0,0 +1,33 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_HPP_
+
+// Boost.Preprocessor author P. Mensodines confirmed on an Boost email thread
+// (subject ``check if a token is a keyword (was "BOOST_PP_IS_UNARY()")'')
+// that it is OK to used `PP_IS_UNARY()` to check if tokens match predefined
+// "keyword" as it is done by the macros below (even if `PP_IS_UNARY()` is
+// technically only part of Boost.Preprocessor private API).
+#include <boost/preprocessor/detail/is_unary.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// `chekcing_prefix ## tokens` expand to unary (e.g., `(1)`) iff `tokens` start
+// with keyword to check.
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_FRONT(tokens, checking_prefix) \
+ BOOST_PP_IS_UNARY(BOOST_PP_CAT(checking_prefix, tokens))
+
+// `token ## chekcing_postfix` expand to unary (e.g., `(1)`) iff `token` is the
+// keyword to check. This check only works if `token` is a single token, it
+// will always expand to 0 if token is multiple tokens (e.g., `const *this`).
+// This check will expand to 0 with no error if `token` starts with a
+// non-alphanumeric symbol (e.g., `*this`).
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_IS_BACK(token, checking_postfix) \
+ BOOST_PP_IS_UNARY(BOOST_PP_CAT(token, checking_postfix))
+
+#endif // #include guard
+

Added: sandbox/local/boost/detail/preprocessor/keyword/_facility/remove.hpp
==============================================================================
--- (empty file)
+++ sandbox/local/boost/detail/preprocessor/keyword/_facility/remove.hpp 2011-03-18 17:39:26 EDT (Fri, 18 Mar 2011)
@@ -0,0 +1,38 @@
+
+// Copyright (C) 2009-2011 Lorenzo Caminiti
+// Use, modification, and distribution is subject to the
+// Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#ifndef BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_HPP_
+
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// `is_front_macro(tokens)` is 1 iff `tokens` start with keyword to remove.
+// `removing_prefix ## <keyword-to-remove>` must expand to nothing.
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_FRONT( \
+ tokens, is_front_macro, removing_prefix) \
+ BOOST_PP_EXPAND( /* without EXPAND doesn't expand on MSVC */ \
+ BOOST_PP_IIF(is_front_macro(tokens), \
+ BOOST_PP_CAT \
+ , \
+ tokens BOOST_PP_TUPLE_EAT(2) \
+ )(removing_prefix, tokens) \
+ )
+
+// `is_back_macro(tokens)` is 1 iff `tokens` end with keyword to remove.
+// `<keyword-to-remove> ## removing_postfix` must expand to nothing.
+#define BOOST_DETAIL_PP_KEYWORD_FACILITY_REMOVE_BACK( \
+ tokens, is_back_macro, removing_prefix) \
+ BOOST_PP_IIF(is_back_macro(tokens), \
+ BOOST_PP_CAT \
+ , \
+ tokens BOOST_PP_TUPLE_EAT(2) \
+ )(tokens, removing_postfix)
+
+#endif // #include guard
+


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