~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to libs/boost-lib/libs/regex/src/wc_regex_traits.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#define BOOST_REGEX_SOURCE
21
21
 
22
 
#include <boost/config.hpp>
 
22
#include <boost/detail/workaround.hpp>
 
23
#include <memory>
 
24
#include <string>
 
25
 
 
26
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \
 
27
   && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))\
 
28
   && BOOST_WORKAROUND(BOOST_MSVC, <1600)
 
29
//
 
30
// This is a horrible workaround, but without declaring these symbols extern we get
 
31
// duplicate symbol errors when linking if the application is built without
 
32
// /Zc:wchar_t
 
33
//
 
34
#ifdef _CRTIMP2_PURE
 
35
#  define BOOST_REGEX_STDLIB_DECL _CRTIMP2_PURE
 
36
#else
 
37
#  define BOOST_REGEX_STDLIB_DECL _CRTIMP2
 
38
#endif
 
39
 
 
40
namespace std{
 
41
 
 
42
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
 
43
template class BOOST_REGEX_STDLIB_DECL allocator<unsigned short>;
 
44
template class BOOST_REGEX_STDLIB_DECL _String_val<unsigned short, allocator<unsigned short> >;
 
45
template class BOOST_REGEX_STDLIB_DECL basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >;
 
46
#endif
 
47
 
 
48
#if BOOST_WORKAROUND(BOOST_MSVC, > 1300) && BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
 
49
template<> BOOST_REGEX_STDLIB_DECL std::size_t __cdecl char_traits<unsigned short>::length(unsigned short const*);
 
50
#endif
 
51
 
 
52
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
 
53
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
 
54
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
 
55
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
 
56
   const unsigned short *,
 
57
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
 
58
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator==(
 
59
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
 
60
   const unsigned short *);
 
61
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator<(
 
62
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
 
63
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
 
64
template BOOST_REGEX_STDLIB_DECL bool __cdecl operator>(
 
65
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
 
66
   const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
 
67
}
 
68
#endif
 
69
 
 
70
#include <boost/regex/config.hpp>
23
71
#include <boost/detail/workaround.hpp>
24
72
 
25
73
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
114
162
   char_class_graph=char_class_alnum|char_class_punct,
115
163
   char_class_blank=1<<9,
116
164
   char_class_word=1<<10,
117
 
   char_class_unicode=1<<11
 
165
   char_class_unicode=1<<11,
 
166
   char_class_horizontal=1<<12,
 
167
   char_class_vertical=1<<13
118
168
};
119
169
 
120
170
c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* p1, const wchar_t* p2) 
129
179
      char_class_digit,
130
180
      char_class_digit,
131
181
      char_class_graph,
 
182
      char_class_horizontal,
132
183
      char_class_lower,
133
184
      char_class_lower,
134
185
      char_class_print,
138
189
      char_class_upper,
139
190
      char_class_unicode,
140
191
      char_class_upper,
 
192
      char_class_vertical,
141
193
      char_class_alnum | char_class_word, 
142
194
      char_class_alnum | char_class_word, 
143
195
      char_class_xdigit,
144
196
   };
145
197
 
146
 
   int id = ::boost::re_detail::get_default_class_id(p1, p2);
147
 
   if(id < 0)
 
198
   int idx = ::boost::re_detail::get_default_class_id(p1, p2);
 
199
   if(idx < 0)
148
200
   {
149
201
      std::wstring s(p1, p2);
150
202
      for(std::wstring::size_type i = 0; i < s.size(); ++i)
151
203
         s[i] = (std::towlower)(s[i]);
152
 
      id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
 
204
      idx = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
153
205
   }
154
 
   BOOST_ASSERT(id+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
155
 
   return masks[id+1];
 
206
   BOOST_ASSERT(idx+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
 
207
   return masks[idx+1];
156
208
}
157
209
 
158
210
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask) 
169
221
      || ((mask & char_class_xdigit) && (std::iswxdigit)(c))
170
222
      || ((mask & char_class_blank) && (std::iswspace)(c) && !::boost::re_detail::is_separator(c))
171
223
      || ((mask & char_class_word) && (c == '_'))
172
 
      || ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)));
 
224
      || ((mask & char_class_unicode) && (c & ~static_cast<wchar_t>(0xff)))
 
225
      || ((mask & char_class_vertical) && (::boost::re_detail::is_separator(c) || (c == L'\v')))
 
226
      || ((mask & char_class_horizontal) && (std::iswspace)(c) && !::boost::re_detail::is_separator(c) && (c != L'\v'));
173
227
}
174
228
 
175
229
c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(const wchar_t* p1, const wchar_t* p2)