/usr/include/boost/regex/mfc.hpp is in libboost1.46-dev 1.46.1-7ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | /*
*
* 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 mfc.hpp
* VERSION see <boost/version.hpp>
* DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex.
*/
#ifndef BOOST_REGEX_MFC_HPP
#define BOOST_REGEX_MFC_HPP
#include <atlsimpstr.h>
#include <boost/regex.hpp>
namespace boost{
//
// define the types used for TCHAR's:
typedef basic_regex<TCHAR> tregex;
typedef match_results<TCHAR const*> tmatch;
typedef regex_iterator<TCHAR const*> tregex_iterator;
typedef regex_token_iterator<TCHAR const*> tregex_token_iterator;
#if _MSC_VER >= 1310
#define SIMPLE_STRING_PARAM class B, bool b
#define SIMPLE_STRING_ARG_LIST B, b
#else
#define SIMPLE_STRING_PARAM class B
#define SIMPLE_STRING_ARG_LIST B
#endif
//
// define regex creation functions:
//
template <SIMPLE_STRING_PARAM>
inline basic_regex<B>
make_regex(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal)
{
basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f);
return result;
}
//
// regex_match overloads:
//
template <SIMPLE_STRING_PARAM, class A, class T>
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
match_results<const B*, A>& what,
const basic_regex<B, T>& e,
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
return ::boost::regex_match(s.GetString(),
s.GetString() + s.GetLength(),
what,
e,
f);
}
template <SIMPLE_STRING_PARAM, class T>
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
const basic_regex<B, T>& e,
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
return ::boost::regex_match(s.GetString(),
s.GetString() + s.GetLength(),
e,
f);
}
//
// regex_search overloads:
//
template <SIMPLE_STRING_PARAM, class A, class T>
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
match_results<const B*, A>& what,
const basic_regex<B, T>& e,
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
return ::boost::regex_search(s.GetString(),
s.GetString() + s.GetLength(),
what,
e,
f);
}
template <SIMPLE_STRING_PARAM, class T>
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
const basic_regex<B, T>& e,
boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
return ::boost::regex_search(s.GetString(),
s.GetString() + s.GetLength(),
e,
f);
}
//
// regex_iterator creation:
//
template <SIMPLE_STRING_PARAM>
inline regex_iterator<B const*>
make_regex_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f);
return result;
}
template <SIMPLE_STRING_PARAM>
inline regex_token_iterator<B const*>
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f);
return result;
}
template <SIMPLE_STRING_PARAM>
inline regex_token_iterator<B const*>
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const std::vector<int>& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
return result;
}
template <SIMPLE_STRING_PARAM, std::size_t N>
inline regex_token_iterator<B const*>
make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
{
regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
return result;
}
template <class OutputIterator, class BidirectionalIterator, class traits,
SIMPLE_STRING_PARAM>
OutputIterator regex_replace(OutputIterator out,
BidirectionalIterator first,
BidirectionalIterator last,
const basic_regex<B, traits>& e,
const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
match_flag_type flags = match_default)
{
return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags);
}
namespace re_detail{
template <SIMPLE_STRING_PARAM>
class mfc_string_out_iterator
{
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>* out;
public:
mfc_string_out_iterator(ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s) : out(&s) {}
mfc_string_out_iterator& operator++() { return *this; }
mfc_string_out_iterator& operator++(int) { return *this; }
mfc_string_out_iterator& operator*() { return *this; }
mfc_string_out_iterator& operator=(B v)
{
out->AppendChar(v);
return *this;
}
typedef std::ptrdiff_t difference_type;
typedef B value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef std::output_iterator_tag iterator_category;
};
}
template <class traits, SIMPLE_STRING_PARAM>
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> regex_replace(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
const basic_regex<B, traits>& e,
const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
match_flag_type flags = match_default)
{
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> result(s.GetManager());
re_detail::mfc_string_out_iterator<SIMPLE_STRING_ARG_LIST> i(result);
regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags);
return result;
}
} // namespace boost.
#endif
|