summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/include/Nanorex/Utility/NXStringTokenizer.h
blob: fac0fd03f44a96cc66650702d1fec575168ee480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

#ifndef NX_STRINGTOKENIZER_H
#define NX_STRINGTOKENIZER_H

#ifdef WIN32
#	ifdef _MSC_VER
#		pragma warning(disable:4786)
#	endif
#endif

#include <string>

namespace Nanorex {


/* CLASS: NXStringTokenizer */
/**
 * Breaks delimited strings up into accessible tokens. Here is an example
 * usage:
 * \code
 std::string colors = "red,green,blue";
 nanohive::StringTokenizer tokenizer(colors, ",");
 while (tokenizer.hasMoreTokens())
	std::cout << tokenizer.getNextToken() << std::endl;
 * \endcode
 * This example would print:
 * \code
 red
 green
 blue
 * \endcode
 *
 * @ingroup NanoHiveUtil
 */
class NXStringTokenizer {
	public:
		NXStringTokenizer(const std::string& line,
						const std::string& delimiters = " ");
		std::string getNextToken();
		bool hasMoreTokens();

	private:
		std::string inString, delimiters;
		int inStringLength, position;
};

} // Nanorex::

#endif