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
* 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
16
namespace
ns3
17
{
18
19
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
(String,
"std::string"
);
20
ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME
(std::string, String);
21
22
StringVector
23
SplitString
(
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
ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME
#define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name)
Define the MaketypeChecker function for class type .
Definition
attribute-helper.h:370
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:283
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SplitString
StringVector SplitString(const std::string &str, const std::string &delim)
Split a string on a delimiter.
Definition
string.cc:23
ns3::StringVector
std::vector< std::string > StringVector
Return type of SplitString.
Definition
string.h:26
string.h
ns3::StringValue attribute value declarations.
src
core
model
string.cc
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0