A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
string.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */
18
19#include "string.h"
20
27namespace ns3
28{
29
32
34SplitString(const std::string& str, const std::string& delim)
35{
36 std::vector<std::string> result;
37 std::string token;
38 std::size_t pos{0};
39 do
40 {
41 std::size_t next = str.find(delim, pos);
42 std::string token{str.substr(pos, next - pos)};
43 result.push_back(token);
44 if (next < str.size())
45 {
46 pos = next + delim.size();
47 }
48 else
49 {
50 pos = str.size() + 1;
51 }
52 } while (pos <= str.size());
53 return result;
54}
55
56} // namespace ns3
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MaketypeChecker function for class type.
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type, name)
Define the class methods belonging to the attribute value class nameValue of the underlying class typ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< std::string > StringVector
Return type of SplitString.
Definition: string.h:37
StringVector SplitString(const std::string &str, const std::string &delim)
Split a string on a delimiter.
Definition: string.cc:34
ns3::StringValue attribute value declarations.