Browse Source

Update phonenumber proto and logging.

pull/567/head
Philip Liard 15 years ago
committed by Mihaela Rosca
parent
commit
8505b3840d
4 changed files with 56 additions and 12 deletions
  1. +33
    -1
      cpp/CMakeLists.txt
  2. +5
    -5
      cpp/src/default_logger.cc
  3. +6
    -6
      cpp/src/default_logger.h
  4. +12
    -0
      cpp/src/phonenumber.proto

+ 33
- 1
cpp/CMakeLists.txt View File

@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: Philippe Liard
cmake_minimum_required (VERSION 2.8)
project (libphonenumber)
@ -61,6 +64,25 @@ if (PROTOC STREQUAL "PROTOC-NOTFOUND")
"Please read README.")
endif ()
# Find ICU
find_path (ICU_INCLUDE_DIR unicode/unistr.h unicode/normlzr.h)
if (ICU_INCLUDE_DIR STREQUAL "ICU_INCLUDE_DIR-NOTFOUND")
message (FATAL_ERROR
"Can't find ICU headers. Please read README.")
endif ()
include_directories (${ICU_INCLUDE_DIR})
find_library (ICU_LIB icui18n)
if (ICU_LIB STREQUAL "ICU_LIB-NOTFOUND")
message (FATAL_ERROR
"Can't find ICU library. Please read README.")
endif ()
# Add protoc (Protocol Buffers compiler) target
set (
PROTOBUF_SOURCES "${CMAKE_SOURCE_DIR}/src/phonemetadata.proto"
@ -95,12 +117,20 @@ set (
SOURCES
"src/base/at_exit.cc"
"src/base/lazy_instance.cc"
"src/base/string_piece.cc"
"src/base/synchronization/lock.cc"
"src/base/threading/thread_restrictions.cc"
"src/default_logger.cc"
"src/logger_adapter.cc"
"src/metadata.cc" # Generated by src/embed_binary_data.sh
"src/phonemetadata.pb.cc" # Generated by Protocol Buffers
"src/phonenumber.pb.cc" # Generated by Protocol Buffers
"src/phonenumberutil.cc"
"src/re2_cache.cc"
"src/stringutil.cc"
"src/utf/rune.c"
"src/utf/unicodetext.cc"
"src/utf/unilib.cc"
)
if (UNIX)
@ -141,11 +171,12 @@ endif ()
include_directories ("src")
include_directories (".")
add_library (phonenumber STATIC ${SOURCES})
add_dependencies (phonenumber generate-sources)
target_link_libraries (phonenumber re2)
target_link_libraries (phonenumber re2 protobuf icui18n)
# Tests
@ -154,6 +185,7 @@ set (TEST_SOURCES
"src/re2_cache_test.cc"
"src/run_tests.cc"
"src/stringutil_test.cc"
"src/test_metadata.cc"
)
add_executable (libphonenumber_test ${TEST_SOURCES})


+ 5
- 5
cpp/src/default_logger.cc View File

@ -30,31 +30,31 @@ DefaultLogger::DefaultLogger(LogLevel level) : level_(level) {}
DefaultLogger::~DefaultLogger() {}
void DefaultLogger::Fatal(const string& msg) const {
if (level_ >= FATAL) {
if (level_ >= LOG_FATAL) {
cerr << "FATAL libphonenumber " << msg << endl;
}
}
void DefaultLogger::Error(const string& msg) const {
if (level_ >= ERROR) {
if (level_ >= LOG_ERROR) {
cerr << "ERROR libphonenumber " << msg << endl;
}
}
void DefaultLogger::Warning(const string& msg) const {
if (level_ >= WARNING) {
if (level_ >= LOG_WARNING) {
cerr << "WARNING libphonenumber " << msg << endl;
}
}
void DefaultLogger::Info(const string& msg) const {
if (level_ >= INFO) {
if (level_ >= LOG_INFO) {
cout << "INFO libphonenumber " << msg << endl;
}
}
void DefaultLogger::Debug(const string& msg) const {
if (level_ >= DEBUG) {
if (level_ >= LOG_DEBUG) {
cout << "DEBUG libphonenumber " << msg << endl;
}
}


+ 6
- 6
cpp/src/default_logger.h View File

@ -23,18 +23,18 @@ namespace i18n {
namespace phonenumbers {
enum LogLevel {
FATAL,
ERROR,
WARNING,
INFO,
DEBUG,
LOG_FATAL,
LOG_ERROR,
LOG_WARNING,
LOG_INFO,
LOG_DEBUG,
};
class DefaultLogger : public LoggerAdapter {
public:
virtual ~DefaultLogger();
DefaultLogger(LogLevel level = WARNING);
DefaultLogger(LogLevel level = LOG_WARNING);
virtual void Fatal(const string& msg) const;


+ 12
- 0
cpp/src/phonenumber.proto View File

@ -54,6 +54,10 @@ message PhoneNumber {
// necessary automatically.
optional bool italian_leading_zero = 4;
// The next few fields are non-essential fields for a phone number. They retain extra information
// about the form the phone number was in when it was provided to us to parse. They can be safely
// ignored by most clients.
// This field is used to store the raw input string containing phone numbers before it was
// canonicalized by the library. For example, it could be used to store alphanumerical numbers
// such as "1-800-GOOG-411".
@ -83,6 +87,14 @@ message PhoneNumber {
// The source from which the country_code is derived.
optional CountryCodeSource country_code_source = 6;
// The carrier selection code that is preferred when calling this phone number domestically. This
// also includes codes that need to be dialed in some countries when calling from landlines to
// mobiles or vice versa. For example, in Columbia, a "3" needs to be dialed before the phone number
// itself when calling from a mobile phone to a domestic landline phone and vice versa.
//
// Note this is the "preferred" code, which means other codes may work as well.
optional string preferred_domestic_carrier_code = 7;
}
// Examples


Loading…
Cancel
Save