summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-05-03 13:49:35 +0000
committerphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-05-03 13:49:35 +0000
commitfa6ddeed736e42c266027a0d7b696909083d066b (patch)
tree03ddb871b8754439273acbf4ea88c7d05acc08af
parent96b80a3b937dfdd22d738ab9a71bfb10d5c5ad60 (diff)
downloadphonenumbers-fa6ddeed736e42c266027a0d7b696909083d066b.tar.gz
CPP: Make r570 compile in Chromium.
This CL ensures that: - All declarations in headers are made in the i18n::phonenumbers namespace. - All USE flags/macros are prefixed with I18N_PHONENUMBERS_ to avoid name clashes. - All the code in base/ is actually used (by deleting unused code). - Outdated occurrences of USE_GOOGLE_BASE don't exist anymore. - Logging in PhoneNumberUtil is disabled by default (in production). However it can be enabled by calling PhoneNumberUtil::SetLogger() as it is now done during testing. BUG=http://crbug.com/236272 R=jia.shao.peng@gmail.com Review URL: https://codereview.appspot.com/9162043 git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@571 ee073f10-1060-11df-b6a4-87a95322a99c
-rw-r--r--base/basictypes.h107
-rw-r--r--base/memory/scoped_ptr.h29
-rw-r--r--base/thread_checker.h9
-rw-r--r--default_logger.cc5
-rw-r--r--default_logger.h29
-rw-r--r--phonenumbermatcher.cc41
-rw-r--r--phonenumberutil.cc9
-rw-r--r--phonenumberutil.h17
-rw-r--r--regexp_cache.cc2
-rw-r--r--regexp_cache.h4
-rw-r--r--regexp_factory.h14
-rw-r--r--utf/unicodetext.cc7
-rw-r--r--utf/unicodetext.h7
-rw-r--r--utf/unilib.cc4
-rw-r--r--utf/unilib.h4
15 files changed, 81 insertions, 207 deletions
diff --git a/base/basictypes.h b/base/basictypes.h
index 312252f..a35e9fc 100644
--- a/base/basictypes.h
+++ b/base/basictypes.h
@@ -4,7 +4,6 @@
#ifndef I18N_PHONENUMBERS_BASE_BASICTYPES_H_
#define I18N_PHONENUMBERS_BASE_BASICTYPES_H_
-#pragma once
#include <limits.h> // So we can set the bounds of our types
#include <stddef.h> // For size_t
@@ -15,6 +14,9 @@
#include <stdint.h> // For intptr_t.
#endif
+namespace i18n {
+namespace phonenumbers {
+
#ifdef INT64_MAX
// INT64_MAX is defined if C99 stdint.h is included; use the
@@ -94,26 +96,11 @@ typedef signed int char32;
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
+#if !defined(DISALLOW_COPY_AND_ASSIGN)
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
-
-// An older, deprecated, politically incorrect name for the above.
-// NOTE: The usage of this macro was baned from our code base, but some
-// third_party libraries are yet using it.
-// TODO(tfarina): Figure out how to fix the usage of this macro in the
-// third_party libraries and get rid of it.
-#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
-
-// A macro to disallow all the implicit constructors, namely the
-// default constructor, copy constructor and operator= functions.
-//
-// This should be used in the private: declarations for a class
-// that wants to prevent anyone from instantiating it. This is
-// especially useful for classes containing only static methods.
-#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
- TypeName(); \
- DISALLOW_COPY_AND_ASSIGN(TypeName)
+#endif
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
@@ -140,7 +127,9 @@ template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif
+#if !defined(arraysize)
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+#endif
// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
// but can be used on anonymous types or types defined inside
@@ -179,32 +168,11 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
// where a pointer is 4 bytes, this means all pointers to a type whose
// size is 3 or greater than 4 will be (righteously) rejected.
+#if !defined(ARRAYSIZE_UNSAFE)
#define ARRAYSIZE_UNSAFE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
-
-
-// Use implicit_cast as a safe version of static_cast or const_cast
-// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
-// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
-// a const pointer to Foo).
-// When you use implicit_cast, the compiler checks that the cast is safe.
-// Such explicit implicit_casts are necessary in surprisingly many
-// situations where C++ demands an exact type match instead of an
-// argument type convertable to a target type.
-//
-// The From type can be inferred, so the preferred syntax for using
-// implicit_cast is the same as for static_cast etc.:
-//
-// implicit_cast<ToType>(expr)
-//
-// implicit_cast would have been part of the C++ standard library,
-// but the proposal was submitted too late. It will probably make
-// its way into the language in the future.
-template<typename To, typename From>
-inline To implicit_cast(From const &f) {
- return f;
-}
+#endif
// The COMPILE_ASSERT macro can be used to verify that a compile time
// expression is true. For example, you could use it to verify the
@@ -225,61 +193,12 @@ template <bool>
struct CompileAssert {
};
-#undef COMPILE_ASSERT
+#if !defined(COMPILE_ASSERT)
#define COMPILE_ASSERT(expr, msg) \
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+#endif
-// Implementation details of COMPILE_ASSERT:
-//
-// - COMPILE_ASSERT works by defining an array type that has -1
-// elements (and thus is invalid) when the expression is false.
-//
-// - The simpler definition
-//
-// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
-//
-// does not work, as gcc supports variable-length arrays whose sizes
-// are determined at run-time (this is gcc's extension and not part
-// of the C++ standard). As a result, gcc fails to reject the
-// following code with the simple definition:
-//
-// int foo;
-// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
-// // not a compile-time constant.
-//
-// - By using the type CompileAssert<(bool(expr))>, we ensures that
-// expr is a compile-time constant. (Template arguments must be
-// determined at compile-time.)
-//
-// - The outter parentheses in CompileAssert<(bool(expr))> are necessary
-// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
-//
-// CompileAssert<bool(expr)>
-//
-// instead, these compilers will refuse to compile
-//
-// COMPILE_ASSERT(5 > 0, some_message);
-//
-// (They seem to think the ">" in "5 > 0" marks the end of the
-// template argument list.)
-//
-// - The array size is (bool(expr) ? 1 : -1), instead of simply
-//
-// ((expr) ? 1 : -1).
-//
-// This is to avoid running into a bug in MS VC 7.1, which
-// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
-
-// Used to explicitly mark the return value of a function as unused. If you are
-// really sure you don't want to do anything with the return value of a function
-// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
-//
-// scoped_ptr<MyType> my_var = ...;
-// if (TakeOwnership(my_var.get()) == SUCCESS)
-// ignore_result(my_var.release());
-//
-template<typename T>
-inline void ignore_result(const T&) {
-}
+} // namespace phonenumbers
+} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_BASICTYPES_H_
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index 5619e11..5c3e931 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -93,8 +93,6 @@ struct FreeDeleter {
}
};
-namespace internal {
-
// Minimal implementation of the core logic of scoped_ptr, suitable for
// reuse in both scoped_ptr and its specializations.
template <class T, class D>
@@ -197,10 +195,6 @@ class scoped_ptr_impl {
DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl);
};
-} // namespace internal
-} // namespace phonenumbers
-} // namespace i18n
-
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
// automatically deletes the pointer it holds (if any).
// That is, scoped_ptr<T> owns the T object that it points to.
@@ -217,7 +211,7 @@ class scoped_ptr_impl {
// unique_ptr<> features. Known deficiencies include not supporting move-only
// deleteres, function pointers as deleters, and deleters with reference
// types.
-template <class T, class D = i18n::phonenumbers::DefaultDeleter<T> >
+template <class T, class D = DefaultDeleter<T> >
class scoped_ptr {
public:
// The element and deleter types.
@@ -245,8 +239,7 @@ class scoped_ptr {
// implementation of scoped_ptr.
template <typename U, typename V>
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
- COMPILE_ASSERT(!i18n::phonenumbers::is_array<U>::value,
- U_cannot_be_an_array);
+ COMPILE_ASSERT(!is_array<U>::value, U_cannot_be_an_array);
}
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
@@ -261,8 +254,7 @@ class scoped_ptr {
// scoped_ptr.
template <typename U, typename V>
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
- COMPILE_ASSERT(!i18n::phonenumbers::is_array<U>::value,
- U_cannot_be_an_array);
+ COMPILE_ASSERT(!is_array<U>::value, U_cannot_be_an_array);
impl_.TakeState(&rhs.impl_);
return *this;
}
@@ -290,8 +282,7 @@ class scoped_ptr {
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
- typedef i18n::phonenumbers::internal::scoped_ptr_impl<
- element_type, deleter_type> scoped_ptr::*Testable;
+ typedef scoped_ptr_impl<element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
@@ -319,8 +310,7 @@ class scoped_ptr {
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class scoped_ptr;
- i18n::phonenumbers::internal::scoped_ptr_impl<
- element_type, deleter_type> impl_;
+ scoped_ptr_impl<element_type, deleter_type> impl_;
// Forbid comparison of scoped_ptr types. If U != T, it totally
// doesn't make sense, and if U == T, it still doesn't make sense
@@ -376,8 +366,7 @@ class scoped_ptr<T[], D> {
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
// implicitly convertible to a real bool (which is dangerous).
private:
- typedef i18n::phonenumbers::internal::scoped_ptr_impl<
- element_type, deleter_type> scoped_ptr::*Testable;
+ typedef scoped_ptr_impl<element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
@@ -407,8 +396,7 @@ class scoped_ptr<T[], D> {
enum { type_must_be_complete = sizeof(element_type) };
// Actually hold the data.
- i18n::phonenumbers::internal::scoped_ptr_impl<
- element_type, deleter_type> impl_;
+ scoped_ptr_impl<element_type, deleter_type> impl_;
// Disable initialization from any type other than element_type*, by
// providing a constructor that matches such an initialization, but is
@@ -455,5 +443,8 @@ scoped_ptr<T> make_scoped_ptr(T* ptr) {
return scoped_ptr<T>(ptr);
}
+} // namespace phonenumbers
+} // namespace i18n
+
#endif // !I18N_PHONENUMBERS_USE_BOOST
#endif // I18N_PHONENUMBERS_BASE_MEMORY_SCOPED_PTR_H_
diff --git a/base/thread_checker.h b/base/thread_checker.h
index 38ef54c..bac8048 100644
--- a/base/thread_checker.h
+++ b/base/thread_checker.h
@@ -14,8 +14,8 @@
// Author: Philippe Liard
-#ifndef I18N_PHONENUMBERS_BASE_THREAD_SAFETY_CHECK_H_
-#define I18N_PHONENUMBERS_BASE_THREAD_SAFETY_CHECK_H_
+#ifndef I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
+#define I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
#if !defined(I18N_PHONENUMBERS_USE_BOOST)
@@ -23,7 +23,8 @@
// user of the library know that it can't be used in a thread-safe manner when
// it is not depending on Boost.
#if !defined(I18N_PHONENUMBERS_NO_THREAD_SAFETY)
-#error "Building without Boost, please provide -DNO_THREAD_SAFETY"
+#error Building without Boost, please provide \
+ -DI18N_PHONENUMBERS_NO_THREAD_SAFETY
#endif
#endif
@@ -65,4 +66,4 @@ class ThreadChecker {
} // namespace phonenumbers
} // namespace i18n
-#endif // I18N_PHONENUMBERS_BASE_THREAD_SAFETY_CHECK_H_
+#endif // I18N_PHONENUMBERS_BASE_THREAD_CHECKER_H_
diff --git a/default_logger.cc b/default_logger.cc
index 49d5513..44379a5 100644
--- a/default_logger.cc
+++ b/default_logger.cc
@@ -14,9 +14,6 @@
// Author: Philippe Liard
-// This file should not be compiled when using Google base/.
-#ifndef USE_GOOGLE_BASE
-
#include <iostream>
#include "phonenumbers/default_logger.h"
@@ -50,5 +47,3 @@ void StdoutLogger::WriteLevel() {
} // namespace phonenumbers
} // namespace i18n
-
-#endif // USE_GOOGLE_BASE
diff --git a/default_logger.h b/default_logger.h
index d6ba050..afb6fc9 100644
--- a/default_logger.h
+++ b/default_logger.h
@@ -19,33 +19,16 @@
#include "phonenumbers/logger.h"
-#ifdef USE_GOOGLE_BASE
+#include <sstream>
+#include <string>
namespace i18n {
namespace phonenumbers {
-// If Google base/ is used, LOG() and VLOG() from base/logging.h are used
-// therefore the default logger implementation (StdoutLogger) instantiated in
-// phonenumberutil will actually never be used.
-typedef NullLogger StdoutLogger;
-
-} // namespace phonenumbers
-} // namespace i18n
-
-#else
-
-#include <sstream>
-#include <string>
-
+using i18n::phonenumbers::Logger;
using std::string;
using std::stringstream;
-// Make the logging functions private (not declared in logger.h) as the client
-// should not have any reason to use them.
-namespace {
-
-using i18n::phonenumbers::Logger;
-
// Class template used to inline the right implementation for the T -> string
// conversion.
template <typename T>
@@ -91,11 +74,6 @@ class LoggerHandler {
Logger* const impl_;
};
-} // namespace
-
-namespace i18n {
-namespace phonenumbers {
-
inline LoggerHandler VLOG(int n) {
Logger* const logger_impl = Logger::mutable_logger_impl();
if (logger_impl->level() < n) {
@@ -122,5 +100,4 @@ class StdoutLogger : public Logger {
} // namespace phonenumbers
} // namespace i18n
-#endif // USE_GOOGLE_BASE
#endif // I18N_PHONENUMBERS_DEFAULT_LOGGER_H_
diff --git a/phonenumbermatcher.cc b/phonenumbermatcher.cc
index 039ff90..9446226 100644
--- a/phonenumbermatcher.cc
+++ b/phonenumbermatcher.cc
@@ -20,9 +20,10 @@
#include "phonenumbers/phonenumbermatcher.h"
-#ifndef USE_ICU_REGEXP
-#error phonenumbermatcher depends on ICU (i.e. USE_ICU_REGEXP must be set)
-#endif // USE_ICU_REGEXP
+#ifndef I18N_PHONENUMBERS_USE_ICU_REGEXP
+#error phonenumbermatcher depends on ICU \
+ (i.e. I18N_PHONENUMBERS_USE_ICU_REGEXP must be set)
+#endif // I18N_PHONENUMBERS_USE_ICU_REGEXP
#include <ctype.h>
#include <iostream>
@@ -51,9 +52,9 @@
#include "phonenumbers/regexp_adapter_icu.h"
#include "phonenumbers/stringutil.h"
-#ifdef USE_RE2
+#ifdef I18N_PHONENUMBERS_USE_RE2
#include "phonenumbers/regexp_adapter_re2.h"
-#endif // USE_RE2_AND_ICU
+#endif // I18N_PHONENUMBERS_USE_RE2_AND_ICU
using std::cerr;
using std::endl;
@@ -168,14 +169,10 @@ bool LoadAlternateFormats(PhoneMetadataCollection* alternate_formats) {
}
} // namespace
-#ifdef USE_GOOGLE_BASE
-class PhoneNumberMatcherRegExps {
- friend struct DefaultSingletonTraits<PhoneNumberMatcherRegExps>;
-#else
class PhoneNumberMatcherRegExps : public Singleton<PhoneNumberMatcherRegExps> {
- friend class Singleton<PhoneNumberMatcherRegExps>;
-#endif // USE_GOOGLE_BASE
private:
+ friend class Singleton<PhoneNumberMatcherRegExps>;
+
string opening_parens_;
string closing_parens_;
string non_parens_;
@@ -248,12 +245,6 @@ class PhoneNumberMatcherRegExps : public Singleton<PhoneNumberMatcherRegExps> {
// Phone number pattern allowing optional punctuation.
scoped_ptr<const RegExp> pattern_;
-#ifdef USE_GOOGLE_BASE
- static PhoneNumberMatcherRegExps* GetInstance() {
- return Singleton<PhoneNumberMatcherRegExps>::get();
- }
-#endif // USE_GOOGLE_BASE
-
PhoneNumberMatcherRegExps()
: opening_parens_("(\\[\xEF\xBC\x88\xEF\xBC\xBB" /* "(\\[([" */),
closing_parens_(")\\]\xEF\xBC\x89\xEF\xBC\xBD" /* ")\\])]" */),
@@ -281,11 +272,11 @@ class PhoneNumberMatcherRegExps : public Singleton<PhoneNumberMatcherRegExps> {
PhoneNumberUtil::GetInstance()->GetExtnPatternsForMatching(),
")?")),
regexp_factory_for_pattern_(new ICURegExpFactory()),
-#ifdef USE_RE2
+#ifdef I18N_PHONENUMBERS_USE_RE2
regexp_factory_(new RE2RegExpFactory()),
#else
regexp_factory_(new ICURegExpFactory()),
-#endif // USE_RE2
+#endif // I18N_PHONENUMBERS_USE_RE2
pub_pages_(regexp_factory_->CreateRegExp(
"\\d{1,5}-+\\d{1,5}\\s{0,4}\\(\\d{1,4}")),
slash_separated_dates_(regexp_factory_->CreateRegExp(
@@ -315,24 +306,12 @@ class PhoneNumberMatcherRegExps : public Singleton<PhoneNumberMatcherRegExps> {
DISALLOW_COPY_AND_ASSIGN(PhoneNumberMatcherRegExps);
};
-#ifdef USE_GOOGLE_BASE
-class AlternateFormats {
- friend struct DefaultSingletonTraits<AlternateFormats>;
-#else
class AlternateFormats : public Singleton<AlternateFormats> {
- friend class Singleton<AlternateFormats>;
-#endif // USE_GOOGLE_BASE
public:
PhoneMetadataCollection format_data_;
map<int, const PhoneMetadata*> calling_code_to_alternate_formats_map_;
-#ifdef USE_GOOGLE_BASE
- static AlternateFormats* GetInstance() {
- return Singleton<AlternateFormats>::get();
- }
-#endif // USE_GOOGLE_BASE
-
AlternateFormats()
: format_data_(),
calling_code_to_alternate_formats_map_() {
diff --git a/phonenumberutil.cc b/phonenumberutil.cc
index a7967a7..317e14a 100644
--- a/phonenumberutil.cc
+++ b/phonenumberutil.cc
@@ -369,7 +369,8 @@ PhoneNumberUtil::ValidationResult TestNumberLengthAgainstPattern(
} // namespace
void PhoneNumberUtil::SetLogger(Logger* logger) {
- Logger::set_logger_impl(logger);
+ logger_.reset(logger);
+ Logger::set_logger_impl(logger_.get());
}
class PhoneNumberRegExpsAndMappings {
@@ -657,7 +658,7 @@ class PhoneNumberRegExpsAndMappings {
// Private constructor. Also takes care of initialisation.
PhoneNumberUtil::PhoneNumberUtil()
- : logger_(Logger::set_logger_impl(new StdoutLogger())),
+ : logger_(Logger::set_logger_impl(new NullLogger())),
reg_exps_(new PhoneNumberRegExpsAndMappings),
country_calling_code_to_region_code_map_(new vector<IntRegionsPair>()),
nanpa_regions_(new set<string>()),
@@ -739,11 +740,9 @@ void PhoneNumberUtil::GetSupportedRegions(set<string>* regions) const {
// Public wrapper function to get a PhoneNumberUtil instance with the default
// metadata file.
// static
-#ifdef USE_GOOGLE_BASE
PhoneNumberUtil* PhoneNumberUtil::GetInstance() {
- return Singleton<PhoneNumberUtil>::get();
+ return Singleton<PhoneNumberUtil>::GetInstance();
}
-#endif
const string& PhoneNumberUtil::GetExtnPatternsForMatching() const {
return reg_exps_->extn_patterns_for_matching_;
diff --git a/phonenumberutil.h b/phonenumberutil.h
index 1ba4ddf..528e584 100644
--- a/phonenumberutil.h
+++ b/phonenumberutil.h
@@ -59,13 +59,8 @@ class RegExp;
// codes can be found here:
// http://www.iso.org/iso/english_country_names_and_code_elements
-#ifdef USE_GOOGLE_BASE
-class PhoneNumberUtil {
- friend struct DefaultSingletonTraits<PhoneNumberUtil>;
-#else
class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
- friend class Singleton<PhoneNumberUtil>;
-#endif
+ private:
friend class AsYouTypeFormatter;
friend class PhoneNumberMatcher;
friend class PhoneNumberMatcherRegExps;
@@ -74,6 +69,8 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
friend class PhoneNumberUtilTest;
friend class ShortNumberUtil;
friend class ShortNumberUtilTest;
+ friend class Singleton<PhoneNumberUtil>;
+
public:
~PhoneNumberUtil();
static const char kRegionCodeForNonGeoEntity[];
@@ -172,9 +169,7 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
//
// The PhoneNumberUtil is implemented as a singleton. Therefore, calling
// GetInstance multiple times will only result in one instance being created.
-#ifdef USE_GOOGLE_BASE
static PhoneNumberUtil* GetInstance();
-#endif
// Returns true if the number is a valid vanity (alpha) number such as 800
// MICROSOFT. A valid vanity number will start with at least 3 digits and will
@@ -552,9 +547,9 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
MatchType IsNumberMatchWithOneString(const PhoneNumber& first_number,
const string& second_number) const;
- // Overrides the default logging system. The provided logger destruction is
- // handled by this class (i.e don't delete it).
- static void SetLogger(Logger* logger);
+ // Overrides the default logging system. This takes ownership of the provided
+ // logger.
+ void SetLogger(Logger* logger);
// Gets an AsYouTypeFormatter for the specific region.
// Returns an AsYouTypeFormatter object, which could be used to format phone
diff --git a/regexp_cache.cc b/regexp_cache.cc
index dbd7676..d010aee 100644
--- a/regexp_cache.cc
+++ b/regexp_cache.cc
@@ -31,7 +31,7 @@ namespace phonenumbers {
RegExpCache::RegExpCache(const AbstractRegExpFactory& regexp_factory,
size_t min_items)
: regexp_factory_(regexp_factory),
-#ifdef USE_TR1_UNORDERED_MAP
+#ifdef I18N_PHONENUMBERS_USE_TR1_UNORDERED_MAP
cache_impl_(new CacheImpl(min_items))
#else
cache_impl_(new CacheImpl())
diff --git a/regexp_cache.h b/regexp_cache.h
index c2c471a..75fcace 100644
--- a/regexp_cache.h
+++ b/regexp_cache.h
@@ -34,7 +34,7 @@
#include "phonenumbers/base/memory/scoped_ptr.h"
#include "phonenumbers/base/synchronization/lock.h"
-#ifdef USE_TR1_UNORDERED_MAP
+#ifdef I18N_PHONENUMBERS_USE_TR1_UNORDERED_MAP
# include <tr1/unordered_map>
#else
# include <map>
@@ -50,7 +50,7 @@ class RegExp;
class RegExpCache {
private:
-#ifdef USE_TR1_UNORDERED_MAP
+#ifdef I18N_PHONENUMBERS_USE_TR1_UNORDERED_MAP
typedef std::tr1::unordered_map<string, const RegExp*> CacheImpl;
#else
typedef std::map<string, const RegExp*> CacheImpl;
diff --git a/regexp_factory.h b/regexp_factory.h
index 318896a..3e69b43 100644
--- a/regexp_factory.h
+++ b/regexp_factory.h
@@ -18,25 +18,25 @@
#define I18N_PHONENUMBERS_REGEXP_ADAPTER_FACTORY_H_
// This file selects the right implementation of the abstract regexp factory at
-// compile time depending on the compilation flags (USE_RE2). The default
-// abstract regexp factory implementation can be obtained using the type
-// RegExpFactory. This will be set to RE2RegExpFactory if RE2 is used or
+// compile time depending on the compilation flags (I18N_PHONENUMBERS_USE_RE2).
+// The default abstract regexp factory implementation can be obtained using the
+// type RegExpFactory. This will be set to RE2RegExpFactory if RE2 is used or
// ICURegExpFactory otherwise.
-#ifdef USE_RE2
+#ifdef I18N_PHONENUMBERS_USE_RE2
#include "phonenumbers/regexp_adapter_re2.h"
#else
#include "phonenumbers/regexp_adapter_icu.h"
-#endif // USE_RE2
+#endif // I18N_PHONENUMBERS_USE_RE2
namespace i18n {
namespace phonenumbers {
-#ifdef USE_RE2
+#ifdef I18N_PHONENUMBERS_USE_RE2
typedef RE2RegExpFactory RegExpFactory;
#else
typedef ICURegExpFactory RegExpFactory;
-#endif // USE_RE2
+#endif // I18N_PHONENUMBERS_USE_RE2
} // namespace phonenumbers
} // namespace i18n
diff --git a/utf/unicodetext.cc b/utf/unicodetext.cc
index 262a129..175d1f9 100644
--- a/utf/unicodetext.cc
+++ b/utf/unicodetext.cc
@@ -19,12 +19,14 @@
#include <cassert>
#include "phonenumbers/utf/unicodetext.h"
-//#include "phonenumbers/base/logging.h"
#include "phonenumbers/utf/stringpiece.h"
//#include "utf/stringprintf.h"
#include "phonenumbers/utf/utf.h"
#include "phonenumbers/utf/unilib.h"
+namespace i18n {
+namespace phonenumbers {
+
using std::stringstream;
using std::max;
using std::hex;
@@ -512,3 +514,6 @@ string UnicodeText::const_iterator::DebugString() const {
return result;
}
+
+} // namespace phonenumbers
+} // namespace i18n
diff --git a/utf/unicodetext.h b/utf/unicodetext.h
index 990842d..5c1d584 100644
--- a/utf/unicodetext.h
+++ b/utf/unicodetext.h
@@ -21,7 +21,9 @@
#include <string>
#include <utility>
#include "phonenumbers/base/basictypes.h"
-//#include "util/utf8/public/config.h"
+
+namespace i18n {
+namespace phonenumbers {
using std::string;
using std::bidirectional_iterator_tag;
@@ -453,4 +455,7 @@ inline string UnicodeTextToUTF8(const UnicodeText& t) {
return string(t.utf8_data(), t.utf8_length());
}
+} // namespace phonenumbers
+} // namespace i18n
+
#endif // UTIL_UTF8_UNICODETEXT_H__
diff --git a/utf/unilib.cc b/utf/unilib.cc
index 064c724..ffcb8b0 100644
--- a/utf/unilib.cc
+++ b/utf/unilib.cc
@@ -21,6 +21,8 @@
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/utf/utf.h"
+namespace i18n {
+namespace phonenumbers {
namespace UniLib {
namespace {
@@ -62,3 +64,5 @@ int SpanInterchangeValid(const char* begin, int byte_length) {
}
} // namespace UniLib
+} // namespace phonenumbers
+} // namespace i18n
diff --git a/utf/unilib.h b/utf/unilib.h
index b70966c..1230002 100644
--- a/utf/unilib.h
+++ b/utf/unilib.h
@@ -34,6 +34,8 @@
#include <string>
#include "phonenumbers/base/basictypes.h"
+namespace i18n {
+namespace phonenumbers {
namespace UniLib {
// Returns true unless a surrogate code point
@@ -91,5 +93,7 @@ inline bool IsInterchangeValid(const std::string& src) {
}
} // namespace UniLib
+} // namespace phonenumbers
+} // namespace i18n
#endif // UTIL_UTF8_PUBLIC_UNILIB_H_