summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-04-30 15:40:46 +0000
committerphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>2013-04-30 15:40:46 +0000
commit94f3dc686d5f369ee596aa3e22344683f6773494 (patch)
treea4c05b5bc7386a10315a5800ea18c73f5d035d9d
parent01e7fad6acf43df86b266928f602d9709af67bae (diff)
downloadphonenumbers-94f3dc686d5f369ee596aa3e22344683f6773494.tar.gz
CPP: Move base code to i18n::phonenumbers namespace.
This is needed to avoid name clashes when the library is embedded into Chromium. BUG=http://crbug.com/236272 R=jia.shao.peng@gmail.com Review URL: https://codereview.appspot.com/9029045 git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@569 ee073f10-1060-11df-b6a4-87a95322a99c
-rw-r--r--base/basictypes.h17
-rw-r--r--base/memory/scoped_ptr.h31
-rw-r--r--base/strings/string_piece.cc6
-rw-r--r--base/strings/string_piece.h6
-rw-r--r--base/synchronization/lock.h18
-rw-r--r--base/template_util.h6
-rw-r--r--regexp_cache.cc2
-rw-r--r--regexp_cache.h2
-rw-r--r--utf/stringpiece.h2
9 files changed, 44 insertions, 46 deletions
diff --git a/base/basictypes.h b/base/basictypes.h
index 4a9d693..312252f 100644
--- a/base/basictypes.h
+++ b/base/basictypes.h
@@ -282,21 +282,4 @@ template<typename T>
inline void ignore_result(const T&) {
}
-// The following enum should be used only as a constructor argument to indicate
-// that the variable has static storage class, and that the constructor should
-// do nothing to its state. It indicates to the reader that it is legal to
-// declare a static instance of the class, provided the constructor is given
-// the base::LINKER_INITIALIZED argument. Normally, it is unsafe to declare a
-// static variable that has a constructor or a destructor because invocation
-// order is undefined. However, IF the type can be initialized by filling with
-// zeroes (which the loader does for static variables), AND the destructor also
-// does nothing to the storage, AND there are no virtual methods, then a
-// constructor declared as
-// explicit MyClass(base::LinkerInitialized x) {}
-// and invoked as
-// static MyClass my_variable_name(base::LINKER_INITIALIZED);
-namespace base {
-enum LinkerInitialized { LINKER_INITIALIZED };
-} // base
-
#endif // I18N_PHONENUMBERS_BASE_BASICTYPES_H_
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index d6147a7..5619e11 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -24,7 +24,8 @@ using boost::scoped_ptr;
#include "phonenumbers/base/basictypes.h"
#include "phonenumbers/base/template_util.h"
-namespace base {
+namespace i18n {
+namespace phonenumbers {
// Function object which deletes its parameter, which must be a pointer.
// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
@@ -47,7 +48,7 @@ struct DefaultDeleter {
// cannot convert to T*.
enum { T_must_be_complete = sizeof(T) };
enum { U_must_be_complete = sizeof(U) };
- COMPILE_ASSERT((base::is_convertible<U*, T*>::value),
+ COMPILE_ASSERT((is_convertible<U*, T*>::value),
U_ptr_must_implicitly_convert_to_T_ptr);
}
inline void operator()(T* ptr) const {
@@ -197,8 +198,8 @@ class scoped_ptr_impl {
};
} // namespace internal
-
-} // namespace base
+} // 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).
@@ -216,7 +217,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 = base::DefaultDeleter<T> >
+template <class T, class D = i18n::phonenumbers::DefaultDeleter<T> >
class scoped_ptr {
public:
// The element and deleter types.
@@ -244,7 +245,8 @@ class scoped_ptr {
// implementation of scoped_ptr.
template <typename U, typename V>
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
- COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
+ COMPILE_ASSERT(!i18n::phonenumbers::is_array<U>::value,
+ U_cannot_be_an_array);
}
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
@@ -259,7 +261,8 @@ class scoped_ptr {
// scoped_ptr.
template <typename U, typename V>
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
- COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
+ COMPILE_ASSERT(!i18n::phonenumbers::is_array<U>::value,
+ U_cannot_be_an_array);
impl_.TakeState(&rhs.impl_);
return *this;
}
@@ -287,8 +290,8 @@ 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 base::internal::scoped_ptr_impl<element_type, deleter_type>
- scoped_ptr::*Testable;
+ typedef i18n::phonenumbers::internal::scoped_ptr_impl<
+ element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
@@ -316,7 +319,8 @@ class scoped_ptr {
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class scoped_ptr;
- base::internal::scoped_ptr_impl<element_type, deleter_type> impl_;
+ i18n::phonenumbers::internal::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
@@ -372,8 +376,8 @@ 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 base::internal::scoped_ptr_impl<element_type, deleter_type>
- scoped_ptr::*Testable;
+ typedef i18n::phonenumbers::internal::scoped_ptr_impl<
+ element_type, deleter_type> scoped_ptr::*Testable;
public:
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
@@ -403,7 +407,8 @@ class scoped_ptr<T[], D> {
enum { type_must_be_complete = sizeof(element_type) };
// Actually hold the data.
- base::internal::scoped_ptr_impl<element_type, deleter_type> impl_;
+ i18n::phonenumbers::internal::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
diff --git a/base/strings/string_piece.cc b/base/strings/string_piece.cc
index 774c94e..64a4923 100644
--- a/base/strings/string_piece.cc
+++ b/base/strings/string_piece.cc
@@ -8,7 +8,8 @@
#include "phonenumbers/base/strings/string_piece.h"
-namespace base {
+namespace i18n {
+namespace phonenumbers {
typedef StringPiece::size_type size_type;
@@ -216,4 +217,5 @@ StringPiece StringPiece::substr(size_type pos, size_type n) const {
const StringPiece::size_type StringPiece::npos = size_type(-1);
-} // namespace base
+} // namespace phonenumbers
+} // namespace i18n
diff --git a/base/strings/string_piece.h b/base/strings/string_piece.h
index 8ff8633..3d856f9 100644
--- a/base/strings/string_piece.h
+++ b/base/strings/string_piece.h
@@ -23,7 +23,8 @@
#include "phonenumbers/base/basictypes.h"
-namespace base {
+namespace i18n {
+namespace phonenumbers {
class StringPiece {
public:
@@ -187,6 +188,7 @@ inline bool operator>=(const StringPiece& x, const StringPiece& y) {
return !(x < y);
}
-} // namespace base
+} // namespace phonenumbers
+} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_STRINGS_STRING_PIECE_H_
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index 502c75f..c68fefd 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -20,15 +20,20 @@
#if defined(I18N_PHONENUMBERS_USE_BOOST)
#include <boost/thread/mutex.hpp>
-namespace base {
- typedef boost::mutex Lock;
- typedef boost::mutex::scoped_lock AutoLock;
-}
+namespace i18n {
+namespace phonenumbers {
+
+typedef boost::mutex Lock;
+typedef boost::mutex::scoped_lock AutoLock;
+
+} // namespace phonenumbers
+} // namespace i18n
#else // I18N_PHONENUMBERS_USE_BOOST
#include "phonenumbers/base/thread_safety_check.h"
-namespace base {
+namespace i18n {
+namespace phonenumbers {
// Dummy lock implementation. If you care about thread-safety, please compile
// with -DI18N_PHONENUMBERS_USE_BOOST.
@@ -38,7 +43,8 @@ struct AutoLock {
AutoLock(Lock) {}
};
-} // namespace base
+} // namespace phonenumbers
+} // namespace i18n
#endif // I18N_PHONENUMBERS_USE_BOOST
#endif // I18N_PHONENUMBERS_BASE_SYNCHRONIZATION_LOCK_H_
diff --git a/base/template_util.h b/base/template_util.h
index 8076e1e..e619dc6 100644
--- a/base/template_util.h
+++ b/base/template_util.h
@@ -7,7 +7,8 @@
#include <cstddef> // For size_t.
-namespace base {
+namespace i18n {
+namespace phonenumbers {
// template definitions from tr1
@@ -101,6 +102,7 @@ struct is_class
sizeof(internal::YesType)> {
};
-} // namespace base
+} // namespace phonenumbers
+} // namespace i18n
#endif // I18N_PHONENUMBERS_BASE_TEMPLATE_UTIL_H_
diff --git a/regexp_cache.cc b/regexp_cache.cc
index 24adc5b..dbd7676 100644
--- a/regexp_cache.cc
+++ b/regexp_cache.cc
@@ -28,8 +28,6 @@ using std::string;
namespace i18n {
namespace phonenumbers {
-using base::AutoLock;
-
RegExpCache::RegExpCache(const AbstractRegExpFactory& regexp_factory,
size_t min_items)
: regexp_factory_(regexp_factory),
diff --git a/regexp_cache.h b/regexp_cache.h
index 46234c0..c2c471a 100644
--- a/regexp_cache.h
+++ b/regexp_cache.h
@@ -65,7 +65,7 @@ class RegExpCache {
private:
const AbstractRegExpFactory& regexp_factory_;
- base::Lock lock_; // protects cache_impl_
+ Lock lock_; // protects cache_impl_
scoped_ptr<CacheImpl> cache_impl_; // protected by lock_
friend class RegExpCacheTest_CacheConstructor_Test;
DISALLOW_COPY_AND_ASSIGN(RegExpCache);
diff --git a/utf/stringpiece.h b/utf/stringpiece.h
index 962b117..70d3f76 100644
--- a/utf/stringpiece.h
+++ b/utf/stringpiece.h
@@ -18,6 +18,6 @@
#include "phonenumbers/base/strings/string_piece.h"
-using base::StringPiece;
+using i18n::phonenumbers::StringPiece;
#endif // STRINGS_STRINGPIECE_H_