imgtools/imglib/boostlibrary/boost/regex/mfc.hpp
author srilekhas <srilekhas@symbian.org>
Wed, 18 Aug 2010 11:18:38 +0100
changeset 627 cb3264f4c6e6
parent 600 6d08f4a05d93
permissions -rw-r--r--
Merge : re-applies missing part of fix for Bug 2901,Add export for s60ibymacros.pm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
/*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
 *
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
 * Copyright (c) 2004
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
 * John Maddock
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
 *
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
 * Use, modification and distribution are subject to the 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
 * Boost Software License, Version 1.0. (See accompanying file 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
 *
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
 */
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
 /*
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
  *   LOCATION:    see http://www.boost.org for most recent version.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
  *   FILE         mfc.hpp
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
  *   VERSION      see <boost/version.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
  *   DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
  */
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
#ifndef BOOST_REGEX_MFC_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
#define BOOST_REGEX_MFC_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#include <atlsimpstr.h>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
#include <boost/regex.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
namespace boost{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
// define the types used for TCHAR's:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
typedef basic_regex<TCHAR> tregex;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
typedef match_results<TCHAR const*> tmatch;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
typedef regex_iterator<TCHAR const*> tregex_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
typedef regex_token_iterator<TCHAR const*> tregex_token_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
#if _MSC_VER >= 1310
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
#define SIMPLE_STRING_PARAM class B, bool b
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
#define SIMPLE_STRING_ARG_LIST B, b
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
#else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
#define SIMPLE_STRING_PARAM class B
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
#define SIMPLE_STRING_ARG_LIST B
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
// define regex creation functions:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
template <SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
inline basic_regex<B> 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
make_regex(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
   basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
// regex_match overloads:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
template <SIMPLE_STRING_PARAM, class A, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
                 match_results<const B*, A>& what,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
                 const basic_regex<B, T>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
   return ::boost::regex_match(s.GetString(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
                               s.GetString() + s.GetLength(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
                               what,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
                               e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
                               f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
template <SIMPLE_STRING_PARAM, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
                 const basic_regex<B, T>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
   return ::boost::regex_match(s.GetString(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
                               s.GetString() + s.GetLength(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
                               e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
                               f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
// regex_search overloads:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
template <SIMPLE_STRING_PARAM, class A, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
                 match_results<const B*, A>& what,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
                 const basic_regex<B, T>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
   return ::boost::regex_search(s.GetString(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
                               s.GetString() + s.GetLength(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
                               what,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
                               e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
                               f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
template <SIMPLE_STRING_PARAM, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
                 const basic_regex<B, T>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
   return ::boost::regex_search(s.GetString(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
                               s.GetString() + s.GetLength(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
                               e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
                               f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
// regex_iterator creation:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
template <SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
inline regex_iterator<B const*> 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
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)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
   regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
template <SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
inline regex_token_iterator<B const*> 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
   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)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
template <SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
inline regex_token_iterator<B const*> 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
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)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
template <SIMPLE_STRING_PARAM, std::size_t N>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
inline regex_token_iterator<B const*> 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
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)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
template <class OutputIterator, class BidirectionalIterator, class traits,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
          SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
OutputIterator regex_replace(OutputIterator out,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
                           BidirectionalIterator first,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
                           BidirectionalIterator last,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
                           const basic_regex<B, traits>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
                           const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
                           match_flag_type flags = match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
   return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
namespace re_detail{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
template <SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
class mfc_string_out_iterator
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>* out;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
public:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
   mfc_string_out_iterator(ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s) : out(&s) {}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
   mfc_string_out_iterator& operator++() { return *this; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
   mfc_string_out_iterator& operator++(int) { return *this; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
   mfc_string_out_iterator& operator*() { return *this; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
   mfc_string_out_iterator& operator=(B v) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
   { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
      out->AppendChar(v); 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
      return *this; 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
   }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
   typedef std::ptrdiff_t difference_type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
   typedef B value_type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
   typedef value_type* pointer;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
   typedef value_type& reference;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
   typedef std::output_iterator_tag iterator_category;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
template <class traits, SIMPLE_STRING_PARAM>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> regex_replace(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
                            const basic_regex<B, traits>& e,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
                            const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
                            match_flag_type flags = match_default)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> result(s.GetManager());
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
   re_detail::mfc_string_out_iterator<SIMPLE_STRING_ARG_LIST> i(result);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
   regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
   return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
} // namespace boost.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
#endif