File indexing completed on 2025-01-18 09:51:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_REGEX_V4_SUB_MATCH_HPP
0020 #define BOOST_REGEX_V4_SUB_MATCH_HPP
0021
0022 #ifdef BOOST_MSVC
0023 #pragma warning(push)
0024 #pragma warning(disable: 4103)
0025 #endif
0026 #ifdef BOOST_HAS_ABI_HEADERS
0027 # include BOOST_ABI_PREFIX
0028 #endif
0029 #ifdef BOOST_MSVC
0030 #pragma warning(pop)
0031 #endif
0032
0033 namespace boost{
0034
0035 template <class BidiIterator>
0036 struct sub_match : public std::pair<BidiIterator, BidiIterator>
0037 {
0038 typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::value_type value_type;
0039 #if defined(BOOST_NO_STD_ITERATOR_TRAITS)
0040 typedef std::ptrdiff_t difference_type;
0041 #else
0042 typedef typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<BidiIterator>::difference_type difference_type;
0043 #endif
0044 typedef BidiIterator iterator_type;
0045 typedef BidiIterator iterator;
0046 typedef BidiIterator const_iterator;
0047
0048 bool matched;
0049
0050 sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
0051 sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
0052 #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
0053 && !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0551)\
0054 && !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
0055 template <class T, class A>
0056 operator std::basic_string<value_type, T, A> ()const
0057 {
0058 return matched ? std::basic_string<value_type, T, A>(this->first, this->second) : std::basic_string<value_type, T, A>();
0059 }
0060 #else
0061 operator std::basic_string<value_type> ()const
0062 {
0063 return str();
0064 }
0065 #endif
0066 difference_type BOOST_REGEX_CALL length()const
0067 {
0068 difference_type n = matched ? ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
0069 return n;
0070 }
0071 std::basic_string<value_type> str()const
0072 {
0073 std::basic_string<value_type> result;
0074 if(matched)
0075 {
0076 std::size_t len = ::boost::BOOST_REGEX_DETAIL_NS::distance((BidiIterator)this->first, (BidiIterator)this->second);
0077 result.reserve(len);
0078 BidiIterator i = this->first;
0079 while(i != this->second)
0080 {
0081 result.append(1, *i);
0082 ++i;
0083 }
0084 }
0085 return result;
0086 }
0087 int compare(const sub_match& s)const
0088 {
0089 if(matched != s.matched)
0090 return static_cast<int>(matched) - static_cast<int>(s.matched);
0091 return str().compare(s.str());
0092 }
0093 int compare(const std::basic_string<value_type>& s)const
0094 {
0095 return str().compare(s);
0096 }
0097 int compare(const value_type* p)const
0098 {
0099 return str().compare(p);
0100 }
0101
0102 bool operator==(const sub_match& that)const
0103 { return compare(that) == 0; }
0104 bool BOOST_REGEX_CALL operator !=(const sub_match& that)const
0105 { return compare(that) != 0; }
0106 bool operator<(const sub_match& that)const
0107 { return compare(that) < 0; }
0108 bool operator>(const sub_match& that)const
0109 { return compare(that) > 0; }
0110 bool operator<=(const sub_match& that)const
0111 { return compare(that) <= 0; }
0112 bool operator>=(const sub_match& that)const
0113 { return compare(that) >= 0; }
0114
0115 #ifdef BOOST_REGEX_MATCH_EXTRA
0116 typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
0117
0118 const capture_sequence_type& captures()const
0119 {
0120 if(!m_captures)
0121 m_captures.reset(new capture_sequence_type());
0122 return *m_captures;
0123 }
0124
0125
0126
0127 capture_sequence_type& get_captures()const
0128 {
0129 if(!m_captures)
0130 m_captures.reset(new capture_sequence_type());
0131 return *m_captures;
0132 }
0133
0134 private:
0135 mutable boost::scoped_ptr<capture_sequence_type> m_captures;
0136 public:
0137
0138 #endif
0139 sub_match(const sub_match& that, bool
0140 #ifdef BOOST_REGEX_MATCH_EXTRA
0141 deep_copy
0142 #endif
0143 = true
0144 )
0145 : std::pair<BidiIterator, BidiIterator>(that),
0146 matched(that.matched)
0147 {
0148 #ifdef BOOST_REGEX_MATCH_EXTRA
0149 if(that.m_captures)
0150 if(deep_copy)
0151 m_captures.reset(new capture_sequence_type(*(that.m_captures)));
0152 #endif
0153 }
0154 sub_match& operator=(const sub_match& that)
0155 {
0156 this->first = that.first;
0157 this->second = that.second;
0158 matched = that.matched;
0159 #ifdef BOOST_REGEX_MATCH_EXTRA
0160 if(that.m_captures)
0161 get_captures() = *(that.m_captures);
0162 #endif
0163 return *this;
0164 }
0165
0166
0167
0168 BidiIterator begin()const { return this->first; }
0169 BidiIterator end()const { return this->second; }
0170
0171
0172 #ifdef BOOST_OLD_REGEX_H
0173
0174
0175
0176 operator int()const;
0177 operator unsigned int()const;
0178 operator short()const
0179 {
0180 return (short)(int)(*this);
0181 }
0182 operator unsigned short()const
0183 {
0184 return (unsigned short)(unsigned int)(*this);
0185 }
0186 #endif
0187 };
0188
0189 typedef sub_match<const char*> csub_match;
0190 typedef sub_match<std::string::const_iterator> ssub_match;
0191 #ifndef BOOST_NO_WREGEX
0192 typedef sub_match<const wchar_t*> wcsub_match;
0193 typedef sub_match<std::wstring::const_iterator> wssub_match;
0194 #endif
0195
0196
0197 template <class RandomAccessIterator, class traits, class Allocator>
0198 inline bool operator == (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0199 const sub_match<RandomAccessIterator>& m)
0200 { return s.compare(m.str()) == 0; }
0201 template <class RandomAccessIterator, class traits, class Allocator>
0202 inline bool operator != (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0203 const sub_match<RandomAccessIterator>& m)
0204 { return s.compare(m.str()) != 0; }
0205 template <class RandomAccessIterator, class traits, class Allocator>
0206 inline bool operator < (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0207 const sub_match<RandomAccessIterator>& m)
0208 { return s.compare(m.str()) < 0; }
0209 template <class RandomAccessIterator, class traits, class Allocator>
0210 inline bool operator <= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0211 const sub_match<RandomAccessIterator>& m)
0212 { return s.compare(m.str()) <= 0; }
0213 template <class RandomAccessIterator, class traits, class Allocator>
0214 inline bool operator >= (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0215 const sub_match<RandomAccessIterator>& m)
0216 { return s.compare(m.str()) >= 0; }
0217 template <class RandomAccessIterator, class traits, class Allocator>
0218 inline bool operator > (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0219 const sub_match<RandomAccessIterator>& m)
0220 { return s.compare(m.str()) > 0; }
0221
0222 template <class RandomAccessIterator, class traits, class Allocator>
0223 inline bool operator == (const sub_match<RandomAccessIterator>& m,
0224 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0225 { return m.str().compare(s) == 0; }
0226 template <class RandomAccessIterator, class traits, class Allocator>
0227 inline bool operator != (const sub_match<RandomAccessIterator>& m,
0228 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0229 { return m.str().compare(s) != 0; }
0230 template <class RandomAccessIterator, class traits, class Allocator>
0231 inline bool operator < (const sub_match<RandomAccessIterator>& m,
0232 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0233 { return m.str().compare(s) < 0; }
0234 template <class RandomAccessIterator, class traits, class Allocator>
0235 inline bool operator > (const sub_match<RandomAccessIterator>& m,
0236 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0237 { return m.str().compare(s) > 0; }
0238 template <class RandomAccessIterator, class traits, class Allocator>
0239 inline bool operator <= (const sub_match<RandomAccessIterator>& m,
0240 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0241 { return m.str().compare(s) <= 0; }
0242 template <class RandomAccessIterator, class traits, class Allocator>
0243 inline bool operator >= (const sub_match<RandomAccessIterator>& m,
0244 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0245 { return m.str().compare(s) >= 0; }
0246
0247 template <class RandomAccessIterator>
0248 inline bool operator == (const sub_match<RandomAccessIterator>& m,
0249 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0250 { return m.str().compare(s) == 0; }
0251 template <class RandomAccessIterator>
0252 inline bool operator != (const sub_match<RandomAccessIterator>& m,
0253 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0254 { return m.str().compare(s) != 0; }
0255 template <class RandomAccessIterator>
0256 inline bool operator > (const sub_match<RandomAccessIterator>& m,
0257 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0258 { return m.str().compare(s) > 0; }
0259 template <class RandomAccessIterator>
0260 inline bool operator < (const sub_match<RandomAccessIterator>& m,
0261 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0262 { return m.str().compare(s) < 0; }
0263 template <class RandomAccessIterator>
0264 inline bool operator >= (const sub_match<RandomAccessIterator>& m,
0265 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0266 { return m.str().compare(s) >= 0; }
0267 template <class RandomAccessIterator>
0268 inline bool operator <= (const sub_match<RandomAccessIterator>& m,
0269 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s)
0270 { return m.str().compare(s) <= 0; }
0271
0272 template <class RandomAccessIterator>
0273 inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0274 const sub_match<RandomAccessIterator>& m)
0275 { return m.str().compare(s) == 0; }
0276 template <class RandomAccessIterator>
0277 inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0278 const sub_match<RandomAccessIterator>& m)
0279 { return m.str().compare(s) != 0; }
0280 template <class RandomAccessIterator>
0281 inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0282 const sub_match<RandomAccessIterator>& m)
0283 { return m.str().compare(s) > 0; }
0284 template <class RandomAccessIterator>
0285 inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0286 const sub_match<RandomAccessIterator>& m)
0287 { return m.str().compare(s) < 0; }
0288 template <class RandomAccessIterator>
0289 inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0290 const sub_match<RandomAccessIterator>& m)
0291 { return m.str().compare(s) >= 0; }
0292 template <class RandomAccessIterator>
0293 inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0294 const sub_match<RandomAccessIterator>& m)
0295 { return m.str().compare(s) <= 0; }
0296
0297
0298 template <class RandomAccessIterator>
0299 inline bool operator == (const sub_match<RandomAccessIterator>& m,
0300 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0301 { return m.str().compare(0, m.length(), &s, 1) == 0; }
0302 template <class RandomAccessIterator>
0303 inline bool operator != (const sub_match<RandomAccessIterator>& m,
0304 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0305 { return m.str().compare(0, m.length(), &s, 1) != 0; }
0306 template <class RandomAccessIterator>
0307 inline bool operator > (const sub_match<RandomAccessIterator>& m,
0308 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0309 { return m.str().compare(0, m.length(), &s, 1) > 0; }
0310 template <class RandomAccessIterator>
0311 inline bool operator < (const sub_match<RandomAccessIterator>& m,
0312 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0313 { return m.str().compare(0, m.length(), &s, 1) < 0; }
0314 template <class RandomAccessIterator>
0315 inline bool operator >= (const sub_match<RandomAccessIterator>& m,
0316 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0317 { return m.str().compare(0, m.length(), &s, 1) >= 0; }
0318 template <class RandomAccessIterator>
0319 inline bool operator <= (const sub_match<RandomAccessIterator>& m,
0320 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0321 { return m.str().compare(0, m.length(), &s, 1) <= 0; }
0322
0323 template <class RandomAccessIterator>
0324 inline bool operator == (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0325 const sub_match<RandomAccessIterator>& m)
0326 { return m.str().compare(0, m.length(), &s, 1) == 0; }
0327 template <class RandomAccessIterator>
0328 inline bool operator != (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0329 const sub_match<RandomAccessIterator>& m)
0330 { return m.str().compare(0, m.length(), &s, 1) != 0; }
0331 template <class RandomAccessIterator>
0332 inline bool operator < (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0333 const sub_match<RandomAccessIterator>& m)
0334 { return m.str().compare(0, m.length(), &s, 1) > 0; }
0335 template <class RandomAccessIterator>
0336 inline bool operator > (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0337 const sub_match<RandomAccessIterator>& m)
0338 { return m.str().compare(0, m.length(), &s, 1) < 0; }
0339 template <class RandomAccessIterator>
0340 inline bool operator <= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0341 const sub_match<RandomAccessIterator>& m)
0342 { return m.str().compare(0, m.length(), &s, 1) >= 0; }
0343 template <class RandomAccessIterator>
0344 inline bool operator >= (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0345 const sub_match<RandomAccessIterator>& m)
0346 { return m.str().compare(0, m.length(), &s, 1) <= 0; }
0347
0348
0349 template <class RandomAccessIterator, class traits, class Allocator>
0350 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
0351 operator + (const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
0352 const sub_match<RandomAccessIterator>& m)
0353 {
0354 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
0355 result.reserve(s.size() + m.length() + 1);
0356 return result.append(s).append(m.first, m.second);
0357 }
0358 template <class RandomAccessIterator, class traits, class Allocator>
0359 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
0360 operator + (const sub_match<RandomAccessIterator>& m,
0361 const std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
0362 {
0363 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
0364 result.reserve(s.size() + m.length() + 1);
0365 return result.append(m.first, m.second).append(s);
0366 }
0367 #if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE))
0368 template <class RandomAccessIterator>
0369 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0370 operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0371 const sub_match<RandomAccessIterator>& m)
0372 {
0373 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
0374 result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
0375 return result.append(s).append(m.first, m.second);
0376 }
0377 template <class RandomAccessIterator>
0378 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0379 operator + (const sub_match<RandomAccessIterator>& m,
0380 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s)
0381 {
0382 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
0383 result.reserve(std::char_traits<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
0384 return result.append(m.first, m.second).append(s);
0385 }
0386 #else
0387
0388 template <class RandomAccessIterator>
0389 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0390 operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const* s,
0391 const sub_match<RandomAccessIterator>& m)
0392 {
0393 return s + m.str();
0394 }
0395 template <class RandomAccessIterator>
0396 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0397 operator + (const sub_match<RandomAccessIterator>& m,
0398 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const * s)
0399 {
0400 return m.str() + s;
0401 }
0402 #endif
0403 template <class RandomAccessIterator>
0404 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0405 operator + (typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s,
0406 const sub_match<RandomAccessIterator>& m)
0407 {
0408 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
0409 result.reserve(m.length() + 2);
0410 return result.append(1, s).append(m.first, m.second);
0411 }
0412 template <class RandomAccessIterator>
0413 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0414 operator + (const sub_match<RandomAccessIterator>& m,
0415 typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type const& s)
0416 {
0417 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
0418 result.reserve(m.length() + 2);
0419 return result.append(m.first, m.second).append(1, s);
0420 }
0421 template <class RandomAccessIterator>
0422 inline std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type>
0423 operator + (const sub_match<RandomAccessIterator>& m1,
0424 const sub_match<RandomAccessIterator>& m2)
0425 {
0426 std::basic_string<typename BOOST_REGEX_DETAIL_NS::regex_iterator_traits<RandomAccessIterator>::value_type> result;
0427 result.reserve(m1.length() + m2.length() + 1);
0428 return result.append(m1.first, m1.second).append(m2.first, m2.second);
0429 }
0430 #ifndef BOOST_NO_STD_LOCALE
0431 template <class charT, class traits, class RandomAccessIterator>
0432 std::basic_ostream<charT, traits>&
0433 operator << (std::basic_ostream<charT, traits>& os,
0434 const sub_match<RandomAccessIterator>& s)
0435 {
0436 return (os << s.str());
0437 }
0438 #else
0439 template <class RandomAccessIterator>
0440 std::ostream& operator << (std::ostream& os,
0441 const sub_match<RandomAccessIterator>& s)
0442 {
0443 return (os << s.str());
0444 }
0445 #endif
0446
0447 #ifdef BOOST_OLD_REGEX_H
0448 namespace BOOST_REGEX_DETAIL_NS{
0449 template <class BidiIterator, class charT>
0450 int do_toi(BidiIterator i, BidiIterator j, char c, int radix)
0451 {
0452 std::string s(i, j);
0453 char* p;
0454 int result = std::strtol(s.c_str(), &p, radix);
0455 if(*p)raise_regex_exception("Bad sub-expression");
0456 return result;
0457 }
0458
0459
0460
0461 template <class I, class charT>
0462 int do_toi(I& i, I j, charT c)
0463 {
0464 int result = 0;
0465 while((i != j) && (isdigit(*i)))
0466 {
0467 result = result*10 + (*i - '0');
0468 ++i;
0469 }
0470 return result;
0471 }
0472 }
0473
0474
0475 template <class BidiIterator>
0476 sub_match<BidiIterator>::operator int()const
0477 {
0478 BidiIterator i = first;
0479 BidiIterator j = second;
0480 if(i == j)raise_regex_exception("Bad sub-expression");
0481 int neg = 1;
0482 if((i != j) && (*i == '-'))
0483 {
0484 neg = -1;
0485 ++i;
0486 }
0487 neg *= BOOST_REGEX_DETAIL_NS::do_toi(i, j, *i);
0488 if(i != j)raise_regex_exception("Bad sub-expression");
0489 return neg;
0490 }
0491 template <class BidiIterator>
0492 sub_match<BidiIterator>::operator unsigned int()const
0493 {
0494 BidiIterator i = first;
0495 BidiIterator j = second;
0496 if(i == j)
0497 raise_regex_exception("Bad sub-expression");
0498 return BOOST_REGEX_DETAIL_NS::do_toi(i, j, *first);
0499 }
0500 #endif
0501
0502 }
0503
0504 #ifdef BOOST_MSVC
0505 #pragma warning(push)
0506 #pragma warning(disable: 4103)
0507 #endif
0508 #ifdef BOOST_HAS_ABI_HEADERS
0509 # include BOOST_ABI_SUFFIX
0510 #endif
0511 #ifdef BOOST_MSVC
0512 #pragma warning(pop)
0513 #endif
0514
0515 #endif
0516