alternative to std::to_string
Change-Id: Icb80e9c21cad92d2bb35426126ac7554d3c9fd0c refs:#5
This commit is contained in:
1 parent
e7a5b746ef
commit
8e99023187
2 files changed
+59
-58
No files matched your search
+40
-40
@@ -33,6 +33,7 @@
|
||||
#include <ndn-cxx/exclude.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/name-component.hpp>
|
||||
#include <ndn-cxx/util/backports.hpp>
|
||||
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
NdnTrafficClient(const char* programName)
|
||||
: m_programName(programName)
|
||||
, m_logger("NdnTrafficClient")
|
||||
, m_instanceId(std::to_string(std::rand()))
|
||||
, m_instanceId(to_string(std::rand()))
|
||||
, m_hasError(false)
|
||||
, m_hasQuietLogging(false)
|
||||
, m_interestInterval(getDefaultInterestInterval())
|
||||
@@ -96,34 +97,33 @@ public:
|
||||
std::string detail;
|
||||
|
||||
if (m_trafficPercentage > 0)
|
||||
detail += "TrafficPercentage=" + std::to_string(m_trafficPercentage) + ", ";
|
||||
detail += "TrafficPercentage=" + to_string(m_trafficPercentage) + ", ";
|
||||
if (!m_name.empty())
|
||||
detail += "Name=" + m_name + ", ";
|
||||
if (m_nameAppendBytes > 0)
|
||||
detail += "NameAppendBytes=" + std::to_string(m_nameAppendBytes) + ", ";
|
||||
detail += "NameAppendBytes=" + to_string(m_nameAppendBytes) + ", ";
|
||||
if (m_nameAppendSequenceNumber > 0)
|
||||
detail += "NameAppendSequenceNumber=" + std::to_string(m_nameAppendSequenceNumber) + ", ";
|
||||
detail += "NameAppendSequenceNumber=" + to_string(m_nameAppendSequenceNumber) + ", ";
|
||||
if (m_minSuffixComponents >= 0)
|
||||
detail += "MinSuffixComponents=" + std::to_string(m_minSuffixComponents) + ", ";
|
||||
detail += "MinSuffixComponents=" + to_string(m_minSuffixComponents) + ", ";
|
||||
if (m_maxSuffixComponents >= 0)
|
||||
detail += "MaxSuffixComponents=" + std::to_string(m_maxSuffixComponents) + ", ";
|
||||
detail += "MaxSuffixComponents=" + to_string(m_maxSuffixComponents) + ", ";
|
||||
if (!m_excludeBefore.empty())
|
||||
detail += "ExcludeBefore=" + m_excludeBefore + ", ";
|
||||
if (!m_excludeAfter.empty())
|
||||
detail += "ExcludeAfter=" + m_excludeAfter + ", ";
|
||||
if (m_excludeBeforeBytes > 0)
|
||||
detail += "ExcludeBeforeBytes=" + std::to_string(m_excludeBeforeBytes) + ", ";
|
||||
detail += "ExcludeBeforeBytes=" + to_string(m_excludeBeforeBytes) + ", ";
|
||||
if (m_excludeAfterBytes > 0)
|
||||
detail += "ExcludeAfterBytes=" + std::to_string(m_excludeAfterBytes) + ", ";
|
||||
detail += "ExcludeAfterBytes=" + to_string(m_excludeAfterBytes) + ", ";
|
||||
if (m_childSelector >= 0)
|
||||
detail += "ChildSelector=" + std::to_string(m_childSelector) + ", ";
|
||||
detail += "ChildSelector=" + to_string(m_childSelector) + ", ";
|
||||
if (m_mustBeFresh >= 0)
|
||||
detail += "MustBeFresh=" + std::to_string(m_mustBeFresh) + ", ";
|
||||
detail += "MustBeFresh=" + to_string(m_mustBeFresh) + ", ";
|
||||
if (m_nonceDuplicationPercentage > 0)
|
||||
detail += "NonceDuplicationPercentage=" +
|
||||
std::to_string(m_nonceDuplicationPercentage) + ", ";
|
||||
detail += "NonceDuplicationPercentage=" + to_string(m_nonceDuplicationPercentage) + ", ";
|
||||
if (m_interestLifetime >= time::milliseconds(0))
|
||||
detail += "InterestLifetime=" + std::to_string(m_interestLifetime.count()) + ", ";
|
||||
detail += "InterestLifetime=" + to_string(m_interestLifetime.count()) + ", ";
|
||||
if (!m_expectedContent.empty())
|
||||
detail += "ExpectedContent=" + m_expectedContent + ", ";
|
||||
if (detail.length() >= 2)
|
||||
@@ -198,12 +198,12 @@ public:
|
||||
else if (parameter == "ExpectedContent")
|
||||
m_expectedContent = value;
|
||||
else
|
||||
logger.log("Line " + std::to_string(lineNumber) +
|
||||
logger.log("Line " + to_string(lineNumber) +
|
||||
" \t- Invalid Parameter='" + parameter + "'", false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log("Line " + std::to_string(lineNumber) +
|
||||
logger.log("Line " + to_string(lineNumber) +
|
||||
" \t- Improper Traffic Configuration Line- " + detail, false, true);
|
||||
return false;
|
||||
}
|
||||
@@ -322,16 +322,16 @@ public:
|
||||
{
|
||||
m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = " +
|
||||
std::to_string(m_trafficPatterns.size()), false, true);
|
||||
to_string(m_trafficPatterns.size()), false, true);
|
||||
m_logger.log("Total Interests Sent = " +
|
||||
std::to_string(m_nInterestsSent), false, true);
|
||||
to_string(m_nInterestsSent), false, true);
|
||||
m_logger.log("Total Responses Received = " +
|
||||
std::to_string(m_nInterestsReceived), false, true);
|
||||
to_string(m_nInterestsReceived), false, true);
|
||||
|
||||
double loss = 0;
|
||||
if (m_nInterestsSent > 0)
|
||||
loss = (m_nInterestsSent - m_nInterestsReceived) * 100.0 / m_nInterestsSent;
|
||||
m_logger.log("Total Interest Loss = " + std::to_string(loss) + "%", false, true);
|
||||
m_logger.log("Total Interest Loss = " + to_string(loss) + "%", false, true);
|
||||
if (m_nContentInconsistencies != 0 || m_nInterestsSent != m_nInterestsReceived)
|
||||
m_hasError = true;
|
||||
|
||||
@@ -343,21 +343,21 @@ public:
|
||||
inconsistency = m_nContentInconsistencies * 100.0 / m_nInterestsReceived;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = " +
|
||||
std::to_string(inconsistency) + "%", false, true);
|
||||
to_string(inconsistency) + "%", false, true);
|
||||
m_logger.log("Total Round Trip Time = " +
|
||||
std::to_string(m_totalInterestRoundTripTime) + "ms", false, true);
|
||||
to_string(m_totalInterestRoundTripTime) + "ms", false, true);
|
||||
m_logger.log("Average Round Trip Time = " +
|
||||
std::to_string(average) + "ms\n", false, true);
|
||||
to_string(average) + "ms\n", false, true);
|
||||
|
||||
for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
|
||||
{
|
||||
m_logger.log("Traffic Pattern Type #" +
|
||||
std::to_string(patternId + 1), false, true);
|
||||
to_string(patternId + 1), false, true);
|
||||
m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("Total Interests Sent = " +
|
||||
std::to_string(m_trafficPatterns[patternId].m_nInterestsSent), false, true);
|
||||
to_string(m_trafficPatterns[patternId].m_nInterestsSent), false, true);
|
||||
m_logger.log("Total Responses Received = " +
|
||||
std::to_string(m_trafficPatterns[patternId].m_nInterestsReceived), false, true);
|
||||
to_string(m_trafficPatterns[patternId].m_nInterestsReceived), false, true);
|
||||
loss = 0;
|
||||
if (m_trafficPatterns[patternId].m_nInterestsSent > 0)
|
||||
{
|
||||
@@ -366,7 +366,7 @@ public:
|
||||
loss *= 100.0;
|
||||
loss /= m_trafficPatterns[patternId].m_nInterestsSent;
|
||||
}
|
||||
m_logger.log("Total Interest Loss = " + std::to_string(loss) + "%", false, true);
|
||||
m_logger.log("Total Interest Loss = " + to_string(loss) + "%", false, true);
|
||||
average = 0;
|
||||
inconsistency = 0;
|
||||
if (m_trafficPatterns[patternId].m_nInterestsReceived > 0)
|
||||
@@ -377,12 +377,12 @@ public:
|
||||
inconsistency *= 100.0 / m_trafficPatterns[patternId].m_nInterestsReceived;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = " +
|
||||
std::to_string(inconsistency) + "%", false, true);
|
||||
to_string(inconsistency) + "%", false, true);
|
||||
m_logger.log("Total Round Trip Time = " +
|
||||
std::to_string(m_trafficPatterns[patternId].m_totalInterestRoundTripTime) +
|
||||
to_string(m_trafficPatterns[patternId].m_totalInterestRoundTripTime) +
|
||||
"ms", false, true);
|
||||
m_logger.log("Average Round Trip Time = " +
|
||||
std::to_string(average) + "ms\n", false, true);
|
||||
to_string(average) + "ms\n", false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ public:
|
||||
for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
|
||||
{
|
||||
m_logger.log("Traffic Pattern Type #" +
|
||||
std::to_string(patternId + 1), false, false);
|
||||
to_string(patternId + 1), false, false);
|
||||
m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("", false, false);
|
||||
}
|
||||
@@ -527,9 +527,9 @@ public:
|
||||
int patternId,
|
||||
time::steady_clock::TimePoint sentTime)
|
||||
{
|
||||
std::string logLine = "Data Received - PatternType=" + std::to_string(patternId + 1);
|
||||
logLine += ", GlobalID=" + std::to_string(globalReference);
|
||||
logLine += ", LocalID=" + std::to_string(localReference);
|
||||
std::string logLine = "Data Received - PatternType=" + to_string(patternId + 1);
|
||||
logLine += ", GlobalID=" + to_string(globalReference);
|
||||
logLine += ", LocalID=" + to_string(localReference);
|
||||
logLine += ", Name=" + interest.getName().toUri();
|
||||
|
||||
m_nInterestsReceived++;
|
||||
@@ -578,9 +578,9 @@ public:
|
||||
int localReference,
|
||||
int patternId)
|
||||
{
|
||||
std::string logLine = "Interest Timed Out - PatternType=" + std::to_string(patternId + 1);
|
||||
logLine += ", GlobalID=" + std::to_string(globalReference);
|
||||
logLine += ", LocalID=" + std::to_string(localReference);
|
||||
std::string logLine = "Interest Timed Out - PatternType=" + to_string(patternId + 1);
|
||||
logLine += ", GlobalID=" + to_string(globalReference);
|
||||
logLine += ", LocalID=" + to_string(localReference);
|
||||
logLine += ", Name=" + interest.getName().toUri();
|
||||
m_logger.log(logLine, true, false);
|
||||
if (m_nMaximumInterests >= 0 && globalReference == m_nMaximumInterests)
|
||||
@@ -612,7 +612,7 @@ public:
|
||||
if (m_trafficPatterns[patternId].m_nameAppendSequenceNumber >= 0)
|
||||
{
|
||||
interestName.append(
|
||||
std::to_string(m_trafficPatterns[patternId].m_nameAppendSequenceNumber));
|
||||
to_string(m_trafficPatterns[patternId].m_nameAppendSequenceNumber));
|
||||
m_trafficPatterns[patternId].m_nameAppendSequenceNumber++;
|
||||
}
|
||||
|
||||
@@ -708,10 +708,10 @@ public:
|
||||
|
||||
if (!m_hasQuietLogging) {
|
||||
std::string logLine =
|
||||
"Sending Interest - PatternType=" + std::to_string(patternId + 1) +
|
||||
", GlobalID=" + std::to_string(m_nInterestsSent) +
|
||||
"Sending Interest - PatternType=" + to_string(patternId + 1) +
|
||||
", GlobalID=" + to_string(m_nInterestsSent) +
|
||||
", LocalID=" +
|
||||
std::to_string(m_trafficPatterns[patternId].m_nInterestsSent) +
|
||||
to_string(m_trafficPatterns[patternId].m_nInterestsSent) +
|
||||
", Name=" + interest.getName().toUri();
|
||||
m_logger.log(logLine, true, false);
|
||||
}
|
||||
|
||||
+19
-18
@@ -33,6 +33,7 @@
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/backports.hpp>
|
||||
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -51,7 +52,7 @@ public:
|
||||
, m_nMaximumInterests(-1)
|
||||
, m_nInterestsReceived(0)
|
||||
, m_contentDelay(time::milliseconds(-1))
|
||||
, m_instanceId(std::to_string(std::rand()))
|
||||
, m_instanceId(to_string(std::rand()))
|
||||
, m_face(m_ioService)
|
||||
{
|
||||
}
|
||||
@@ -77,17 +78,17 @@ public:
|
||||
if (!m_name.empty())
|
||||
detail += "Name=" + m_name + ", ";
|
||||
if (m_contentType >= 0)
|
||||
detail += "ContentType=" + std::to_string(m_contentType) + ", ";
|
||||
detail += "ContentType=" + to_string(m_contentType) + ", ";
|
||||
if (m_freshnessPeriod >= time::milliseconds(0))
|
||||
detail += "FreshnessPeriod=" +
|
||||
std::to_string(static_cast<int>(m_freshnessPeriod.count())) + ", ";
|
||||
to_string(static_cast<int>(m_freshnessPeriod.count())) + ", ";
|
||||
if (m_contentBytes >= 0)
|
||||
detail += "ContentBytes=" + std::to_string(m_contentBytes) + ", ";
|
||||
detail += "ContentBytes=" + to_string(m_contentBytes) + ", ";
|
||||
if (m_contentDelay >= time::milliseconds(0))
|
||||
detail += "ContentDelay=" + std::to_string(m_contentDelay.count()) + ", ";
|
||||
detail += "ContentDelay=" + to_string(m_contentDelay.count()) + ", ";
|
||||
if (!m_content.empty())
|
||||
detail += "Content=" + m_content + ", ";
|
||||
detail += "SignWithSha256=" + std::to_string(m_signWithSha256) + ", ";
|
||||
detail += "SignWithSha256=" + to_string(m_signWithSha256) + ", ";
|
||||
if (detail.length() >= 2)
|
||||
detail = detail.substr(0, detail.length() - 2);
|
||||
|
||||
@@ -156,17 +157,17 @@ public:
|
||||
m_signWithSha256 = true;
|
||||
}
|
||||
else {
|
||||
logger.log("Line " + std::to_string(lineNumber) +
|
||||
logger.log("Line " + to_string(lineNumber) +
|
||||
" \t- Invalid SignWithSha256 Value='" + value + "'", false, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.log("Line " + std::to_string(lineNumber) +
|
||||
logger.log("Line " + to_string(lineNumber) +
|
||||
" \t- Invalid Parameter='" + parameter + "'", false, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.log("Line " + std::to_string(lineNumber) +
|
||||
logger.log("Line " + to_string(lineNumber) +
|
||||
" \t- Improper Traffic Configuration Line - " + detail, false, true);
|
||||
return false;
|
||||
}
|
||||
@@ -262,18 +263,18 @@ public:
|
||||
{
|
||||
m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = " +
|
||||
std::to_string(m_trafficPatterns.size()), false, true);
|
||||
to_string(m_trafficPatterns.size()), false, true);
|
||||
m_logger.log("Total Interests Received = " +
|
||||
std::to_string(m_nInterestsReceived), false, true);
|
||||
to_string(m_nInterestsReceived), false, true);
|
||||
|
||||
if (m_nInterestsReceived < m_nMaximumInterests)
|
||||
m_hasError = true;
|
||||
|
||||
for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
|
||||
{
|
||||
m_logger.log("\nTraffic Pattern Type #" + std::to_string(patternId + 1), false, true);
|
||||
m_logger.log("\nTraffic Pattern Type #" + to_string(patternId + 1), false, true);
|
||||
m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("Total Interests Received = " + std::to_string(
|
||||
m_logger.log("Total Interests Received = " + to_string(
|
||||
m_trafficPatterns[patternId].m_nInterestsReceived) + "\n", false, true);
|
||||
}
|
||||
}
|
||||
@@ -338,7 +339,7 @@ public:
|
||||
for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++)
|
||||
{
|
||||
m_logger.log("Traffic Pattern Type #" +
|
||||
std::to_string(patternId + 1), false, false);
|
||||
to_string(patternId + 1), false, false);
|
||||
m_trafficPatterns[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("", false, false);
|
||||
}
|
||||
@@ -422,9 +423,9 @@ public:
|
||||
|
||||
if (!m_hasQuietLogging) {
|
||||
std::string logLine =
|
||||
"Interest Received - PatternType=" + std::to_string(patternId + 1) +
|
||||
", GlobalID=" + std::to_string(m_nInterestsReceived) +
|
||||
", LocalID=" + std::to_string(pattern.m_nInterestsReceived) +
|
||||
"Interest Received - PatternType=" + to_string(patternId + 1) +
|
||||
", GlobalID=" + to_string(m_nInterestsReceived) +
|
||||
", LocalID=" + to_string(pattern.m_nInterestsReceived) +
|
||||
", Name=" + pattern.m_name;
|
||||
m_logger.log(logLine, true, false);
|
||||
}
|
||||
@@ -448,7 +449,7 @@ public:
|
||||
onRegisterFailed(const ndn::Name& prefix, const std::string& reason, int patternId)
|
||||
{
|
||||
std::string logLine;
|
||||
logLine += "Prefix Registration Failed - PatternType=" + std::to_string(patternId + 1);
|
||||
logLine += "Prefix Registration Failed - PatternType=" + to_string(patternId + 1);
|
||||
logLine += ", Name=" + m_trafficPatterns[patternId].m_name;
|
||||
m_logger.log(logLine, true, true);
|
||||
|
||||
|
||||
Reference in new issue
Block a user