OMNeT++ API 6.2.0
Discrete Event Simulation Library
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 
77 class SIM_API cStringTokenizer
78 {
79  public:
80  enum Options {
81  NONE = 0,
82  KEEP_EMPTY = 1 << 1,
83  NO_TRIM = 1 << 2,
84  HONOR_QUOTES = 1 << 3,
85  HONOR_PARENS = 1 << 4
86  };
87 
88  private:
89  common::StringTokenizer *impl;
90 
91  cStringTokenizer(const cStringTokenizer&) = delete;
92  void operator=(const cStringTokenizer&) = delete;
93 
94  public:
99  cStringTokenizer(const char *str, const char *sep=" \t\n\r\f") : cStringTokenizer(str, sep, NONE) {}
100 
105  cStringTokenizer(const char *str, const char *delimiters, int options);
106 
110  ~cStringTokenizer();
111 
115  void setDelimiterChars(const char *s);
116 
122  void setQuoteChars(const char *quotes);
123 
129  void setParenthesisChars(const char *parens);
130 
135  bool hasMoreTokens();
136 
142  const char *nextToken();
143 
148  std::vector<std::string> asVector();
149 
154  std::vector<int> asIntVector();
155 
160  std::vector<double> asDoubleVector();
161 };
162 
163 } // namespace omnetpp
164 
165 
166 #endif
167 
omnetpp::cStringTokenizer::cStringTokenizer
cStringTokenizer(const char *str, const char *sep=" \t\n\r\f")
Definition: cstringtokenizer.h:99
omnetpp::cStringTokenizer
String tokenizer that supports quoted strings and nested parenthesis.
Definition: cstringtokenizer.h:77