source: trunk/include/cppbase/bs_tokenizer.h@ 422

Last change on this file since 422 was 422, checked in by pr, 11 years ago

Add BSTokenizer class.

File size: 2.1 KB
Line 
1
2/*
3 * bs_tokenizer.h:
4 * header file for the BSTokenizer class.
5 *
6 *@@added V1.0.21 (2015-01-29) [pr]
7 *@@include #include "cppbase\bs_base.h"
8 *@@include #include "cppbase\bs_string.h"
9 *@@include #include "cppbase\bs_list.h"
10 */
11
12/*
13 * This file Copyright (C) 2011-2015 Paul Ratcliffe.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, in version 2 as it comes in the COPYING
17 * file of this distribution.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 */
23
24#ifndef WARPIN_TOKENIZER_HEADER_INCLUDED
25 #define WARPIN_TOKENIZER_HEADER_INCLUDED
26
27 #include "cppbase\bs_base.h"
28 #include "cppbase\bs_string.h"
29 #include "cppbase\bs_list.h"
30
31 /*
32 *@@ BSTokenizer:
33 *
34 * Really wanted a vector here, but have to mis-use a list instead as that's
35 * all we have.
36 *
37 */
38
39 class BSTokenizer : public BSRoot
40 {
41 private:
42 list<BSString *> *_pTokens;
43 size_t _size;
44
45 BSTokenizer(const BSTokenizer &);
46 BSTokenizer &operator=(const BSTokenizer &);
47
48 public:
49 DECLARE_CLASS(BSTokenizer);
50
51 static BSString &Dequote(BSString &str);
52
53 BSTokenizer();
54 BSTokenizer(const BSString &str, const BSString &delimiters = " ", BOOL unquote = TRUE);
55 virtual ~BSTokenizer();
56
57 size_t Tokenize(const BSString &str, const BSString &delimiters = " ", BOOL unquote = TRUE);
58 inline size_t Size(void) const { return _size; }
59 inline list<BSString *>::iterator begin() const { return _pTokens->begin(); }
60 inline const list<BSString *>::iterator end() const { return (const list<BSString *>::iterator) NULL; }
61 const char *GetString(size_t num) const;
62 };
63
64#endif
65
Note: See TracBrowser for help on using the repository browser.