A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
27
namespace
ns3
28
{
29
30
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(String,
"std::string"
);
31
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(std::string, String);
32
33
StringVector
34
SplitString
(
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
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MaketypeChecker function for class type.
Definition:
attribute-helper.h:380
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type, name)
Define the class methods belonging to the attribute value class nameValue of the underlying class typ...
Definition:
attribute-helper.h:294
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::StringVector
std::vector< std::string > StringVector
Return type of SplitString.
Definition:
string.h:37
ns3::SplitString
StringVector SplitString(const std::string &str, const std::string &delim)
Split a string on a delimiter.
Definition:
string.cc:34
string.h
ns3::StringValue attribute value declarations.
src
core
model
string.cc
Generated on Sun Jul 2 2023 18:21:32 for ns-3 by
1.9.6