1 // Boost tokenizer.hpp -----------------------------------------------------//
3 // (c) Copyright Jeremy Siek and John R. Bandela 2001.
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/libs/tokenizer for documenation
12 // 03 Jul 2003 John Bandela
13 // Converted to new iterator adapter
14 // 02 Feb 2002 Jeremy Siek
15 // Removed tabs and a little cleanup.
17 #ifndef BOOST_TOKENIZER_JRB070303_HPP_
18 #define BOOST_TOKENIZER_JRB070303_HPP_
20 #include <boost/token_iterator.hpp>
25 //===========================================================================
26 // A container-view of a tokenized "sequence"
28 typename TokenizerFunc
= char_delimiters_separator
<char>,
29 typename Iterator
= std::string::const_iterator
,
30 typename Type
= std::string
34 typedef token_iterator_generator
<TokenizerFunc
,Iterator
,Type
> TGen
;
36 // It seems that MSVC does not like the unqualified use of iterator,
37 // Thus we use iter internally when it is used unqualified and
38 // the users of this class will always qualify iterator.
39 typedef typename
TGen::type iter
;
43 typedef iter iterator
;
44 typedef iter const_iterator
;
45 typedef Type value_type
;
46 typedef value_type
& reference
;
47 typedef const value_type
& const_reference
;
48 typedef value_type
* pointer
;
49 typedef const pointer const_pointer
;
50 typedef void size_type
;
51 typedef void difference_type
;
53 tokenizer(Iterator first
, Iterator last
,
54 const TokenizerFunc
& f
= TokenizerFunc())
55 : first_(first
), last_(last
), f_(f
) { }
57 template <typename Container
>
58 tokenizer(const Container
& c
)
59 : first_(c
.begin()), last_(c
.end()), f_() { }
61 template <typename Container
>
62 tokenizer(const Container
& c
,const TokenizerFunc
& f
)
63 : first_(c
.begin()), last_(c
.end()), f_(f
) { }
65 void assign(Iterator first
, Iterator last
){
70 void assign(Iterator first
, Iterator last
, const TokenizerFunc
& f
){
75 template <typename Container
>
76 void assign(const Container
& c
){
77 assign(c
.begin(),c
.end());
81 template <typename Container
>
82 void assign(const Container
& c
, const TokenizerFunc
& f
){
83 assign(c
.begin(),c
.end(),f
);
86 iter
begin() const { return iter(f_
,first_
,last_
); }
87 iter
end() const { return iter(f_
,last_
,last_
); }