coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
chew.h
Go to the documentation of this file.
1 #ifndef CHEW_H
2 #define CHEW_H
3 #pragma once
4 /***************************************************************************
5  * Copyright (C) 2007-2013 Mike Kinghan, imk@burroingroingjoing.com *
6  * All rights reserved. *
7  * *
8  * Contributed by Mike Kinghan, imk@burroingroingjoing.com, *
9  * derived from the code of Tony Finch *
10  * *
11  * Redistribution and use in source and binary forms, with or without *
12  * modification, are permitted provided that the following conditions *
13  * are met: *
14  * *
15  * Redistributions of source code must retain the above copyright *
16  * notice, this list of conditions and the following disclaimer. *
17  * *
18  * Redistributions in binary form must reproduce the above copyright *
19  * notice, this list of conditions and the following disclaimer in the *
20  * documentation and/or other materials provided with the distribution. *
21  * *
22  * Neither the name of Mike Kinghan nor the names of its contributors *
23  * may be used to endorse or promote products derived from this software *
24  * without specific prior written permission. *
25  * *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
29  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
30  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
32  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
33  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED *
34  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
35  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
36  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
37  * DAMAGE. *
38  * *
39  **************************************************************************/
40 #include "prohibit.h"
41 #include "eol.h"
42 #include <type_traits>
43 #include <cctype>
44 
51 namespace chew_mode
52 {
53 
55 static bool const plaintext = false;
57 static bool const cxxtext = true;
58 
60 enum class text_type
61 {
62  none,
63  whitespace,
64  greyspace,
67  c_comment,
72  code,
73  name,
77  stringify,
79 };
81 struct whitespace
82 {
84  static text_type const id = text_type::whitespace;
85  whitespace() {}
86 };
88 struct greyspace
89 {
91  static text_type const id = text_type::greyspace;
92  greyspace() {}
93 };
96 {
98  static text_type const id = text_type::continuation;
99  continuation() {}
100 };
103 {
105  static text_type const id = text_type::cxx_comment;
106  cxx_comment() {}
107 };
108 
110 struct c_comment
111 {
113  static text_type const id = text_type::c_comment;
114  c_comment() {}
115 };
116 
119 {
121  static text_type const id = text_type::string_literal;
122  string_literal() {}
123 };
124 
127 {
129  static text_type const id = text_type::character_literal;
130  character_literal() {}
131 };
132 
135 {
137  static text_type const id = text_type::raw_string_literal;
138  raw_string_literal() {}
139 };
140 
143 {
145  static text_type const id = text_type::header_name;
146  header_name() {}
147 };
148 
150 struct code
151 {
153  static text_type const id = text_type::code;
154  code() {}
155 };
156 
158 struct name
159 {
161  static text_type const id = text_type::name;
162  name() {}
163 };
164 
167 {
169  static text_type const id = text_type::literal_space;
170  literal_space() {}
171 };
172 
175 {
177  static text_type const id = text_type::punctuation;
178  punctuation() {}
179 };
180 
183 {
185  static text_type const id = text_type::number_space;
186  number_space() {}
187 };
188 
190 struct stringify
191 {
193  static text_type const id = text_type::stringify;
194  stringify() {}
195 };
196 
199 {
201  static text_type const id = text_type::token_paste;
202  token_paste() {}
203 };
204 
205 
206 } // namespace chew_mode
207 
240 
247 template<class CharSeq>
248 struct chewer : private no_assign
249 {
251 
253  using sequence_type = CharSeq;
255  using char_type = typename sequence_type::value_type;
257  template<class Mode1, class Mode2>
258  using void_if =
259  typename std::enable_if<std::is_same<Mode1,Mode2>::value>::type;
260 
268  explicit chewer(bool cxx, sequence_type & seq, size_t off = 0)
269  : _cxx(cxx),_seq(seq),_buf(nullptr),_cur(off),_len(0) {
270  sync();
271  }
272 
282  template<class Mode>
283  explicit chewer(bool cxx, Mode mode, sequence_type & seq, size_t off = 0)
284  : _cxx(cxx), _seq(seq),_buf(nullptr),_cur(off),_len(0) {
285  scan<Mode>();
286  }
287 
289  bool cxx() const {
290  return _cxx;
291  }
292 
299  void sync() {
300  _buf = const_cast<char_type *>(_seq.data());
301  _len = _seq.size();
302  }
303 
305  template<class Mode>
306  void scan(Mode mode, size_t off) {
307  cursor(off);
308  scan<Mode>();
309  }
310 
323  template<class FirstMode, class ...OtherModes>
324  void scan( ptrdiff_t adjust,
325  FirstMode first_mode, OtherModes... other_modes) {
326  adjust >= 0 ? on(adjust) : back(-adjust);
327  scan<FirstMode,OtherModes...>();
328  }
329 
336  template<class FirstMode, class ...OtherModes>
337  void scan() {
338  sync();
339  consume<FirstMode,OtherModes...>();
340  }
341 
344  bool overshoot(size_t off = 0) const {
345  return _cur + off >= _len;
346  }
347 
349  char_type atoff(ptrdiff_t off) const {
350  return _buf[_cur + off];
351  }
352 
355  char_type & atoff(size_t off) {
356  return _buf[_cur + off];
357  }
358 
360  char_type operator[](size_t off) const {
361  return atoff(off);
362  }
363 
365  char_type & operator[](size_t off) {
366  return atoff(off);
367  }
368 
370  size_t cursor() const {
371  return _cur;
372  }
373 
376  size_t remaining() const {
377  return _len - _cur;
378  }
379 
385  void cursor(size_t off) {
386  sync();
387  _cur = off;
388  }
389 
391  char_type curch() const {
392  return _buf[_cur];
393  }
394 
397  return _buf[_cur];
398  }
399 
401  chewer & operator=(size_t off) {
402  cursor(off);
403  return *this;
404  }
405 
407  explicit operator size_t () const {
408  return cursor();
409  }
410 
414  return _seq;
415  }
416  sequence_type const & buf() const {
417  return _seq;
418  }
420 
423  return curch();
424  }
427  return curch();
428  }
429 
431  explicit operator bool () const {
432  return !overshoot();
433  }
434 
441  void on(size_t n) {
442  _cur += n;
443  }
444 
450  void back(size_t n) {
451  _cur -= n;
452  }
453 
456  ++_cur;
457  return *this;
458  }
459 
462  --_cur;
463  return *this;
464  }
465 
467  chewer & operator+=(size_t n) {
468  on(n);
469  return *this;
470  }
471 
473  chewer & operator-=(size_t n) {
474  back(n);
475  return *this;
476  }
477 
479  template<class Mode>
480  chewer & operator()(ptrdiff_t move, Mode mode) {
481  scan(move,mode);
482  return *this;
483  }
484 
486  template<class FirstMode, class ...OtherModes>
487  typename
488  std::enable_if<!std::is_arithmetic<FirstMode>::value,chewer &>::type
489  operator()(FirstMode first_mode, OtherModes... other_modes) {
490  scan<FirstMode,OtherModes...>();
491  return *this;
492  }
493 
494 private:
495 
497  template<typename U>
499  typename
500  std::enable_if<traits::has_extend_method<U>::value>::type;
501 
503  template<typename U>
505  typename
506  std::enable_if<!traits::has_extend_method<U>::value>::type;
507 
510  template<typename U = sequence_type>
512  _seq.extend();
513  sync();
514  }
515  template<typename U = sequence_type>
516  void extend(if_sequence_is_not_extensible<U> * = nullptr) {}
518 
520 
523  template<typename U = sequence_type>
524  void extend(size_t skip, if_sequence_is_extensible<U> * = nullptr) {
525  _seq.extend(skip);
526  sync();
527  }
528  template<typename U = sequence_type>
529  void
530  extend(
531  size_t skip,
532  if_sequence_is_not_extensible<U> * = nullptr) {}
534 
542  unsigned eol(size_t off = 0) {
543  return ::eol(_seq,_cur + off);
544  }
545 
550  bool line_continues(size_t off = 0) {
551  return atoff(off) == '\\' && eol(off + 1);
552  }
553 
555  template<class Mode>
559  size_t nl_len;
560  for ( ; curch() == '\\' && (nl_len = eol(1)); on(nl_len + 1)) {
561  if (overshoot(nl_len + 1)) {
562  extend(nl_len);
563  }
564  }
565  }
566 
567  template<class Mode>
568  void_if<Mode,chew_mode::whitespace> consume() {
569  consume<chew_mode::continuation>();
570  for ( ;!overshoot() && isspace(curch());
571  ++_cur,consume<chew_mode::continuation>()) {}
572  }
573 
574  template<class Mode>
575  void_if<Mode,chew_mode::number_space> consume() {
576  consume<chew_mode::continuation>();
577  size_t mark = _cur;
578  if (!overshoot() && curch() == '.') {
579  ++_cur;
580  }
581  if (overshoot() || !isdigit(curch())) {
582  _cur = mark;
583  return;
584  }
585  for (++_cur ;!overshoot() && (
586  isalnum(curch()) || curch() == '_' || curch() == '+' ||
587  curch() == '-' || curch() == '.');
588  ++_cur,consume<chew_mode::continuation>()) {}
589  }
590 
591  template<class Mode>
592  void_if<Mode,chew_mode::name> consume() {
593  consume<chew_mode::continuation>();
594  if (!overshoot() && (isalpha(curch()) || curch() == '_')) {
595  for (++_cur; !overshoot() && (isalnum(curch()) || curch() == '_');
596  ++_cur,consume<chew_mode::continuation>()){}
597  }
598  }
599 
600 
601  template<class Mode>
602  void_if<Mode,chew_mode::punctuation> consume() {
603  consume<chew_mode::continuation>();
604  for ( ;!overshoot() && ispunct(curch()) &&
605  (curch() != '_' && curch() != '\'' && curch() != '\"');
606  ++_cur,consume<chew_mode::continuation>()) {}
607  }
608 
609  template<class Mode>
610  void_if<Mode,chew_mode::stringify> consume() {
611  consume<chew_mode::continuation>();
612  _cur += !overshoot() && curch() == '#';
613  }
614 
615  template<class Mode>
616  void_if<Mode,chew_mode::token_paste> consume() {
617  size_t mark = _cur;
618  consume<chew_mode::continuation>();
619  if ((_cur += !overshoot() && curch() == '#') > mark) {
620  consume<chew_mode::continuation>();
621  if (!overshoot() && curch() == '#') {
622  ++_cur;
623  } else {
624  _cur = mark;
625  }
626  }
627  }
628 
629  template<class Mode>
630  void_if<Mode,chew_mode::cxx_comment> consume() {
631  consume<chew_mode::continuation>();
632  size_t mark = _cur;
633  if (!overshoot() && curch() == '/') {
634  ++_cur;
635  consume<chew_mode::continuation>();
636  if (overshoot() || curch() != '/') {
637  _cur = mark;
638  return;
639  }
640  for(++_cur;
641  !overshoot();
642  ++_cur,consume<chew_mode::continuation>()){};
643  }
644  }
645 
646  template<class Mode>
647  void_if<Mode,chew_mode::c_comment> consume() {
648  consume<chew_mode::continuation>();
649  size_t mark = _cur;
650  if (overshoot() || curch() != '/') {
651  return;
652  }
653  ++_cur;
654  consume<chew_mode::continuation>();
655  if (overshoot() || curch() != '*') {
656  _cur = mark;
657  return;
658  }
659  bool closing = false;
660  ++_cur;
661  consume<chew_mode::continuation>();
662  for ( ; !overshoot();
663  closing = (curch() == '*'),
664  ++_cur,consume<chew_mode::continuation>()) {
665  if (curch() == '/') {
666  if (closing) {
667  ++_cur;
668  return;
669  }
670  } else {
671  size_t nl_len = eol();
672  if (nl_len && overshoot(nl_len + 1)) {
673  extend(nl_len);
674  }
675  }
676  }
677  eof_in_comment();
678  }
679 
680  template<class Mode>
681  void_if<Mode,chew_mode::string_literal> consume() {
682  consume<chew_mode::continuation>();
683  consume_enclosed_string<'\"','\"'>();
684  }
685 
686  template<class Mode>
687  void_if<Mode,chew_mode::header_name> consume() {
688  consume<chew_mode::continuation>();
689  size_t mark = _cur;
690  consume_enclosed_string<'<','>'>();
691  if (_cur == mark) {
692  consume_enclosed_string<'\"','\"'>();
693  }
694  }
695 
696  template<class Mode>
697  void_if<Mode,chew_mode::character_literal> consume() {
698  consume<chew_mode::continuation>();
699  if (overshoot() || curch() != '\'') {
700  return;
701  }
702  size_t mark = _cur;
703  ++_cur;
704  consume<chew_mode::continuation>();
705  bool escape = false;
706  for ( ; !overshoot(); ++_cur,consume<chew_mode::continuation>()) {
707  if (curch() == '\'') {
708  if (!escape) {
709  ++_cur;
710  return;
711  }
712  escape = false;
713  } else if (curch() == '\\') {
714  escape = !escape;
715  } else {
716  escape = false;
717  }
718  }
719  _cur = mark;
720  }
721 
722  template<class Mode>
723  void_if<Mode,chew_mode::raw_string_literal> consume() {
724  consume<chew_mode::continuation>();
725  if (overshoot() || curch() != 'R') {
726  return;
727  }
728  size_t mark = _cur;
729  ++_cur;
730  consume<chew_mode::continuation>();
731  if (overshoot() || curch() != '\"') {
732  _cur = mark;
733  return;
734  }
735  ++_cur;
736  consume<chew_mode::continuation>();
737  for ( ; !overshoot(); ++_cur,consume<chew_mode::continuation>()) {
738  if (!isgraph(curch()) || curch() == '\\') {
739  _cur = mark;
740  return;
741  }
742  if (curch() == '(') {
743  break;
744  }
745  }
746  ++_cur;
747  consume<chew_mode::continuation>();
748  for ( ; !overshoot(); ++_cur,consume<chew_mode::continuation>()) {
749  if (curch() == ')') {
750  break;
751  }
752  size_t nl_len = eol();
753  if (nl_len != 0) {
754  extend(nl_len);
755  }
756  }
757  ++_cur;
758  consume<chew_mode::continuation>();
759  for (; !overshoot(); ++_cur,consume<chew_mode::continuation>()) {
760  if (!isgraph(curch()) || curch() == '\\') {
761  break;
762  }
763  if (curch() == '\"') {
764  ++_cur;
765  return;
766  }
767  }
768  missing_terminator(mark,'\"');
769  }
770 
771  template<class Mode>
772  void_if<Mode,chew_mode::greyspace> consume() {
773  if (!_cxx) {
774  consume<chew_mode::whitespace>();
775  return;
776  }
777  for ( ;!overshoot(); ) {
778  consume<chew_mode::whitespace>();
779  size_t mark = _cur;
780  consume<chew_mode::cxx_comment>();
781  if (_cur != mark) {
782  break;
783  }
784  consume<chew_mode::c_comment>();
785  if (_cur == mark) {
786  break;
787  }
788  }
789  }
790 
791  template<class Mode>
792  void_if<Mode,chew_mode::code> consume() {
793  for ( ;!overshoot(); ++_cur) {
794  consume<chew_mode::greyspace>();
795  consume<chew_mode::character_literal>();
796  consume<chew_mode::string_literal>();
797  consume<chew_mode::raw_string_literal>();
798  }
799  }
800 
801  template<class Mode>
802  void_if<Mode,chew_mode::literal_space> consume() {
803  consume<chew_mode::character_literal,
804  chew_mode::string_literal,
805  chew_mode::raw_string_literal>();
806  }
808 
812  template<class First, class Next, class ...Rest>
813  typename std::enable_if<sizeof ...(Rest) == 0>::type
814  consume();
815 
816  template<class First, class Next, class ...Rest>
817  typename std::enable_if<sizeof ...(Rest) != 0>::type
818  consume();
820 
821 
823  template<char_type Opener, char_type Closer>
824  void consume_enclosed_string();
825 
827  void missing_terminator(size_t off, char_type missing);
829  void eof_in_comment();
830 
832  bool _cxx;
834  sequence_type & _seq;
836  char_type *_buf;
838  size_t _cur;
840  size_t _len;
841 
842 };
843 
844 template<class CharSeq>
845 template<
846  typename chewer<CharSeq>::char_type Opener,
847  typename chewer<CharSeq>::char_type Closer
848 >
849 void chewer<CharSeq>::consume_enclosed_string()
850 {
851  if (overshoot() || curch() != Opener) {
852  return;
853  }
854  size_t mark = _cur++;
855  consume<chew_mode::continuation>();
856  bool escape = false;
857  for ( ; !overshoot(); ++_cur,consume<chew_mode::continuation>()) {
858  if (curch() == Closer) {
859  if (!escape) {
860  ++_cur;
861  return;
862  }
863  escape = false;
864  } else if (curch() == '\\') {
865  escape = !escape;
866  } else {
867  escape = false;
868  }
869  }
870  if (overshoot()) {
871  missing_terminator(mark,Closer);
872  }
873 }
874 
875 template<class CharSeq>
876 template<class First, class Next, class ...Rest>
877 typename std::enable_if<sizeof ...(Rest) == 0>::type
878 chewer<CharSeq>::consume() {
879  for ( ;!overshoot(); ) {
880  size_t mark = _cur;
881  consume<First>();
882  consume<Next>();
883  if (_cur == mark) {
884  break;
885  }
886  }
887 }
888 
889 template<class CharSeq>
890 template<class First, class Next, class ...Rest>
891 typename std::enable_if<sizeof ...(Rest) != 0>::type
892 chewer<CharSeq>::consume() {
893  for ( ;!overshoot(); ) {
894  size_t mark = _cur;
895  consume<First>();
896  consume<Next,Rest...>();
897  if (_cur == mark) {
898  break;
899  }
900  }
901 }
902 
903 #endif /* EOF*/
template struct traits::is_random_access_char_sequence<T> exports a static const boolean member value...
Definition: traits.h:166
unsigned eol(CharSeq const &seq, size_t off)
Test for a newline-sequence at an offset in a character sequence.
Definition: eol.h:53
A tag class for selecting a chew mode.
Definition: chew.h:126
A tag class for selecting a chew mode.
Definition: chew.h:190
void back(size_t n)
Retreat the scanning position an amount.
Definition: chew.h:450
A tag class for selecting a chew mode.
Definition: chew.h:110
chewer & operator()(ptrdiff_t move, Mode mode)
operator()(move,mode) calls scan(move,mode) returning *this
Definition: chew.h:480
char_type * _buf
Pointer to the data controlled by _seq
Definition: chew.h:836
chew_mode::character_literal const character_literal
An exemplar chew_mode::character_literal
Definition: chew.h:221
A tag class for selecting a chew mode.
Definition: chew.h:174
chewer(bool cxx, sequence_type &seq, size_t off=0)
Construct from a sequence_type and initial offset.
Definition: chew.h:268
A tag class for selecting a chew mode.
Definition: chew.h:198
void_if< Mode, chew_mode::continuation > consume()
Consume characters satisfying a given mode, without preliminary snyc()
Definition: chew.h:558
void scan()
Scan in a sequence of modes.
Definition: chew.h:337
A tag class for selecting a chew mode.
Definition: chew.h:134
bool cxx() const
Say whether scanning as C/C++ source.
Definition: chew.h:289
A utility class to prevent assignment of containing class.
Definition: prohibit.h:56
chewer(bool cxx, Mode mode, sequence_type &seq, size_t off=0)
Construct, scanning a given a sequence_type from a given offset.
Definition: chew.h:283
typename std::enable_if< traits::has_extend_method< U >::value >::type if_sequence_is_extensible
SFINAE type equating to void if sequence_type has an extend method.
Definition: chew.h:500
A tag class for selecting a chew mode.
Definition: chew.h:142
chew_mode::string_literal const string_literal
An exemplar chew_mode::string_literal
Definition: chew.h:219
chew_mode::token_paste const token_paste
An exemplar chew_mode::token_paste
Definition: chew.h:239
void scan(ptrdiff_t adjust, FirstMode first_mode, OtherModes...other_modes)
Adjust position and then scan in a sequence of modes.
Definition: chew.h:324
chewer & operator=(size_t off)
Assign the scanning position, returning *this
Definition: chew.h:401
chew_mode::c_comment const c_comment
An exemplar chew_mode::c_comment
Definition: chew.h:217
CharSeq sequence_type
Type of the character-sequence consumed.
Definition: chew.h:253
void cursor(size_t off)
Set the scanning position.
Definition: chew.h:385
bool overshoot(size_t off=0) const
Say whether the scanning position is past the end of the associated sequence_type ...
Definition: chew.h:344
chew_mode::raw_string_literal const raw_string_literal
An exemplar chew_mode::raw_string_literal
Definition: chew.h:223
unsigned eol(size_t off=0)
Test for a newline-sequence at an offset from the scanning position.
Definition: chew.h:542
A tag class for selecting a chew mode.
Definition: chew.h:118
chewer & operator--()
Decrement the scanning position, returning *this
Definition: chew.h:461
char_type operator*() const
operator*() const is an alias for curch() const.
Definition: chew.h:422
A tag class for selecting a chew mode.
Definition: chew.h:88
chew_mode::whitespace const whitespace
An exemplar chew_mode::whitespace
Definition: chew.h:209
sequence_type & buf()
Get a [const] reference to the associated sequence_type
Definition: chew.h:413
A tag class for selecting a chew mode.
Definition: chew.h:102
void extend(size_t skip, if_sequence_is_extensible< U > *=nullptr)
Extend the associated sequence_type by reading more input, possibly replacing skip characters ahead o...
Definition: chew.h:524
size_t remaining() const
Get the remaining length of the associated sequence_type from the scanning position.
Definition: chew.h:376
char_type curch() const
Get the character at the scanning position.
Definition: chew.h:391
chew_mode::continuation const continuation
An exemplar chew_mode::continuation
Definition: chew.h:213
A tag class for selecting a chew mode.
Definition: chew.h:182
chew_mode::name const name
An exemplar chew_mode::name
Definition: chew.h:229
chew_mode::number_space const number_space
An exemplar chew_mode::number_space
Definition: chew.h:235
char_type & atoff(size_t off)
Get a reference to the character at an offset from the scanning position.
Definition: chew.h:355
bool _cxx
Scanning C/C++ source?
Definition: chew.h:832
chew_mode::cxx_comment const cxx_comment
An exemplar chew_mode::cxx_comment
Definition: chew.h:215
void sync()
Synchronise the object with the associated sequence_type
Definition: chew.h:299
void on(size_t n)
Advance the scanning position an amount.
Definition: chew.h:441
char_type & operator[](size_t off)
operator[]() is an alias for atoff()
Definition: chew.h:365
void eof_in_comment()
Diagnose end of file in C-comment.
chew_mode::greyspace const greyspace
An exemplar chew_mode::greyspace
Definition: chew.h:211
size_t _cur
The scanning position in _buf.
Definition: chew.h:838
chew_mode::header_name const header_name
An exemplar chew_mode::header_name
Definition: chew.h:225
chewer & operator++()
Increment the scanning position, returning *this
Definition: chew.h:455
chew_mode::code const code
An exemplar chew_mode::code
Definition: chew.h:227
std::enable_if<!std::is_arithmetic< FirstMode >::value, chewer & >::type operator()(FirstMode first_mode, OtherModes...other_modes)
operator()(mode) calls scan(mode) returning *this
Definition: chew.h:489
`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence t...
Definition: chew.h:248
typename std::enable_if< std::is_same< Mode1, Mode2 >::value >::type void_if
SFINAE type equating to void if enabled.
Definition: chew.h:259
sequence_type & _seq
The sequence that is consumed.
Definition: chew.h:834
size_t _len
The length of the data at `_buf'.
Definition: chew.h:840
A tag class for selecting a chew mode.
Definition: chew.h:150
A tag class for selecting a chew mode.
Definition: chew.h:95
typename sequence_type::value_type char_type
Value-type of the character-sequence.
Definition: chew.h:255
chewer & operator+=(size_t n)
Advance the scanning position an amount, returning *this
Definition: chew.h:467
void scan(Mode mode, size_t off)
Scan the associated sequence_type in a given mode from a given offset.
Definition: chew.h:306
char_type operator[](size_t off) const
operator[]() const is an alias for atoff() const
Definition: chew.h:360
A tag class for selecting a chew mode.
Definition: chew.h:81
void extend(if_sequence_is_extensible< U > *=nullptr)
Extend the associated sequence_type by reading more input.
Definition: chew.h:511
char_type & curch()
Get a reference to the character at the scanning position.
Definition: chew.h:396
void consume_enclosed_string()
Consume characters between delimiting characters.
Definition: chew.h:849
A tag class for selecting a chew mode.
Definition: chew.h:166
typename std::enable_if<!traits::has_extend_method< U >::value >::type if_sequence_is_not_extensible
SFINAE type equating to void if sequence_type lacks an extend method.
Definition: chew.h:506
chew_mode::punctuation const punctuation
An exemplar chew_mode::punctuation
Definition: chew.h:233
size_t cursor() const
Get the scanning position.
Definition: chew.h:370
char_type atoff(ptrdiff_t off) const
Get the character at an offset from the scanning position.
Definition: chew.h:349
A tag class for selecting a chew mode.
Definition: chew.h:158
bool line_continues(size_t off=0)
Say whether there is a line-continuation at an offset.
Definition: chew.h:550
chewer & operator-=(size_t n)
Retreat the scanning position an amount, returning *this
Definition: chew.h:473
chew_mode::literal_space const literal_space
An exemplar chew_mode::literal_space
Definition: chew.h:231
chew_mode::stringify const stringify
An exemplar chew_mode::stringify
Definition: chew.h:237