From 7c182618ed2d5102b5ebcc211fb129600b1d96ee Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Mon, 17 Oct 2022 20:35:40 +0000 Subject: [PATCH] Fix clang-tidy readability-redundant-string-cstr warnings --- .../three-gpp-v2v-channel-example.cc | 4 +-- examples/matrix-topology/matrix-topology.cc | 14 +++++----- examples/routing/manet-routing-compare.cc | 14 +++++----- examples/tcp/tcp-linux-reno.cc | 2 +- examples/tcp/tcp-validation.cc | 27 +++++++++--------- examples/tcp/tcp-variants-comparison.cc | 6 ++-- examples/wireless/wifi-multirate.cc | 2 +- .../wifi-power-adaptation-distance.cc | 4 +-- .../wifi-power-adaptation-interference.cc | 24 ++++++++-------- .../wireless/wifi-rate-adaptation-distance.cc | 2 +- examples/wireless/wifi-sleep.cc | 4 +-- examples/wireless/wifi-spatial-reuse.cc | 2 +- src/applications/model/udp-trace-client.cc | 2 +- .../outdoor-group-mobility-example.cc | 2 +- src/config-store/model/raw-text-config.cc | 4 +-- src/core/examples/hash-example.cc | 2 +- src/core/model/ascii-file.cc | 2 +- src/core/model/des-metrics.cc | 2 +- src/core/model/test.cc | 2 +- src/core/test/threaded-test-suite.cc | 2 +- src/dsdv/examples/dsdv-manet.cc | 4 +-- src/dsr/model/dsr-routing.cc | 4 +-- .../helper/emu-fd-net-device-helper.cc | 2 +- .../helper/netmap-net-device-helper.cc | 2 +- src/fd-net-device/model/dpdk-net-device.cc | 4 +-- src/flow-monitor/model/flow-monitor.cc | 2 +- src/lte/examples/lena-distributed-ffr.cc | 4 +-- src/lte/examples/lena-dual-stripe.cc | 6 ++-- src/lte/examples/lena-frequency-reuse.cc | 4 +-- src/lte/examples/lena-radio-link-failure.cc | 4 +-- src/lte/helper/mac-stats-calculator.cc | 12 ++++---- src/lte/helper/phy-rx-stats-calculator.cc | 12 ++++---- src/lte/helper/phy-stats-calculator.cc | 18 ++++++------ src/lte/helper/phy-tx-stats-calculator.cc | 12 ++++---- .../helper/radio-bearer-stats-calculator.cc | 22 +++++++-------- src/lte/test/lte-test-carrier-aggregation.cc | 4 +-- src/mobility/examples/ns2-mobility-trace.cc | 2 +- src/mobility/helper/ns2-mobility-helper.cc | 8 +++--- .../test/ns2-mobility-helper-test-suite.cc | 2 +- .../examples/colors-link-description.cc | 2 +- src/netanim/examples/dumbbell-animation.cc | 2 +- src/netanim/examples/resources-counters.cc | 2 +- src/netanim/model/animation-interface.cc | 27 +++++++++--------- src/network/model/address.cc | 10 +++---- src/network/utils/mac16-address.cc | 4 +-- src/network/utils/mac48-address.cc | 4 +-- src/network/utils/mac64-address.cc | 4 +-- src/network/utils/output-stream-wrapper.cc | 2 +- src/network/utils/pcap-file.cc | 2 +- src/openflow/examples/openflow-switch.cc | 2 +- src/spectrum/model/trace-fading-loss-model.cc | 2 +- src/stats/examples/gnuplot-example.cc | 6 ++-- src/stats/model/file-aggregator.cc | 2 +- src/stats/model/gnuplot-aggregator.cc | 6 ++-- src/stats/model/omnet-data-output.cc | 2 +- .../model/inet-topology-reader.cc | 2 +- .../model/orbis-topology-reader.cc | 2 +- .../model/rocketfuel-topology-reader.cc | 2 +- .../examples/adaptive-red-tests.cc | 5 ++-- .../examples/fqcodel-l4s-example.cc | 28 +++++++++---------- src/traffic-control/examples/pie-example.cc | 5 ++-- src/traffic-control/examples/red-tests.cc | 4 +-- src/uan/examples/uan-cw-example.cc | 4 +-- src/uan/examples/uan-rc-example.cc | 2 +- src/visualizer/model/pyviz.cc | 10 +++---- src/wave/examples/vanet-routing-compare.cc | 10 +++---- src/wifi/examples/wifi-bianchi.cc | 12 ++++---- src/wifi/examples/wifi-manager-example.cc | 2 +- src/wifi/helper/athstats-helper.cc | 5 ++-- .../rate-control/minstrel-ht-wifi-manager.cc | 2 +- .../rate-control/minstrel-wifi-manager.cc | 2 +- src/wifi/test/inter-bss-test-suite.cc | 2 +- .../model/snr-to-block-error-rate-manager.cc | 4 +-- utils/bench-scheduler.cc | 2 +- 74 files changed, 215 insertions(+), 220 deletions(-) diff --git a/examples/channel-models/three-gpp-v2v-channel-example.cc b/examples/channel-models/three-gpp-v2v-channel-example.cc index 59bb959cc..346a69327 100644 --- a/examples/channel-models/three-gpp-v2v-channel-example.cc +++ b/examples/channel-models/three-gpp-v2v-channel-example.cc @@ -146,7 +146,7 @@ ComputeSnr(const ComputeSnrParams& params) } /** - * Generates a GNU-plottable file representig the buildings deployed in the + * Generates a GNU-plottable file representing the buildings deployed in the * scenario * \param filename the name of the output file */ @@ -154,7 +154,7 @@ void PrintGnuplottableBuildingListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/examples/matrix-topology/matrix-topology.cc b/examples/matrix-topology/matrix-topology.cc index 7f3a7291c..6d050123c 100644 --- a/examples/matrix-topology/matrix-topology.cc +++ b/examples/matrix-topology/matrix-topology.cc @@ -272,11 +272,11 @@ main(int argc, char* argv[]) AsciiTraceHelper ascii; p2p.EnableAsciiAll(ascii.CreateFileStream(tr_name)); - // p2p.EnablePcapAll (pcap_name.c_str()); + // p2p.EnablePcapAll(pcap_name); // Ptr flowmon; // FlowMonitorHelper flowmonHelper; - // flowmon = flowmonHelper.InstallAll (); + // flowmon = flowmonHelper.InstallAll(); // Configure animator with default settings @@ -285,7 +285,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(SimTime)); Simulator::Run(); - // flowmon->SerializeToXmlFile (flow_name.c_str(), true, true); + // flowmon->SerializeToXmlFile(flow_name, true, true); Simulator::Destroy(); // ---------- End of Simulation Monitoring --------------------------------- @@ -299,10 +299,10 @@ std::vector> readNxNMatrix(std::string adj_mat_file_name) { std::ifstream adj_mat_file; - adj_mat_file.open(adj_mat_file_name.c_str(), std::ios::in); + adj_mat_file.open(adj_mat_file_name, std::ios::in); if (adj_mat_file.fail()) { - NS_FATAL_ERROR("File " << adj_mat_file_name.c_str() << " not found"); + NS_FATAL_ERROR("File " << adj_mat_file_name << " not found"); } std::vector> array; int i = 0; @@ -364,10 +364,10 @@ std::vector> readCordinatesFile(std::string node_coordinates_file_name) { std::ifstream node_coordinates_file; - node_coordinates_file.open(node_coordinates_file_name.c_str(), std::ios::in); + node_coordinates_file.open(node_coordinates_file_name, std::ios::in); if (node_coordinates_file.fail()) { - NS_FATAL_ERROR("File " << node_coordinates_file_name.c_str() << " not found"); + NS_FATAL_ERROR("File " << node_coordinates_file_name << " not found"); } std::vector> coord_array; int m = 0; diff --git a/examples/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc index 490aa8fc0..bac711faf 100644 --- a/examples/routing/manet-routing-compare.cc +++ b/examples/routing/manet-routing-compare.cc @@ -187,7 +187,7 @@ RoutingExperiment::CheckThroughput() double kbs = (bytesTotal * 8.0) / 1000; bytesTotal = 0; - std::ofstream out(m_CSVfileName.c_str(), std::ios::app); + std::ofstream out(m_CSVfileName, std::ios::app); out << (Simulator::Now()).GetSeconds() << "," << kbs << "," << packetsReceived << "," << m_nSinks << "," << m_protocolName << "," << m_txp << "" << std::endl; @@ -227,7 +227,7 @@ main(int argc, char* argv[]) std::string CSVfileName = experiment.CommandSetup(argc, argv); // blank out the last output file and write the column headers - std::ofstream out(CSVfileName.c_str()); + std::ofstream out(CSVfileName); out << "SimulationSecond," << "ReceiveRate," << "PacketsReceived," @@ -401,19 +401,19 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) ss4 << rate; std::string sRate = ss4.str(); - // NS_LOG_INFO ("Configure Tracing."); + // NS_LOG_INFO("Configure Tracing."); // tr_name = tr_name + "_" + m_protocolName +"_" + nodes + "nodes_" + sNodeSpeed + "speed_" + // sNodePause + "pause_" + sRate + "rate"; // AsciiTraceHelper ascii; - // Ptr osw = ascii.CreateFileStream ( (tr_name + ".tr").c_str()); - // wifiPhy.EnableAsciiAll (osw); + // Ptr osw = ascii.CreateFileStream(tr_name + ".tr"); + // wifiPhy.EnableAsciiAll(osw); AsciiTraceHelper ascii; MobilityHelper::EnableAsciiAll(ascii.CreateFileStream(tr_name + ".mob")); // Ptr flowmon; // FlowMonitorHelper flowmonHelper; - // flowmon = flowmonHelper.InstallAll (); + // flowmon = flowmonHelper.InstallAll(); NS_LOG_INFO("Run Simulation."); @@ -422,7 +422,7 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) Simulator::Stop(Seconds(TotalTime)); Simulator::Run(); - // flowmon->SerializeToXmlFile ((tr_name + ".flowmon").c_str(), false, false); + // flowmon->SerializeToXmlFile(tr_name + ".flowmon", false, false); Simulator::Destroy(); } diff --git a/examples/tcp/tcp-linux-reno.cc b/examples/tcp/tcp-linux-reno.cc index 163d361bc..e617b6aee 100644 --- a/examples/tcp/tcp-linux-reno.cc +++ b/examples/tcp/tcp-linux-reno.cc @@ -60,7 +60,7 @@ CheckQueueSize(Ptr queue) // Check queue size every 1/100 of a second Simulator::Schedule(Seconds(0.001), &CheckQueueSize, queue); - std::ofstream fPlotQueue(std::stringstream(dir + "queue-size.dat").str().c_str(), + std::ofstream fPlotQueue(std::stringstream(dir + "queue-size.dat").str(), std::ios::out | std::ios::app); fPlotQueue << Simulator::Now().GetSeconds() << " " << qSize << std::endl; fPlotQueue.close(); diff --git a/examples/tcp/tcp-validation.cc b/examples/tcp/tcp-validation.cc index ef95a75d4..6c71e3751 100644 --- a/examples/tcp/tcp-validation.cc +++ b/examples/tcp/tcp-validation.cc @@ -843,29 +843,28 @@ main(int argc, char* argv[]) std::ofstream queueLengthOfStream; if (g_validate == "") { - pingOfStream.open(pingTraceFile.c_str(), std::ofstream::out); - firstTcpRttOfStream.open(firstTcpRttTraceFile.c_str(), std::ofstream::out); - firstTcpCwndOfStream.open(firstTcpCwndTraceFile.c_str(), std::ofstream::out); - firstTcpThroughputOfStream.open(firstTcpThroughputTraceFile.c_str(), std::ofstream::out); + pingOfStream.open(pingTraceFile, std::ofstream::out); + firstTcpRttOfStream.open(firstTcpRttTraceFile, std::ofstream::out); + firstTcpCwndOfStream.open(firstTcpCwndTraceFile, std::ofstream::out); + firstTcpThroughputOfStream.open(firstTcpThroughputTraceFile, std::ofstream::out); if (firstTcpType == "dctcp") { - firstTcpDctcpOfStream.open(firstDctcpTraceFile.c_str(), std::ofstream::out); + firstTcpDctcpOfStream.open(firstDctcpTraceFile, std::ofstream::out); } if (enableSecondTcp) { - secondTcpRttOfStream.open(secondTcpRttTraceFile.c_str(), std::ofstream::out); - secondTcpCwndOfStream.open(secondTcpCwndTraceFile.c_str(), std::ofstream::out); - secondTcpThroughputOfStream.open(secondTcpThroughputTraceFile.c_str(), - std::ofstream::out); + secondTcpRttOfStream.open(secondTcpRttTraceFile, std::ofstream::out); + secondTcpCwndOfStream.open(secondTcpCwndTraceFile, std::ofstream::out); + secondTcpThroughputOfStream.open(secondTcpThroughputTraceFile, std::ofstream::out); if (secondTcpType == "dctcp") { - secondTcpDctcpOfStream.open(secondDctcpTraceFile.c_str(), std::ofstream::out); + secondTcpDctcpOfStream.open(secondDctcpTraceFile, std::ofstream::out); } } - queueDropOfStream.open(queueDropTraceFile.c_str(), std::ofstream::out); - queueMarkOfStream.open(queueMarkTraceFile.c_str(), std::ofstream::out); - queueMarksFrequencyOfStream.open(queueMarksFrequencyTraceFile.c_str(), std::ofstream::out); - queueLengthOfStream.open(queueLengthTraceFile.c_str(), std::ofstream::out); + queueDropOfStream.open(queueDropTraceFile, std::ofstream::out); + queueMarkOfStream.open(queueMarkTraceFile, std::ofstream::out); + queueMarksFrequencyOfStream.open(queueMarksFrequencyTraceFile, std::ofstream::out); + queueLengthOfStream.open(queueLengthTraceFile, std::ofstream::out); } //////////////////////////////////////////////////////////// diff --git a/examples/tcp/tcp-variants-comparison.cc b/examples/tcp/tcp-variants-comparison.cc index 2ed1f78fa..e987a7b08 100644 --- a/examples/tcp/tcp-variants-comparison.cc +++ b/examples/tcp/tcp-variants-comparison.cc @@ -28,7 +28,7 @@ * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), * US Department of Defense (DoD), and ITTC at The University of Kansas. * - * “TCP Westwood(+) Protocol Implementation in ns-3” + * "TCP Westwood(+) Protocol Implementation in ns-3" * Siddharth Gangadhar, Trúc Anh Ngọc Nguyễn , Greeshma Umapathi, and James P.G. Sterbenz, * ICST SIMUTools Workshop on ns-3 (WNS3), Cannes, France, March 2013 */ @@ -552,13 +552,13 @@ main(int argc, char* argv[]) { std::ofstream ascii; Ptr ascii_wrap; - ascii.open((prefix_file_name + "-ascii").c_str()); + ascii.open(prefix_file_name + "-ascii"); ascii_wrap = new OutputStreamWrapper(prefix_file_name + "-ascii", std::ios::out); stack.EnableAsciiIpv4All(ascii_wrap); for (uint16_t index = 0; index < num_flows; index++) { - std::string flowString(""); + std::string flowString; if (num_flows > 1) { flowString = "-flow" + std::to_string(index); diff --git a/examples/wireless/wifi-multirate.cc b/examples/wireless/wifi-multirate.cc index a293954ec..b68a26035 100644 --- a/examples/wireless/wifi-multirate.cc +++ b/examples/wireless/wifi-multirate.cc @@ -701,7 +701,7 @@ main(int argc, char* argv[]) // for commandline input experiment.CommandSetup(argc, argv); - std::ofstream outfile((experiment.GetOutputFileName() + ".plt").c_str()); + std::ofstream outfile(experiment.GetOutputFileName() + ".plt"); MobilityHelper mobility; Gnuplot gnuplot; diff --git a/examples/wireless/wifi-power-adaptation-distance.cc b/examples/wireless/wifi-power-adaptation-distance.cc index ea74ac7ab..08e28624f 100644 --- a/examples/wireless/wifi-power-adaptation-distance.cc +++ b/examples/wireless/wifi-power-adaptation-distance.cc @@ -558,7 +558,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(simuTime)); Simulator::Run(); - std::ofstream outfile(("throughput-" + outputFileName + ".plt").c_str()); + std::ofstream outfile("throughput-" + outputFileName + ".plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -569,7 +569,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfile2(("power-" + outputFileName + ".plt").c_str()); + std::ofstream outfile2("power-" + outputFileName + ".plt"); gnuplot = Gnuplot("power-" + outputFileName + ".eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); diff --git a/examples/wireless/wifi-power-adaptation-interference.cc b/examples/wireless/wifi-power-adaptation-interference.cc index f6142e6ac..b7a8a5baf 100644 --- a/examples/wireless/wifi-power-adaptation-interference.cc +++ b/examples/wireless/wifi-power-adaptation-interference.cc @@ -711,7 +711,7 @@ main(int argc, char* argv[]) } // Plots for AP0 - std::ofstream outfileTh0(("throughput-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileTh0("throughput-" + outputFileName + "-0.plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + "-0.eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -722,7 +722,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfilePower0(("power-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfilePower0("power-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("power-" + outputFileName + "-0.eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); @@ -731,7 +731,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfilePower0); } - std::ofstream outfileTx0(("tx-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileTx0("tx-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("tx-" + outputFileName + "-0.eps", "Time in TX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -739,7 +739,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetTxDatafile()); gnuplot.GenerateOutput(outfileTx0); - std::ofstream outfileRx0(("rx-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileRx0("rx-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("rx-" + outputFileName + "-0.eps", "Time in RX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -747,7 +747,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetRxDatafile()); gnuplot.GenerateOutput(outfileRx0); - std::ofstream outfileBusy0(("busy-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileBusy0("busy-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("busy-" + outputFileName + "-0.eps", "Time in Busy State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -755,7 +755,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetBusyDatafile()); gnuplot.GenerateOutput(outfileBusy0); - std::ofstream outfileIdle0(("idle-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileIdle0("idle-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("idle-" + outputFileName + "-0.eps", "Time in Idle State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -764,7 +764,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfileIdle0); // Plots for AP1 - std::ofstream outfileTh1(("throughput-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileTh1("throughput-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("throughput-" + outputFileName + "-1.eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -775,7 +775,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfilePower1(("power-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfilePower1("power-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("power-" + outputFileName + "-1.eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); @@ -784,7 +784,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfilePower1); } - std::ofstream outfileTx1(("tx-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileTx1("tx-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("tx-" + outputFileName + "-1.eps", "Time in TX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -792,7 +792,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetTxDatafile()); gnuplot.GenerateOutput(outfileTx1); - std::ofstream outfileRx1(("rx-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileRx1("rx-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("rx-" + outputFileName + "-1.eps", "Time in RX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -800,7 +800,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetRxDatafile()); gnuplot.GenerateOutput(outfileRx1); - std::ofstream outfileBusy1(("busy-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileBusy1("busy-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("busy-" + outputFileName + "-1.eps", "Time in Busy State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -808,7 +808,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetBusyDatafile()); gnuplot.GenerateOutput(outfileBusy1); - std::ofstream outfileIdle1(("idle-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileIdle1("idle-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("idle-" + outputFileName + "-1.eps", "Time in Idle State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); diff --git a/examples/wireless/wifi-rate-adaptation-distance.cc b/examples/wireless/wifi-rate-adaptation-distance.cc index 41547f88e..14d2eef4e 100644 --- a/examples/wireless/wifi-rate-adaptation-distance.cc +++ b/examples/wireless/wifi-rate-adaptation-distance.cc @@ -366,7 +366,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(simuTime)); Simulator::Run(); - std::ofstream outfile(("throughput-" + outputFileName + ".plt").c_str()); + std::ofstream outfile("throughput-" + outputFileName + ".plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); diff --git a/examples/wireless/wifi-sleep.cc b/examples/wireless/wifi-sleep.cc index 0d1593d91..cc3a5260e 100644 --- a/examples/wireless/wifi-sleep.cc +++ b/examples/wireless/wifi-sleep.cc @@ -79,7 +79,7 @@ RemainingEnergyTrace(double oldValue, double newValue) std::stringstream ss; ss << "energy_" << node << ".log"; - static std::fstream f(ss.str().c_str(), std::ios::out); + static std::fstream f(ss.str(), std::ios::out); f << Simulator::Now().GetSeconds() << " remaining energy=" << newValue << std::endl; } @@ -100,7 +100,7 @@ PhyStateTrace(std::string context, Time start, Time duration, WifiPhyState state std::stringstream ss; ss << "state_" << node << ".log"; - static std::fstream f(ss.str().c_str(), std::ios::out); + static std::fstream f(ss.str(), std::ios::out); f << Simulator::Now().GetSeconds() << " state=" << state << " start=" << start << " duration=" << duration << std::endl; diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index d5ee7ca70..9bd4ad4a5 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -108,7 +108,7 @@ ContextToNodeId(std::string context) { std::string sub = context.substr(10); uint32_t pos = sub.find("/Device"); - return atoi(sub.substr(0, pos).c_str()); + return std::stoi(sub.substr(0, pos)); } void diff --git a/src/applications/model/udp-trace-client.cc b/src/applications/model/udp-trace-client.cc index 4c378fa7c..b45180dd2 100644 --- a/src/applications/model/udp-trace-client.cc +++ b/src/applications/model/udp-trace-client.cc @@ -192,7 +192,7 @@ UdpTraceClient::LoadTrace(std::string filename) char frameType; TraceEntry entry; std::ifstream ifTraceFile; - ifTraceFile.open(filename.c_str(), std::ifstream::in); + ifTraceFile.open(filename, std::ifstream::in); m_entries.clear(); if (!ifTraceFile.good()) { diff --git a/src/buildings/examples/outdoor-group-mobility-example.cc b/src/buildings/examples/outdoor-group-mobility-example.cc index 2847f1385..fa3b81b28 100644 --- a/src/buildings/examples/outdoor-group-mobility-example.cc +++ b/src/buildings/examples/outdoor-group-mobility-example.cc @@ -104,7 +104,7 @@ void PrintGnuplottableBuildingListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 556edab1f..4c8d90ca6 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -59,7 +59,7 @@ RawTextConfigSave::SetFilename(std::string filename) { NS_LOG_FUNCTION(this << filename); m_os = new std::ofstream(); - m_os->open(filename.c_str(), std::ios::out); + m_os->open(filename, std::ios::out); } void @@ -226,7 +226,7 @@ RawTextConfigLoad::SetFilename(std::string filename) { NS_LOG_FUNCTION(this << filename); m_is = new std::ifstream(); - m_is->open(filename.c_str(), std::ios::in); + m_is->open(filename, std::ios::in); } std::string diff --git a/src/core/examples/hash-example.cc b/src/core/examples/hash-example.cc index 975d4abf2..c3a3420e5 100644 --- a/src/core/examples/hash-example.cc +++ b/src/core/examples/hash-example.cc @@ -475,7 +475,7 @@ class DictFiles // Open the file std::ifstream dictStream; - dictStream.open(dictFile.c_str()); + dictStream.open(dictFile); if (!dictStream.is_open()) { std::cerr << "Failed to open dictionary file." diff --git a/src/core/model/ascii-file.cc b/src/core/model/ascii-file.cc index eb4ddc5d7..98d4e813b 100644 --- a/src/core/model/ascii-file.cc +++ b/src/core/model/ascii-file.cc @@ -71,7 +71,7 @@ AsciiFile::Open(const std::string& filename, std::ios::openmode mode) NS_ASSERT((mode & std::ios::app) == 0); NS_ASSERT(!m_file.fail()); - m_file.open(filename.c_str(), mode); + m_file.open(filename, mode); } void diff --git a/src/core/model/des-metrics.cc b/src/core/model/des-metrics.cc index f06f7ed1e..2d54743d3 100644 --- a/src/core/model/des-metrics.cc +++ b/src/core/model/des-metrics.cc @@ -70,7 +70,7 @@ DesMetrics::Initialize(std::vector args, std::string outDir /* = "" const char* date = ctime(¤t_time); std::string capture_date(date, 24); // discard trailing newline from ctime - m_os.open(jsonFile.c_str()); + m_os.open(jsonFile); m_os << "{" << std::endl; m_os << " \"simulator_name\" : \"ns-3\"," << std::endl; m_os << " \"model_name\" : \"" << model_name << "\"," << std::endl; diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 4f3ec1307..b2392a904 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -1073,7 +1073,7 @@ TestRunnerImpl::Run(int argc, char* argv[]) { mode |= std::ios_base::trunc; } - ofs->open(out.c_str(), mode); + ofs->open(out, mode); os = ofs; } else diff --git a/src/core/test/threaded-test-suite.cc b/src/core/test/threaded-test-suite.cc index 1b2e1fa2d..4a5e45383 100644 --- a/src/core/test/threaded-test-suite.cc +++ b/src/core/test/threaded-test-suite.cc @@ -272,7 +272,7 @@ ThreadedSimulatorEventsTestCase::DoRun() Simulator::Run(); Simulator::Destroy(); - NS_TEST_EXPECT_MSG_EQ(m_error.empty(), true, m_error.c_str()); + NS_TEST_EXPECT_MSG_EQ(m_error.empty(), true, m_error); NS_TEST_EXPECT_MSG_EQ(m_a, m_b, "Bad scheduling"); NS_TEST_EXPECT_MSG_EQ(m_a, m_c, "Bad scheduling"); NS_TEST_EXPECT_MSG_EQ(m_a, m_d, "Bad scheduling"); diff --git a/src/dsdv/examples/dsdv-manet.cc b/src/dsdv/examples/dsdv-manet.cc index e20f102c7..cff66e7ac 100644 --- a/src/dsdv/examples/dsdv-manet.cc +++ b/src/dsdv/examples/dsdv-manet.cc @@ -176,7 +176,7 @@ main(int argc, char** argv) CSVfileName); cmd.Parse(argc, argv); - std::ofstream out(CSVfileName.c_str()); + std::ofstream out(CSVfileName); out << "SimulationSecond," << "ReceiveRate," << "PacketsReceived," @@ -230,7 +230,7 @@ DsdvManetExample::CheckThroughput() double kbs = (bytesTotal * 8.0) / 1000; bytesTotal = 0; - std::ofstream out(m_CSVfileName.c_str(), std::ios::app); + std::ofstream out(m_CSVfileName, std::ios::app); out << (Simulator::Now()).GetSeconds() << "," << kbs << "," << packetsReceived << "," << m_nSinks << std::endl; diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index d0183cfdb..4ec41cba5 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -540,9 +540,9 @@ DsrRouting::GetNetDeviceFromContext(std::string context) // where element [1] is the Node Id // element [2] is the NetDevice Id std::vector elements = GetElementsFromContext(context); - Ptr n = NodeList::GetNode(atoi(elements[1].c_str())); + Ptr n = NodeList::GetNode(std::stoi(elements[1])); NS_ASSERT(n); - return n->GetDevice(atoi(elements[3].c_str())); + return n->GetDevice(std::stoi(elements[3])); } std::vector diff --git a/src/fd-net-device/helper/emu-fd-net-device-helper.cc b/src/fd-net-device/helper/emu-fd-net-device-helper.cc index ee9edf09d..763bb9935 100644 --- a/src/fd-net-device/helper/emu-fd-net-device-helper.cc +++ b/src/fd-net-device/helper/emu-fd-net-device-helper.cc @@ -181,7 +181,7 @@ EmuFdNetDeviceHelper::SetFileDescriptor(Ptr device) const if ((ifr.ifr_flags & IFF_PROMISC) == 0) { NS_FATAL_ERROR("EmuFdNetDeviceHelper::SetFileDescriptor (): " - << m_deviceName.c_str() << " is not in promiscuous mode"); + << m_deviceName << " is not in promiscuous mode"); } if ((ifr.ifr_flags & IFF_BROADCAST) != IFF_BROADCAST) diff --git a/src/fd-net-device/helper/netmap-net-device-helper.cc b/src/fd-net-device/helper/netmap-net-device-helper.cc index 71e4ceabe..c68c6ce0d 100644 --- a/src/fd-net-device/helper/netmap-net-device-helper.cc +++ b/src/fd-net-device/helper/netmap-net-device-helper.cc @@ -154,7 +154,7 @@ NetmapNetDeviceHelper::SetDeviceAttributes(Ptr device) const if ((ifr.ifr_flags & IFF_PROMISC) == 0) { NS_FATAL_ERROR("NetmapNetDeviceHelper::SetFileDescriptor (): " - << m_deviceName.c_str() + << m_deviceName << " is not in promiscuous mode. Please config the interface in promiscuous " "mode before to run the simulation."); } diff --git a/src/fd-net-device/model/dpdk-net-device.cc b/src/fd-net-device/model/dpdk-net-device.cc index 07b1449d2..4d895bfd3 100644 --- a/src/fd-net-device/model/dpdk-net-device.cc +++ b/src/fd-net-device/model/dpdk-net-device.cc @@ -256,9 +256,9 @@ DpdkNetDevice::InitDpdk(int argc, char** argv, std::string dpdkDriver) std::string command; command.append("dpdk-devbind.py --force "); command.append("--bind="); - command.append(dpdkDriver.c_str()); + command.append(dpdkDriver); command.append(" "); - command.append(m_deviceName.c_str()); + command.append(m_deviceName); printf("Executing: %s\n", command.c_str()); if (system(command.c_str())) { diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 60212da59..fd6b3a693 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -528,7 +528,7 @@ void FlowMonitor::SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes) { NS_LOG_FUNCTION(this << fileName << enableHistograms << enableProbes); - std::ofstream os(fileName.c_str(), std::ios::out | std::ios::binary); + std::ofstream os(fileName, std::ios::out | std::ios::binary); os << "\n"; SerializeToXmlStream(os, 0, enableHistograms, enableProbes); os.close(); diff --git a/src/lte/examples/lena-distributed-ffr.cc b/src/lte/examples/lena-distributed-ffr.cc index 8a4482641..599911000 100644 --- a/src/lte/examples/lena-distributed-ffr.cc +++ b/src/lte/examples/lena-distributed-ffr.cc @@ -39,7 +39,7 @@ void PrintGnuplottableUeListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); @@ -68,7 +68,7 @@ void PrintGnuplottableEnbListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc index 57515d141..4ca1c4b0b 100644 --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -177,7 +177,7 @@ void PrintGnuplottableBuildingListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); @@ -202,7 +202,7 @@ void PrintGnuplottableUeListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); @@ -236,7 +236,7 @@ void PrintGnuplottableEnbListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/src/lte/examples/lena-frequency-reuse.cc b/src/lte/examples/lena-frequency-reuse.cc index eb1d4b62c..ef8cc7772 100644 --- a/src/lte/examples/lena-frequency-reuse.cc +++ b/src/lte/examples/lena-frequency-reuse.cc @@ -35,7 +35,7 @@ void PrintGnuplottableUeListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); @@ -64,7 +64,7 @@ void PrintGnuplottableEnbListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/src/lte/examples/lena-radio-link-failure.cc b/src/lte/examples/lena-radio-link-failure.cc index ade7ddc3a..49dfbad74 100644 --- a/src/lte/examples/lena-radio-link-failure.cc +++ b/src/lte/examples/lena-radio-link-failure.cc @@ -318,12 +318,12 @@ Throughput(bool firstWrite, Time binSize, std::string fileName) if (firstWrite == true) { - output.open(fileName.c_str(), std::ofstream::out); + output.open(fileName, std::ofstream::out); firstWrite = false; } else { - output.open(fileName.c_str(), std::ofstream::app); + output.open(fileName, std::ofstream::app); } // Instantaneous throughput every 200 ms diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index 4c61c850c..0339fc16f 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -108,14 +108,14 @@ MacStatsCalculator::DlScheduling(uint16_t cellId, << dlSchedulingCallbackInfo.subframeNo << dlSchedulingCallbackInfo.rnti << (uint32_t)dlSchedulingCallbackInfo.mcsTb1 << dlSchedulingCallbackInfo.sizeTb1 << (uint32_t)dlSchedulingCallbackInfo.mcsTb2 << dlSchedulingCallbackInfo.sizeTb2); - NS_LOG_INFO("Write DL Mac Stats in " << GetDlOutputFilename().c_str()); + NS_LOG_INFO("Write DL Mac Stats in " << GetDlOutputFilename()); if (m_dlFirstWrite == true) { - m_dlOutFile.open(GetDlOutputFilename().c_str()); + m_dlOutFile.open(GetDlOutputFilename()); if (!m_dlOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetDlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetDlOutputFilename()); return; } m_dlFirstWrite = false; @@ -149,14 +149,14 @@ MacStatsCalculator::UlScheduling(uint16_t cellId, { NS_LOG_FUNCTION(this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t)mcsTb << size); - NS_LOG_INFO("Write UL Mac Stats in " << GetUlOutputFilename().c_str()); + NS_LOG_INFO("Write UL Mac Stats in " << GetUlOutputFilename()); if (m_ulFirstWrite == true) { - m_ulOutFile.open(GetUlOutputFilename().c_str()); + m_ulOutFile.open(GetUlOutputFilename()); if (!m_ulOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUlOutputFilename()); return; } m_ulFirstWrite = false; diff --git a/src/lte/helper/phy-rx-stats-calculator.cc b/src/lte/helper/phy-rx-stats-calculator.cc index 74f11f716..447edb8be 100644 --- a/src/lte/helper/phy-rx-stats-calculator.cc +++ b/src/lte/helper/phy-rx-stats-calculator.cc @@ -104,14 +104,14 @@ PhyRxStatsCalculator::DlPhyReception(PhyReceptionStatParameters params) NS_LOG_FUNCTION(this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness); - NS_LOG_INFO("Write DL Rx Phy Stats in " << GetDlRxOutputFilename().c_str()); + NS_LOG_INFO("Write DL Rx Phy Stats in " << GetDlRxOutputFilename()); if (m_dlRxFirstWrite == true) { - m_dlRxOutFile.open(GetDlRxOutputFilename().c_str()); + m_dlRxOutFile.open(GetDlRxOutputFilename()); if (!m_dlRxOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetDlRxOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetDlRxOutputFilename()); return; } m_dlRxFirstWrite = false; @@ -140,14 +140,14 @@ PhyRxStatsCalculator::UlPhyReception(PhyReceptionStatParameters params) NS_LOG_FUNCTION(this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness); - NS_LOG_INFO("Write UL Rx Phy Stats in " << GetUlRxOutputFilename().c_str()); + NS_LOG_INFO("Write UL Rx Phy Stats in " << GetUlRxOutputFilename()); if (m_ulRxFirstWrite == true) { - m_ulRxOutFile.open(GetUlRxOutputFilename().c_str()); + m_ulRxOutFile.open(GetUlRxOutputFilename()); if (!m_ulRxOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUlRxOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUlRxOutputFilename()); return; } m_ulRxFirstWrite = false; diff --git a/src/lte/helper/phy-stats-calculator.cc b/src/lte/helper/phy-stats-calculator.cc index 94b5f4ee7..ffa07a31d 100644 --- a/src/lte/helper/phy-stats-calculator.cc +++ b/src/lte/helper/phy-stats-calculator.cc @@ -130,14 +130,14 @@ PhyStatsCalculator::ReportCurrentCellRsrpSinr(uint16_t cellId, uint8_t componentCarrierId) { NS_LOG_FUNCTION(this << cellId << imsi << rnti << rsrp << sinr); - NS_LOG_INFO("Write RSRP/SINR Phy Stats in " << GetCurrentCellRsrpSinrFilename().c_str()); + NS_LOG_INFO("Write RSRP/SINR Phy Stats in " << GetCurrentCellRsrpSinrFilename()); if (m_RsrpSinrFirstWrite == true) { - m_rsrpOutFile.open(GetCurrentCellRsrpSinrFilename().c_str()); + m_rsrpOutFile.open(GetCurrentCellRsrpSinrFilename()); if (!m_rsrpOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetCurrentCellRsrpSinrFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetCurrentCellRsrpSinrFilename()); return; } m_RsrpSinrFirstWrite = false; @@ -162,14 +162,14 @@ PhyStatsCalculator::ReportUeSinr(uint16_t cellId, uint8_t componentCarrierId) { NS_LOG_FUNCTION(this << cellId << imsi << rnti << sinrLinear); - NS_LOG_INFO("Write SINR Linear Phy Stats in " << GetUeSinrFilename().c_str()); + NS_LOG_INFO("Write SINR Linear Phy Stats in " << GetUeSinrFilename()); if (m_UeSinrFirstWrite == true) { - m_ueSinrOutFile.open(GetUeSinrFilename().c_str()); + m_ueSinrOutFile.open(GetUeSinrFilename()); if (!m_ueSinrOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUeSinrFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUeSinrFilename()); return; } m_UeSinrFirstWrite = false; @@ -188,14 +188,14 @@ void PhyStatsCalculator::ReportInterference(uint16_t cellId, Ptr interference) { NS_LOG_FUNCTION(this << cellId << interference); - NS_LOG_INFO("Write Interference Phy Stats in " << GetInterferenceFilename().c_str()); + NS_LOG_INFO("Write Interference Phy Stats in " << GetInterferenceFilename()); if (m_InterferenceFirstWrite == true) { - m_interferenceOutFile.open(GetInterferenceFilename().c_str()); + m_interferenceOutFile.open(GetInterferenceFilename()); if (!m_interferenceOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetInterferenceFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetInterferenceFilename()); return; } m_InterferenceFirstWrite = false; diff --git a/src/lte/helper/phy-tx-stats-calculator.cc b/src/lte/helper/phy-tx-stats-calculator.cc index cbb1b5f53..3cff748cb 100644 --- a/src/lte/helper/phy-tx-stats-calculator.cc +++ b/src/lte/helper/phy-tx-stats-calculator.cc @@ -104,14 +104,14 @@ PhyTxStatsCalculator::DlPhyTransmission(PhyTransmissionStatParameters params) NS_LOG_FUNCTION(this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi); - NS_LOG_INFO("Write DL Tx Phy Stats in " << GetDlTxOutputFilename().c_str()); + NS_LOG_INFO("Write DL Tx Phy Stats in " << GetDlTxOutputFilename()); if (m_dlTxFirstWrite == true) { - m_dlTxOutFile.open(GetDlOutputFilename().c_str()); + m_dlTxOutFile.open(GetDlOutputFilename()); if (!m_dlTxOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetDlTxOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetDlTxOutputFilename()); return; } m_dlTxFirstWrite = false; @@ -138,14 +138,14 @@ PhyTxStatsCalculator::UlPhyTransmission(PhyTransmissionStatParameters params) NS_LOG_FUNCTION(this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi); - NS_LOG_INFO("Write UL Tx Phy Stats in " << GetUlTxOutputFilename().c_str()); + NS_LOG_INFO("Write UL Tx Phy Stats in " << GetUlTxOutputFilename()); if (m_ulTxFirstWrite == true) { - m_ulTxOutFile.open(GetUlTxOutputFilename().c_str()); + m_ulTxOutFile.open(GetUlTxOutputFilename()); if (!m_ulTxOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUlTxOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUlTxOutputFilename()); return; } m_ulTxFirstWrite = false; diff --git a/src/lte/helper/radio-bearer-stats-calculator.cc b/src/lte/helper/radio-bearer-stats-calculator.cc index 86d83920f..9685ac491 100644 --- a/src/lte/helper/radio-bearer-stats-calculator.cc +++ b/src/lte/helper/radio-bearer-stats-calculator.cc @@ -237,26 +237,26 @@ RadioBearerStatsCalculator::DlRxPdu(uint16_t cellId, void RadioBearerStatsCalculator::ShowResults() { - NS_LOG_FUNCTION(this << GetUlOutputFilename().c_str() << GetDlOutputFilename().c_str()); - NS_LOG_INFO("Write Rlc Stats in " << GetUlOutputFilename().c_str() << " and in " - << GetDlOutputFilename().c_str()); + NS_LOG_FUNCTION(this << GetUlOutputFilename() << GetDlOutputFilename()); + NS_LOG_INFO("Write Rlc Stats in " << GetUlOutputFilename() << " and in " + << GetDlOutputFilename()); std::ofstream ulOutFile; std::ofstream dlOutFile; if (m_firstWrite == true) { - ulOutFile.open(GetUlOutputFilename().c_str()); + ulOutFile.open(GetUlOutputFilename()); if (!ulOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUlOutputFilename()); return; } - dlOutFile.open(GetDlOutputFilename().c_str()); + dlOutFile.open(GetDlOutputFilename()); if (!dlOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetDlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetDlOutputFilename()); return; } m_firstWrite = false; @@ -271,17 +271,17 @@ RadioBearerStatsCalculator::ShowResults() } else { - ulOutFile.open(GetUlOutputFilename().c_str(), std::ios_base::app); + ulOutFile.open(GetUlOutputFilename(), std::ios_base::app); if (!ulOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetUlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetUlOutputFilename()); return; } - dlOutFile.open(GetDlOutputFilename().c_str(), std::ios_base::app); + dlOutFile.open(GetDlOutputFilename(), std::ios_base::app); if (!dlOutFile.is_open()) { - NS_LOG_ERROR("Can't open file " << GetDlOutputFilename().c_str()); + NS_LOG_ERROR("Can't open file " << GetDlOutputFilename()); return; } } diff --git a/src/lte/test/lte-test-carrier-aggregation.cc b/src/lte/test/lte-test-carrier-aggregation.cc index f329bfbc7..e2ee71c8b 100644 --- a/src/lte/test/lte-test-carrier-aggregation.cc +++ b/src/lte/test/lte-test-carrier-aggregation.cc @@ -536,7 +536,7 @@ void CarrierAggregationTestCase::WriteResultToFile() { std::ofstream dlOutFile; - dlOutFile.open(dlResultsFileName.c_str(), std::ofstream::out | std::ofstream::app); + dlOutFile.open(dlResultsFileName, std::ofstream::out | std::ofstream::app); dlOutFile.setf(std::ios_base::fixed); if (!dlOutFile.is_open()) @@ -549,7 +549,7 @@ CarrierAggregationTestCase::WriteResultToFile() dlOutFile.close(); std::ofstream ulOutFile; - ulOutFile.open(ulResultsFileName.c_str(), std::ofstream::out | std::ofstream::app); + ulOutFile.open(ulResultsFileName, std::ofstream::out | std::ofstream::app); ulOutFile.setf(std::ios_base::fixed); if (!ulOutFile.is_open()) diff --git a/src/mobility/examples/ns2-mobility-trace.cc b/src/mobility/examples/ns2-mobility-trace.cc index db54ec9cc..d8d78fc7c 100644 --- a/src/mobility/examples/ns2-mobility-trace.cc +++ b/src/mobility/examples/ns2-mobility-trace.cc @@ -117,7 +117,7 @@ main(int argc, char* argv[]) // open log file for output std::ofstream os; - os.open(logFile.c_str()); + os.open(logFile); // Create all nodes. NodeContainer stas; diff --git a/src/mobility/helper/ns2-mobility-helper.cc b/src/mobility/helper/ns2-mobility-helper.cc index e19a16831..77ed711c1 100644 --- a/src/mobility/helper/ns2-mobility-helper.cc +++ b/src/mobility/helper/ns2-mobility-helper.cc @@ -233,10 +233,10 @@ static Vector SetSchedPosition(Ptr model, Ns2MobilityHelper::Ns2MobilityHelper(std::string filename) : m_filename(filename) { - std::ifstream file(m_filename.c_str(), std::ios::in); + std::ifstream file(m_filename, std::ios::in); if (!(file.is_open())) { - NS_FATAL_ERROR("Could not open trace file " << m_filename.c_str() + NS_FATAL_ERROR("Could not open trace file " << m_filename << " for reading, aborting here \n"); } } @@ -274,7 +274,7 @@ Ns2MobilityHelper::ConfigNodesMovements(const ObjectStore& store) const // Look through the whole the file for the the initial node // positions to make this helper robust to handle trace files with // the initial node positions at the end. - std::ifstream file(m_filename.c_str(), std::ios::in); + std::ifstream file(m_filename, std::ios::in); if (file.is_open()) { while (!file.eof()) @@ -346,7 +346,7 @@ Ns2MobilityHelper::ConfigNodesMovements(const ObjectStore& store) const // The reason the file is parsed again is to make this helper robust // to handle trace files with the initial node positions at the end. - file.open(m_filename.c_str(), std::ios::in); + file.open(m_filename, std::ios::in); if (file.is_open()) { while (!file.eof()) diff --git a/src/mobility/test/ns2-mobility-helper-test-suite.cc b/src/mobility/test/ns2-mobility-helper-test-suite.cc index 896ee8d07..b037e59d5 100644 --- a/src/mobility/test/ns2-mobility-helper-test-suite.cc +++ b/src/mobility/test/ns2-mobility-helper-test-suite.cc @@ -195,7 +195,7 @@ class Ns2MobilityHelperTest : public TestCase bool WriteTrace() { m_traceFile = CreateTempDirFilename("Ns2MobilityHelperTest.tcl"); - std::ofstream of(m_traceFile.c_str()); + std::ofstream of(m_traceFile); NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(of.is_open(), true, "Need to write tmp. file"); of << m_trace; of.close(); diff --git a/src/netanim/examples/colors-link-description.cc b/src/netanim/examples/colors-link-description.cc index ec2521a90..b6f928b70 100644 --- a/src/netanim/examples/colors-link-description.cc +++ b/src/netanim/examples/colors-link-description.cc @@ -160,7 +160,7 @@ main(int argc, char* argv[]) Ipv4GlobalRoutingHelper::PopulateRoutingTables(); Simulator::Run(); - std::cout << "Animation Trace file created:" << animFile.c_str() << std::endl; + std::cout << "Animation Trace file created:" << animFile << std::endl; Simulator::Destroy(); delete pAnim; return 0; diff --git a/src/netanim/examples/dumbbell-animation.cc b/src/netanim/examples/dumbbell-animation.cc index bd1d04315..6398bf579 100644 --- a/src/netanim/examples/dumbbell-animation.cc +++ b/src/netanim/examples/dumbbell-animation.cc @@ -104,7 +104,7 @@ main(int argc, char* argv[]) Ipv4GlobalRoutingHelper::PopulateRoutingTables(); Simulator::Run(); - std::cout << "Animation Trace file created:" << animFile.c_str() << std::endl; + std::cout << "Animation Trace file created:" << animFile << std::endl; Simulator::Destroy(); return 0; } diff --git a/src/netanim/examples/resources-counters.cc b/src/netanim/examples/resources-counters.cc index db3c4356b..feee6f013 100644 --- a/src/netanim/examples/resources-counters.cc +++ b/src/netanim/examples/resources-counters.cc @@ -211,7 +211,7 @@ main(int argc, char* argv[]) Ipv4GlobalRoutingHelper::PopulateRoutingTables(); Simulator::Run(); - std::cout << "Animation Trace file created:" << animFile.c_str() << std::endl; + std::cout << "Animation Trace file created:" << animFile << std::endl; Simulator::Destroy(); delete pAnim; return 0; diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index 6b1c37420..a9192ec1f 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -577,7 +577,7 @@ AnimationInterface::WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements) { - NS_LOG_INFO("Writing Route Path From :" << nodeId << " To: " << destination.c_str()); + NS_LOG_INFO("Writing Route Path From :" << nodeId << " To: " << destination); WriteXmlRp(nodeId, destination, rpElements); /*for (Ipv4RoutePathElements::const_iterator i = rpElements.begin (); i != rpElements.end (); @@ -623,7 +623,7 @@ AnimationInterface::GetNodeFromContext(const std::string& context) const // where element [1] is the Node Id std::vector elements = GetElementsFromContext(context); - Ptr n = NodeList::GetNode(atoi(elements.at(1).c_str())); + Ptr n = NodeList::GetNode(std::stoi(elements.at(1))); NS_ASSERT(n); return n; @@ -639,7 +639,7 @@ AnimationInterface::GetNetDeviceFromContext(std::string context) std::vector elements = GetElementsFromContext(context); Ptr n = GetNodeFromContext(context); - return n->GetDevice(atoi(elements.at(3).c_str())); + return n->GetDevice(std::stoi(elements.at(3))); } uint64_t @@ -864,7 +864,7 @@ AnimationInterface::GenericWirelessTxTrace(std::string context, UpdatePosition(ndev); ++gAnimUid; - NS_LOG_INFO(ProtocolTypeToString(protocolType).c_str() + NS_LOG_INFO(ProtocolTypeToString(protocolType) << " GenericWirelessTxTrace for packet:" << gAnimUid); AddByteTag(gAnimUid, p); AnimPacketInfo pktInfo(ndev, Simulator::Now()); @@ -896,11 +896,10 @@ AnimationInterface::GenericWirelessRxTrace(std::string context, NS_ASSERT(ndev); UpdatePosition(ndev); uint64_t animUid = GetAnimUidFromPacket(p); - NS_LOG_INFO(ProtocolTypeToString(protocolType).c_str() << " for packet:" << animUid); + NS_LOG_INFO(ProtocolTypeToString(protocolType) << " for packet:" << animUid); if (!IsPacketPending(animUid, protocolType)) { - NS_LOG_WARN(ProtocolTypeToString(protocolType).c_str() - << " GenericWirelessRxTrace: unknown Uid"); + NS_LOG_WARN(ProtocolTypeToString(protocolType) << " GenericWirelessRxTrace: unknown Uid"); return; } AnimUidPacketInfoMap* pendingPackets = ProtocolTypeToPendingPackets(protocolType); @@ -2171,12 +2170,12 @@ AnimationInterface::SetOutputFile(const std::string& fn, bool routing) return; } - NS_LOG_INFO("Creating new trace file:" << fn.c_str()); + NS_LOG_INFO("Creating new trace file:" << fn); FILE* f = nullptr; f = std::fopen(fn.c_str(), "w"); if (!f) { - NS_FATAL_ERROR("Unable to open output file:" << fn.c_str()); + NS_FATAL_ERROR("Unable to open output file:" << fn); return; // Can't open output file } if (routing) @@ -2320,7 +2319,7 @@ AnimationInterface::TrackIpv4RoutePaths() NS_LOG_WARN("Routing protocol object not found"); continue; } - NS_LOG_INFO("Begin Track Route for: " << trackElement.destination.c_str() + NS_LOG_INFO("Begin Track Route for: " << trackElement.destination << " From:" << trackElement.fromNodeId); Ptr pkt = Create(); Ipv4Header header; @@ -2330,7 +2329,7 @@ AnimationInterface::TrackIpv4RoutePaths() Ipv4RoutePathElements rpElements; if (!rt) { - NS_LOG_INFO("No route to :" << trackElement.destination.c_str()); + NS_LOG_INFO("No route to :" << trackElement.destination); Ipv4RoutePathElement elem = {trackElement.fromNodeId, "-1"}; rpElements.push_back(elem); WriteRoutePath(trackElement.fromNodeId, trackElement.destination, rpElements); @@ -2413,10 +2412,10 @@ AnimationInterface::RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements& rpElements) { - NS_LOG_INFO("RecursiveIpv4RoutePathSearch from:" << from.c_str() << " to:" << to.c_str()); - if ((from == "0.0.0.0") || (from == "127.0.0.1")) + NS_LOG_INFO("RecursiveIpv4RoutePathSearch from:" << from << " to:" << to); + if (from == "0.0.0.0" || from == "127.0.0.1") { - NS_LOG_INFO("Got " << from.c_str() << " End recursion"); + NS_LOG_INFO("Got " << from << " End recursion"); return; } Ptr fromNode = NodeList::GetNode(m_ipv4ToNodeIdMap[from]); diff --git a/src/network/model/address.cc b/src/network/model/address.cc index 733c0b6f1..71e54078d 100644 --- a/src/network/model/address.cc +++ b/src/network/model/address.cc @@ -269,11 +269,11 @@ operator>>(std::istream& is, Address& address) std::string::size_type secondDash; firstDash = v.find('-'); secondDash = v.find('-', firstDash + 1); - std::string type = v.substr(0, firstDash - 0); + std::string type = v.substr(0, firstDash); std::string len = v.substr(firstDash + 1, secondDash - (firstDash + 1)); - address.m_type = strtoul(type.c_str(), nullptr, 16); - address.m_len = strtoul(len.c_str(), nullptr, 16); + address.m_type = std::stoul(type, nullptr, 16); + address.m_len = std::stoul(len, nullptr, 16); NS_ASSERT(address.m_len <= Address::MAX_SIZE); std::string::size_type col = secondDash + 1; @@ -285,13 +285,13 @@ operator>>(std::istream& is, Address& address) if (next == std::string::npos) { tmp = v.substr(col, v.size() - col); - address.m_data[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_data[i] = std::stoul(tmp, nullptr, 16); break; } else { tmp = v.substr(col, next - col); - address.m_data[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_data[i] = std::stoul(tmp, nullptr, 16); col = next + 1; } } diff --git a/src/network/utils/mac16-address.cc b/src/network/utils/mac16-address.cc index e6a75ce7c..0c4bb8453 100644 --- a/src/network/utils/mac16-address.cc +++ b/src/network/utils/mac16-address.cc @@ -266,13 +266,13 @@ operator>>(std::istream& is, Mac16Address& address) if (next == std::string::npos) { tmp = v.substr(col, v.size() - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); break; } else { tmp = v.substr(col, next - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); col = next + 1; } } diff --git a/src/network/utils/mac48-address.cc b/src/network/utils/mac48-address.cc index 7611e5687..a292922e2 100644 --- a/src/network/utils/mac48-address.cc +++ b/src/network/utils/mac48-address.cc @@ -316,13 +316,13 @@ operator>>(std::istream& is, Mac48Address& address) if (next == std::string::npos) { tmp = v.substr(col, v.size() - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); break; } else { tmp = v.substr(col, next - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); col = next + 1; } } diff --git a/src/network/utils/mac64-address.cc b/src/network/utils/mac64-address.cc index 1f2aec961..6340f2b55 100644 --- a/src/network/utils/mac64-address.cc +++ b/src/network/utils/mac64-address.cc @@ -219,13 +219,13 @@ operator>>(std::istream& is, Mac64Address& address) if (next == std::string::npos) { tmp = v.substr(col, v.size() - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); break; } else { tmp = v.substr(col, next - col); - address.m_address[i] = strtoul(tmp.c_str(), nullptr, 16); + address.m_address[i] = std::stoul(tmp, nullptr, 16); col = next + 1; } } diff --git a/src/network/utils/output-stream-wrapper.cc b/src/network/utils/output-stream-wrapper.cc index 8bb6fb618..4fb7d9f49 100644 --- a/src/network/utils/output-stream-wrapper.cc +++ b/src/network/utils/output-stream-wrapper.cc @@ -33,7 +33,7 @@ OutputStreamWrapper::OutputStreamWrapper(std::string filename, std::ios::openmod { NS_LOG_FUNCTION(this << filename << filemode); std::ofstream* os = new std::ofstream(); - os->open(filename.c_str(), filemode); + os->open(filename, filemode); m_ostream = os; FatalImpl::RegisterStream(m_ostream); NS_ABORT_MSG_UNLESS(os->is_open(), diff --git a/src/network/utils/pcap-file.cc b/src/network/utils/pcap-file.cc index 9f5c70bc7..4b792a8ba 100644 --- a/src/network/utils/pcap-file.cc +++ b/src/network/utils/pcap-file.cc @@ -339,7 +339,7 @@ PcapFile::Open(const std::string& filename, std::ios::openmode mode) mode |= std::ios::binary; m_filename = filename; - m_file.open(filename.c_str(), mode); + m_file.open(filename, mode); if (mode & std::ios::in) { // will set the fail bit if file header is invalid. diff --git a/src/openflow/examples/openflow-switch.cc b/src/openflow/examples/openflow-switch.cc index 8a52359d7..2e29bdd04 100644 --- a/src/openflow/examples/openflow-switch.cc +++ b/src/openflow/examples/openflow-switch.cc @@ -69,7 +69,7 @@ SetTimeout(std::string value) { try { - timeout = ns3::Seconds(atof(value.c_str())); + timeout = ns3::Seconds(std::stof(value)); return true; } catch (...) diff --git a/src/spectrum/model/trace-fading-loss-model.cc b/src/spectrum/model/trace-fading-loss-model.cc index eb35f46a4..3a02633e4 100644 --- a/src/spectrum/model/trace-fading-loss-model.cc +++ b/src/spectrum/model/trace-fading-loss-model.cc @@ -120,7 +120,7 @@ TraceFadingLossModel::LoadTrace() { NS_LOG_FUNCTION(this << "Loading Fading Trace " << m_traceFile); std::ifstream ifTraceFile; - ifTraceFile.open(m_traceFile.c_str(), std::ifstream::in); + ifTraceFile.open(m_traceFile, std::ifstream::in); m_fadingTrace.clear(); if (!ifTraceFile.good()) { diff --git a/src/stats/examples/gnuplot-example.cc b/src/stats/examples/gnuplot-example.cc index dfb5756f9..34fc41e0e 100644 --- a/src/stats/examples/gnuplot-example.cc +++ b/src/stats/examples/gnuplot-example.cc @@ -79,7 +79,7 @@ Create2DPlotFile() plot.AddDataset(dataset); // Open the plot file. - std::ofstream plotFile(plotFileName.c_str()); + std::ofstream plotFile(plotFileName); // Write the plot file. plot.GenerateOutput(plotFile); @@ -153,7 +153,7 @@ Create2DPlotWithErrorBarsFile() plot.AddDataset(dataset); // Open the plot file. - std::ofstream plotFile(plotFileName.c_str()); + std::ofstream plotFile(plotFileName); // Write the plot file. plot.GenerateOutput(plotFile); @@ -233,7 +233,7 @@ Create3DPlotFile() plot.AddDataset(dataset); // Open the plot file. - std::ofstream plotFile(plotFileName.c_str()); + std::ofstream plotFile(plotFileName); // Write the plot file. plot.GenerateOutput(plotFile); diff --git a/src/stats/model/file-aggregator.cc b/src/stats/model/file-aggregator.cc index c560407ce..5793f0793 100644 --- a/src/stats/model/file-aggregator.cc +++ b/src/stats/model/file-aggregator.cc @@ -74,7 +74,7 @@ FileAggregator::FileAggregator(const std::string& outputFileName, enum FileType break; } - m_file.open(m_outputFileName.c_str()); + m_file.open(m_outputFileName); } FileAggregator::~FileAggregator() diff --git a/src/stats/model/gnuplot-aggregator.cc b/src/stats/model/gnuplot-aggregator.cc index faf2d0221..b89fd8f98 100644 --- a/src/stats/model/gnuplot-aggregator.cc +++ b/src/stats/model/gnuplot-aggregator.cc @@ -73,9 +73,9 @@ GnuplotAggregator::~GnuplotAggregator() // Open the gnuplot plot and data files. std::ofstream plotFile; - plotFile.open(plotFileName.c_str()); + plotFile.open(plotFileName); std::ofstream dataFile; - dataFile.open(dataFileName.c_str()); + dataFile.open(dataFileName); // Skip any NaN's that appear in data. m_gnuplot.AppendExtra("set datafile missing \"-nan\""); @@ -89,7 +89,7 @@ GnuplotAggregator::~GnuplotAggregator() // Open the shell script file. std::ofstream scriptFile; - scriptFile.open(scriptFileName.c_str()); + scriptFile.open(scriptFileName); // Write the shell script file. scriptFile << "#!/bin/sh" << std::endl; diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index c0446603e..25cdea9d9 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -111,7 +111,7 @@ OmnetDataOutput::Output(DataCollector& dc) std::ofstream scalarFile; std::string fn = m_filePrefix + "-" + dc.GetRunLabel() + ".sca"; - scalarFile.open(fn.c_str(), std::ios_base::out); + scalarFile.open(fn, std::ios_base::out); /// \todo add timestamp to the runlevel scalarFile << "run " << dc.GetRunLabel() << std::endl; diff --git a/src/topology-read/model/inet-topology-reader.cc b/src/topology-read/model/inet-topology-reader.cc index d44a7f6e7..7fb90c534 100644 --- a/src/topology-read/model/inet-topology-reader.cc +++ b/src/topology-read/model/inet-topology-reader.cc @@ -64,7 +64,7 @@ NodeContainer InetTopologyReader::Read() { std::ifstream topgen; - topgen.open(GetFileName().c_str()); + topgen.open(GetFileName()); std::map> nodeMap; NodeContainer nodes; diff --git a/src/topology-read/model/orbis-topology-reader.cc b/src/topology-read/model/orbis-topology-reader.cc index 315dc6676..fd7683c71 100644 --- a/src/topology-read/model/orbis-topology-reader.cc +++ b/src/topology-read/model/orbis-topology-reader.cc @@ -64,7 +64,7 @@ NodeContainer OrbisTopologyReader::Read() { std::ifstream topgen; - topgen.open(GetFileName().c_str()); + topgen.open(GetFileName()); std::map> nodeMap; NodeContainer nodes; diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc index 20db03481..af769e770 100644 --- a/src/topology-read/model/rocketfuel-topology-reader.cc +++ b/src/topology-read/model/rocketfuel-topology-reader.cc @@ -337,7 +337,7 @@ NodeContainer RocketfuelTopologyReader::Read() { std::ifstream topgen; - topgen.open(GetFileName().c_str()); + topgen.open(GetFileName()); NodeContainer nodes; std::istringstream lineBuffer; diff --git a/src/traffic-control/examples/adaptive-red-tests.cc b/src/traffic-control/examples/adaptive-red-tests.cc index bad24305e..4f32d4d6a 100644 --- a/src/traffic-control/examples/adaptive-red-tests.cc +++ b/src/traffic-control/examples/adaptive-red-tests.cc @@ -117,12 +117,11 @@ CheckQueueDiscSize(Ptr queue) // check queue disc size every 1/100 of a second Simulator::Schedule(Seconds(0.01), &CheckQueueDiscSize, queue); - std::ofstream fPlotQueueDisc(filePlotQueueDisc.str().c_str(), std::ios::out | std::ios::app); + std::ofstream fPlotQueueDisc(filePlotQueueDisc.str(), std::ios::out | std::ios::app); fPlotQueueDisc << Simulator::Now().GetSeconds() << " " << qSize << std::endl; fPlotQueueDisc.close(); - std::ofstream fPlotQueueDiscAvg(filePlotQueueDiscAvg.str().c_str(), - std::ios::out | std::ios::app); + std::ofstream fPlotQueueDiscAvg(filePlotQueueDiscAvg.str(), std::ios::out | std::ios::app); fPlotQueueDiscAvg << Simulator::Now().GetSeconds() << " " << avgQueueDiscSize / checkTimes << std::endl; fPlotQueueDiscAvg.close(); diff --git a/src/traffic-control/examples/fqcodel-l4s-example.cc b/src/traffic-control/examples/fqcodel-l4s-example.cc index 52889a8d4..d78995538 100644 --- a/src/traffic-control/examples/fqcodel-l4s-example.cc +++ b/src/traffic-control/examples/fqcodel-l4s-example.cc @@ -684,35 +684,35 @@ main(int argc, char* argv[]) } std::ofstream pingOfStream; - pingOfStream.open(pingTraceFile.c_str(), std::ofstream::out); + pingOfStream.open(pingTraceFile, std::ofstream::out); std::ofstream n0TcpRttOfStream; - n0TcpRttOfStream.open(n0TcpRttTraceFile.c_str(), std::ofstream::out); + n0TcpRttOfStream.open(n0TcpRttTraceFile, std::ofstream::out); std::ofstream n0TcpCwndOfStream; - n0TcpCwndOfStream.open(n0TcpCwndTraceFile.c_str(), std::ofstream::out); + n0TcpCwndOfStream.open(n0TcpCwndTraceFile, std::ofstream::out); std::ofstream n0TcpThroughputOfStream; - n0TcpThroughputOfStream.open(n0TcpThroughputTraceFile.c_str(), std::ofstream::out); + n0TcpThroughputOfStream.open(n0TcpThroughputTraceFile, std::ofstream::out); std::ofstream n1TcpRttOfStream; - n1TcpRttOfStream.open(n1TcpRttTraceFile.c_str(), std::ofstream::out); + n1TcpRttOfStream.open(n1TcpRttTraceFile, std::ofstream::out); std::ofstream n1TcpCwndOfStream; - n1TcpCwndOfStream.open(n1TcpCwndTraceFile.c_str(), std::ofstream::out); + n1TcpCwndOfStream.open(n1TcpCwndTraceFile, std::ofstream::out); std::ofstream n1TcpThroughputOfStream; - n1TcpThroughputOfStream.open(n1TcpThroughputTraceFile.c_str(), std::ofstream::out); + n1TcpThroughputOfStream.open(n1TcpThroughputTraceFile, std::ofstream::out); // Queue disc files std::ofstream dropOfStream; - dropOfStream.open(dropTraceFile.c_str(), std::ofstream::out); + dropOfStream.open(dropTraceFile, std::ofstream::out); std::ofstream markOfStream; - markOfStream.open(markTraceFile.c_str(), std::ofstream::out); + markOfStream.open(markTraceFile, std::ofstream::out); std::ofstream dropsFrequencyOfStream; - dropsFrequencyOfStream.open(dropsFrequencyTraceFile.c_str(), std::ofstream::out); + dropsFrequencyOfStream.open(dropsFrequencyTraceFile, std::ofstream::out); std::ofstream marksFrequencyOfStream; - marksFrequencyOfStream.open(marksFrequencyTraceFile.c_str(), std::ofstream::out); + marksFrequencyOfStream.open(marksFrequencyTraceFile, std::ofstream::out); std::ofstream lengthOfStream; - lengthOfStream.open(lengthTraceFile.c_str(), std::ofstream::out); + lengthOfStream.open(lengthTraceFile, std::ofstream::out); std::ofstream queueDelayN0OfStream; - queueDelayN0OfStream.open(queueDelayN0TraceFile.c_str(), std::ofstream::out); + queueDelayN0OfStream.open(queueDelayN0TraceFile, std::ofstream::out); std::ofstream queueDelayN1OfStream; - queueDelayN1OfStream.open(queueDelayN1TraceFile.c_str(), std::ofstream::out); + queueDelayN1OfStream.open(queueDelayN1TraceFile, std::ofstream::out); //////////////////////////////////////////////////////////// // scenario setup // diff --git a/src/traffic-control/examples/pie-example.cc b/src/traffic-control/examples/pie-example.cc index e8622ef38..9ee4a965b 100644 --- a/src/traffic-control/examples/pie-example.cc +++ b/src/traffic-control/examples/pie-example.cc @@ -80,12 +80,11 @@ CheckQueueDiscSize(Ptr queue) // check queue disc size every 1/100 of a second Simulator::Schedule(Seconds(0.01), &CheckQueueDiscSize, queue); - std::ofstream fPlotQueueDisc(filePlotQueueDisc.str().c_str(), std::ios::out | std::ios::app); + std::ofstream fPlotQueueDisc(filePlotQueueDisc.str(), std::ios::out | std::ios::app); fPlotQueueDisc << Simulator::Now().GetSeconds() << " " << qSize << std::endl; fPlotQueueDisc.close(); - std::ofstream fPlotQueueDiscAvg(filePlotQueueDiscAvg.str().c_str(), - std::ios::out | std::ios::app); + std::ofstream fPlotQueueDiscAvg(filePlotQueueDiscAvg.str(), std::ios::out | std::ios::app); fPlotQueueDiscAvg << Simulator::Now().GetSeconds() << " " << avgQueueDiscSize / checkTimes << std::endl; fPlotQueueDiscAvg.close(); diff --git a/src/traffic-control/examples/red-tests.cc b/src/traffic-control/examples/red-tests.cc index c59cc7a57..be44d23e3 100644 --- a/src/traffic-control/examples/red-tests.cc +++ b/src/traffic-control/examples/red-tests.cc @@ -91,11 +91,11 @@ CheckQueueSize(Ptr queue) // check queue size every 1/100 of a second Simulator::Schedule(Seconds(0.01), &CheckQueueSize, queue); - std::ofstream fPlotQueue(filePlotQueue.str().c_str(), std::ios::out | std::ios::app); + std::ofstream fPlotQueue(filePlotQueue.str(), std::ios::out | std::ios::app); fPlotQueue << Simulator::Now().GetSeconds() << " " << qSize << std::endl; fPlotQueue.close(); - std::ofstream fPlotQueueAvg(filePlotQueueAvg.str().c_str(), std::ios::out | std::ios::app); + std::ofstream fPlotQueueAvg(filePlotQueueAvg.str(), std::ios::out | std::ios::app); fPlotQueueAvg << Simulator::Now().GetSeconds() << " " << avgQueueSize / checkTimes << std::endl; fPlotQueueAvg.close(); } diff --git a/src/uan/examples/uan-cw-example.cc b/src/uan/examples/uan-cw-example.cc index e6a58c4d1..84be22f6f 100644 --- a/src/uan/examples/uan-cw-example.cc +++ b/src/uan/examples/uan-cw-example.cc @@ -222,7 +222,7 @@ Experiment::Run(UanHelper& uan) m_bytesTotal = 0; - std::ofstream ascii(m_asciitracefile.c_str()); + std::ofstream ascii(m_asciitracefile); if (!ascii.is_open()) { NS_FATAL_ERROR("Could not open ascii trace file: " << m_asciitracefile); @@ -321,7 +321,7 @@ main(int argc, char** argv) gp.AddDataset(ds); - std::ofstream of(exp.m_gnudatfile.c_str()); + std::ofstream of(exp.m_gnudatfile); if (!of.is_open()) { NS_FATAL_ERROR("Can not open GNU Plot outfile: " << exp.m_gnudatfile); diff --git a/src/uan/examples/uan-rc-example.cc b/src/uan/examples/uan-rc-example.cc index 1bc1b9f3e..c1aefaa2a 100644 --- a/src/uan/examples/uan-rc-example.cc +++ b/src/uan/examples/uan-rc-example.cc @@ -301,7 +301,7 @@ main(int argc, char* argv[]) Gnuplot gp; gp.AddDataset(ds); - std::ofstream of(exp.m_gnuplotfile.c_str()); + std::ofstream of(exp.m_gnuplotfile); if (!of.is_open()) { NS_FATAL_ERROR("Can not open GNU Plot outfile: " << exp.m_gnuplotfile); diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index 177faa62d..28e8c1a80 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -478,7 +478,7 @@ PyViz::TraceDevQueueDrop(std::string context, Ptr packet) { NS_LOG_FUNCTION(context << packet->GetUid()); std::vector splitPath = PathSplit(context); - int nodeIndex = std::atoi(splitPath[1].c_str()); + int nodeIndex = std::stoi(splitPath[1]); Ptr node = NodeList::GetNode(nodeIndex); if (m_nodesOfInterest.find(nodeIndex) == m_nodesOfInterest.end()) @@ -543,8 +543,8 @@ PyViz::TraceNetDevTxCommon(const std::string& context, NS_LOG_FUNCTION(context << packet->GetUid() << *packet); std::vector splitPath = PathSplit(context); - int nodeIndex = std::atoi(splitPath[1].c_str()); - int devIndex = std::atoi(splitPath[3].c_str()); + int nodeIndex = std::stoi(splitPath[1]); + int devIndex = std::stoi(splitPath[3]); Ptr node = NodeList::GetNode(nodeIndex); Ptr device = node->GetDevice(devIndex); @@ -674,8 +674,8 @@ PyViz::TraceNetDevRxCommon(const std::string& context, NS_LOG_FUNCTION(context << uid); std::vector splitPath = PathSplit(context); - int nodeIndex = std::atoi(splitPath[1].c_str()); - int devIndex = std::atoi(splitPath[3].c_str()); + int nodeIndex = std::stoi(splitPath[1]); + int devIndex = std::stoi(splitPath[3]); // ---- statistics NetDeviceStatistics& stats = FindNetDeviceStatistics(nodeIndex, devIndex); diff --git a/src/wave/examples/vanet-routing-compare.cc b/src/wave/examples/vanet-routing-compare.cc index e716e9362..1d5d57b5c 100644 --- a/src/wave/examples/vanet-routing-compare.cc +++ b/src/wave/examples/vanet-routing-compare.cc @@ -1743,7 +1743,7 @@ VanetRoutingExperiment::ProcessOutputs() << "Kbps MAC/PHY-oh=" << mac_phy_oh); } - std::ofstream out(m_CSVfileName2.c_str(), std::ios::app); + std::ofstream out(m_CSVfileName2, std::ios::app); out << bsm_pdr1 << "," << bsm_pdr2 << "," << bsm_pdr3 << "," << bsm_pdr4 << "," << bsm_pdr5 << "," << bsm_pdr6 << "," << bsm_pdr7 << "," << bsm_pdr8 << "," << bsm_pdr9 << "," @@ -1832,7 +1832,7 @@ VanetRoutingExperiment::CheckThroughput() mac_phy_oh = (double)(totalPhyBytes - totalAppBytes) / (double)totalPhyBytes; } - std::ofstream out(m_CSVfileName.c_str(), std::ios::app); + std::ofstream out(m_CSVfileName, std::ios::app); if (m_log != 0) { @@ -2132,7 +2132,7 @@ void VanetRoutingExperiment::SetupLogFile() { // open log file for output - m_os.open(m_logFile.c_str()); + m_os.open(m_logFile); } void @@ -2450,7 +2450,7 @@ void VanetRoutingExperiment::WriteCsvHeader() { // blank out the last output file and write the column headers - std::ofstream out(m_CSVfileName.c_str()); + std::ofstream out(m_CSVfileName); out << "SimulationSecond," << "ReceiveRate," << "PacketsReceived," @@ -2475,7 +2475,7 @@ VanetRoutingExperiment::WriteCsvHeader() << "MacPhyOverhead" << std::endl; out.close(); - std::ofstream out2(m_CSVfileName2.c_str()); + std::ofstream out2(m_CSVfileName2); out2 << "BSM_PDR1," << "BSM_PDR2," << "BSM_PDR3," diff --git a/src/wifi/examples/wifi-bianchi.cc b/src/wifi/examples/wifi-bianchi.cc index 65833bbed..15a663e28 100644 --- a/src/wifi/examples/wifi-bianchi.cc +++ b/src/wifi/examples/wifi-bianchi.cc @@ -85,14 +85,14 @@ std::map std::map phyHeaderFailed; ///< Map that stores the total number of ///< unsuccessfully received PHY headers per STA std::map - rxEventWhileTxing; ///< Map that stores the number of reception events per STA that occured + rxEventWhileTxing; ///< Map that stores the number of reception events per STA that occurred ///< while PHY was already transmitting a PPDU std::map - rxEventWhileRxing; ///< Map that stores the number of reception events per STA that occured + rxEventWhileRxing; ///< Map that stores the number of reception events per STA that occurred ///< while PHY was already receiving a PPDU std::map rxEventWhileDecodingPreamble; ///< Map that stores the number of reception events per STA that - ///< occured while PHY was already decoding a preamble + ///< occurred while PHY was already decoding a preamble std::map rxEventAbortedByTx; ///< Map that stores the number of reception events aborted per STA because ///< the PHY has started to transmit @@ -1914,7 +1914,7 @@ ContextToNodeId(std::string context) { std::string sub = context.substr(10); uint32_t pos = sub.find("/Device"); - return atoi(sub.substr(0, pos).c_str()); + return std::stoi(sub.substr(0, pos)); } /** @@ -1928,7 +1928,7 @@ ContextToMac(std::string context) { std::string sub = context.substr(10); uint32_t pos = sub.find("/Device"); - uint32_t nodeId = atoi(sub.substr(0, pos).c_str()); + uint32_t nodeId = std::stoi(sub.substr(0, pos)); Ptr n = NodeList::GetNode(nodeId); Ptr d; for (uint32_t i = 0; i < n->GetNDevices(); i++) @@ -2833,7 +2833,7 @@ main(int argc, char* argv[]) ss << "wifi-" << standard << "-p-" << pktSize << (infra ? "-infrastructure" : "-adhoc") << "-r-" << phyModeStr.str() << "-min-" << nMinStas << "-max-" << nMaxStas << "-step-" << nStepSize << "-throughput.plt"; - std::ofstream throughputPlot(ss.str().c_str()); + std::ofstream throughputPlot(ss.str()); ss.str(""); ss << "wifi-" << standard << "-p-" << pktSize << (infra ? "-infrastructure" : "-adhoc") << "-r-" << phyModeStr.str() << "-min-" << nMinStas << "-max-" << nMaxStas << "-step-" << nStepSize diff --git a/src/wifi/examples/wifi-manager-example.cc b/src/wifi/examples/wifi-manager-example.cc index 78288acc6..fd886f9df 100644 --- a/src/wifi/examples/wifi-manager-example.cc +++ b/src/wifi/examples/wifi-manager-example.cc @@ -584,7 +584,7 @@ main(int argc, char* argv[]) } plotName += ".eps"; dataName += ".plt"; - std::ofstream outfile(dataName.c_str()); + std::ofstream outfile(dataName); Gnuplot gnuplot = Gnuplot(plotName); Config::SetDefault("ns3::WifiRemoteStationManager::MaxSlrc", UintegerValue(maxSlrc)); diff --git a/src/wifi/helper/athstats-helper.cc b/src/wifi/helper/athstats-helper.cc index d0ba7dab9..1411b5daf 100644 --- a/src/wifi/helper/athstats-helper.cc +++ b/src/wifi/helper/athstats-helper.cc @@ -273,10 +273,9 @@ AthstatsWifiTraceSink::Open(const std::string& name) NS_LOG_LOGIC("Created writer " << m_writer); - m_writer->open(name.c_str(), std::ios_base::binary | std::ios_base::out); + m_writer->open(name, std::ios_base::binary | std::ios_base::out); NS_ABORT_MSG_IF(m_writer->fail(), - "AthstatsWifiTraceSink::Open (): m_writer->open (" << name.c_str() - << ") failed"); + "AthstatsWifiTraceSink::Open (): m_writer->open (" << name << ") failed"); NS_ASSERT_MSG(m_writer->is_open(), "AthstatsWifiTraceSink::Open (): m_writer not open"); diff --git a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc index 013d764ff..4682d4236 100644 --- a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc @@ -1995,7 +1995,7 @@ MinstrelHtWifiManager::PrintTable(MinstrelHtWifiRemoteStation* station) { std::ostringstream tmp; tmp << "minstrel-ht-stats-" << station->m_state->m_address << ".txt"; - station->m_statsFile.open(tmp.str().c_str(), std::ios::out); + station->m_statsFile.open(tmp.str(), std::ios::out); } station->m_statsFile diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-wifi-manager.cc index aa2a94613..4f8f4f45c 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.cc @@ -1127,7 +1127,7 @@ MinstrelWifiManager::PrintTable(MinstrelWifiRemoteStation* station) { std::ostringstream tmp; tmp << "minstrel-stats-" << station->m_state->m_address << ".txt"; - station->m_statsFile.open(tmp.str().c_str(), std::ios::out); + station->m_statsFile.open(tmp.str(), std::ios::out); } station->m_statsFile diff --git a/src/wifi/test/inter-bss-test-suite.cc b/src/wifi/test/inter-bss-test-suite.cc index 3212c962d..7bb611a62 100644 --- a/src/wifi/test/inter-bss-test-suite.cc +++ b/src/wifi/test/inter-bss-test-suite.cc @@ -44,7 +44,7 @@ ConvertContextToNodeId(std::string context) { std::string sub = context.substr(10); uint32_t pos = sub.find("/Device"); - uint32_t nodeId = atoi(sub.substr(0, pos).c_str()); + uint32_t nodeId = std::stoi(sub.substr(0, pos)); return nodeId; } diff --git a/src/wimax/model/snr-to-block-error-rate-manager.cc b/src/wimax/model/snr-to-block-error-rate-manager.cc index f02445fab..7901e168c 100644 --- a/src/wimax/model/snr-to-block-error-rate-manager.cc +++ b/src/wimax/model/snr-to-block-error-rate-manager.cc @@ -97,7 +97,7 @@ SNRToBlockErrorRateManager::LoadTraces() std::stringstream traceFilePath; traceFilePath << m_traceFilePath << "/modulation" << i << ".txt"; - traceFile.open(traceFilePath.str().c_str(), std::ifstream::in); + traceFile.open(traceFilePath.str(), std::ifstream::in); if (traceFile.good() == false) { NS_LOG_INFO("Unable to load " << traceFilePath.str() << "!! Loading default traces..."); @@ -236,7 +236,7 @@ SNRToBlockErrorRateManager::ReLoadTraces() std::stringstream traceFilePath; traceFilePath << m_traceFilePath << "/Modulation" << i << ".txt"; - traceFile.open(traceFilePath.str().c_str(), std::ifstream::in); + traceFile.open(traceFilePath.str(), std::ifstream::in); if (traceFile.good() == false) { NS_LOG_INFO("Unable to load " << traceFilePath.str() << "!!Loading default traces..."); diff --git a/utils/bench-scheduler.cc b/utils/bench-scheduler.cc index d263bb422..35c4fbcf8 100644 --- a/utils/bench-scheduler.cc +++ b/utils/bench-scheduler.cc @@ -420,7 +420,7 @@ GetRandomStream(std::string filename) else { LOG(" Event time distribution: from " << filename); - input = new std::ifstream(filename.c_str()); + input = new std::ifstream(filename); } double value;