36 std::string::size_type n = s.find_first_not_of(
"0123456789.");
37 if (n != std::string::npos)
39 std::istringstream iss;
40 iss.str(s.substr(0, n));
43 std::string trailer = s.substr(n, std::string::npos);
48 *value =
static_cast<uint32_t
>(r);
50 else if (trailer ==
"kB" || trailer ==
"KB")
54 *value =
static_cast<uint32_t
>(r * 1000);
56 else if (trailer ==
"KiB")
60 *value =
static_cast<uint32_t
>(r * 1024);
62 else if (trailer ==
"MB")
66 *value =
static_cast<uint32_t
>(r * 1000000);
68 else if (trailer ==
"MiB")
72 *value =
static_cast<uint32_t
>(r * 1048576);
74 else if (trailer ==
"p")
78 *value =
static_cast<uint32_t
>(r);
80 else if (trailer ==
"kp" || trailer ==
"Kp")
84 *value =
static_cast<uint32_t
>(r * 1000);
86 else if (trailer ==
"Kip")
90 *value =
static_cast<uint32_t
>(r * 1024);
92 else if (trailer ==
"Mp")
96 *value =
static_cast<uint32_t
>(r * 1000000);
98 else if (trailer ==
"Mip")
102 *value =
static_cast<uint32_t
>(r * 1048576);
215 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(ValueClassTest)
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)