Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49457 - in sandbox/compile-in-place: . Boost_1_35_0/boost/regex
From: doomster_at_[hidden]
Date: 2008-10-26 11:15:41


Author: eckhardt
Date: 2008-10-26 11:15:40 EDT (Sun, 26 Oct 2008)
New Revision: 49457
URL: http://svn.boost.org/trac/boost/changeset/49457

Log:
- Add include file to compile the regex library in-place.
- Add example for the in-place compiled regex library.

Added:
   sandbox/compile-in-place/Boost_1_35_0/boost/regex/compile_in_place.cpp (contents, props changed)
   sandbox/compile-in-place/test-regex.cpp (contents, props changed)

Added: sandbox/compile-in-place/Boost_1_35_0/boost/regex/compile_in_place.cpp
==============================================================================
--- (empty file)
+++ sandbox/compile-in-place/Boost_1_35_0/boost/regex/compile_in_place.cpp 2008-10-26 11:15:40 EDT (Sun, 26 Oct 2008)
@@ -0,0 +1,80 @@
+/* compile in-place support for Boost.Regex
+
+Copyright 2008 Ulrich Eckhardt
+
+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)
+*/
+// $Id$
+
+// This file must not be included more than once. Note that this 'once' is
+// not per translation unit but per binary! Never include this in a header!
+#ifdef BOOST_REGEX_COMPILE_IN_PLACE_CPP_INCLUDED
+# error "this file should only be included once per binary"
+#endif
+
+#define BOOST_REGEX_COMPILE_IN_PLACE_CPP_INCLUDED
+/* Note: the three *instances.cpp files actually only define some macros and
+then include boost/regex/v4/instances.hpp which instantiates some templates.
+However, instead of really including that file, they include boost/regex.hpp
+which has include guards, so it is impossible to compile these three files as
+they are into the same translation unit. The result is the code below, which
+is labeled "template instances". */
+#include "../../libs/regex/src/c_regex_traits.cpp"
+#include "../../libs/regex/src/cpp_regex_traits.cpp"
+#include "../../libs/regex/src/cregex.cpp"
+#include "../../libs/regex/src/fileiter.cpp"
+#include "../../libs/regex/src/icu.cpp"
+#include "../../libs/regex/src/instances.cpp"
+#include "../../libs/regex/src/posix_api.cpp"
+#include "../../libs/regex/src/regex.cpp"
+#include "../../libs/regex/src/regex_debug.cpp"
+#include "../../libs/regex/src/regex_raw_buffer.cpp"
+#include "../../libs/regex/src/regex_traits_defaults.cpp"
+#include "../../libs/regex/src/static_mutex.cpp"
+#include "../../libs/regex/src/usinstances.cpp"
+#include "../../libs/regex/src/w32_regex_traits.cpp"
+#include "../../libs/regex/src/wc_regex_traits.cpp"
+#include "../../libs/regex/src/wide_posix_api.cpp"
+#include "../../libs/regex/src/winstances.cpp"
+
+
+//
+// Note: the code below is copied from boost/regex/v4/regex.hpp
+//
+// template instances:
+//
+#define BOOST_REGEX_CHAR_T char
+#ifdef BOOST_REGEX_NARROW_INSTANTIATE
+# define BOOST_REGEX_INSTANTIATE
+#endif
+#include <boost/regex/v4/instances.hpp>
+#undef BOOST_REGEX_CHAR_T
+#ifdef BOOST_REGEX_INSTANTIATE
+# undef BOOST_REGEX_INSTANTIATE
+#endif
+
+#ifndef BOOST_NO_WREGEX
+# define BOOST_REGEX_CHAR_T wchar_t
+# ifdef BOOST_REGEX_WIDE_INSTANTIATE
+# define BOOST_REGEX_INSTANTIATE
+# endif
+# include <boost/regex/v4/instances.hpp>
+# undef BOOST_REGEX_CHAR_T
+# ifdef BOOST_REGEX_INSTANTIATE
+# undef BOOST_REGEX_INSTANTIATE
+# endif
+#endif
+
+#if !defined(BOOST_NO_WREGEX) && defined(BOOST_REGEX_HAS_OTHER_WCHAR_T)
+# define BOOST_REGEX_CHAR_T unsigned short
+# ifdef BOOST_REGEX_US_INSTANTIATE
+# define BOOST_REGEX_INSTANTIATE
+# endif
+# include <boost/regex/v4/instances.hpp>
+# undef BOOST_REGEX_CHAR_T
+# ifdef BOOST_REGEX_INSTANTIATE
+# undef BOOST_REGEX_INSTANTIATE
+# endif
+#endif
+

Added: sandbox/compile-in-place/test-regex.cpp
==============================================================================
--- (empty file)
+++ sandbox/compile-in-place/test-regex.cpp 2008-10-26 11:15:40 EDT (Sun, 26 Oct 2008)
@@ -0,0 +1,30 @@
+/* example to demonstrate compile-in-place for Boost.Regex
+
+Compile with
+ $CXX -I path/to/boost_X_YY_Z test-regex.cpp
+
+Notes:
+
+$Id$
+*/
+#include <boost/regex.hpp>
+#include <boost/regex/compile_in_place.cpp>
+#include <iostream>
+#include <ostream>
+#ifndef BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED
+# error
+#endif
+int main( int argc, char** argv)
+{
+ if(argc!=3)
+ {
+ std::cerr << argv[0] << " <regex> <string>" << std::endl;
+ return 1;
+ }
+
+ boost::regex e( argv[1]);
+
+ std::cout << "regex_match(" << argv[2] << ", " << e << ") = " << regex_match( argv[2], e) << std::endl;
+
+ return 0;
+}


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