1 // Boost tokenizer.hpp -----------------------------------------------------//
3 // © Copyright Jeremy Siek and John R. Bandela 2001.
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all
7 // copies. This software is provided "as is" without express or
8 // implied warranty, and with no claim as to its suitability for any
11 // See http://www.boost.org/libs/tokenizer for documenation
14 // 03 Jul 2003 John Bandela
15 // Converted to new iterator adapter
16 // 02 Feb 2002 Jeremy Siek
17 // Removed tabs and a little cleanup.
19 #ifndef BOOST_TOKENIZER_JRB070303_HPP_
20 #define BOOST_TOKENIZER_JRB070303_HPP_
22 #include <boost/token_iterator.hpp>
27 //===========================================================================
28 // A container-view of a tokenized "sequence"
30 typename TokenizerFunc = char_delimiters_separator<char>,
31 typename Iterator = std::string::const_iterator,
32 typename Type = std::string
36 typedef token_iterator_generator<TokenizerFunc,Iterator,Type> TGen;
38 // It seems that MSVC does not like the unqualified use of iterator,
39 // Thus we use iter internally when it is used unqualified and
40 // the users of this class will always qualify iterator.
41 typedef typename TGen::type iter;
45 typedef iter iterator;
46 typedef iter const_iterator;
47 typedef Type value_type;
48 typedef value_type& reference;
49 typedef const value_type& const_reference;
50 typedef value_type* pointer;
51 typedef const pointer const_pointer;
52 typedef void size_type;
53 typedef void difference_type;
55 tokenizer(Iterator first, Iterator last,
56 const TokenizerFunc& f = TokenizerFunc())
57 : first_(first), last_(last), f_(f) { }
59 template <typename Container>
60 tokenizer(const Container& c)
61 : first_(c.begin()), last_(c.end()), f_() { }
63 template <typename Container>
64 tokenizer(const Container& c,const TokenizerFunc& f)
65 : first_(c.begin()), last_(c.end()), f_(f) { }
67 void assign(Iterator first, Iterator last){
72 void assign(Iterator first, Iterator last, const TokenizerFunc& f){
77 template <typename Container>
78 void assign(const Container& c){
79 assign(c.begin(),c.end());
83 template <typename Container>
84 void assign(const Container& c, const TokenizerFunc& f){
85 assign(c.begin(),c.end(),f);
88 iter begin() const { return iter(f_,first_,last_); }
89 iter end() const { return iter(f_,last_,last_); }