OMNeT++ Simulation Library  6.0.3
cstringtokenizer.h
1 //==========================================================================
2 // CSTRINGTOKENIZER.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CSTRINGTOKENIZER_H
17 #define __OMNETPP_CSTRINGTOKENIZER_H
18 
19 #include <string>
20 #include <vector>
21 #include "simkerneldefs.h"
22 
23 namespace omnetpp {
24 
25 namespace common {
26 class StringTokenizer;
27 }
28 
80 class SIM_API cStringTokenizer
81 {
82  public:
83  enum Options {
84  NONE = 0,
85  KEEP_EMPTY = 1 << 1,
86  NO_TRIM = 1 << 2,
87  HONOR_QUOTES = 1 << 3,
88  HONOR_PARENS = 1 << 4
89  };
90 
91  private:
92  common::StringTokenizer *impl;
93 
94  cStringTokenizer(const cStringTokenizer&) = delete;
95  void operator=(const cStringTokenizer&) = delete;
96 
97  public:
102  cStringTokenizer(const char *str, const char *sep=" \t\n\r\f") : cStringTokenizer(str, sep, NONE) {}
103 
108  cStringTokenizer(const char *str, const char *delimiters, int options);
109 
113  ~cStringTokenizer();
114 
118  void setDelimiterChars(const char *s);
119 
125  void setQuoteChars(const char *quotes);
126 
132  void setParenthesisChars(const char *parens);
133 
138  bool hasMoreTokens();
139 
145  const char *nextToken();
146 
151  std::vector<std::string> asVector();
152 
157  std::vector<int> asIntVector();
158 
163  std::vector<double> asDoubleVector();
164 };
165 
166 } // namespace omnetpp
167 
168 
169 #endif
170 
omnetpp::cStringTokenizer::cStringTokenizer
cStringTokenizer(const char *str, const char *sep=" \t\n\r\f")
Definition: cstringtokenizer.h:102
omnetpp::cStringTokenizer
String tokenizer that supports quoted strings and nested parenthesis.
Definition: cstringtokenizer.h:80