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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8#include "string.h"
9
10/**
11 * @file
12 * @ingroup attribute_String
13 * ns3::StringValue attribute value implementation.
14 */
15
16namespace ns3
17{
18
21
23SplitString(const std::string& str, const std::string& delim)
24{
25 std::vector<std::string> result;
26 std::string token;
27 std::size_t pos{0};
28 do
29 {
30 std::size_t next = str.find(delim, pos);
31 std::string token{str.substr(pos, next - pos)};
32 result.push_back(token);
33 if (next < str.size())
34 {
35 pos = next + delim.size();
36 }
37 else
38 {
39 pos = str.size() + 1;
40 }
41 } while (pos <= str.size());
42 return result;
43}
44
45} // 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...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
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:26
StringVector SplitString(const std::string &str, const std::string &delim)
Split a string on a delimiter.
Definition string.cc:23
ns3::StringValue attribute value declarations.