35 std::string::size_type n = s.find_first_not_of (
"0123456789.");
36 if (n != std::string::npos)
38 std::istringstream iss;
39 iss.str (s.substr (0, n));
42 std::string trailer = s.substr (n, std::string::npos);
47 *value =
static_cast<uint32_t
>(r);
49 else if (trailer ==
"kB" || trailer ==
"KB")
53 *value =
static_cast<uint32_t
>(r * 1000);
55 else if (trailer ==
"KiB")
59 *value =
static_cast<uint32_t
>(r * 1024);
61 else if (trailer ==
"MB")
65 *value =
static_cast<uint32_t
>(r * 1000000);
67 else if (trailer ==
"MiB")
71 *value =
static_cast<uint32_t
>(r * 1048576);
73 else if (trailer ==
"p")
77 *value =
static_cast<uint32_t
>(r);
79 else if (trailer ==
"kp" || trailer ==
"Kp")
83 *value =
static_cast<uint32_t
>(r * 1000);
85 else if (trailer ==
"Kip")
89 *value =
static_cast<uint32_t
>(r * 1024);
91 else if (trailer ==
"Mp")
95 *value =
static_cast<uint32_t
>(r * 1000000);
97 else if (trailer ==
"Mip")
101 *value =
static_cast<uint32_t
>(r * 1048576);
203 is.setstate (std::ios_base::failbit);
Class for representing queue sizes.
bool operator>(const QueueSize &rhs) const
bool operator<(const QueueSize &rhs) const
bool operator<=(const QueueSize &rhs) const
QueueSizeUnit GetUnit() const
Get the underlying unit.
bool operator!=(const QueueSize &rhs) const
uint32_t m_value
queue size [bytes or packets]
bool operator>=(const QueueSize &rhs) const
bool operator==(const QueueSize &rhs) const
static bool DoParse(const std::string s, QueueSizeUnit *unit, uint32_t *value)
Parse a string representing a QueueSize.
uint32_t GetValue() const
Get the underlying value.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
QueueSizeUnit
Enumeration of the operating modes of queues.
@ BYTES
Use number of bytes for queue size.
@ PACKETS
Use number of packets for queue size.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ATTRIBUTE_HELPER_CPP(Length)
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)