summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-10-18 09:56:13 +0000
committerphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-10-18 09:56:13 +0000
commit8d8b5b3b2035197795d27573d4cf566b5d9ad689 (patch)
tree3f423e7042eb9e1e94aef2081bfbc4bd8c48f4dc
parent18404d8ed386420aabe8027d3c1da1d06a03f696 (diff)
downloadphonenumbers-8d8b5b3b2035197795d27573d4cf566b5d9ad689.tar.gz
CPP: Remove uses of std::{cerr,endl} in production code.
They generated static initializers on Clang/Mac. This also adds the previously missing <algorithm> include in unicodetext.cc causing a compilation error on VS2013. This is a squash of (very slightly modified) patches contributed by thakis@ and yosin@. R=roes@google.com Review URL: https://codereview.appspot.com/14930044 git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@621 ee073f10-1060-11df-b6a4-87a95322a99c
-rw-r--r--phonenumbermatcher.cc5
-rw-r--r--phonenumberutil.cc11
-rw-r--r--shortnumberinfo.cc4
-rw-r--r--utf/unicodetext.cc16
4 files changed, 11 insertions, 25 deletions
diff --git a/phonenumbermatcher.cc b/phonenumbermatcher.cc
index 156717d..2c0f619 100644
--- a/phonenumbermatcher.cc
+++ b/phonenumbermatcher.cc
@@ -27,7 +27,6 @@
#include <ctype.h>
#include <stddef.h>
-#include <iostream>
#include <limits>
#include <map>
#include <string>
@@ -56,8 +55,6 @@
#include "phonenumbers/regexp_adapter_re2.h"
#endif // I18N_PHONENUMBERS_USE_RE2_AND_ICU
-using std::cerr;
-using std::endl;
using std::make_pair;
using std::map;
using std::numeric_limits;
@@ -173,7 +170,7 @@ bool LoadAlternateFormats(PhoneMetadataCollection* alternate_formats) {
#if defined(I18N_PHONENUMBERS_USE_ALTERNATE_FORMATS)
if (!alternate_formats->ParseFromArray(alternate_format_get(),
alternate_format_size())) {
- cerr << "Could not parse binary data." << endl;
+ LOG(ERROR) << "Could not parse binary data.";
return false;
}
return true;
diff --git a/phonenumberutil.cc b/phonenumberutil.cc
index d966a35..fcca95f 100644
--- a/phonenumberutil.cc
+++ b/phonenumberutil.cc
@@ -17,14 +17,11 @@
#include "phonenumbers/phonenumberutil.h"
-#include <string.h>
#include <algorithm>
#include <cctype>
-#include <fstream>
-#include <iostream>
+#include <cstring>
#include <iterator>
#include <map>
-#include <sstream>
#include <utility>
#include <vector>
@@ -55,12 +52,8 @@
namespace i18n {
namespace phonenumbers {
-using std::cerr;
-using std::endl;
-using std::ifstream;
using std::make_pair;
using std::sort;
-using std::stringstream;
using google::protobuf::RepeatedPtrField;
@@ -118,7 +111,7 @@ const char kSingleExtnSymbolsForMatching[] =
bool LoadCompiledInMetadata(PhoneMetadataCollection* metadata) {
if (!metadata->ParseFromArray(metadata_get(), metadata_size())) {
- cerr << "Could not parse binary data." << endl;
+ LOG(ERROR) << "Could not parse binary data.";
return false;
}
return true;
diff --git a/shortnumberinfo.cc b/shortnumberinfo.cc
index 82b2f18..ad72b20 100644
--- a/shortnumberinfo.cc
+++ b/shortnumberinfo.cc
@@ -31,15 +31,13 @@
namespace i18n {
namespace phonenumbers {
-using std::cerr;
-using std::endl;
using std::make_pair;
using std::map;
using std::string;
bool LoadCompiledInMetadata(PhoneMetadataCollection* metadata) {
if (!metadata->ParseFromArray(short_metadata_get(), short_metadata_size())) {
- cerr << "Could not parse binary data." << endl;
+ LOG(ERROR) << "Could not parse binary data.";
return false;
}
return true;
diff --git a/utf/unicodetext.cc b/utf/unicodetext.cc
index 175d1f9..55ffedf 100644
--- a/utf/unicodetext.cc
+++ b/utf/unicodetext.cc
@@ -14,9 +14,10 @@
// Author: Jim Meehan
-#include <iostream>
+#include <algorithm>
#include <sstream>
#include <cassert>
+#include <cstdio>
#include "phonenumbers/utf/unicodetext.h"
#include "phonenumbers/utf/stringpiece.h"
@@ -31,8 +32,6 @@ using std::stringstream;
using std::max;
using std::hex;
using std::dec;
-using std::cerr;
-using std::endl;
static int CodepointDistance(const char* start, const char* end) {
int n = 0;
@@ -232,7 +231,7 @@ UnicodeText& UnicodeText::Copy(const UnicodeText& src) {
UnicodeText& UnicodeText::CopyUTF8(const char* buffer, int byte_length) {
repr_.Copy(buffer, byte_length);
if (!UniLib:: IsInterchangeValid(buffer, byte_length)) {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.\n");
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
return *this;
@@ -251,7 +250,7 @@ UnicodeText& UnicodeText::TakeOwnershipOfUTF8(char* buffer,
int byte_capacity) {
repr_.TakeOwnershipOf(buffer, byte_length, byte_capacity);
if (!UniLib:: IsInterchangeValid(buffer, byte_length)) {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.\n");
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
return *this;
@@ -270,7 +269,7 @@ UnicodeText& UnicodeText::PointToUTF8(const char* buffer, int byte_length) {
if (UniLib:: IsInterchangeValid(buffer, byte_length)) {
repr_.PointTo(buffer, byte_length);
} else {
- cerr << "UTF-8 buffer is not interchange-valid." << endl;
+ fprintf(stderr, "UTF-8 buffer is not interchange-valid.");
repr_.Copy(buffer, byte_length);
repr_.size_ = ConvertToInterchangeValid(repr_.data_, byte_length);
}
@@ -367,12 +366,11 @@ void UnicodeText::push_back(char32 c) {
if (UniLib::IsInterchangeValid(buf, len)) {
repr_.append(buf, len);
} else {
- cerr << "Unicode value 0x" << hex << c
- << " is not valid for interchange" << endl;
+ fprintf(stderr, "Unicode value 0x%x is not valid for interchange\n", c);
repr_.append(" ", 1);
}
} else {
- cerr << "Illegal Unicode value: 0x" << hex << c << endl;
+ fprintf(stderr, "Illegal Unicode value: 0x%x\n", c);
repr_.append(" ", 1);
}
}