File indexing completed on 2025-01-31 10:02:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_SPIRIT_CHSET_OPERATORS_IPP
0010 #define BOOST_SPIRIT_CHSET_OPERATORS_IPP
0011
0012
0013 #include <boost/limits.hpp>
0014
0015
0016 namespace boost { namespace spirit {
0017
0018 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0019
0020
0021
0022
0023
0024
0025 template <typename CharT>
0026 inline chset<CharT>
0027 operator|(chset<CharT> const& a, chset<CharT> const& b)
0028 {
0029 return chset<CharT>(a) |= b;
0030 }
0031
0032
0033 template <typename CharT>
0034 inline chset<CharT>
0035 operator-(chset<CharT> const& a, chset<CharT> const& b)
0036 {
0037 return chset<CharT>(a) -= b;
0038 }
0039
0040
0041 template <typename CharT>
0042 inline chset<CharT>
0043 operator~(chset<CharT> const& a)
0044 {
0045 return chset<CharT>(a).inverse();
0046 }
0047
0048
0049 template <typename CharT>
0050 inline chset<CharT>
0051 operator&(chset<CharT> const& a, chset<CharT> const& b)
0052 {
0053 return chset<CharT>(a) &= b;
0054 }
0055
0056
0057 template <typename CharT>
0058 inline chset<CharT>
0059 operator^(chset<CharT> const& a, chset<CharT> const& b)
0060 {
0061 return chset<CharT>(a) ^= b;
0062 }
0063
0064
0065
0066
0067
0068
0069 template <typename CharT>
0070 inline chset<CharT>
0071 operator|(chset<CharT> const& a, range<CharT> const& b)
0072 {
0073 chset<CharT> a_(a);
0074 a_.set(b);
0075 return a_;
0076 }
0077
0078
0079 template <typename CharT>
0080 inline chset<CharT>
0081 operator&(chset<CharT> const& a, range<CharT> const& b)
0082 {
0083 chset<CharT> a_(a);
0084 if(b.first != (std::numeric_limits<CharT>::min)()) {
0085 a_.clear(range<CharT>((std::numeric_limits<CharT>::min)(), b.first - 1));
0086 }
0087 if(b.last != (std::numeric_limits<CharT>::max)()) {
0088 a_.clear(range<CharT>(b.last + 1, (std::numeric_limits<CharT>::max)()));
0089 }
0090 return a_;
0091 }
0092
0093
0094 template <typename CharT>
0095 inline chset<CharT>
0096 operator-(chset<CharT> const& a, range<CharT> const& b)
0097 {
0098 chset<CharT> a_(a);
0099 a_.clear(b);
0100 return a_;
0101 }
0102
0103
0104 template <typename CharT>
0105 inline chset<CharT>
0106 operator^(chset<CharT> const& a, range<CharT> const& b)
0107 {
0108 return a ^ chset<CharT>(b);
0109 }
0110
0111
0112 template <typename CharT>
0113 inline chset<CharT>
0114 operator|(range<CharT> const& a, chset<CharT> const& b)
0115 {
0116 chset<CharT> b_(b);
0117 b_.set(a);
0118 return b_;
0119 }
0120
0121
0122 template <typename CharT>
0123 inline chset<CharT>
0124 operator&(range<CharT> const& a, chset<CharT> const& b)
0125 {
0126 chset<CharT> b_(b);
0127 if(a.first != (std::numeric_limits<CharT>::min)()) {
0128 b_.clear(range<CharT>((std::numeric_limits<CharT>::min)(), a.first - 1));
0129 }
0130 if(a.last != (std::numeric_limits<CharT>::max)()) {
0131 b_.clear(range<CharT>(a.last + 1, (std::numeric_limits<CharT>::max)()));
0132 }
0133 return b_;
0134 }
0135
0136
0137 template <typename CharT>
0138 inline chset<CharT>
0139 operator-(range<CharT> const& a, chset<CharT> const& b)
0140 {
0141 return chset<CharT>(a) - b;
0142 }
0143
0144
0145 template <typename CharT>
0146 inline chset<CharT>
0147 operator^(range<CharT> const& a, chset<CharT> const& b)
0148 {
0149 return chset<CharT>(a) ^ b;
0150 }
0151
0152
0153
0154
0155
0156
0157 template <typename CharT>
0158 inline chset<CharT>
0159 operator|(chset<CharT> const& a, CharT b)
0160 {
0161 return a | chset<CharT>(b);
0162 }
0163
0164
0165 template <typename CharT>
0166 inline chset<CharT>
0167 operator&(chset<CharT> const& a, CharT b)
0168 {
0169 return a & chset<CharT>(b);
0170 }
0171
0172
0173 template <typename CharT>
0174 inline chset<CharT>
0175 operator-(chset<CharT> const& a, CharT b)
0176 {
0177 return a - chset<CharT>(b);
0178 }
0179
0180
0181 template <typename CharT>
0182 inline chset<CharT>
0183 operator^(chset<CharT> const& a, CharT b)
0184 {
0185 return a ^ chset<CharT>(b);
0186 }
0187
0188
0189 template <typename CharT>
0190 inline chset<CharT>
0191 operator|(CharT a, chset<CharT> const& b)
0192 {
0193 return chset<CharT>(a) | b;
0194 }
0195
0196
0197 template <typename CharT>
0198 inline chset<CharT>
0199 operator&(CharT a, chset<CharT> const& b)
0200 {
0201 return chset<CharT>(a) & b;
0202 }
0203
0204
0205 template <typename CharT>
0206 inline chset<CharT>
0207 operator-(CharT a, chset<CharT> const& b)
0208 {
0209 return chset<CharT>(a) - b;
0210 }
0211
0212
0213 template <typename CharT>
0214 inline chset<CharT>
0215 operator^(CharT a, chset<CharT> const& b)
0216 {
0217 return chset<CharT>(a) ^ b;
0218 }
0219
0220
0221
0222
0223
0224
0225 template <typename CharT>
0226 inline chset<CharT>
0227 operator|(chset<CharT> const& a, chlit<CharT> const& b)
0228 {
0229 return a | chset<CharT>(b.ch);
0230 }
0231
0232
0233 template <typename CharT>
0234 inline chset<CharT>
0235 operator&(chset<CharT> const& a, chlit<CharT> const& b)
0236 {
0237 return a & chset<CharT>(b.ch);
0238 }
0239
0240
0241 template <typename CharT>
0242 inline chset<CharT>
0243 operator-(chset<CharT> const& a, chlit<CharT> const& b)
0244 {
0245 return a - chset<CharT>(b.ch);
0246 }
0247
0248
0249 template <typename CharT>
0250 inline chset<CharT>
0251 operator^(chset<CharT> const& a, chlit<CharT> const& b)
0252 {
0253 return a ^ chset<CharT>(b.ch);
0254 }
0255
0256
0257 template <typename CharT>
0258 inline chset<CharT>
0259 operator|(chlit<CharT> const& a, chset<CharT> const& b)
0260 {
0261 return chset<CharT>(a.ch) | b;
0262 }
0263
0264
0265 template <typename CharT>
0266 inline chset<CharT>
0267 operator&(chlit<CharT> const& a, chset<CharT> const& b)
0268 {
0269 return chset<CharT>(a.ch) & b;
0270 }
0271
0272
0273 template <typename CharT>
0274 inline chset<CharT>
0275 operator-(chlit<CharT> const& a, chset<CharT> const& b)
0276 {
0277 return chset<CharT>(a.ch) - b;
0278 }
0279
0280
0281 template <typename CharT>
0282 inline chset<CharT>
0283 operator^(chlit<CharT> const& a, chset<CharT> const& b)
0284 {
0285 return chset<CharT>(a.ch) ^ b;
0286 }
0287
0288
0289
0290
0291
0292
0293 template <typename CharT>
0294 inline chset<CharT>
0295 operator|(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b)
0296 {
0297 return a | chset<CharT>(b);
0298 }
0299
0300
0301 template <typename CharT>
0302 inline chset<CharT>
0303 operator&(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b)
0304 {
0305 return a & chset<CharT>(b);
0306 }
0307
0308
0309 template <typename CharT>
0310 inline chset<CharT>
0311 operator-(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b)
0312 {
0313 return a - chset<CharT>(b);
0314 }
0315
0316
0317 template <typename CharT>
0318 inline chset<CharT>
0319 operator^(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b)
0320 {
0321 return a ^ chset<CharT>(b);
0322 }
0323
0324
0325 template <typename CharT>
0326 inline chset<CharT>
0327 operator|(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b)
0328 {
0329 return chset<CharT>(a) | b;
0330 }
0331
0332
0333 template <typename CharT>
0334 inline chset<CharT>
0335 operator&(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b)
0336 {
0337 return chset<CharT>(a) & b;
0338 }
0339
0340
0341 template <typename CharT>
0342 inline chset<CharT>
0343 operator-(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b)
0344 {
0345 return chset<CharT>(a) - b;
0346 }
0347
0348
0349 template <typename CharT>
0350 inline chset<CharT>
0351 operator^(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b)
0352 {
0353 return chset<CharT>(a) ^ b;
0354 }
0355
0356
0357
0358
0359
0360
0361 template <typename CharT>
0362 inline chset<CharT>
0363 operator|(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b)
0364 {
0365 return a | chset<CharT>(b);
0366 }
0367
0368
0369 template <typename CharT>
0370 inline chset<CharT>
0371 operator&(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b)
0372 {
0373 return a & chset<CharT>(b);
0374 }
0375
0376
0377 template <typename CharT>
0378 inline chset<CharT>
0379 operator-(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b)
0380 {
0381 return a - chset<CharT>(b);
0382 }
0383
0384
0385 template <typename CharT>
0386 inline chset<CharT>
0387 operator^(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b)
0388 {
0389 return a ^ chset<CharT>(b);
0390 }
0391
0392
0393 template <typename CharT>
0394 inline chset<CharT>
0395 operator|(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b)
0396 {
0397 return chset<CharT>(a) | b;
0398 }
0399
0400
0401 template <typename CharT>
0402 inline chset<CharT>
0403 operator&(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b)
0404 {
0405 return chset<CharT>(a) & b;
0406 }
0407
0408
0409 template <typename CharT>
0410 inline chset<CharT>
0411 operator-(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b)
0412 {
0413 return chset<CharT>(a) - b;
0414 }
0415
0416
0417 template <typename CharT>
0418 inline chset<CharT>
0419 operator^(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b)
0420 {
0421 return chset<CharT>(a) ^ b;
0422 }
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433 namespace impl {
0434
0435 template <typename CharT>
0436 inline BOOST_SPIRIT_CLASSIC_NS::range<CharT> const&
0437 full()
0438 {
0439 static BOOST_SPIRIT_CLASSIC_NS::range<CharT> full_(
0440 (std::numeric_limits<CharT>::min)(),
0441 (std::numeric_limits<CharT>::max)());
0442 return full_;
0443 }
0444
0445 template <typename CharT>
0446 inline BOOST_SPIRIT_CLASSIC_NS::range<CharT> const&
0447 empty()
0448 {
0449 static BOOST_SPIRIT_CLASSIC_NS::range<CharT> empty_;
0450 return empty_;
0451 }
0452 }
0453
0454
0455 template <typename CharT>
0456 inline chset<CharT>
0457 operator|(chset<CharT> const&, anychar_parser)
0458 {
0459 return chset<CharT>(impl::full<CharT>());
0460 }
0461
0462
0463 template <typename CharT>
0464 inline chset<CharT>
0465 operator&(chset<CharT> const& a, anychar_parser)
0466 {
0467 return a;
0468 }
0469
0470
0471 template <typename CharT>
0472 inline chset<CharT>
0473 operator-(chset<CharT> const&, anychar_parser)
0474 {
0475 return chset<CharT>();
0476 }
0477
0478
0479 template <typename CharT>
0480 inline chset<CharT>
0481 operator^(chset<CharT> const& a, anychar_parser)
0482 {
0483 return ~a;
0484 }
0485
0486
0487 template <typename CharT>
0488 inline chset<CharT>
0489 operator|(anychar_parser, chset<CharT> const& )
0490 {
0491 return chset<CharT>(impl::full<CharT>());
0492 }
0493
0494
0495 template <typename CharT>
0496 inline chset<CharT>
0497 operator&(anychar_parser, chset<CharT> const& b)
0498 {
0499 return b;
0500 }
0501
0502
0503 template <typename CharT>
0504 inline chset<CharT>
0505 operator-(anychar_parser, chset<CharT> const& b)
0506 {
0507 return ~b;
0508 }
0509
0510
0511 template <typename CharT>
0512 inline chset<CharT>
0513 operator^(anychar_parser, chset<CharT> const& b)
0514 {
0515 return ~b;
0516 }
0517
0518
0519
0520
0521
0522
0523 template <typename CharT>
0524 inline chset<CharT>
0525 operator|(chset<CharT> const& a, nothing_parser)
0526 {
0527 return a;
0528 }
0529
0530
0531 template <typename CharT>
0532 inline chset<CharT>
0533 operator&(chset<CharT> const& , nothing_parser)
0534 {
0535 return impl::empty<CharT>();
0536 }
0537
0538
0539 template <typename CharT>
0540 inline chset<CharT>
0541 operator-(chset<CharT> const& a, nothing_parser)
0542 {
0543 return a;
0544 }
0545
0546
0547 template <typename CharT>
0548 inline chset<CharT>
0549 operator^(chset<CharT> const& a, nothing_parser)
0550 {
0551 return a;
0552 }
0553
0554
0555 template <typename CharT>
0556 inline chset<CharT>
0557 operator|(nothing_parser, chset<CharT> const& b)
0558 {
0559 return b;
0560 }
0561
0562
0563 template <typename CharT>
0564 inline chset<CharT>
0565 operator&(nothing_parser, chset<CharT> const& )
0566 {
0567 return impl::empty<CharT>();
0568 }
0569
0570
0571 template <typename CharT>
0572 inline chset<CharT>
0573 operator-(nothing_parser, chset<CharT> const& )
0574 {
0575 return impl::empty<CharT>();
0576 }
0577
0578
0579 template <typename CharT>
0580 inline chset<CharT>
0581 operator^(nothing_parser, chset<CharT> const& b)
0582 {
0583 return b;
0584 }
0585
0586
0587 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0588
0589 }}
0590
0591 #endif
0592