Stop using 'using namespace'.

This CL removes all the instances of 'using namespace' from C++ code
(more info https://abseil.io/tips/153).

Bug: webrtc:9855
Change-Id: Ic940fe87c5047742cfa6d60857d2f97be380ed18
Reviewed-on: https://webrtc-review.googlesource.com/c/113948
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25985}
This commit is contained in:
Mirko Bonadei
2018-12-11 18:43:40 +01:00
committed by Commit Bot
parent cd3929731a
commit e10b163dd4
10 changed files with 75 additions and 53 deletions

View File

@ -41,8 +41,6 @@
#endif
#endif
using namespace std;
int main(int argc, char* argv[]) {
char inname[100], outname[100], bottleneck_file[100], vadfile[100];
FILE *inp, *outp, *f_bn = NULL, *vadp = NULL, *bandwidthp;
@ -425,27 +423,27 @@ int main(int argc, char* argv[]) {
printf("Output file: %s\n\n", outname);
if ((inp = fopen(inname, "rb")) == NULL) {
printf(" Error iSAC Cannot read file %s.\n", inname);
cout << flush;
std::cout << std::flush;
exit(1);
}
if ((outp = fopen(outname, "wb")) == NULL) {
printf(" Error iSAC Cannot write file %s.\n", outname);
cout << flush;
std::cout << std::flush;
getc(stdin);
exit(1);
}
if (VADusage) {
if ((vadp = fopen(vadfile, "rb")) == NULL) {
printf(" Error iSAC Cannot read file %s.\n", vadfile);
cout << flush;
std::cout << std::flush;
exit(1);
}
}
if ((bandwidthp = fopen("bwe.pcm", "wb")) == NULL) {
printf(" Error iSAC Cannot read file %s.\n", "bwe.pcm");
cout << flush;
std::cout << std::flush;
exit(1);
}
@ -472,7 +470,7 @@ int main(int argc, char* argv[]) {
/* Error check */
if (err < 0) {
printf("\n\n Error in create.\n\n");
cout << flush;
std::cout << std::flush;
exit(EXIT_FAILURE);
}
}
@ -508,7 +506,7 @@ int main(int argc, char* argv[]) {
if (testNum != 1) {
if (WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode) < 0) {
printf("Error could not initialize the encoder \n");
cout << flush;
std::cout << std::flush;
return 0;
}
}
@ -520,7 +518,7 @@ int main(int argc, char* argv[]) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in initialization (control): %d.\n\n", errtype);
cout << flush;
std::cout << std::flush;
if (testNum == 0) {
exit(EXIT_FAILURE);
}
@ -534,7 +532,7 @@ int main(int argc, char* argv[]) {
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in Control BWE: %d.\n\n", errtype);
cout << flush;
std::cout << std::flush;
exit(EXIT_FAILURE);
}
}
@ -545,7 +543,7 @@ int main(int argc, char* argv[]) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in SetMaxPayloadSize: %d.\n\n", errtype);
cout << flush;
std::cout << std::flush;
exit(EXIT_FAILURE);
}
}
@ -555,14 +553,14 @@ int main(int argc, char* argv[]) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in SetMaxRateInBytes: %d.\n\n", errtype);
cout << flush;
std::cout << std::flush;
exit(EXIT_FAILURE);
}
}
*speechType = 1;
cout << "\n" << flush;
std::cout << "\n" << std::flush;
length_file = 0;
int16_t bnIdxTC = 0;
@ -575,7 +573,7 @@ int main(int argc, char* argv[]) {
if (err < 0) {
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in encoderinit: %d.\n\n", errtype);
cout << flush;
std::cout << std::flush;
}
WebRtcIsac_DecoderInit(ISAC_main_inst);
@ -613,7 +611,7 @@ int main(int argc, char* argv[]) {
printf("\nError: Streamsize out of range %d\n",
stream_len_int - payloadSize);
cout << flush;
std::cout << std::flush;
}
WebRtcIsac_GetUplinkBw(ISAC_main_inst, &sendBN);
@ -671,7 +669,7 @@ int main(int argc, char* argv[]) {
/* exit if returned with error */
errtype = WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr, "Error in encoder: %d.\n", errtype);
cout << flush;
std::cout << std::flush;
exit(0);
}
stream_len = static_cast<size_t>(stream_len_int);
@ -787,7 +785,7 @@ int main(int argc, char* argv[]) {
}
printf("Error: in decoder: %d.", errtype);
cout << flush;
std::cout << std::flush;
if (testNum == 0) {
printf("\n\n");
}
@ -804,7 +802,7 @@ int main(int argc, char* argv[]) {
printf("\n\n");
}
printf(" Error: in getFrameLen %d.", errtype);
cout << flush;
std::cout << std::flush;
if (testNum == 0) {
printf("\n\n");
}
@ -840,7 +838,7 @@ int main(int argc, char* argv[]) {
printf("\n\n");
}
printf(" Error: in decoder %d.", errtype);
cout << flush;
std::cout << std::flush;
if (testNum == 0) {
printf("\n\n");
}
@ -851,7 +849,7 @@ int main(int argc, char* argv[]) {
printf("\n\n");
}
printf(" Error: in decoding the transcoded stream");
cout << flush;
std::cout << std::flush;
if (testNum == 0) {
printf("\n\n");
}

View File

@ -23,8 +23,6 @@
#define NUM_CLIENTS 2
using namespace std;
int main(int argc, char* argv[]) {
char fileNameWB[MAX_FILE_NAME];
char fileNameSWB[MAX_FILE_NAME];
@ -306,7 +304,7 @@ int main(int argc, char* argv[]) {
// &rateIndexLB, &rateIndexUB);
// printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
cout << flush;
std::cout << std::flush;
lenEncodedInBytesTmp[senderIdx] = 0;
lenAudioIn10msTmp[senderIdx] = 0;
// if(senderIdx == (NUM_CLIENTS - 1))

View File

@ -18,8 +18,8 @@
#include "rtc_base/testbase64.h"
#include "test/gtest.h"
using namespace std;
using namespace rtc;
namespace rtc {
namespace {
static struct {
size_t plain_length;
@ -337,7 +337,7 @@ size_t Base64Escape(const unsigned char* src,
size_t szdest) {
std::string escaped;
Base64::EncodeFromArray((const char*)src, szsrc, &escaped);
memcpy(dest, escaped.data(), min(escaped.size(), szdest));
memcpy(dest, escaped.data(), std::min(escaped.size(), szdest));
return escaped.size();
}
@ -348,7 +348,7 @@ size_t Base64Unescape(const char* src,
std::string unescaped;
EXPECT_TRUE(
Base64::DecodeFromArray(src, szsrc, Base64::DO_LAX, &unescaped, nullptr));
memcpy(dest, unescaped.data(), min(unescaped.size(), szdest));
memcpy(dest, unescaped.data(), std::min(unescaped.size(), szdest));
return unescaped.size();
}
@ -1448,3 +1448,6 @@ TEST(Base64, GetNextBase64Char) {
EXPECT_FALSE(Base64::GetNextBase64Char('&', &next_char));
EXPECT_FALSE(Base64::GetNextBase64Char('Z', nullptr));
}
} // namespace
} // namespace rtc

View File

@ -23,7 +23,8 @@
#include "rtc_base/thread.h"
#include "rtc_base/timeutils.h"
using namespace rtc;
namespace rtc {
namespace {
class MessageQueueTest : public testing::Test, public MessageQueue {
public:
@ -231,3 +232,6 @@ TEST(MessageQueueManager, ClearReentrant) {
t->Post(RTC_FROM_HERE, &handler, 0,
new ScopedRefMessageData<RefCountedHandler>(inner_handler));
}
} // namespace
} // namespace rtc

View File

@ -37,7 +37,8 @@
#include "rtc_base/virtualsocketserver.h"
#include "test/gtest.h"
using namespace rtc;
namespace rtc {
namespace {
bool CheckReceive(TestClient* client,
bool should_receive,
@ -400,4 +401,6 @@ TEST_F(NatTcpTest, DISABLED_TestConnectOut) {
out->Send(buf, len);
EXPECT_TRUE(in->CheckNextPacket(buf, len, &trans_addr));
}
// #endif
} // namespace
} // namespace rtc

View File

@ -17,7 +17,8 @@
#include "rtc_base/thread.h"
#include "test/gtest.h"
using namespace rtc;
namespace rtc {
namespace {
// 10 seconds.
static const int kTimeout = 10000;
@ -208,3 +209,6 @@ TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) {
ExpectState(1, 0, 0, 1, 0);
ExpectStateWait(1, 1, 0, 1, 1, kTimeout);
}
} // namespace
} // namespace rtc

View File

@ -23,7 +23,8 @@
#include "rtc_base/thread.h"
#include "test/gtest.h"
using namespace rtc;
namespace rtc {
namespace {
#define MAYBE_SKIP_IPV4 \
if (!HasIPv4Enabled()) { \
@ -101,3 +102,6 @@ TEST(TestClientTest, MAYBE_TestTcpIPv6) {
MAYBE_SKIP_IPV6;
TestTcpInternal(SocketAddress("::1", 0));
}
} // namespace
} // namespace rtc

View File

@ -23,8 +23,6 @@
namespace webrtc {
namespace testing {
using namespace rtc;
///////////////////////////////////////////////////////////////////////////////
// StreamSink - Monitor asynchronously signalled events from StreamInterface
// or AsyncSocket (which should probably be a StreamInterface.
@ -34,10 +32,10 @@ using namespace rtc;
// event.
enum StreamSinkEvent {
SSE_OPEN = SE_OPEN,
SSE_READ = SE_READ,
SSE_WRITE = SE_WRITE,
SSE_CLOSE = SE_CLOSE,
SSE_OPEN = rtc::SE_OPEN,
SSE_READ = rtc::SE_READ,
SSE_WRITE = rtc::SE_WRITE,
SSE_CLOSE = rtc::SE_CLOSE,
SSE_ERROR = 16
};
@ -46,25 +44,25 @@ class StreamSink : public sigslot::has_slots<> {
StreamSink();
~StreamSink() override;
void Monitor(StreamInterface* stream) {
void Monitor(rtc::StreamInterface* stream) {
stream->SignalEvent.connect(this, &StreamSink::OnEvent);
events_.erase(stream);
}
void Unmonitor(StreamInterface* stream) {
void Unmonitor(rtc::StreamInterface* stream) {
stream->SignalEvent.disconnect(this);
// In case you forgot to unmonitor a previous object with this address
events_.erase(stream);
}
bool Check(StreamInterface* stream,
bool Check(rtc::StreamInterface* stream,
StreamSinkEvent event,
bool reset = true) {
return DoCheck(stream, event, reset);
}
int Events(StreamInterface* stream, bool reset = true) {
int Events(rtc::StreamInterface* stream, bool reset = true) {
return DoEvents(stream, reset);
}
void Monitor(AsyncSocket* socket) {
void Monitor(rtc::AsyncSocket* socket) {
socket->SignalConnectEvent.connect(this, &StreamSink::OnConnectEvent);
socket->SignalReadEvent.connect(this, &StreamSink::OnReadEvent);
socket->SignalWriteEvent.connect(this, &StreamSink::OnWriteEvent);
@ -72,33 +70,35 @@ class StreamSink : public sigslot::has_slots<> {
// In case you forgot to unmonitor a previous object with this address
events_.erase(socket);
}
void Unmonitor(AsyncSocket* socket) {
void Unmonitor(rtc::AsyncSocket* socket) {
socket->SignalConnectEvent.disconnect(this);
socket->SignalReadEvent.disconnect(this);
socket->SignalWriteEvent.disconnect(this);
socket->SignalCloseEvent.disconnect(this);
events_.erase(socket);
}
bool Check(AsyncSocket* socket, StreamSinkEvent event, bool reset = true) {
bool Check(rtc::AsyncSocket* socket,
StreamSinkEvent event,
bool reset = true) {
return DoCheck(socket, event, reset);
}
int Events(AsyncSocket* socket, bool reset = true) {
int Events(rtc::AsyncSocket* socket, bool reset = true) {
return DoEvents(socket, reset);
}
private:
typedef std::map<void*, int> EventMap;
void OnEvent(StreamInterface* stream, int events, int error) {
void OnEvent(rtc::StreamInterface* stream, int events, int error) {
if (error) {
events = SSE_ERROR;
}
AddEvents(stream, events);
}
void OnConnectEvent(AsyncSocket* socket) { AddEvents(socket, SSE_OPEN); }
void OnReadEvent(AsyncSocket* socket) { AddEvents(socket, SSE_READ); }
void OnWriteEvent(AsyncSocket* socket) { AddEvents(socket, SSE_WRITE); }
void OnCloseEvent(AsyncSocket* socket, int error) {
void OnConnectEvent(rtc::AsyncSocket* socket) { AddEvents(socket, SSE_OPEN); }
void OnReadEvent(rtc::AsyncSocket* socket) { AddEvents(socket, SSE_READ); }
void OnWriteEvent(rtc::AsyncSocket* socket) { AddEvents(socket, SSE_WRITE); }
void OnCloseEvent(rtc::AsyncSocket* socket, int error) {
AddEvents(socket, (0 == error) ? SSE_CLOSE : SSE_ERROR);
}

View File

@ -24,7 +24,8 @@
#include <comdef.h> // NOLINT
#endif
using namespace rtc;
namespace rtc {
namespace {
// Generates a sequence of numbers (collaboratively).
class TestGenerator {
@ -669,3 +670,6 @@ TEST_F(GuardedAsyncInvokeTest, FlushWithIds) {
EXPECT_FALSE(flag1.get());
EXPECT_TRUE(flag2.get());
}
} // namespace
} // namespace rtc

View File

@ -43,7 +43,8 @@
#include "rtc_base/virtualsocketserver.h"
#include "test/gtest.h"
using namespace rtc;
namespace rtc {
namespace {
using webrtc::testing::SSE_CLOSE;
using webrtc::testing::SSE_ERROR;
@ -1143,3 +1144,6 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) {
}
}
}
} // namespace
} // namespace rtc