OMNeT++ Simulation Library  5.6.1
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 
57 class SIM_API cStringTokenizer
58 {
59  private:
60  char *str; // copy of full string
61  char *rest; // rest of string (to be tokenized)
62  std::string delimiter;
63 
64  private:
65  void copy(const cStringTokenizer& other);
66 
67  public:
73  cStringTokenizer(const char *str, const char *delimiters=nullptr);
74 
79  cStringTokenizer(const cStringTokenizer& other);
80 
85 
90  cStringTokenizer& operator=(const cStringTokenizer& other);
91 
96  void setDelimiter(const char *s);
97 
102  bool hasMoreTokens();
103 
109  const char *nextToken();
110 
115  std::vector<std::string> asVector();
116 
121  std::vector<int> asIntVector();
122 
127  std::vector<double> asDoubleVector();
128 };
129 
130 } // namespace omnetpp
131 
132 
133 #endif
134 
Definition: cabstracthistogram.h:21
String tokenizer class, modelled after strtok().
Definition: cstringtokenizer.h:57