| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Tokenizer.h
Go to the documentation of this file.
1 //==============================================================================
2 // Tokenizer.h
3 //------------------------------------------------------------------------------
4 //
5 // Package : Kernel
6 // The LHCb definition package
7 //
8 // Author : M.Frank
9 //
10 // Changes : M.Frank , 01/10/00: Initialil version
11 //
12 //==============================================================================
13 #ifndef KERNEL_TOKENIZER_H
14 #define KERNEL_TOKENIZER_H
15
17 #include "GaudiKernel/Kernel.h"
18 #include <string>
19 #include <vector>
20
21
24 class GAUDI_API Tokenizer {
25 public:
28 class Token {
30 long m_length;
32 std::string m_tag;
34 std::string m_value;
35 public:
37 Token(const Token& copy) : m_length(copy.m_length), m_tag(copy.m_tag), m_value(copy.m_value) {
38 }
40 Token() : m_length(0) {
41 }
43 void make(const std::string& s, long st, const char* delim, const char* tagBegin, const char* tagEnd, const char* eq, const char* valBegin, const char* valEnd);
45 virtual ~Token() {
46 }
48 Token& operator=(const Token& copy);
49 // Equality operator
50 bool operator==(const Token& copy) const {
51 return m_tag == copy.m_tag && m_value == copy.m_value && m_length == copy.m_length;
52 }
54 long length() const {
55 return m_length;
56 }
58 const std::string& tag() const {
59 return m_tag;
60 }
62 const std::string& value() const {
63 return m_value;
64 }
66 void resolveValue();
67 };
68 typedef Token Item;
69 typedef std::vector<Token> Items;
70 protected:
72 Items m_tokens;
74 bool m_resolve;
75 public:
77 Tokenizer() : m_resolve(false) {}
79 Tokenizer(bool resolve) : m_resolve(resolve) {}
81 virtual ~Tokenizer() {
82 m_tokens.erase(m_tokens.begin(), m_tokens.end());
83 }
85 void analyse(const std::string& s, const char* delim, const char* tagBegin, const char* tagEnd, const char* eq, const char* valBegin, const char* valEnd);
87 void analyse(const std::string& s, const char* delim, const char* tag, const char* eq, const char* val) {
88 analyse(s, delim, tag, tag, eq, val, val);
89 }
91 void analyse(const std::string& s, const char* delim, const char* eq, const char* val) {
92 analyse(s, delim, "", "", eq, val, val);
93 }
95 void analyse(const std::string& s, const char* delim=" ", const char* eq="=") {
96 analyse(s, delim, "", "", eq, "", "");
97 }
99 Items& items() {
100 return m_tokens;
101 }
103 const Items& items() const {
104 return m_tokens;
105 }
106 };
107 #endif // KERNEL_TOKENIZER_H