Browse Source

去掉第三方库集成,否则跨平台很难处理
增加自动检测glog gflags gmock的cmake脚本

tanghai 14 năm trước cách đây
mục cha
commit
9628a763d5
100 tập tin đã thay đổi với 206 bổ sung40441 xóa
  1. 23 4
      Src/CMakeLists.txt
  2. 60 0
      Src/Cmake/FindGFlags.cmake
  3. 60 0
      Src/Cmake/FindGLog.cmake
  4. 60 0
      Src/Cmake/FindGMock.cmake
  5. 1 6
      Src/Egametang/Python/CMakeLists.txt
  6. 1 7
      Src/Egametang/Rpc/CMakeLists.txt
  7. 1 6
      Src/Egametang/Thread/CMakeLists.txt
  8. 0 8
      Src/ThirdParty/CMakeLists.txt
  9. 0 10
      Src/ThirdParty/gflags/CMakeLists.txt
  10. 0 585
      Src/ThirdParty/gflags/gflags.h
  11. 0 121
      Src/ThirdParty/gflags/gflags_completions.h
  12. 0 110
      Src/ThirdParty/gflags/src/config.h
  13. 0 64
      Src/ThirdParty/gflags/src/config_for_unittests.h
  14. 0 1958
      Src/ThirdParty/gflags/src/gflags.cc
  15. 0 585
      Src/ThirdParty/gflags/src/gflags/gflags.h
  16. 0 121
      Src/ThirdParty/gflags/src/gflags/gflags_completions.h
  17. 0 765
      Src/ThirdParty/gflags/src/gflags_completions.cc
  18. 0 69
      Src/ThirdParty/gflags/src/gflags_nc.cc
  19. 0 446
      Src/ThirdParty/gflags/src/gflags_reporting.cc
  20. 0 58
      Src/ThirdParty/gflags/src/gflags_strip_flags_test.cc
  21. 0 1591
      Src/ThirdParty/gflags/src/gflags_unittest-main.cc
  22. 0 1591
      Src/ThirdParty/gflags/src/gflags_unittest.cc
  23. 0 1591
      Src/ThirdParty/gflags/src/gflags_unittest_main.cc
  24. 0 34
      Src/ThirdParty/gflags/src/google/gflags.h
  25. 0 34
      Src/ThirdParty/gflags/src/google/gflags_completions.h
  26. 0 349
      Src/ThirdParty/gflags/src/mutex.h
  27. 0 139
      Src/ThirdParty/gflags/src/windows/config.h
  28. 0 601
      Src/ThirdParty/gflags/src/windows/gflags/gflags.h
  29. 0 130
      Src/ThirdParty/gflags/src/windows/gflags/gflags_completions.h
  30. 0 56
      Src/ThirdParty/gflags/src/windows/port.cc
  31. 0 88
      Src/ThirdParty/gflags/src/windows/port.h
  32. 0 13
      Src/ThirdParty/glog/CMakeLists.txt
  33. 0 84
      Src/ThirdParty/glog/log_severity.h
  34. 0 1506
      Src/ThirdParty/glog/logging.h
  35. 0 185
      Src/ThirdParty/glog/raw_logging.h
  36. 0 132
      Src/ThirdParty/glog/src/base/commandlineflags.h
  37. 0 51
      Src/ThirdParty/glog/src/base/googleinit.h
  38. 0 325
      Src/ThirdParty/glog/src/base/mutex.h
  39. 0 167
      Src/ThirdParty/glog/src/config.h
  40. 0 66
      Src/ThirdParty/glog/src/config_for_unittests.h
  41. 0 1231
      Src/ThirdParty/glog/src/demangle.cc
  42. 0 84
      Src/ThirdParty/glog/src/demangle.h
  43. 0 116
      Src/ThirdParty/glog/src/demangle_unittest.cc
  44. 0 84
      Src/ThirdParty/glog/src/glog/log_severity.h
  45. 0 1506
      Src/ThirdParty/glog/src/glog/logging.h
  46. 0 185
      Src/ThirdParty/glog/src/glog/raw_logging.h
  47. 0 154
      Src/ThirdParty/glog/src/glog/stl_logging.h
  48. 0 129
      Src/ThirdParty/glog/src/glog/vlog_is_on.h
  49. 0 604
      Src/ThirdParty/glog/src/googletest.h
  50. 0 1781
      Src/ThirdParty/glog/src/logging.cc
  51. 0 35
      Src/ThirdParty/glog/src/logging_striptest10.cc
  52. 0 35
      Src/ThirdParty/glog/src/logging_striptest2.cc
  53. 0 68
      Src/ThirdParty/glog/src/logging_striptest_main.cc
  54. 0 1210
      Src/ThirdParty/glog/src/logging_unittest.cc
  55. 0 155
      Src/ThirdParty/glog/src/mock-log.h
  56. 0 106
      Src/ThirdParty/glog/src/mock-log_test.cc
  57. 0 172
      Src/ThirdParty/glog/src/raw_logging.cc
  58. 0 348
      Src/ThirdParty/glog/src/signalhandler.cc
  59. 0 95
      Src/ThirdParty/glog/src/signalhandler_unittest.cc
  60. 0 60
      Src/ThirdParty/glog/src/stacktrace.h
  61. 0 59
      Src/ThirdParty/glog/src/stacktrace_generic-inl.h
  62. 0 87
      Src/ThirdParty/glog/src/stacktrace_libunwind-inl.h
  63. 0 130
      Src/ThirdParty/glog/src/stacktrace_powerpc-inl.h
  64. 0 157
      Src/ThirdParty/glog/src/stacktrace_unittest.cc
  65. 0 139
      Src/ThirdParty/glog/src/stacktrace_x86-inl.h
  66. 0 105
      Src/ThirdParty/glog/src/stacktrace_x86_64-inl.h
  67. 0 191
      Src/ThirdParty/glog/src/stl_logging_unittest.cc
  68. 0 681
      Src/ThirdParty/glog/src/symbolize.cc
  69. 0 116
      Src/ThirdParty/glog/src/symbolize.h
  70. 0 365
      Src/ThirdParty/glog/src/symbolize_unittest.cc
  71. 0 335
      Src/ThirdParty/glog/src/utilities.cc
  72. 0 222
      Src/ThirdParty/glog/src/utilities.h
  73. 0 54
      Src/ThirdParty/glog/src/utilities_unittest.cc
  74. 0 249
      Src/ThirdParty/glog/src/vlog_is_on.cc
  75. 0 136
      Src/ThirdParty/glog/src/windows/config.h
  76. 0 88
      Src/ThirdParty/glog/src/windows/glog/log_severity.h
  77. 0 1510
      Src/ThirdParty/glog/src/windows/glog/logging.h
  78. 0 189
      Src/ThirdParty/glog/src/windows/glog/raw_logging.h
  79. 0 158
      Src/ThirdParty/glog/src/windows/glog/stl_logging.h
  80. 0 133
      Src/ThirdParty/glog/src/windows/glog/vlog_is_on.h
  81. 0 64
      Src/ThirdParty/glog/src/windows/port.cc
  82. 0 149
      Src/ThirdParty/glog/src/windows/port.h
  83. 0 118
      Src/ThirdParty/glog/src/windows/preprocess.sh
  84. 0 154
      Src/ThirdParty/glog/stl_logging.h
  85. 0 129
      Src/ThirdParty/glog/vlog_is_on.h
  86. 0 5
      Src/ThirdParty/gmock/CMakeLists.txt
  87. 0 1076
      Src/ThirdParty/gmock/gmock-actions.h
  88. 0 146
      Src/ThirdParty/gmock/gmock-cardinalities.h
  89. 0 2419
      Src/ThirdParty/gmock/gmock-generated-actions.h
  90. 0 929
      Src/ThirdParty/gmock/gmock-generated-function-mockers.h
  91. 0 2054
      Src/ThirdParty/gmock/gmock-generated-matchers.h
  92. 0 274
      Src/ThirdParty/gmock/gmock-generated-nice-strict.h
  93. 0 3066
      Src/ThirdParty/gmock/gmock-matchers.h
  94. 0 233
      Src/ThirdParty/gmock/gmock-more-actions.h
  95. 0 1749
      Src/ThirdParty/gmock/gmock-spec-builders.h
  96. 0 93
      Src/ThirdParty/gmock/gmock.h
  97. 0 277
      Src/ThirdParty/gmock/internal/gmock-generated-internal-utils.h
  98. 0 463
      Src/ThirdParty/gmock/internal/gmock-internal-utils.h
  99. 0 78
      Src/ThirdParty/gmock/internal/gmock-port.h
  100. 0 47
      Src/ThirdParty/gmock/src/gmock-all.cc

+ 23 - 4
Src/CMakeLists.txt

@@ -14,11 +14,21 @@ ENDIF()
 INCLUDE_DIRECTORIES(Egametang)
 INCLUDE_DIRECTORIES(ThirdParty)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/Egametang)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ThirdParty)
+
+FIND_PACKAGE(GFlags REQUIRED)
+INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIR})
+
+FIND_PACKAGE(GLog REQUIRED)
+INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIR})
+
+FIND_PACKAGE(GTest REQUIRED)
+INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIR})
+
+FIND_PACKAGE(GMock REQUIRED)
+INCLUDE_DIRECTORIES(${GMOCK_INCLUDE_DIR})
 
 FIND_PACKAGE(Protobuf REQUIRED)
 INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS})
-LINK_DIRECTORIES(${PROTOBUF_LIBRARIES})
 
 FIND_PACKAGE(PythonLibs REQUIRED)
 INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
@@ -29,5 +39,14 @@ SET(Boost_USE_MULTITHREADED  ON)
 SET(Boost_USE_STATIC_RUNTIME OFF)
 INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS})
 
-ADD_SUBDIRECTORY(Egametang)
-ADD_SUBDIRECTORY(ThirdParty)
+set(LinkLibs
+	${GLOG_LIBRARY}
+	${GFLAGS_LIBRARY}
+	${GTEST_LIBRARY}
+	${GMOCK_LIBRARY}
+	${PROTOBUF_LIBRARY}
+	${Boost_LIBRARIES}
+	${PYTHON_LIBRARY}
+	)
+
+ADD_SUBDIRECTORY(Egametang)

+ 60 - 0
Src/Cmake/FindGFlags.cmake

@@ -0,0 +1,60 @@
+function(_gflags_append_debugs _endvar _library)
+    if(${_library} AND ${_library}_DEBUG)
+        set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
+    else()
+        set(_output ${${_library}})
+    endif()
+    set(${_endvar} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(_gflags_find_library _name)
+    find_library(${_name}
+        NAMES ${ARGN}
+        HINTS
+            $ENV{GFLAGS_ROOT}
+            ${GFLAGS_ROOT}
+        PATH_SUFFIXES ${_gflags_libpath_suffixes}
+    )
+    mark_as_advanced(${_name})
+endfunction()
+
+if(NOT DEFINED GFLAGS_MSVC_SEARCH)
+    set(GFLAGS_MSVC_SEARCH MD)
+endif()
+
+set(_gflags_libpath_suffixes lib)
+if(MSVC)
+    if(GFLAGS_MSVC_SEARCH STREQUAL "MD")
+        list(APPEND _gflags_libpath_suffixes
+            msvc/gflags-md/Debug
+            msvc/gflags-md/Release)
+    elseif(GFLAGS_MSVC_SEARCH STREQUAL "MT")
+        list(APPEND _gflags_libpath_suffixes
+            msvc/gflags/Debug
+            msvc/gflags/Release)
+    endif()
+endif()
+
+
+find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
+    HINTS
+        $ENV{GFLAGS_ROOT}/include
+        ${GFLAGS_ROOT}/include
+)
+mark_as_advanced(GFLAGS_INCLUDE_DIR)
+
+if(MSVC AND GFLAGS_MSVC_SEARCH STREQUAL "MD")
+    # The provided /MD project files for Google Log add -md suffixes to the
+    # library names.
+    _gflags_find_library(GFLAGS_LIBRARY            gflags-md  gflags)
+else()
+    _gflags_find_library(GFLAGS_LIBRARY            gflags)
+endif()
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GFlags DEFAULT_MSG GFLAGS_LIBRARY)
+
+if(GFLAGS_FOUND)
+    set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
+    _gflags_append_debugs(GFLAGS_LIBRARIES      GFLAGS_LIBRARY)
+endif()

+ 60 - 0
Src/Cmake/FindGLog.cmake

@@ -0,0 +1,60 @@
+function(_glog_append_debugs _endvar _library)
+    if(${_library} AND ${_library}_DEBUG)
+        set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
+    else()
+        set(_output ${${_library}})
+    endif()
+    set(${_endvar} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(_glog_find_library _name)
+    find_library(${_name}
+        NAMES ${ARGN}
+        HINTS
+            $ENV{GLOG_ROOT}
+            ${GLOG_ROOT}
+        PATH_SUFFIXES ${_glog_libpath_suffixes}
+    )
+    mark_as_advanced(${_name})
+endfunction()
+
+if(NOT DEFINED GLOG_MSVC_SEARCH)
+    set(GLOG_MSVC_SEARCH MD)
+endif()
+
+set(_glog_libpath_suffixes lib)
+if(MSVC)
+    if(GLOG_MSVC_SEARCH STREQUAL "MD")
+        list(APPEND _glog_libpath_suffixes
+            msvc/glog-md/Debug
+            msvc/glog-md/Release)
+    elseif(GLOG_MSVC_SEARCH STREQUAL "MT")
+        list(APPEND _glog_libpath_suffixes
+            msvc/glog/Debug
+            msvc/glog/Release)
+    endif()
+endif()
+
+
+find_path(GLOG_INCLUDE_DIR glog/logging.h
+    HINTS
+        $ENV{GLOG_ROOT}/include
+        ${GLOG_ROOT}/include
+)
+mark_as_advanced(GLOG_INCLUDE_DIR)
+
+if(MSVC AND GLOG_MSVC_SEARCH STREQUAL "MD")
+    # The provided /MD project files for Google Log add -md suffixes to the
+    # library names.
+    _glog_find_library(GLOG_LIBRARY            glog-md  glog)
+else()
+    _glog_find_library(GLOG_LIBRARY            glog)
+endif()
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLog DEFAULT_MSG GLOG_LIBRARY)
+
+if(GLOG_FOUND)
+    set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
+    _glog_append_debugs(GLOG_LIBRARIES      GLOG_LIBRARY)
+endif()

+ 60 - 0
Src/Cmake/FindGMock.cmake

@@ -0,0 +1,60 @@
+function(_gmock_append_debugs _endvar _library)
+    if(${_library} AND ${_library}_DEBUG)
+        set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
+    else()
+        set(_output ${${_library}})
+    endif()
+    set(${_endvar} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(_gmock_find_library _name)
+    find_library(${_name}
+        NAMES ${ARGN}
+        HINTS
+            $ENV{GMOCK_ROOT}
+            ${GMOCK_ROOT}
+        PATH_SUFFIXES ${_gmock_libpath_suffixes}
+    )
+    mark_as_advanced(${_name})
+endfunction()
+
+if(NOT DEFINED GMOCK_MSVC_SEARCH)
+    set(GMOCK_MSVC_SEARCH MD)
+endif()
+
+set(_gmock_libpath_suffixes lib)
+if(MSVC)
+    if(GMOCK_MSVC_SEARCH STREQUAL "MD")
+        list(APPEND _gmock_libpath_suffixes
+            msvc/gmock-md/Debug
+            msvc/gmock-md/Release)
+    elseif(GMOCK_MSVC_SEARCH STREQUAL "MT")
+        list(APPEND _gmock_libpath_suffixes
+            msvc/gmock/Debug
+            msvc/gmock/Release)
+    endif()
+endif()
+
+
+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
+    HINTS
+        $ENV{GMOCK_ROOT}/include
+        ${GMOCK_ROOT}/include
+)
+mark_as_advanced(GMOCK_INCLUDE_DIR)
+
+if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD")
+    # The provided /MD project files for Google Log add -md suffixes to the
+    # library names.
+    _gmock_find_library(GMOCK_LIBRARY            gmock-md  gmock)
+else()
+    _gmock_find_library(GMOCK_LIBRARY            gmock)
+endif()
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY)
+
+if(GMOCK_FOUND)
+    set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR})
+    _gmock_append_debugs(GMOCK_LIBRARIES      GMOCK_LIBRARY)
+endif()

+ 1 - 6
Src/Egametang/Python/CMakeLists.txt

@@ -15,12 +15,7 @@ SET(Excutes
 FOREACH(Excute ${Excutes})
 	TARGET_LINK_LIBRARIES(${Excute}
 		PythonInterpreter
-		Glog
-		Gflags
-		Gtest
-		Gmock
-		${Boost_LIBRARIES}
-		${PYTHON_LIBRARY}
+		${LinkLibs}
 	)
 	ADD_TEST(${Excute} ${Excute})
 ENDFOREACH()

+ 1 - 7
Src/Egametang/Rpc/CMakeLists.txt

@@ -25,13 +25,7 @@ FOREACH(Excute ${Excutes})
 	TARGET_LINK_LIBRARIES(${Excute}
 		Rpc
 		Thread
-		Glog
-		Gflags
-		Gtest
-		Gmock
-		${Boost_LIBRARIES}
-		${PYTHON_LIBRARY}
-		${PROTOBUF_LIBRARY}
+		${LinkLibs}
 	)
 	ADD_TEST(${Excute} ${Excute})
 ENDFOREACH()

+ 1 - 6
Src/Egametang/Thread/CMakeLists.txt

@@ -15,12 +15,7 @@ SET(Excutes
 FOREACH(Excute ${Excutes})
 	TARGET_LINK_LIBRARIES(${Excute}
 		Thread
-		Glog
-		Gflags
-		Gtest
-		Gmock
-		${Boost_LIBRARIES}
-		${PYTHON_LIBRARY}
+		${LinkLibs}
 	)
 	ADD_TEST(${Excute} ${Excute})
 ENDFOREACH()

+ 0 - 8
Src/ThirdParty/CMakeLists.txt

@@ -1,8 +0,0 @@
-# 请先下载源码包,跑一遍第三方库的test,保证所有test通过
-# gtest-1.6.0
-# gmock-1.6.0
-
-ADD_SUBDIRECTORY(glog)
-ADD_SUBDIRECTORY(gmock)
-ADD_SUBDIRECTORY(gtest)
-ADD_SUBDIRECTORY(gflags)

+ 0 - 10
Src/ThirdParty/gflags/CMakeLists.txt

@@ -1,10 +0,0 @@
-SET(Gflags 
-	src/gflags_completions.cc
-	src/gflags_nc.cc
-	src/gflags_reporting.cc
-	src/gflags.cc
-)
-
-INCLUDE_DIRECTORIES(./src)
-
-ADD_LIBRARY(Gflags ${Gflags})

+ 0 - 585
Src/ThirdParty/gflags/gflags.h

@@ -1,585 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Ray Sidney
-// Revamped and reorganized by Craig Silverstein
-//
-// This is the file that should be included by any file which declares
-// or defines a command line flag or wants to parse command line flags
-// or print a program usage message (which will include information about
-// flags).  Executive summary, in the form of an example foo.cc file:
-//
-//    #include "foo.h"         // foo.h has a line "DECLARE_int32(start);"
-//    #include "validators.h"  // hypothetical file defining ValidateIsFile()
-//
-//    DEFINE_int32(end, 1000, "The last record to read");
-//
-//    DEFINE_string(filename, "my_file.txt", "The file to read");
-//    // Crash if the specified file does not exist.
-//    static bool dummy = RegisterFlagValidator(&FLAGS_filename,
-//                                              &ValidateIsFile);
-//
-//    DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
-//
-//    void MyFunc() {
-//      if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
-//    }
-//
-// Then, at the command-line:
-//    ./foo --noverbose --start=5 --end=100
-//
-// For more details, see
-//    doc/gflags.html
-//
-// --- A note about thread-safety:
-//
-// We describe many functions in this routine as being thread-hostile,
-// thread-compatible, or thread-safe.  Here are the meanings we use:
-//
-// thread-safe: it is safe for multiple threads to call this routine
-//   (or, when referring to a class, methods of this class)
-//   concurrently.
-// thread-hostile: it is not safe for multiple threads to call this
-//   routine (or methods of this class) concurrently.  In gflags,
-//   most thread-hostile routines are intended to be called early in,
-//   or even before, main() -- that is, before threads are spawned.
-// thread-compatible: it is safe for multiple threads to read from
-//   this variable (when applied to variables), or to call const
-//   methods of this class (when applied to classes), as long as no
-//   other thread is writing to the variable or calling non-const
-//   methods of this class.
-
-#ifndef GOOGLE_GFLAGS_H_
-#define GOOGLE_GFLAGS_H_
-
-#include <string>
-#include <vector>
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at gflags.h.in to see how they're calculated (based on your config).
-#if 1
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 1
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-namespace google {
-
-#if 1      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 1   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0     // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-// --------------------------------------------------------------------
-// To actually define a flag in a file, use DEFINE_bool,
-// DEFINE_string, etc. at the bottom of this file.  You may also find
-// it useful to register a validator with the flag.  This ensures that
-// when the flag is parsed from the commandline, or is later set via
-// SetCommandLineOption, we call the validation function. It is _not_
-// called when you assign the value to the flag directly using the = operator.
-//
-// The validation function should return true if the flag value is valid, and
-// false otherwise. If the function returns false for the new setting of the
-// flag, the flag will retain its current value. If it returns false for the
-// default value, ParseCommandLineFlags() will die.
-//
-// This function is safe to call at global construct time (as in the
-// example below).
-//
-// Example use:
-//    static bool ValidatePort(const char* flagname, int32 value) {
-//       if (value > 0 && value < 32768)   // value is ok
-//         return true;
-//       printf("Invalid value for --%s: %d\n", flagname, (int)value);
-//       return false;
-//    }
-//    DEFINE_int32(port, 0, "What port to listen on");
-//    static bool dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
-
-// Returns true if successfully registered, false if not (because the
-// first argument doesn't point to a command-line flag, or because a
-// validator is already registered for this flag).
-bool RegisterFlagValidator(const bool* flag,
-                           bool (*validate_fn)(const char*, bool));
-bool RegisterFlagValidator(const int32* flag,
-                           bool (*validate_fn)(const char*, int32));
-bool RegisterFlagValidator(const int64* flag,
-                           bool (*validate_fn)(const char*, int64));
-bool RegisterFlagValidator(const uint64* flag,
-                           bool (*validate_fn)(const char*, uint64));
-bool RegisterFlagValidator(const double* flag,
-                           bool (*validate_fn)(const char*, double));
-bool RegisterFlagValidator(const std::string* flag,
-                           bool (*validate_fn)(const char*, const std::string&));
-
-
-// --------------------------------------------------------------------
-// These methods are the best way to get access to info about the
-// list of commandline flags.  Note that these routines are pretty slow.
-//   GetAllFlags: mostly-complete info about the list, sorted by file.
-//   ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
-//   ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
-//
-// In addition to accessing flags, you can also access argv[0] (the program
-// name) and argv (the entire commandline), which we sock away a copy of.
-// These variables are static, so you should only set them once.
-
-struct CommandLineFlagInfo {
-  std::string name;           // the name of the flag
-  std::string type;           // the type of the flag: int32, etc
-  std::string description;    // the "help text" associated with the flag
-  std::string current_value;  // the current value, as a string
-  std::string default_value;  // the default value, as a string
-  std::string filename;       // 'cleaned' version of filename holding the flag
-  bool has_validator_fn;      // true if RegisterFlagValidator called on flag
-  bool is_default;            // true if the flag has the default value and
-                              // has not been set explicitly from the cmdline
-                              // or via SetCommandLineOption
-};
-
-// Using this inside of a validator is a recipe for a deadlock.
-// TODO(wojtekm) Fix locking when validators are running, to make it safe to
-// call validators during ParseAllFlags.
-// Also make sure then to uncomment the corresponding unit test in
-// commandlineflags_unittest.sh
-extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
-// These two are actually defined in commandlineflags_reporting.cc.
-extern void ShowUsageWithFlags(const char *argv0);  // what --help does
-extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
-
-// Create a descriptive string for a flag.
-// Goes to some trouble to make pretty line breaks.
-extern std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
-
-// Thread-hostile; meant to be called before any threads are spawned.
-extern void SetArgv(int argc, const char** argv);
-// The following functions are thread-safe as long as SetArgv() is
-// only called before any threads start.
-extern const std::vector<std::string>& GetArgvs();  // all of argv as a vector
-extern const char* GetArgv();                // all of argv as a string
-extern const char* GetArgv0();               // only argv0
-extern uint32 GetArgvSum();                  // simple checksum of argv
-extern const char* ProgramInvocationName();  // argv0, or "UNKNOWN" if not set
-extern const char* ProgramInvocationShortName();   // basename(argv0)
-// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
-// called before any threads start.
-extern const char* ProgramUsage();           // string set by SetUsageMessage()
-
-
-// --------------------------------------------------------------------
-// Normally you access commandline flags by just saying "if (FLAGS_foo)"
-// or whatever, and set them by calling "FLAGS_foo = bar" (or, more
-// commonly, via the DEFINE_foo macro).  But if you need a bit more
-// control, we have programmatic ways to get/set the flags as well.
-// These programmatic ways to access flags are thread-safe, but direct
-// access is only thread-compatible.
-
-// Return true iff the flagname was found.
-// OUTPUT is set to the flag's value, or unchanged if we return false.
-extern bool GetCommandLineOption(const char* name, std::string* OUTPUT);
-
-// Return true iff the flagname was found. OUTPUT is set to the flag's
-// CommandLineFlagInfo or unchanged if we return false.
-extern bool GetCommandLineFlagInfo(const char* name,
-                                   CommandLineFlagInfo* OUTPUT);
-
-// Return the CommandLineFlagInfo of the flagname.  exit() if name not found.
-// Example usage, to check if a flag's value is currently the default value:
-//   if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
-extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
-
-enum FlagSettingMode {
-  // update the flag's value (can call this multiple times).
-  SET_FLAGS_VALUE,
-  // update the flag's value, but *only if* it has not yet been updated
-  // with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef".
-  SET_FLAG_IF_DEFAULT,
-  // set the flag's default value to this.  If the flag has not yet updated
-  // yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef")
-  // change the flag's current value to the new default value as well.
-  SET_FLAGS_DEFAULT
-};
-
-// Set a particular flag ("command line option").  Returns a string
-// describing the new value that the option has been set to.  The
-// return value API is not well-specified, so basically just depend on
-// it to be empty if the setting failed for some reason -- the name is
-// not a valid flag name, or the value is not a valid value -- and
-// non-empty else.
-
-// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
-extern std::string SetCommandLineOption(const char* name, const char* value);
-extern std::string SetCommandLineOptionWithMode(const char* name, const char* value,
-                                                FlagSettingMode set_mode);
-
-
-// --------------------------------------------------------------------
-// Saves the states (value, default value, whether the user has set
-// the flag, registered validators, etc) of all flags, and restores
-// them when the FlagSaver is destroyed.  This is very useful in
-// tests, say, when you want to let your tests change the flags, but
-// make sure that they get reverted to the original states when your
-// test is complete.
-//
-// Example usage:
-//   void TestFoo() {
-//     FlagSaver s1;
-//     FLAG_foo = false;
-//     FLAG_bar = "some value";
-//
-//     // test happens here.  You can return at any time
-//     // without worrying about restoring the FLAG values.
-//   }
-//
-// Note: This class is marked with __attribute__((unused)) because all the
-// work is done in the constructor and destructor, so in the standard
-// usage example above, the compiler would complain that it's an
-// unused variable.
-//
-// This class is thread-safe.
-
-class FlagSaver {
- public:
-  FlagSaver();
-  ~FlagSaver();
-
- private:
-  class FlagSaverImpl* impl_;   // we use pimpl here to keep API steady
-
-  FlagSaver(const FlagSaver&);  // no copying!
-  void operator=(const FlagSaver&);
-} __attribute__ ((unused));
-
-// --------------------------------------------------------------------
-// Some deprecated or hopefully-soon-to-be-deprecated functions.
-
-// This is often used for logging.  TODO(csilvers): figure out a better way
-extern std::string CommandlineFlagsIntoString();
-// Usually where this is used, a FlagSaver should be used instead.
-extern bool ReadFlagsFromString(const std::string& flagfilecontents,
-                                const char* prog_name,
-                                bool errors_are_fatal); // uses SET_FLAGS_VALUE
-
-// These let you manually implement --flagfile functionality.
-// DEPRECATED.
-extern bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
-extern bool SaveCommandFlags();  // actually defined in google.cc !
-extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
-                              bool errors_are_fatal);   // uses SET_FLAGS_VALUE
-
-
-// --------------------------------------------------------------------
-// Useful routines for initializing flags from the environment.
-// In each case, if 'varname' does not exist in the environment
-// return defval.  If 'varname' does exist but is not valid
-// (e.g., not a number for an int32 flag), abort with an error.
-// Otherwise, return the value.  NOTE: for booleans, for true use
-// 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
-
-extern bool BoolFromEnv(const char *varname, bool defval);
-extern int32 Int32FromEnv(const char *varname, int32 defval);
-extern int64 Int64FromEnv(const char *varname, int64 defval);
-extern uint64 Uint64FromEnv(const char *varname, uint64 defval);
-extern double DoubleFromEnv(const char *varname, double defval);
-extern const char *StringFromEnv(const char *varname, const char *defval);
-
-
-// --------------------------------------------------------------------
-// The next two functions parse commandlineflags from main():
-
-// Set the "usage" message for this program.  For example:
-//   string usage("This program does nothing.  Sample usage:\n");
-//   usage += argv[0] + " <uselessarg1> <uselessarg2>";
-//   SetUsageMessage(usage);
-// Do not include commandline flags in the usage: we do that for you!
-// Thread-hostile; meant to be called before any threads are spawned.
-extern void SetUsageMessage(const std::string& usage);
-
-// Looks for flags in argv and parses them.  Rearranges argv to put
-// flags first, or removes them entirely if remove_flags is true.
-// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.  Returns the index (into argv)
-// of the first non-flag argument.
-// See top-of-file for more details on this function.
-#ifndef SWIG   // In swig, use ParseCommandLineFlagsScript() instead.
-extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
-                                    bool remove_flags);
-#endif
-
-
-// Calls to ParseCommandLineNonHelpFlags and then to
-// HandleCommandLineHelpFlags can be used instead of a call to
-// ParseCommandLineFlags during initialization, in order to allow for
-// changing default values for some FLAGS (via
-// e.g. SetCommandLineOptionWithMode calls) between the time of
-// command line parsing and the time of dumping help information for
-// the flags as a result of command line parsing.  If a flag is
-// defined more than once in the command line or flag file, the last
-// definition is used.  Returns the index (into argv) of the first
-// non-flag argument.  (If remove_flags is true, will always return 1.)
-extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
-                                           bool remove_flags);
-// This is actually defined in commandlineflags_reporting.cc.
-// This function is misnamed (it also handles --version, etc.), but
-// it's too late to change that now. :-(
-extern void HandleCommandLineHelpFlags();   // in commandlineflags_reporting.cc
-
-// Allow command line reparsing.  Disables the error normally
-// generated when an unknown flag is found, since it may be found in a
-// later parse.  Thread-hostile; meant to be called before any threads
-// are spawned.
-extern void AllowCommandLineReparsing();
-
-// Reparse the flags that have not yet been recognized.  Only flags
-// registered since the last parse will be recognized.  Any flag value
-// must be provided as part of the argument using "=", not as a
-// separate command line argument that follows the flag argument.
-// Intended for handling flags from dynamically loaded libraries,
-// since their flags are not registered until they are loaded.
-// Returns the index (into the original argv) of the first non-flag
-// argument.  (If remove_flags is true, will always return 1.)
-extern uint32 ReparseCommandLineNonHelpFlags();
-
-// Clean up memory allocated by flags.  This is only needed to reduce
-// the quantity of "potentially leaked" reports emitted by memory
-// debugging tools such as valgrind.  It is not required for normal
-// operation, or for the perftools heap-checker.  It must only be called
-// when the process is about to exit, and all threads that might
-// access flags are quiescent.  Referencing flags after this is called
-// will have unexpected consequences.  This is not safe to run when
-// multiple threads might be running: the function is thread-hostile.
-extern void ShutDownCommandLineFlags();
-
-
-// --------------------------------------------------------------------
-// Now come the command line flag declaration/definition macros that
-// will actually be used.  They're kind of hairy.  A major reason
-// for this is initialization: we want people to be able to access
-// variables in global constructors and have that not crash, even if
-// their global constructor runs before the global constructor here.
-// (Obviously, we can't guarantee the flags will have the correct
-// default value in that case, but at least accessing them is safe.)
-// The only way to do that is have flags point to a static buffer.
-// So we make one, using a union to ensure proper alignment, and
-// then use placement-new to actually set up the flag with the
-// correct default value.  In the same vein, we have to worry about
-// flag access in global destructors, so FlagRegisterer has to be
-// careful never to destroy the flag-values it constructs.
-//
-// Note that when we define a flag variable FLAGS_<name>, we also
-// preemptively define a junk variable, FLAGS_no<name>.  This is to
-// cause a link-time error if someone tries to define 2 flags with
-// names like "logging" and "nologging".  We do this because a bool
-// flag FLAG can be set from the command line to true with a "-FLAG"
-// argument, and to false with a "-noFLAG" argument, and so this can
-// potentially avert confusion.
-//
-// We also put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the current
-// namespace.  The net result is to force people to use DECLARE to get
-// access to a flag, rather than saying "extern bool FLAGS_whatever;"
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want, and
-// make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-
-class FlagRegisterer {
- public:
-  FlagRegisterer(const char* name, const char* type,
-                 const char* help, const char* filename,
-                 void* current_storage, void* defvalue_storage);
-};
-
-extern bool FlagsTypeWarn(const char *name);
-
-// If your application #defines STRIP_FLAG_HELP to a non-zero value
-// before #including this file, we remove the help message from the
-// binary file. This can reduce the size of the resulting binary
-// somewhat, and may also be useful for security reasons.
-
-extern const char kStrippedFlagHelp[];
-
-}
-
-#ifndef SWIG  // In swig, ignore the main flag declarations
-
-#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
-// Need this construct to avoid the 'defined but not used' warning.
-#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : ::google::kStrippedFlagHelp)
-#else
-#define MAYBE_STRIPPED_HELP(txt) txt
-#endif
-
-// Each command-line flag has two variables associated with it: one
-// with the current value, and one with the default value.  However,
-// we have a third variable, which is where value is assigned; it's a
-// constant.  This guarantees that FLAG_##value is initialized at
-// static initialization time (e.g. before program-start) rather than
-// than global construction time (which is after program-start but
-// before main), at least when 'value' is a compile-time constant.  We
-// use a small trick for the "default value" variable, and call it
-// FLAGS_no<name>.  This serves the second purpose of assuring a
-// compile error if someone tries to define a flag named no<name>
-// which is illegal (--foo and --nofoo both affect the "foo" flag).
-#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
-  namespace fL##shorttype {                                     \
-    static const type FLAGS_nono##name = value;                 \
-    type FLAGS_##name = FLAGS_nono##name;                       \
-    type FLAGS_no##name = FLAGS_nono##name;                     \
-    static ::google::FlagRegisterer o_##name(      \
-      #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__,        \
-      &FLAGS_##name, &FLAGS_no##name);                          \
-  }                                                             \
-  using fL##shorttype::FLAGS_##name
-
-#define DECLARE_VARIABLE(type, shorttype, name) \
-  namespace fL##shorttype {                     \
-    extern type FLAGS_##name;                   \
-  }                                             \
-  using fL##shorttype::FLAGS_##name
-
-// For DEFINE_bool, we want to do the extra check that the passed-in
-// value is actually a bool, and not a string or something that can be
-// coerced to a bool.  These declarations (no definition needed!) will
-// help us do that, and never evaluate From, which is important.
-// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
-// that the compiler have different sizes for bool & double. Since
-// this is not guaranteed by the standard, we check it with a
-// compile-time assert (msg[-1] will give a compile-time error).
-namespace fLB {
-struct CompileAssert {};
-typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
-                      (sizeof(double) != sizeof(bool)) ? 1 : -1];
-template<typename From> double IsBoolFlag(const From& from);
-bool IsBoolFlag(bool from);
-}  // namespace fLB
-
-#define DECLARE_bool(name)          DECLARE_VARIABLE(bool, B, name)
-#define DEFINE_bool(name, val, txt)                                       \
-  namespace fLB {                                                         \
-    typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[       \
-            (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
-  }                                                                       \
-  DEFINE_VARIABLE(bool, B, name, val, txt)
-
-#define DECLARE_int32(name)         DECLARE_VARIABLE(::google::int32, I, name)
-#define DEFINE_int32(name,val,txt)  DEFINE_VARIABLE(::google::int32, I, name, val, txt)
-
-#define DECLARE_int64(name)         DECLARE_VARIABLE(::google::int64, I64, name)
-#define DEFINE_int64(name,val,txt)  DEFINE_VARIABLE(::google::int64, I64, name, val, txt)
-
-#define DECLARE_uint64(name)        DECLARE_VARIABLE(::google::uint64, U64, name)
-#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt)
-
-#define DECLARE_double(name)          DECLARE_VARIABLE(double, D, name)
-#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
-
-// Strings are trickier, because they're not a POD, so we can't
-// construct them at static-initialization time (instead they get
-// constructed at global-constructor time, which is much later).  To
-// try to avoid crashes in that case, we use a char buffer to store
-// the string, which we can static-initialize, and then placement-new
-// into it later.  It's not perfect, but the best we can do.
-
-namespace fLS {
-// The meaning of "string" might be different between now and when the
-// macros below get invoked (e.g., if someone is experimenting with
-// other string implementations that get defined after this file is
-// included).  Save the current meaning now and use it in the macros.
-typedef std::string clstring;
-
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const char *value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const clstring &value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           int value);
-}  // namespace fLS
-
-#define DECLARE_string(name)  namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
-                              using fLS::FLAGS_##name
-
-// We need to define a var named FLAGS_no##name so people don't define
-// --string and --nostring.  And we need a temporary place to put val
-// so we don't have to evaluate it twice.  Two great needs that go
-// great together!
-// The weird 'using' + 'extern' inside the fLS namespace is to work around
-// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10.  See
-//    http://code.google.com/p/google-gflags/issues/detail?id=20
-#define DEFINE_string(name, val, txt)                                       \
-  namespace fLS {                                                           \
-    using ::fLS::clstring;                                                  \
-    static union { void* align; char s[sizeof(clstring)]; } s_##name[2];    \
-    clstring* const FLAGS_no##name = ::fLS::                                \
-                                   dont_pass0toDEFINE_string(s_##name[0].s, \
-                                                             val);          \
-    static ::google::FlagRegisterer o_##name(                  \
-        #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__,                \
-        s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name));      \
-    extern clstring& FLAGS_##name;                                          \
-    using fLS::FLAGS_##name;                                                \
-    clstring& FLAGS_##name = *FLAGS_no##name;                               \
-  }                                                                         \
-  using fLS::FLAGS_##name
-
-#endif  // SWIG
-
-#endif  // GOOGLE_GFLAGS_H_

+ 0 - 121
Src/ThirdParty/gflags/gflags_completions.h

@@ -1,121 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Dave Nicponski
-//
-// Implement helpful bash-style command line flag completions
-//
-// ** Functional API:
-// HandleCommandLineCompletions() should be called early during
-// program startup, but after command line flag code has been
-// initialized, such as the beginning of HandleCommandLineHelpFlags().
-// It checks the value of the flag --tab_completion_word.  If this
-// flag is empty, nothing happens here.  If it contains a string,
-// however, then HandleCommandLineCompletions() will hijack the
-// process, attempting to identify the intention behind this
-// completion.  Regardless of the outcome of this deduction, the
-// process will be terminated, similar to --helpshort flag
-// handling.
-//
-// ** Overview of Bash completions:
-// Bash can be told to programatically determine completions for the
-// current 'cursor word'.  It does this by (in this case) invoking a
-// command with some additional arguments identifying the command
-// being executed, the word being completed, and the previous word
-// (if any).  Bash then expects a sequence of output lines to be
-// printed to stdout.  If these lines all contain a common prefix
-// longer than the cursor word, bash will replace the cursor word
-// with that common prefix, and display nothing.  If there isn't such
-// a common prefix, bash will display the lines in pages using 'more'.
-//
-// ** Strategy taken for command line completions:
-// If we can deduce either the exact flag intended, or a common flag
-// prefix, we'll output exactly that.  Otherwise, if information
-// must be displayed to the user, we'll take the opportunity to add
-// some helpful information beyond just the flag name (specifically,
-// we'll include the default flag value and as much of the flag's
-// description as can fit on a single terminal line width, as specified
-// by the flag --tab_completion_columns).  Furthermore, we'll try to
-// make bash order the output such that the most useful or relevent
-// flags are the most likely to be shown at the top.
-//
-// ** Additional features:
-// To assist in finding that one really useful flag, substring matching
-// was implemented.  Before pressing a <TAB> to get completion for the
-// current word, you can append one or more '?' to the flag to do
-// substring matching.  Here's the semantics:
-//   --foo<TAB>     Show me all flags with names prefixed by 'foo'
-//   --foo?<TAB>    Show me all flags with 'foo' somewhere in the name
-//   --foo??<TAB>   Same as prior case, but also search in module
-//                  definition path for 'foo'
-//   --foo???<TAB>  Same as prior case, but also search in flag
-//                  descriptions for 'foo'
-// Finally, we'll trim the output to a relatively small number of
-// flags to keep bash quiet about the verbosity of output.  If one
-// really wanted to see all possible matches, appending a '+' to the
-// search word will force the exhaustive list of matches to be printed.
-//
-// ** How to have bash accept completions from a binary:
-// Bash requires that it be informed about each command that programmatic
-// completion should be enabled for.  Example addition to a .bashrc
-// file would be (your path to gflags_completions.sh file may differ):
-
-/*
-$ complete -o bashdefault -o default -o nospace -C                        \
- '/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \
-  time  env  binary_name  another_binary  [...]
-*/
-
-// This would allow the following to work:
-//   $ /path/to/binary_name --vmodule<TAB>
-// Or:
-//   $ ./bin/path/another_binary --gfs_u<TAB>
-// (etc)
-//
-// Sadly, it appears that bash gives no easy way to force this behavior for
-// all commands.  That's where the "time" in the above example comes in.
-// If you haven't specifically added a command to the list of completion
-// supported commands, you can still get completions by prefixing the
-// entire command with "env".
-//   $ env /some/brand/new/binary --vmod<TAB>
-// Assuming that "binary" is a newly compiled binary, this should still
-// produce the expected completion output.
-
-
-#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_
-#define GOOGLE_GFLAGS_COMPLETIONS_H_
-
-namespace google {
-
-void HandleCommandLineCompletions(void);
-
-}
-
-#endif  // GOOGLE_GFLAGS_COMPLETIONS_H_

+ 0 - 110
Src/ThirdParty/gflags/src/config.h

@@ -1,110 +0,0 @@
-/* src/config.h.  Generated from config.h.in by configure.  */
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Always the empty-string on non-windows systems. On windows, should be
-   "__declspec(dllexport)". This way, when we compile the dll, we export our
-   functions/classes. It's safe to define this here because config.h is only
-   used internally, to compile the DLL, and every DLL source file #includes
-   "config.h" before anything else. */
-#define GFLAGS_DLL_DECL /**/
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE ::google
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <fnmatch.h> header file. */
-#define HAVE_FNMATCH_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* define if the compiler implements namespaces */
-#define HAVE_NAMESPACES 1
-
-/* Define if you have POSIX threads libraries and header files. */
-#define HAVE_PTHREAD 1
-
-/* Define to 1 if you have the `putenv' function. */
-#define HAVE_PUTENV 1
-
-/* Define to 1 if you have the `setenv' function. */
-#define HAVE_SETENV 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strtoll' function. */
-#define HAVE_STRTOLL 1
-
-/* Define to 1 if you have the `strtoq' function. */
-#define HAVE_STRTOQ 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* define if your compiler has __attribute__ */
-#define HAVE___ATTRIBUTE__ 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "gflags"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "opensource@google.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "gflags"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "gflags 1.5"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "gflags"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.5"
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE std
-
-/* Version number of package */
-#define VERSION "1.5"
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {

+ 0 - 64
Src/ThirdParty/gflags/src/config_for_unittests.h

@@ -1,64 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// All Rights Reserved.
-//
-// Author: Craig Silverstein
-//
-// This file is needed for windows -- unittests are not part of the
-// gflags dll, but still want to include config.h just like the
-// dll does, so they can use internal tools and APIs for testing.
-//
-// The problem is that config.h declares GFLAGS_DLL_DECL to be
-// for exporting symbols, but the unittest needs to *import* symbols
-// (since it's not the dll).
-//
-// The solution is to have this file, which is just like config.h but
-// sets GFLAGS_DLL_DECL to do a dllimport instead of a dllexport.
-//
-// The reason we need this extra GFLAGS_DLL_DECL_FOR_UNITTESTS
-// variable is in case people want to set GFLAGS_DLL_DECL explicitly
-// to something other than __declspec(dllexport).  In that case, they
-// may want to use something other than __declspec(dllimport) for the
-// unittest case.  For that, we allow folks to define both
-// GFLAGS_DLL_DECL and GFLAGS_DLL_DECL_FOR_UNITTESTS explicitly.
-//
-// NOTE: This file is equivalent to config.h on non-windows systems,
-// which never defined GFLAGS_DLL_DECL_FOR_UNITTESTS and always
-// define GFLAGS_DLL_DECL to the empty string.
-
-#include "config.h"
-
-#undef GFLAGS_DLL_DECL
-#ifdef GFLAGS_DLL_DECL_FOR_UNITTESTS
-# define GFLAGS_DLL_DECL  GFLAGS_DLL_DECL_FOR_UNITTESTS
-#else
-# define GFLAGS_DLL_DECL  // if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
-#endif

+ 0 - 1958
Src/ThirdParty/gflags/src/gflags.cc

@@ -1,1958 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Ray Sidney
-// Revamped and reorganized by Craig Silverstein
-//
-// This file contains the implementation of all our command line flags
-// stuff.  Here's how everything fits together
-//
-// * FlagRegistry owns CommandLineFlags owns FlagValue.
-// * FlagSaver holds a FlagRegistry (saves it at construct time,
-//     restores it at destroy time).
-// * CommandLineFlagParser lives outside that hierarchy, but works on
-//     CommandLineFlags (modifying the FlagValues).
-// * Free functions like SetCommandLineOption() work via one of the
-//     above (such as CommandLineFlagParser).
-//
-// In more detail:
-//
-// -- The main classes that hold flag data:
-//
-// FlagValue holds the current value of a flag.  It's
-// pseudo-templatized: every operation on a FlagValue is typed.  It
-// also deals with storage-lifetime issues (so flag values don't go
-// away in a destructor), which is why we need a whole class to hold a
-// variable's value.
-//
-// CommandLineFlag is all the information about a single command-line
-// flag.  It has a FlagValue for the flag's current value, but also
-// the flag's name, type, etc.
-//
-// FlagRegistry is a collection of CommandLineFlags.  There's the
-// global registry, which is where flags defined via DEFINE_foo()
-// live.  But it's possible to define your own flag, manually, in a
-// different registry you create.  (In practice, multiple registries
-// are used only by FlagSaver).
-//
-// A given FlagValue is owned by exactly one CommandLineFlag.  A given
-// CommandLineFlag is owned by exactly one FlagRegistry.  FlagRegistry
-// has a lock; any operation that writes to a FlagValue or
-// CommandLineFlag owned by that registry must acquire the
-// FlagRegistry lock before doing so.
-//
-// --- Some other classes and free functions:
-//
-// CommandLineFlagInfo is a client-exposed version of CommandLineFlag.
-// Once it's instantiated, it has no dependencies or relationships
-// with any other part of this file.
-//
-// FlagRegisterer is the helper class used by the DEFINE_* macros to
-// allow work to be done at global initialization time.
-//
-// CommandLineFlagParser is the class that reads from the commandline
-// and instantiates flag values based on that.  It needs to poke into
-// the innards of the FlagValue->CommandLineFlag->FlagRegistry class
-// hierarchy to do that.  It's careful to acquire the FlagRegistry
-// lock before doing any writing or other non-const actions.
-//
-// GetCommandLineOption is just a hook into registry routines to
-// retrieve a flag based on its name.  SetCommandLineOption, on the
-// other hand, hooks into CommandLineFlagParser.  Other API functions
-// are, similarly, mostly hooks into the functionality described above.
-
-#include "config.h"
-// This comes first to ensure we define __STDC_FORMAT_MACROS in time.
-#ifdef HAVE_INTTYPES_H
-#ifndef __STDC_FORMAT_MACROS
-# define __STDC_FORMAT_MACROS 1   // gcc requires this to get PRId64, etc.
-#endif
-#include <inttypes.h>
-#endif  // HAVE_INTTYPES_H
-#include <stdio.h>     // for snprintf
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdarg.h> // For va_list and related operations
-#include <string.h>
-#include <assert.h>
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif  // HAVE_FNMATCH_H
-#include <string>
-#include <map>
-#include <vector>
-#include <utility>     // for pair<>
-#include <algorithm>
-#include <gflags/gflags.h>
-#include "mutex.h"
-
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR  '/'
-#endif
-
-// Work properly if either strtoll or strtoq is on this system
-#ifdef HAVE_STRTOLL
-# define strtoint64  strtoll
-# define strtouint64  strtoull
-#elif HAVE_STRTOQ
-# define strtoint64  strtoq
-# define strtouint64  strtouq
-#else
-// Neither strtoll nor strtoq are defined.  I hope strtol works!
-# define strtoint64 strtol
-# define strtouint64 strtoul
-#endif
-
-// If we have inttypes.h, it will have defined PRId32/etc for us.  If
-// not, take our best guess.
-#ifndef PRId32
-# define PRId32 "d"
-#endif
-#ifndef PRId64
-# define PRId64 "lld"
-#endif
-#ifndef PRIu64
-# define PRIu64 "llu"
-#endif
-
-typedef signed char int8;
-typedef unsigned char uint8;
-
-// Special flags, type 1: the 'recursive' flags.  They set another flag's val.
-DEFINE_string(flagfile, "",
-              "load flags from file");
-DEFINE_string(fromenv, "",
-              "set flags from the environment"
-              " [use 'export FLAGS_flag1=value']");
-DEFINE_string(tryfromenv, "",
-              "set flags from the environment if present");
-
-// Special flags, type 2: the 'parsing' flags.  They modify how we parse.
-DEFINE_string(undefok, "",
-              "comma-separated list of flag names that it is okay to specify "
-              "on the command line even if the program does not define a flag "
-              "with that name.  IMPORTANT: flags in this list that have "
-              "arguments MUST use the flag=value format");
-
-_START_GOOGLE_NAMESPACE_
-
-using std::map;
-using std::pair;
-using std::sort;
-using std::string;
-using std::vector;
-
-// The help message indicating that the commandline flag has been
-// 'stripped'. It will not show up when doing "-help" and its
-// variants. The flag is stripped if STRIP_FLAG_HELP is set to 1
-// before including gflags/gflags.h.
-
-// This is used by this file, and also in commandlineflags_reporting.cc
-const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001";
-
-// This is used by the unittest to test error-exit code
-void GFLAGS_DLL_DECL (*commandlineflags_exitfunc)(int) = &exit;   // from stdlib.h
-
-namespace {
-
-// There are also 'reporting' flags, in commandlineflags_reporting.cc.
-
-static const char kError[] = "ERROR: ";
-
-// Indicates that undefined options are to be ignored.
-// Enables deferred processing of flags in dynamically loaded libraries.
-static bool allow_command_line_reparsing = false;
-
-static bool logging_is_probably_set_up = false;
-
-// This is a 'prototype' validate-function.  'Real' validate
-// functions, take a flag-value as an argument: ValidateFn(bool) or
-// ValidateFn(uint64).  However, for easier storage, we strip off this
-// argument and then restore it when actually calling the function on
-// a flag value.
-typedef bool (*ValidateFnProto)();
-
-// Whether we should die when reporting an error.
-enum DieWhenReporting { DIE, DO_NOT_DIE };
-
-// Report Error and exit if requested.
-static void ReportError(DieWhenReporting should_die, const char* format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  vfprintf(stderr, format, ap);
-  va_end(ap);
-  if (should_die == DIE)
-    commandlineflags_exitfunc(1);   // almost certainly exit()
-}
-
-
-// --------------------------------------------------------------------
-// FlagValue
-//    This represent the value a single flag might have.  The major
-//    functionality is to convert from a string to an object of a
-//    given type, and back.  Thread-compatible.
-// --------------------------------------------------------------------
-
-class CommandLineFlag;
-class FlagValue {
- public:
-  FlagValue(void* valbuf, const char* type, bool transfer_ownership_of_value);
-  ~FlagValue();
-
-  bool ParseFrom(const char* spec);
-  string ToString() const;
-
- private:
-  friend class CommandLineFlag;  // for many things, including Validate()
-  friend class GOOGLE_NAMESPACE::FlagSaverImpl;  // calls New()
-  friend class FlagRegistry;     // checks value_buffer_ for flags_by_ptr_ map
-  template <typename T> friend T GetFromEnv(const char*, const char*, T);
-  friend bool TryParseLocked(const CommandLineFlag*, FlagValue*,
-                             const char*, string*);  // for New(), CopyFrom()
-
-  enum ValueType {
-    FV_BOOL = 0,
-    FV_INT32 = 1,
-    FV_INT64 = 2,
-    FV_UINT64 = 3,
-    FV_DOUBLE = 4,
-    FV_STRING = 5,
-    FV_MAX_INDEX = 5,
-  };
-  const char* TypeName() const;
-  bool Equal(const FlagValue& x) const;
-  FlagValue* New() const;   // creates a new one with default value
-  void CopyFrom(const FlagValue& x);
-  int ValueSize() const;
-
-  // Calls the given validate-fn on value_buffer_, and returns
-  // whatever it returns.  But first casts validate_fn_proto to a
-  // function that takes our value as an argument (eg void
-  // (*validate_fn)(bool) for a bool flag).
-  bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const;
-
-  void* value_buffer_;          // points to the buffer holding our data
-  int8 type_;                   // how to interpret value_
-  bool owns_value_;         // whether to free value on destruct
-
-  FlagValue(const FlagValue&);   // no copying!
-  void operator=(const FlagValue&);
-};
-
-
-// This could be a templated method of FlagValue, but doing so adds to the
-// size of the .o.  Since there's no type-safety here anyway, macro is ok.
-#define VALUE_AS(type)  *reinterpret_cast<type*>(value_buffer_)
-#define OTHER_VALUE_AS(fv, type)  *reinterpret_cast<type*>(fv.value_buffer_)
-#define SET_VALUE_AS(type, value)  VALUE_AS(type) = (value)
-
-FlagValue::FlagValue(void* valbuf, const char* type,
-                     bool transfer_ownership_of_value)
-    : value_buffer_(valbuf),
-      owns_value_(transfer_ownership_of_value) {
-  for (type_ = 0; type_ <= FV_MAX_INDEX; ++type_) {
-    if (!strcmp(type, TypeName())) {
-      break;
-    }
-  }
-  assert(type_ <= FV_MAX_INDEX);  // Unknown typename
-}
-
-FlagValue::~FlagValue() {
-  if (!owns_value_) {
-    return;
-  }
-  switch (type_) {
-    case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break;
-    case FV_INT32: delete reinterpret_cast<int32*>(value_buffer_); break;
-    case FV_INT64: delete reinterpret_cast<int64*>(value_buffer_); break;
-    case FV_UINT64: delete reinterpret_cast<uint64*>(value_buffer_); break;
-    case FV_DOUBLE: delete reinterpret_cast<double*>(value_buffer_); break;
-    case FV_STRING: delete reinterpret_cast<string*>(value_buffer_); break;
-  }
-}
-
-bool FlagValue::ParseFrom(const char* value) {
-  if (type_ == FV_BOOL) {
-    const char* kTrue[] = { "1", "t", "true", "y", "yes" };
-    const char* kFalse[] = { "0", "f", "false", "n", "no" };
-    for (size_t i = 0; i < sizeof(kTrue)/sizeof(*kTrue); ++i) {
-      if (strcasecmp(value, kTrue[i]) == 0) {
-        SET_VALUE_AS(bool, true);
-        return true;
-      } else if (strcasecmp(value, kFalse[i]) == 0) {
-        SET_VALUE_AS(bool, false);
-        return true;
-      }
-    }
-    return false;   // didn't match a legal input
-
-  } else if (type_ == FV_STRING) {
-    SET_VALUE_AS(string, value);
-    return true;
-  }
-
-  // OK, it's likely to be numeric, and we'll be using a strtoXXX method.
-  if (value[0] == '\0')   // empty-string is only allowed for string type.
-    return false;
-  char* end;
-  // Leading 0x puts us in base 16.  But leading 0 does not put us in base 8!
-  // It caused too many bugs when we had that behavior.
-  int base = 10;    // by default
-  if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X'))
-    base = 16;
-  errno = 0;
-
-  switch (type_) {
-    case FV_INT32: {
-      const int64 r = strtoint64(value, &end, base);
-      if (errno || end != value + strlen(value))  return false;  // bad parse
-      if (static_cast<int32>(r) != r)  // worked, but number out of range
-        return false;
-      SET_VALUE_AS(int32, static_cast<int32>(r));
-      return true;
-    }
-    case FV_INT64: {
-      const int64 r = strtoint64(value, &end, base);
-      if (errno || end != value + strlen(value))  return false;  // bad parse
-      SET_VALUE_AS(int64, r);
-      return true;
-    }
-    case FV_UINT64: {
-      while (*value == ' ') value++;
-      if (*value == '-') return false;  // negative number
-      const uint64 r = strtouint64(value, &end, base);
-      if (errno || end != value + strlen(value))  return false;  // bad parse
-      SET_VALUE_AS(uint64, r);
-      return true;
-    }
-    case FV_DOUBLE: {
-      const double r = strtod(value, &end);
-      if (errno || end != value + strlen(value))  return false;  // bad parse
-      SET_VALUE_AS(double, r);
-      return true;
-    }
-    default: {
-      assert(false);  // unknown type
-      return false;
-    }
-  }
-}
-
-string FlagValue::ToString() const {
-  char intbuf[64];    // enough to hold even the biggest number
-  switch (type_) {
-    case FV_BOOL:
-      return VALUE_AS(bool) ? "true" : "false";
-    case FV_INT32:
-      snprintf(intbuf, sizeof(intbuf), "%"PRId32, VALUE_AS(int32));
-      return intbuf;
-    case FV_INT64:
-      snprintf(intbuf, sizeof(intbuf), "%"PRId64, VALUE_AS(int64));
-      return intbuf;
-    case FV_UINT64:
-      snprintf(intbuf, sizeof(intbuf), "%"PRIu64, VALUE_AS(uint64));
-      return intbuf;
-    case FV_DOUBLE:
-      snprintf(intbuf, sizeof(intbuf), "%.17g", VALUE_AS(double));
-      return intbuf;
-    case FV_STRING:
-      return VALUE_AS(string);
-    default:
-      assert(false);
-      return "";  // unknown type
-  }
-}
-
-bool FlagValue::Validate(const char* flagname,
-                         ValidateFnProto validate_fn_proto) const {
-  switch (type_) {
-    case FV_BOOL:
-      return reinterpret_cast<bool (*)(const char*, bool)>(
-          validate_fn_proto)(flagname, VALUE_AS(bool));
-    case FV_INT32:
-      return reinterpret_cast<bool (*)(const char*, int32)>(
-          validate_fn_proto)(flagname, VALUE_AS(int32));
-    case FV_INT64:
-      return reinterpret_cast<bool (*)(const char*, int64)>(
-          validate_fn_proto)(flagname, VALUE_AS(int64));
-    case FV_UINT64:
-      return reinterpret_cast<bool (*)(const char*, uint64)>(
-          validate_fn_proto)(flagname, VALUE_AS(uint64));
-    case FV_DOUBLE:
-      return reinterpret_cast<bool (*)(const char*, double)>(
-          validate_fn_proto)(flagname, VALUE_AS(double));
-    case FV_STRING:
-      return reinterpret_cast<bool (*)(const char*, const string&)>(
-          validate_fn_proto)(flagname, VALUE_AS(string));
-    default:
-      assert(false);  // unknown type
-      return false;
-  }
-}
-
-const char* FlagValue::TypeName() const {
-  static const char types[] =
-      "bool\0xx"
-      "int32\0x"
-      "int64\0x"
-      "uint64\0"
-      "double\0"
-      "string";
-  if (type_ > FV_MAX_INDEX) {
-    assert(false);
-    return "";
-  }
-  // Directly indexing the strigns in the 'types' string, each of them
-  // is 7 bytes long.
-  return &types[type_ * 7];
-}
-
-bool FlagValue::Equal(const FlagValue& x) const {
-  if (type_ != x.type_)
-    return false;
-  switch (type_) {
-    case FV_BOOL:   return VALUE_AS(bool) == OTHER_VALUE_AS(x, bool);
-    case FV_INT32:  return VALUE_AS(int32) == OTHER_VALUE_AS(x, int32);
-    case FV_INT64:  return VALUE_AS(int64) == OTHER_VALUE_AS(x, int64);
-    case FV_UINT64: return VALUE_AS(uint64) == OTHER_VALUE_AS(x, uint64);
-    case FV_DOUBLE: return VALUE_AS(double) == OTHER_VALUE_AS(x, double);
-    case FV_STRING: return VALUE_AS(string) == OTHER_VALUE_AS(x, string);
-    default: assert(false); return false;  // unknown type
-  }
-}
-
-FlagValue* FlagValue::New() const {
-  const char *type = TypeName();
-  switch (type_) {
-    case FV_BOOL:   return new FlagValue(new bool(false), type, true);
-    case FV_INT32:  return new FlagValue(new int32(0), type, true);
-    case FV_INT64:  return new FlagValue(new int64(0), type, true);
-    case FV_UINT64: return new FlagValue(new uint64(0), type, true);
-    case FV_DOUBLE: return new FlagValue(new double(0.0), type, true);
-    case FV_STRING: return new FlagValue(new string, type, true);
-    default: assert(false); return NULL;  // unknown type
-  }
-}
-
-void FlagValue::CopyFrom(const FlagValue& x) {
-  assert(type_ == x.type_);
-  switch (type_) {
-    case FV_BOOL:   SET_VALUE_AS(bool, OTHER_VALUE_AS(x, bool));      break;
-    case FV_INT32:  SET_VALUE_AS(int32, OTHER_VALUE_AS(x, int32));    break;
-    case FV_INT64:  SET_VALUE_AS(int64, OTHER_VALUE_AS(x, int64));    break;
-    case FV_UINT64: SET_VALUE_AS(uint64, OTHER_VALUE_AS(x, uint64));  break;
-    case FV_DOUBLE: SET_VALUE_AS(double, OTHER_VALUE_AS(x, double));  break;
-    case FV_STRING: SET_VALUE_AS(string, OTHER_VALUE_AS(x, string));  break;
-    default: assert(false);  // unknown type
-  }
-}
-
-int FlagValue::ValueSize() const {
-  if (type_ > FV_MAX_INDEX) {
-    assert(false);  // unknown type
-    return 0;
-  }
-  static const uint8 valuesize[] = {
-    sizeof(bool),
-    sizeof(int32),
-    sizeof(int64),
-    sizeof(uint64),
-    sizeof(double),
-    sizeof(string),
-  };
-  return valuesize[type_];
-}
-
-// --------------------------------------------------------------------
-// CommandLineFlag
-//    This represents a single flag, including its name, description,
-//    default value, and current value.  Mostly this serves as a
-//    struct, though it also knows how to register itself.
-//       All CommandLineFlags are owned by a (exactly one)
-//    FlagRegistry.  If you wish to modify fields in this class, you
-//    should acquire the FlagRegistry lock for the registry that owns
-//    this flag.
-// --------------------------------------------------------------------
-
-class CommandLineFlag {
- public:
-  // Note: we take over memory-ownership of current_val and default_val.
-  CommandLineFlag(const char* name, const char* help, const char* filename,
-                  FlagValue* current_val, FlagValue* default_val);
-  ~CommandLineFlag();
-
-  const char* name() const { return name_; }
-  const char* help() const { return help_; }
-  const char* filename() const { return file_; }
-  const char* CleanFileName() const;  // nixes irrelevant prefix such as homedir
-  string current_value() const { return current_->ToString(); }
-  string default_value() const { return defvalue_->ToString(); }
-  const char* type_name() const { return defvalue_->TypeName(); }
-  ValidateFnProto validate_function() const { return validate_fn_proto_; }
-
-  void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result);
-
-  // If validate_fn_proto_ is non-NULL, calls it on value, returns result.
-  bool Validate(const FlagValue& value) const;
-  bool ValidateCurrent() const { return Validate(*current_); }
-
- private:
-  // for SetFlagLocked() and setting flags_by_ptr_
-  friend class FlagRegistry;
-  friend class GOOGLE_NAMESPACE::FlagSaverImpl;  // for cloning the values
-  // set validate_fn
-  friend bool AddFlagValidator(const void*, ValidateFnProto);
-
-  // This copies all the non-const members: modified, processed, defvalue, etc.
-  void CopyFrom(const CommandLineFlag& src);
-
-  void UpdateModifiedBit();
-
-  const char* const name_;     // Flag name
-  const char* const help_;     // Help message
-  const char* const file_;     // Which file did this come from?
-  bool modified_;              // Set after default assignment?
-  FlagValue* defvalue_;        // Default value for flag
-  FlagValue* current_;         // Current value for flag
-  // This is a casted, 'generic' version of validate_fn, which actually
-  // takes a flag-value as an arg (void (*validate_fn)(bool), say).
-  // When we pass this to current_->Validate(), it will cast it back to
-  // the proper type.  This may be NULL to mean we have no validate_fn.
-  ValidateFnProto validate_fn_proto_;
-
-  CommandLineFlag(const CommandLineFlag&);   // no copying!
-  void operator=(const CommandLineFlag&);
-};
-
-CommandLineFlag::CommandLineFlag(const char* name, const char* help,
-                                 const char* filename,
-                                 FlagValue* current_val, FlagValue* default_val)
-    : name_(name), help_(help), file_(filename), modified_(false),
-      defvalue_(default_val), current_(current_val), validate_fn_proto_(NULL) {
-}
-
-CommandLineFlag::~CommandLineFlag() {
-  delete current_;
-  delete defvalue_;
-}
-
-const char* CommandLineFlag::CleanFileName() const {
-  // Compute top-level directory & file that this appears in
-  // search full path backwards.
-  // Stop going backwards at kRootDir; and skip by the first slash.
-  static const char kRootDir[] = "";    // can set this to root directory,
-                                        // e.g. "myproject"
-
-  if (sizeof(kRootDir)-1 == 0)          // no prefix to strip
-    return filename();
-
-  const char* clean_name = filename() + strlen(filename()) - 1;
-  while ( clean_name > filename() ) {
-    if (*clean_name == PATH_SEPARATOR) {
-      if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) {
-        // ".../myproject/base/logging.cc" ==> "base/logging.cc"
-        clean_name += sizeof(kRootDir)-1;    // past "/myproject/"
-        break;
-      }
-    }
-    --clean_name;
-  }
-  while ( *clean_name == PATH_SEPARATOR ) ++clean_name;  // Skip any slashes
-  return clean_name;
-}
-
-void CommandLineFlag::FillCommandLineFlagInfo(
-    CommandLineFlagInfo* result) {
-  result->name = name();
-  result->type = type_name();
-  result->description = help();
-  result->current_value = current_value();
-  result->default_value = default_value();
-  result->filename = CleanFileName();
-  UpdateModifiedBit();
-  result->is_default = !modified_;
-  result->has_validator_fn = validate_function() != NULL;
-}
-
-void CommandLineFlag::UpdateModifiedBit() {
-  // Update the "modified" bit in case somebody bypassed the
-  // Flags API and wrote directly through the FLAGS_name variable.
-  if (!modified_ && !current_->Equal(*defvalue_)) {
-    modified_ = true;
-  }
-}
-
-void CommandLineFlag::CopyFrom(const CommandLineFlag& src) {
-  // Note we only copy the non-const members; others are fixed at construct time
-  if (modified_ != src.modified_) modified_ = src.modified_;
-  if (!current_->Equal(*src.current_)) current_->CopyFrom(*src.current_);
-  if (!defvalue_->Equal(*src.defvalue_)) defvalue_->CopyFrom(*src.defvalue_);
-  if (validate_fn_proto_ != src.validate_fn_proto_)
-    validate_fn_proto_ = src.validate_fn_proto_;
-}
-
-bool CommandLineFlag::Validate(const FlagValue& value) const {
-  if (validate_function() == NULL)
-    return true;
-  else
-    return value.Validate(name(), validate_function());
-}
-
-
-// --------------------------------------------------------------------
-// FlagRegistry
-//    A FlagRegistry singleton object holds all flag objects indexed
-//    by their names so that if you know a flag's name (as a C
-//    string), you can access or set it.  If the function is named
-//    FooLocked(), you must own the registry lock before calling
-//    the function; otherwise, you should *not* hold the lock, and
-//    the function will acquire it itself if needed.
-// --------------------------------------------------------------------
-
-struct StringCmp {  // Used by the FlagRegistry map class to compare char*'s
-  bool operator() (const char* s1, const char* s2) const {
-    return (strcmp(s1, s2) < 0);
-  }
-};
-
-class FlagRegistry {
- public:
-  FlagRegistry() { }
-  ~FlagRegistry() {
-    for (FlagMap::iterator p = flags_.begin(), e = flags_.end(); p != e; ++p) {
-      CommandLineFlag* flag = p->second;
-      delete flag;
-    }
-  }
-
-  static void DeleteGlobalRegistry() {
-    delete global_registry_;
-    global_registry_ = NULL;
-  }
-
-  void Lock() { lock_.Lock(); }
-  void Unlock() { lock_.Unlock(); }
-
-  // Store a flag in this registry.  Takes ownership of the given pointer.
-  void RegisterFlag(CommandLineFlag* flag);
-
-  // Returns the flag object for the specified name, or NULL if not found.
-  CommandLineFlag* FindFlagLocked(const char* name);
-
-  // Returns the flag object whose current-value is stored at flag_ptr.
-  // That is, for whom current_->value_buffer_ == flag_ptr
-  CommandLineFlag* FindFlagViaPtrLocked(const void* flag_ptr);
-
-  // A fancier form of FindFlag that works correctly if name is of the
-  // form flag=value.  In that case, we set key to point to flag, and
-  // modify v to point to the value (if present), and return the flag
-  // with the given name.  If the flag does not exist, returns NULL
-  // and sets error_message.
-  CommandLineFlag* SplitArgumentLocked(const char* argument,
-                                       string* key, const char** v,
-                                       string* error_message);
-
-  // Set the value of a flag.  If the flag was successfully set to
-  // value, set msg to indicate the new flag-value, and return true.
-  // Otherwise, set msg to indicate the error, leave flag unchanged,
-  // and return false.  msg can be NULL.
-  bool SetFlagLocked(CommandLineFlag* flag, const char* value,
-                     FlagSettingMode set_mode, string* msg);
-
-  static FlagRegistry* GlobalRegistry();   // returns a singleton registry
-
- private:
-  friend class GOOGLE_NAMESPACE::FlagSaverImpl;  // reads all the flags in order to copy them
-  friend class CommandLineFlagParser;    // for ValidateAllFlags
-  friend void GOOGLE_NAMESPACE::GetAllFlags(vector<CommandLineFlagInfo>*);
-
-  // The map from name to flag, for FindFlagLocked().
-  typedef map<const char*, CommandLineFlag*, StringCmp> FlagMap;
-  typedef FlagMap::iterator FlagIterator;
-  typedef FlagMap::const_iterator FlagConstIterator;
-  FlagMap flags_;
-
-  // The map from current-value pointer to flag, fo FindFlagViaPtrLocked().
-  typedef map<const void*, CommandLineFlag*> FlagPtrMap;
-  FlagPtrMap flags_by_ptr_;
-
-  Mutex lock_;
-
-  static FlagRegistry* global_registry_;   // a singleton registry
-  static Mutex global_registry_lock_;  // guards creation of global_registry_
-
-  // Disallow
-  FlagRegistry(const FlagRegistry&);
-  FlagRegistry& operator=(const FlagRegistry&);
-};
-
-FlagRegistry* FlagRegistry::global_registry_ = NULL;
-Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
-
-FlagRegistry* FlagRegistry::GlobalRegistry() {
-  MutexLock acquire_lock(&global_registry_lock_);
-  if (!global_registry_) {
-    global_registry_ = new FlagRegistry;
-  }
-  return global_registry_;
-}
-
-void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
-  Lock();
-  pair<FlagIterator, bool> ins =
-    flags_.insert(pair<const char*, CommandLineFlag*>(flag->name(), flag));
-  if (ins.second == false) {   // means the name was already in the map
-    if (strcmp(ins.first->second->filename(), flag->filename()) != 0) {
-      ReportError(DIE, "ERROR: flag '%s' was defined more than once "
-                  "(in files '%s' and '%s').\n",
-                  flag->name(),
-                  ins.first->second->filename(),
-                  flag->filename());
-    } else {
-      ReportError(DIE, "ERROR: something wrong with flag '%s' in file '%s'.  "
-                  "One possibility: file '%s' is being linked both statically "
-                  "and dynamically into this executable.\n",
-                  flag->name(),
-                  flag->filename(), flag->filename());
-    }
-  }
-  // Also add to the flags_by_ptr_ map.
-  flags_by_ptr_[flag->current_->value_buffer_] = flag;
-  Unlock();
-}
-
-CommandLineFlag* FlagRegistry::FindFlagLocked(const char* name) {
-  FlagConstIterator i = flags_.find(name);
-  if (i == flags_.end()) {
-    return NULL;
-  } else {
-    return i->second;
-  }
-}
-
-CommandLineFlag* FlagRegistry::FindFlagViaPtrLocked(const void* flag_ptr) {
-  FlagPtrMap::const_iterator i = flags_by_ptr_.find(flag_ptr);
-  if (i == flags_by_ptr_.end()) {
-    return NULL;
-  } else {
-    return i->second;
-  }
-}
-
-CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg,
-                                                   string* key,
-                                                   const char** v,
-                                                   string* error_message) {
-  // Find the flag object for this option
-  const char* flag_name;
-  const char* value = strchr(arg, '=');
-  if (value == NULL) {
-    key->assign(arg);
-    *v = NULL;
-  } else {
-    // Strip out the "=value" portion from arg
-    key->assign(arg, value-arg);
-    *v = ++value;    // advance past the '='
-  }
-  flag_name = key->c_str();
-
-  CommandLineFlag* flag = FindFlagLocked(flag_name);
-
-  if (flag == NULL) {
-    // If we can't find the flag-name, then we should return an error.
-    // The one exception is if 1) the flag-name is 'nox', 2) there
-    // exists a flag named 'x', and 3) 'x' is a boolean flag.
-    // In that case, we want to return flag 'x'.
-    if (!(flag_name[0] == 'n' && flag_name[1] == 'o')) {
-      // flag-name is not 'nox', so we're not in the exception case.
-      *error_message = (string(kError) +
-                        "unknown command line flag '" + *key + "'\n");
-      return NULL;
-    }
-    flag = FindFlagLocked(flag_name+2);
-    if (flag == NULL) {
-      // No flag named 'x' exists, so we're not in the exception case.
-      *error_message = (string(kError) +
-                        "unknown command line flag '" + *key + "'\n");
-      return NULL;
-    }
-    if (strcmp(flag->type_name(), "bool") != 0) {
-      // 'x' exists but is not boolean, so we're not in the exception case.
-      *error_message = (string(kError) +
-                        "boolean value (" + *key + ") specified for " +
-                        flag->type_name() + " command line flag\n");
-      return NULL;
-    }
-    // We're in the exception case!
-    // Make up a fake value to replace the "no" we stripped out
-    key->assign(flag_name+2);   // the name without the "no"
-    *v = "0";
-  }
-
-  // Assign a value if this is a boolean flag
-  if (*v == NULL && strcmp(flag->type_name(), "bool") == 0) {
-    *v = "1";    // the --nox case was already handled, so this is the --x case
-  }
-
-  return flag;
-}
-
-bool TryParseLocked(const CommandLineFlag* flag, FlagValue* flag_value,
-                    const char* value, string* msg) {
-  // Use tenative_value, not flag_value, until we know value is valid.
-  FlagValue* tentative_value = flag_value->New();
-  if (!tentative_value->ParseFrom(value)) {
-    if (msg) {
-      *msg += (string(kError) + "illegal value '" + value +
-               + "' specified for " + flag->type_name() + " flag '"
-               + flag->name() + "'\n");
-    }
-    delete tentative_value;
-    return false;
-  } else if (!flag->Validate(*tentative_value)) {
-    if (msg) {
-      *msg += (string(kError) + "failed validation of new value "
-               + "'" + tentative_value->ToString() + "' for flag '" +
-               + flag->name() + "'\n");
-    }
-    delete tentative_value;
-    return false;
-  } else {
-    flag_value->CopyFrom(*tentative_value);
-    if (msg) {
-      *msg += (string(flag->name()) + " set to " + flag_value->ToString()
-               + "\n");
-    }
-    delete tentative_value;
-    return true;
-  }
-}
-
-bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
-                                 const char* value,
-                                 FlagSettingMode set_mode,
-                                 string* msg) {
-  flag->UpdateModifiedBit();
-  switch (set_mode) {
-    case SET_FLAGS_VALUE: {
-      // set or modify the flag's value
-      if (!TryParseLocked(flag, flag->current_, value, msg))
-        return false;
-      flag->modified_ = true;
-      break;
-    }
-    case SET_FLAG_IF_DEFAULT: {
-      // set the flag's value, but only if it hasn't been set by someone else
-      if (!flag->modified_) {
-        if (!TryParseLocked(flag, flag->current_, value, msg))
-          return false;
-        flag->modified_ = true;
-      } else {
-        *msg = string(flag->name()) + " set to " + flag->current_value();
-      }
-      break;
-    }
-    case SET_FLAGS_DEFAULT: {
-      // modify the flag's default-value
-      if (!TryParseLocked(flag, flag->defvalue_, value, msg))
-        return false;
-      if (!flag->modified_) {
-        // Need to set both defvalue *and* current, in this case
-        TryParseLocked(flag, flag->current_, value, NULL);
-      }
-      break;
-    }
-    default: {
-      // unknown set_mode
-      assert(false);
-      return false;
-    }
-  }
-
-  return true;
-}
-
-class FlagRegistryLock {
- public:
-  explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); }
-  ~FlagRegistryLock() { fr_->Unlock(); }
- private:
-  FlagRegistry *const fr_;
-};
-
-// --------------------------------------------------------------------
-// CommandLineFlagParser
-//    Parsing is done in two stages.  In the first, we go through
-//    argv.  For every flag-like arg we can make sense of, we parse
-//    it and set the appropriate FLAGS_* variable.  For every flag-
-//    like arg we can't make sense of, we store it in a vector,
-//    along with an explanation of the trouble.  In stage 2, we
-//    handle the 'reporting' flags like --help and --mpm_version.
-//    (This is via a call to HandleCommandLineHelpFlags(), in
-//    gflags_reporting.cc.)
-//    An optional stage 3 prints out the error messages.
-//       This is a bit of a simplification.  For instance, --flagfile
-//    is handled as soon as it's seen in stage 1, not in stage 2.
-// --------------------------------------------------------------------
-
-class CommandLineFlagParser {
- public:
-  // The argument is the flag-registry to register the parsed flags in
-  explicit CommandLineFlagParser(FlagRegistry* reg) : registry_(reg) {}
-  ~CommandLineFlagParser() {}
-
-  // Stage 1: Every time this is called, it reads all flags in argv.
-  // However, it ignores all flags that have been successfully set
-  // before.  Typically this is only called once, so this 'reparsing'
-  // behavior isn't important.  It can be useful when trying to
-  // reparse after loading a dll, though.
-  uint32 ParseNewCommandLineFlags(int* argc, char*** argv, bool remove_flags);
-
-  // Stage 2: print reporting info and exit, if requested.
-  // In gflags_reporting.cc:HandleCommandLineHelpFlags().
-
-  // Stage 3: validate all the commandline flags that have validators
-  // registered.
-  void ValidateAllFlags();
-
-  // Stage 4: report any errors and return true if any were found.
-  bool ReportErrors();
-
-  // Set a particular command line option.  "newval" is a string
-  // describing the new value that the option has been set to.  If
-  // option_name does not specify a valid option name, or value is not
-  // a valid value for option_name, newval is empty.  Does recursive
-  // processing for --flagfile and --fromenv.  Returns the new value
-  // if everything went ok, or empty-string if not.  (Actually, the
-  // return-string could hold many flag/value pairs due to --flagfile.)
-  // NB: Must have called registry_->Lock() before calling this function.
-  string ProcessSingleOptionLocked(CommandLineFlag* flag,
-                                   const char* value,
-                                   FlagSettingMode set_mode);
-
-  // Set a whole batch of command line options as specified by contentdata,
-  // which is in flagfile format (and probably has been read from a flagfile).
-  // Returns the new value if everything went ok, or empty-string if
-  // not.  (Actually, the return-string could hold many flag/value
-  // pairs due to --flagfile.)
-  // NB: Must have called registry_->Lock() before calling this function.
-  string ProcessOptionsFromStringLocked(const string& contentdata,
-                                        FlagSettingMode set_mode);
-
-  // These are the 'recursive' flags, defined at the top of this file.
-  // Whenever we see these flags on the commandline, we must take action.
-  // These are called by ProcessSingleOptionLocked and, similarly, return
-  // new values if everything went ok, or the empty-string if not.
-  string ProcessFlagfileLocked(const string& flagval, FlagSettingMode set_mode);
-  // diff fromenv/tryfromenv
-  string ProcessFromenvLocked(const string& flagval, FlagSettingMode set_mode,
-                              bool errors_are_fatal);
-
- private:
-  FlagRegistry* const registry_;
-  map<string, string> error_flags_;      // map from name to error message
-  // This could be a set<string>, but we reuse the map to minimize the .o size
-  map<string, string> undefined_names_;  // --[flag] name was not registered
-};
-
-
-// Parse a list of (comma-separated) flags.
-static void ParseFlagList(const char* value, vector<string>* flags) {
-  for (const char *p = value; p && *p; value = p) {
-    p = strchr(value, ',');
-    int len;
-    if (p) {
-      len = static_cast<int>(p - value);
-      p++;
-    } else {
-      len = static_cast<int>(strlen(value));
-    }
-
-    if (len == 0)
-      ReportError(DIE, "ERROR: empty flaglist entry\n");
-    if (value[0] == '-')
-      ReportError(DIE, "ERROR: flag \"%*s\" begins with '-'\n", len, value);
-
-    flags->push_back(string(value, len));
-  }
-}
-
-// Snarf an entire file into a C++ string.  This is just so that we
-// can do all the I/O in one place and not worry about it everywhere.
-// Plus, it's convenient to have the whole file contents at hand.
-// Adds a newline at the end of the file.
-#define PFATAL(s)  do { perror(s); commandlineflags_exitfunc(1); } while (0)
-
-static string ReadFileIntoString(const char* filename) {
-  const int kBufSize = 8092;
-  char buffer[kBufSize];
-  string s;
-  FILE* fp = fopen(filename, "r");
-  if (!fp)  PFATAL(filename);
-  size_t n;
-  while ( (n=fread(buffer, 1, kBufSize, fp)) > 0 ) {
-    if (ferror(fp))  PFATAL(filename);
-    s.append(buffer, n);
-  }
-  fclose(fp);
-  return s;
-}
-
-uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
-                                                       bool remove_flags) {
-  const char *program_name = strrchr((*argv)[0], PATH_SEPARATOR);   // nix path
-  program_name = (program_name == NULL ? (*argv)[0] : program_name+1);
-
-  int first_nonopt = *argc;        // for non-options moved to the end
-
-  registry_->Lock();
-  for (int i = 1; i < first_nonopt; i++) {
-    char* arg = (*argv)[i];
-
-    // Like getopt(), we permute non-option flags to be at the end.
-    if (arg[0] != '-' ||           // must be a program argument
-        (arg[0] == '-' && arg[1] == '\0')) {  // "-" is an argument, not a flag
-      memmove((*argv) + i, (*argv) + i+1, (*argc - (i+1)) * sizeof((*argv)[i]));
-      (*argv)[*argc-1] = arg;      // we go last
-      first_nonopt--;              // we've been pushed onto the stack
-      i--;                         // to undo the i++ in the loop
-      continue;
-    }
-
-    if (arg[0] == '-') arg++;      // allow leading '-'
-    if (arg[0] == '-') arg++;      // or leading '--'
-
-    // -- alone means what it does for GNU: stop options parsing
-    if (*arg == '\0') {
-      first_nonopt = i+1;
-      break;
-    }
-
-    // Find the flag object for this option
-    string key;
-    const char* value;
-    string error_message;
-    CommandLineFlag* flag = registry_->SplitArgumentLocked(arg, &key, &value,
-                                                           &error_message);
-    if (flag == NULL) {
-      undefined_names_[key] = "";    // value isn't actually used
-      error_flags_[key] = error_message;
-      continue;
-    }
-
-    if (value == NULL) {
-      // Boolean options are always assigned a value by SplitArgumentLocked()
-      assert(strcmp(flag->type_name(), "bool") != 0);
-      if (i+1 >= first_nonopt) {
-        // This flag needs a value, but there is nothing available
-        error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'"
-                             + " is missing its argument");
-        if (flag->help() && flag->help()[0] > '\001') {
-          // Be useful in case we have a non-stripped description.
-          error_flags_[key] += string("; flag description: ") + flag->help();
-        }
-        error_flags_[key] += "\n";
-        break;    // we treat this as an unrecoverable error
-      } else {
-        value = (*argv)[++i];                   // read next arg for value
-
-        // Heuristic to detect the case where someone treats a string arg
-        // like a bool:
-        // --my_string_var --foo=bar
-        // We look for a flag of string type, whose value begins with a
-        // dash, and where the flag-name and value are separated by a
-        // space rather than an '='.
-        // To avoid false positives, we also require the word "true"
-        // or "false" in the help string.  Without this, a valid usage
-        // "-lat -30.5" would trigger the warning.  The common cases we
-        // want to solve talk about true and false as values.
-        if (value[0] == '-'
-            && strcmp(flag->type_name(), "string") == 0
-            && (strstr(flag->help(), "true")
-                || strstr(flag->help(), "false"))) {
-          fprintf(stderr, "Did you really mean to set flag '%s'"
-                  " to the value '%s'?\n",
-                  flag->name(), value);
-        }
-      }
-    }
-
-    // TODO(csilvers): only set a flag if we hadn't set it before here
-    ProcessSingleOptionLocked(flag, value, SET_FLAGS_VALUE);
-  }
-  registry_->Unlock();
-
-  if (remove_flags) {   // Fix up argc and argv by removing command line flags
-    (*argv)[first_nonopt-1] = (*argv)[0];
-    (*argv) += (first_nonopt-1);
-    (*argc) -= (first_nonopt-1);
-    first_nonopt = 1;   // because we still don't count argv[0]
-  }
-
-  logging_is_probably_set_up = true;   // because we've parsed --logdir, etc.
-
-  return first_nonopt;
-}
-
-string CommandLineFlagParser::ProcessFlagfileLocked(const string& flagval,
-                                                    FlagSettingMode set_mode) {
-  if (flagval.empty())
-    return "";
-
-  string msg;
-  vector<string> filename_list;
-  ParseFlagList(flagval.c_str(), &filename_list);  // take a list of filenames
-  for (size_t i = 0; i < filename_list.size(); ++i) {
-    const char* file = filename_list[i].c_str();
-    msg += ProcessOptionsFromStringLocked(ReadFileIntoString(file), set_mode);
-  }
-  return msg;
-}
-
-string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval,
-                                                   FlagSettingMode set_mode,
-                                                   bool errors_are_fatal) {
-  if (flagval.empty())
-    return "";
-
-  string msg;
-  vector<string> flaglist;
-  ParseFlagList(flagval.c_str(), &flaglist);
-
-  for (size_t i = 0; i < flaglist.size(); ++i) {
-    const char* flagname = flaglist[i].c_str();
-    CommandLineFlag* flag = registry_->FindFlagLocked(flagname);
-    if (flag == NULL) {
-      error_flags_[flagname] = (string(kError) + "unknown command line flag"
-                                + " '" + flagname + "'"
-                                + " (via --fromenv or --tryfromenv)\n");
-      undefined_names_[flagname] = "";
-      continue;
-    }
-
-    const string envname = string("FLAGS_") + string(flagname);
-    const char* envval = getenv(envname.c_str());
-    if (!envval) {
-      if (errors_are_fatal) {
-        error_flags_[flagname] = (string(kError) + envname +
-                                  " not found in environment\n");
-      }
-      continue;
-    }
-
-    // Avoid infinite recursion.
-    if ((strcmp(envval, "fromenv") == 0) ||
-        (strcmp(envval, "tryfromenv") == 0)) {
-      error_flags_[flagname] = (string(kError) + "infinite recursion on " +
-                                "environment flag '" + envval + "'\n");
-      continue;
-    }
-
-    msg += ProcessSingleOptionLocked(flag, envval, set_mode);
-  }
-  return msg;
-}
-
-string CommandLineFlagParser::ProcessSingleOptionLocked(
-    CommandLineFlag* flag, const char* value, FlagSettingMode set_mode) {
-  string msg;
-  if (value && !registry_->SetFlagLocked(flag, value, set_mode, &msg)) {
-    error_flags_[flag->name()] = msg;
-    return "";
-  }
-
-  // The recursive flags, --flagfile and --fromenv and --tryfromenv,
-  // must be dealt with as soon as they're seen.  They will emit
-  // messages of their own.
-  if (strcmp(flag->name(), "flagfile") == 0) {
-    msg += ProcessFlagfileLocked(FLAGS_flagfile, set_mode);
-
-  } else if (strcmp(flag->name(), "fromenv") == 0) {
-    // last arg indicates envval-not-found is fatal (unlike in --tryfromenv)
-    msg += ProcessFromenvLocked(FLAGS_fromenv, set_mode, true);
-
-  } else if (strcmp(flag->name(), "tryfromenv") == 0) {
-    msg += ProcessFromenvLocked(FLAGS_tryfromenv, set_mode, false);
-  }
-
-  return msg;
-}
-
-void CommandLineFlagParser::ValidateAllFlags() {
-  FlagRegistryLock frl(registry_);
-  for (FlagRegistry::FlagConstIterator i = registry_->flags_.begin();
-       i != registry_->flags_.end(); ++i) {
-    if (!i->second->ValidateCurrent()) {
-      // only set a message if one isn't already there.  (If there's
-      // an error message, our job is done, even if it's not exactly
-      // the same error.)
-      if (error_flags_[i->second->name()].empty())
-        error_flags_[i->second->name()] =
-            string(kError) + "--" + i->second->name() +
-            " must be set on the commandline"
-            " (default value fails validation)\n";
-    }
-  }
-}
-
-bool CommandLineFlagParser::ReportErrors() {
-  // error_flags_ indicates errors we saw while parsing.
-  // But we ignore undefined-names if ok'ed by --undef_ok
-  if (!FLAGS_undefok.empty()) {
-    vector<string> flaglist;
-    ParseFlagList(FLAGS_undefok.c_str(), &flaglist);
-    for (size_t i = 0; i < flaglist.size(); ++i) {
-      // We also deal with --no<flag>, in case the flagname was boolean
-      const string no_version = string("no") + flaglist[i];
-      if (undefined_names_.find(flaglist[i]) != undefined_names_.end()) {
-        error_flags_[flaglist[i]] = "";    // clear the error message
-      } else if (undefined_names_.find(no_version) != undefined_names_.end()) {
-        error_flags_[no_version] = "";
-      }
-    }
-  }
-  // Likewise, if they decided to allow reparsing, all undefined-names
-  // are ok; we just silently ignore them now, and hope that a future
-  // parse will pick them up somehow.
-  if (allow_command_line_reparsing) {
-    for (map<string, string>::const_iterator it = undefined_names_.begin();
-         it != undefined_names_.end();  ++it)
-      error_flags_[it->first] = "";      // clear the error message
-  }
-
-  bool found_error = false;
-  string error_message;
-  for (map<string, string>::const_iterator it = error_flags_.begin();
-       it != error_flags_.end(); ++it) {
-    if (!it->second.empty()) {
-      error_message.append(it->second.data(), it->second.size());
-      found_error = true;
-    }
-  }
-  if (found_error)
-    ReportError(DO_NOT_DIE, "%s", error_message.c_str());
-  return found_error;
-}
-
-string CommandLineFlagParser::ProcessOptionsFromStringLocked(
-    const string& contentdata, FlagSettingMode set_mode) {
-  string retval;
-  const char* flagfile_contents = contentdata.c_str();
-  bool flags_are_relevant = true;   // set to false when filenames don't match
-  bool in_filename_section = false;
-
-  const char* line_end = flagfile_contents;
-  // We read this file a line at a time.
-  for (; line_end; flagfile_contents = line_end + 1) {
-    while (*flagfile_contents && isspace(*flagfile_contents))
-      ++flagfile_contents;
-    line_end = strchr(flagfile_contents, '\n');
-    size_t len = line_end ? static_cast<size_t>(line_end - flagfile_contents)
-                          : strlen(flagfile_contents);
-    string line(flagfile_contents, len);
-
-    // Each line can be one of four things:
-    // 1) A comment line -- we skip it
-    // 2) An empty line -- we skip it
-    // 3) A list of filenames -- starts a new filenames+flags section
-    // 4) A --flag=value line -- apply if previous filenames match
-    if (line.empty() || line[0] == '#') {
-      // comment or empty line; just ignore
-
-    } else if (line[0] == '-') {    // flag
-      in_filename_section = false;  // instead, it was a flag-line
-      if (!flags_are_relevant)      // skip this flag; applies to someone else
-        continue;
-
-      const char* name_and_val = line.c_str() + 1;    // skip the leading -
-      if (*name_and_val == '-')
-        name_and_val++;                               // skip second - too
-      string key;
-      const char* value;
-      string error_message;
-      CommandLineFlag* flag = registry_->SplitArgumentLocked(name_and_val,
-                                                             &key, &value,
-                                                             &error_message);
-      // By API, errors parsing flagfile lines are silently ignored.
-      if (flag == NULL) {
-        // "WARNING: flagname '" + key + "' not found\n"
-      } else if (value == NULL) {
-        // "WARNING: flagname '" + key + "' missing a value\n"
-      } else {
-        retval += ProcessSingleOptionLocked(flag, value, set_mode);
-      }
-
-    } else {                        // a filename!
-      if (!in_filename_section) {   // start over: assume filenames don't match
-        in_filename_section = true;
-        flags_are_relevant = false;
-      }
-
-      // Split the line up at spaces into glob-patterns
-      const char* space = line.c_str();   // just has to be non-NULL
-      for (const char* word = line.c_str(); *space; word = space+1) {
-        if (flags_are_relevant)     // we can stop as soon as we match
-          break;
-        space = strchr(word, ' ');
-        if (space == NULL)
-          space = word + strlen(word);
-        const string glob(word, space - word);
-        // We try matching both against the full argv0 and basename(argv0)
-#ifdef HAVE_FNMATCH_H
-        if (fnmatch(glob.c_str(),
-                    ProgramInvocationName(),
-                    FNM_PATHNAME) == 0 ||
-            fnmatch(glob.c_str(),
-                    ProgramInvocationShortName(),
-                    FNM_PATHNAME) == 0) {
-#else  // !HAVE_FNMATCH_H
-        if ((glob == ProgramInvocationName()) ||
-            (glob == ProgramInvocationShortName())) {
-#endif  // HAVE_FNMATCH_H
-          flags_are_relevant = true;
-        }
-      }
-    }
-  }
-  return retval;
-}
-
-// --------------------------------------------------------------------
-// GetFromEnv()
-// AddFlagValidator()
-//    These are helper functions for routines like BoolFromEnv() and
-//    RegisterFlagValidator, defined below.  They're defined here so
-//    they can live in the unnamed namespace (which makes friendship
-//    declarations for these classes possible).
-// --------------------------------------------------------------------
-
-template<typename T>
-T GetFromEnv(const char *varname, const char* type, T dflt) {
-  const char* const valstr = getenv(varname);
-  if (!valstr)
-    return dflt;
-  FlagValue ifv(new T, type, true);
-  if (!ifv.ParseFrom(valstr))
-    ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n",
-                varname, valstr);
-  return OTHER_VALUE_AS(ifv, T);
-}
-
-bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) {
-  // We want a lock around this routine, in case two threads try to
-  // add a validator (hopefully the same one!) at once.  We could use
-  // our own thread, but we need to loook at the registry anyway, so
-  // we just steal that one.
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  FlagRegistryLock frl(registry);
-  // First, find the flag whose current-flag storage is 'flag'.
-  // This is the CommandLineFlag whose current_->value_buffer_ == flag
-  CommandLineFlag* flag = registry->FindFlagViaPtrLocked(flag_ptr);
-  if (!flag) {
-    // WARNING << "Ignoring RegisterValidateFunction() for flag pointer "
-    //         << flag_ptr << ": no flag found at that address";
-    return false;
-  } else if (validate_fn_proto == flag->validate_function()) {
-    return true;    // ok to register the same function over and over again
-  } else if (validate_fn_proto != NULL && flag->validate_function() != NULL) {
-    // WARNING << "Ignoring RegisterValidateFunction() for flag '"
-    //         << flag->name() << "': validate-fn already registered";
-    return false;
-  } else {
-    flag->validate_fn_proto_ = validate_fn_proto;
-    return true;
-  }
-}
-
-}  // end unnamed namespaces
-
-
-// Now define the functions that are exported via the .h file
-
-// --------------------------------------------------------------------
-// FlagRegisterer
-//    This class exists merely to have a global constructor (the
-//    kind that runs before main(), that goes an initializes each
-//    flag that's been declared.  Note that it's very important we
-//    don't have a destructor that deletes flag_, because that would
-//    cause us to delete current_storage/defvalue_storage as well,
-//    which can cause a crash if anything tries to access the flag
-//    values in a global destructor.
-// --------------------------------------------------------------------
-
-FlagRegisterer::FlagRegisterer(const char* name, const char* type,
-                               const char* help, const char* filename,
-                               void* current_storage, void* defvalue_storage) {
-  if (help == NULL)
-    help = "";
-  // FlagValue expects the type-name to not include any namespace
-  // components, so we get rid of those, if any.
-  if (strchr(type, ':'))
-    type = strrchr(type, ':') + 1;
-  FlagValue* current = new FlagValue(current_storage, type, false);
-  FlagValue* defvalue = new FlagValue(defvalue_storage, type, false);
-  // Importantly, flag_ will never be deleted, so storage is always good.
-  CommandLineFlag* flag = new CommandLineFlag(name, help, filename,
-                                              current, defvalue);
-  FlagRegistry::GlobalRegistry()->RegisterFlag(flag);   // default registry
-}
-
-// --------------------------------------------------------------------
-// GetAllFlags()
-//    The main way the FlagRegistry class exposes its data.  This
-//    returns, as strings, all the info about all the flags in
-//    the main registry, sorted first by filename they are defined
-//    in, and then by flagname.
-// --------------------------------------------------------------------
-
-struct FilenameFlagnameCmp {
-  bool operator()(const CommandLineFlagInfo& a,
-                  const CommandLineFlagInfo& b) const {
-    int cmp = strcmp(a.filename.c_str(), b.filename.c_str());
-    if (cmp == 0)
-      cmp = strcmp(a.name.c_str(), b.name.c_str());  // secondary sort key
-    return cmp < 0;
-  }
-};
-
-void GetAllFlags(vector<CommandLineFlagInfo>* OUTPUT) {
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  registry->Lock();
-  for (FlagRegistry::FlagConstIterator i = registry->flags_.begin();
-       i != registry->flags_.end(); ++i) {
-    CommandLineFlagInfo fi;
-    i->second->FillCommandLineFlagInfo(&fi);
-    OUTPUT->push_back(fi);
-  }
-  registry->Unlock();
-  // Now sort the flags, first by filename they occur in, then alphabetically
-  sort(OUTPUT->begin(), OUTPUT->end(), FilenameFlagnameCmp());
-}
-
-// --------------------------------------------------------------------
-// SetArgv()
-// GetArgvs()
-// GetArgv()
-// GetArgv0()
-// ProgramInvocationName()
-// ProgramInvocationShortName()
-// SetUsageMessage()
-// ProgramUsage()
-//    Functions to set and get argv.  Typically the setter is called
-//    by ParseCommandLineFlags.  Also can get the ProgramUsage string,
-//    set by SetUsageMessage.
-// --------------------------------------------------------------------
-
-// These values are not protected by a Mutex because they are normally
-// set only once during program startup.
-static const char* argv0 = "UNKNOWN";      // just the program name
-static const char* cmdline = "";           // the entire command-line
-static vector<string> argvs;
-static uint32 argv_sum = 0;
-static const char* program_usage = NULL;
-
-void SetArgv(int argc, const char** argv) {
-  static bool called_set_argv = false;
-  if (called_set_argv)         // we already have an argv for you
-    return;
-
-  called_set_argv = true;
-
-  assert(argc > 0);            // every program has at least a progname
-  argv0 = strdup(argv[0]);     // small memory leak, but fn only called once
-  assert(argv0);
-
-  string cmdline_string;       // easier than doing strcats
-  for (int i = 0; i < argc; i++) {
-    if (i != 0) {
-      cmdline_string += " ";
-    }
-    cmdline_string += argv[i];
-    argvs.push_back(argv[i]);
-  }
-  cmdline = strdup(cmdline_string.c_str());  // another small memory leak
-  assert(cmdline);
-
-  // Compute a simple sum of all the chars in argv
-  for (const char* c = cmdline; *c; c++)
-    argv_sum += *c;
-}
-
-const vector<string>& GetArgvs() { return argvs; }
-const char* GetArgv()            { return cmdline; }
-const char* GetArgv0()           { return argv0; }
-uint32 GetArgvSum()              { return argv_sum; }
-const char* ProgramInvocationName() {             // like the GNU libc fn
-  return GetArgv0();
-}
-const char* ProgramInvocationShortName() {        // like the GNU libc fn
-  const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
-  if (!slash)  slash = strrchr(argv0, '\\');
-#endif
-  return slash ? slash + 1 : argv0;
-}
-
-void SetUsageMessage(const string& usage) {
-  if (program_usage != NULL)
-    ReportError(DIE, "ERROR: SetUsageMessage() called twice\n");
-  program_usage = strdup(usage.c_str());      // small memory leak
-}
-
-const char* ProgramUsage() {
-  if (program_usage) {
-    return program_usage;
-  }
-  return "Warning: SetUsageMessage() never called";
-}
-
-// --------------------------------------------------------------------
-// GetCommandLineOption()
-// GetCommandLineFlagInfo()
-// GetCommandLineFlagInfoOrDie()
-// SetCommandLineOption()
-// SetCommandLineOptionWithMode()
-//    The programmatic way to set a flag's value, using a string
-//    for its name rather than the variable itself (that is,
-//    SetCommandLineOption("foo", x) rather than FLAGS_foo = x).
-//    There's also a bit more flexibility here due to the various
-//    set-modes, but typically these are used when you only have
-//    that flag's name as a string, perhaps at runtime.
-//    All of these work on the default, global registry.
-//       For GetCommandLineOption, return false if no such flag
-//    is known, true otherwise.  We clear "value" if a suitable
-//    flag is found.
-// --------------------------------------------------------------------
-
-
-bool GetCommandLineOption(const char* name, string* value) {
-  if (NULL == name)
-    return false;
-  assert(value);
-
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  FlagRegistryLock frl(registry);
-  CommandLineFlag* flag = registry->FindFlagLocked(name);
-  if (flag == NULL) {
-    return false;
-  } else {
-    *value = flag->current_value();
-    return true;
-  }
-}
-
-bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT) {
-  if (NULL == name) return false;
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  FlagRegistryLock frl(registry);
-  CommandLineFlag* flag = registry->FindFlagLocked(name);
-  if (flag == NULL) {
-    return false;
-  } else {
-    assert(OUTPUT);
-    flag->FillCommandLineFlagInfo(OUTPUT);
-    return true;
-  }
-}
-
-CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name) {
-  CommandLineFlagInfo info;
-  if (!GetCommandLineFlagInfo(name, &info)) {
-    fprintf(stderr, "FATAL ERROR: flag name '%s' doesn't exist\n", name);
-    commandlineflags_exitfunc(1);    // almost certainly exit()
-  }
-  return info;
-}
-
-string SetCommandLineOptionWithMode(const char* name, const char* value,
-                                    FlagSettingMode set_mode) {
-  string result;
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  FlagRegistryLock frl(registry);
-  CommandLineFlag* flag = registry->FindFlagLocked(name);
-  if (flag) {
-    CommandLineFlagParser parser(registry);
-    result = parser.ProcessSingleOptionLocked(flag, value, set_mode);
-    if (!result.empty()) {   // in the error case, we've already logged
-      // You could consider logging this change, if you wanted to know it:
-      //fprintf(stderr, "%sFLAGS_%s\n",
-      //        (set_mode == SET_FLAGS_DEFAULT ? "default value of " : ""),
-      //        result);
-    }
-  }
-  // The API of this function is that we return empty string on error
-  return result;
-}
-
-string SetCommandLineOption(const char* name, const char* value) {
-  return SetCommandLineOptionWithMode(name, value, SET_FLAGS_VALUE);
-}
-
-// --------------------------------------------------------------------
-// FlagSaver
-// FlagSaverImpl
-//    This class stores the states of all flags at construct time,
-//    and restores all flags to that state at destruct time.
-//    Its major implementation challenge is that it never modifies
-//    pointers in the 'main' registry, so global FLAG_* vars always
-//    point to the right place.
-// --------------------------------------------------------------------
-
-class FlagSaverImpl {
- public:
-  // Constructs an empty FlagSaverImpl object.
-  explicit FlagSaverImpl(FlagRegistry* main_registry)
-      : main_registry_(main_registry) { }
-  ~FlagSaverImpl() {
-    // reclaim memory from each of our CommandLineFlags
-    vector<CommandLineFlag*>::const_iterator it;
-    for (it = backup_registry_.begin(); it != backup_registry_.end(); ++it)
-      delete *it;
-  }
-
-  // Saves the flag states from the flag registry into this object.
-  // It's an error to call this more than once.
-  // Must be called when the registry mutex is not held.
-  void SaveFromRegistry() {
-    FlagRegistryLock frl(main_registry_);
-    assert(backup_registry_.empty());   // call only once!
-    for (FlagRegistry::FlagConstIterator it = main_registry_->flags_.begin();
-         it != main_registry_->flags_.end();
-         ++it) {
-      const CommandLineFlag* main = it->second;
-      // Sets up all the const variables in backup correctly
-      CommandLineFlag* backup = new CommandLineFlag(
-          main->name(), main->help(), main->filename(),
-          main->current_->New(), main->defvalue_->New());
-      // Sets up all the non-const variables in backup correctly
-      backup->CopyFrom(*main);
-      backup_registry_.push_back(backup);   // add it to a convenient list
-    }
-  }
-
-  // Restores the saved flag states into the flag registry.  We
-  // assume no flags were added or deleted from the registry since
-  // the SaveFromRegistry; if they were, that's trouble!  Must be
-  // called when the registry mutex is not held.
-  void RestoreToRegistry() {
-    FlagRegistryLock frl(main_registry_);
-    vector<CommandLineFlag*>::const_iterator it;
-    for (it = backup_registry_.begin(); it != backup_registry_.end(); ++it) {
-      CommandLineFlag* main = main_registry_->FindFlagLocked((*it)->name());
-      if (main != NULL) {       // if NULL, flag got deleted from registry(!)
-        main->CopyFrom(**it);
-      }
-    }
-  }
-
- private:
-  FlagRegistry* const main_registry_;
-  vector<CommandLineFlag*> backup_registry_;
-
-  FlagSaverImpl(const FlagSaverImpl&);  // no copying!
-  void operator=(const FlagSaverImpl&);
-};
-
-FlagSaver::FlagSaver()
-    : impl_(new FlagSaverImpl(FlagRegistry::GlobalRegistry())) {
-  impl_->SaveFromRegistry();
-}
-
-FlagSaver::~FlagSaver() {
-  impl_->RestoreToRegistry();
-  delete impl_;
-}
-
-
-// --------------------------------------------------------------------
-// CommandlineFlagsIntoString()
-// ReadFlagsFromString()
-// AppendFlagsIntoFile()
-// ReadFromFlagsFile()
-//    These are mostly-deprecated routines that stick the
-//    commandline flags into a file/string and read them back
-//    out again.  I can see a use for CommandlineFlagsIntoString,
-//    for creating a flagfile, but the rest don't seem that useful
-//    -- some, I think, are a poor-man's attempt at FlagSaver --
-//    and are included only until we can delete them from callers.
-//    Note they don't save --flagfile flags (though they do save
-//    the result of having called the flagfile, of course).
-// --------------------------------------------------------------------
-
-static string TheseCommandlineFlagsIntoString(
-    const vector<CommandLineFlagInfo>& flags) {
-  vector<CommandLineFlagInfo>::const_iterator i;
-
-  size_t retval_space = 0;
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    // An (over)estimate of how much space it will take to print this flag
-    retval_space += i->name.length() + i->current_value.length() + 5;
-  }
-
-  string retval;
-  retval.reserve(retval_space);
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    retval += "--";
-    retval += i->name;
-    retval += "=";
-    retval += i->current_value;
-    retval += "\n";
-  }
-  return retval;
-}
-
-string CommandlineFlagsIntoString() {
-  vector<CommandLineFlagInfo> sorted_flags;
-  GetAllFlags(&sorted_flags);
-  return TheseCommandlineFlagsIntoString(sorted_flags);
-}
-
-bool ReadFlagsFromString(const string& flagfilecontents,
-                         const char* /*prog_name*/,  // TODO(csilvers): nix this
-                         bool errors_are_fatal) {
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  FlagSaverImpl saved_states(registry);
-  saved_states.SaveFromRegistry();
-
-  CommandLineFlagParser parser(registry);
-  registry->Lock();
-  parser.ProcessOptionsFromStringLocked(flagfilecontents, SET_FLAGS_VALUE);
-  registry->Unlock();
-  // Should we handle --help and such when reading flags from a string?  Sure.
-  HandleCommandLineHelpFlags();
-  if (parser.ReportErrors()) {
-    // Error.  Restore all global flags to their previous values.
-    if (errors_are_fatal)
-      commandlineflags_exitfunc(1);    // almost certainly exit()
-    saved_states.RestoreToRegistry();
-    return false;
-  }
-  return true;
-}
-
-// TODO(csilvers): nix prog_name in favor of ProgramInvocationShortName()
-bool AppendFlagsIntoFile(const string& filename, const char *prog_name) {
-  FILE *fp = fopen(filename.c_str(), "a");
-  if (!fp) {
-    return false;
-  }
-
-  if (prog_name)
-    fprintf(fp, "%s\n", prog_name);
-
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);
-  // But we don't want --flagfile, which leads to weird recursion issues
-  vector<CommandLineFlagInfo>::iterator i;
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    if (strcmp(i->name.c_str(), "flagfile") == 0) {
-      flags.erase(i);
-      break;
-    }
-  }
-  fprintf(fp, "%s", TheseCommandlineFlagsIntoString(flags).c_str());
-
-  fclose(fp);
-  return true;
-}
-
-bool ReadFromFlagsFile(const string& filename, const char* prog_name,
-                       bool errors_are_fatal) {
-  return ReadFlagsFromString(ReadFileIntoString(filename.c_str()),
-                             prog_name, errors_are_fatal);
-}
-
-
-// --------------------------------------------------------------------
-// BoolFromEnv()
-// Int32FromEnv()
-// Int64FromEnv()
-// Uint64FromEnv()
-// DoubleFromEnv()
-// StringFromEnv()
-//    Reads the value from the environment and returns it.
-//    We use an FlagValue to make the parsing easy.
-//    Example usage:
-//       DEFINE_bool(myflag, BoolFromEnv("MYFLAG_DEFAULT", false), "whatever");
-// --------------------------------------------------------------------
-
-bool BoolFromEnv(const char *v, bool dflt) {
-  return GetFromEnv(v, "bool", dflt);
-}
-int32 Int32FromEnv(const char *v, int32 dflt) {
-  return GetFromEnv(v, "int32", dflt);
-}
-int64 Int64FromEnv(const char *v, int64 dflt)    {
-  return GetFromEnv(v, "int64", dflt);
-}
-uint64 Uint64FromEnv(const char *v, uint64 dflt) {
-  return GetFromEnv(v, "uint64", dflt);
-}
-double DoubleFromEnv(const char *v, double dflt) {
-  return GetFromEnv(v, "double", dflt);
-}
-const char *StringFromEnv(const char *varname, const char *dflt) {
-  const char* const val = getenv(varname);
-  return val ? val : dflt;
-}
-
-
-// --------------------------------------------------------------------
-// RegisterFlagValidator()
-//    RegisterFlagValidator() is the function that clients use to
-//    'decorate' a flag with a validation function.  Once this is
-//    done, every time the flag is set (including when the flag
-//    is parsed from argv), the validator-function is called.
-//       These functions return true if the validator was added
-//    successfully, or false if not: the flag already has a validator,
-//    (only one allowed per flag), the 1st arg isn't a flag, etc.
-//       This function is not thread-safe.
-// --------------------------------------------------------------------
-
-bool RegisterFlagValidator(const bool* flag,
-                           bool (*validate_fn)(const char*, bool)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-bool RegisterFlagValidator(const int32* flag,
-                           bool (*validate_fn)(const char*, int32)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-bool RegisterFlagValidator(const int64* flag,
-                           bool (*validate_fn)(const char*, int64)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-bool RegisterFlagValidator(const uint64* flag,
-                           bool (*validate_fn)(const char*, uint64)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-bool RegisterFlagValidator(const double* flag,
-                           bool (*validate_fn)(const char*, double)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-bool RegisterFlagValidator(const string* flag,
-                           bool (*validate_fn)(const char*, const string&)) {
-  return AddFlagValidator(flag, reinterpret_cast<ValidateFnProto>(validate_fn));
-}
-
-
-// --------------------------------------------------------------------
-// ParseCommandLineFlags()
-// ParseCommandLineNonHelpFlags()
-// HandleCommandLineHelpFlags()
-//    This is the main function called from main(), to actually
-//    parse the commandline.  It modifies argc and argv as described
-//    at the top of gflags.h.  You can also divide this
-//    function into two parts, if you want to do work between
-//    the parsing of the flags and the printing of any help output.
-// --------------------------------------------------------------------
-
-static uint32 ParseCommandLineFlagsInternal(int* argc, char*** argv,
-                                            bool remove_flags, bool do_report) {
-  SetArgv(*argc, const_cast<const char**>(*argv));    // save it for later
-
-  FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
-  CommandLineFlagParser parser(registry);
-
-  // When we parse the commandline flags, we'll handle --flagfile,
-  // --tryfromenv, etc. as we see them (since flag-evaluation order
-  // may be important).  But sometimes apps set FLAGS_tryfromenv/etc.
-  // manually before calling ParseCommandLineFlags.  We want to evaluate
-  // those too, as if they were the first flags on the commandline.
-  registry->Lock();
-  parser.ProcessFlagfileLocked(FLAGS_flagfile, SET_FLAGS_VALUE);
-  // Last arg here indicates whether flag-not-found is a fatal error or not
-  parser.ProcessFromenvLocked(FLAGS_fromenv, SET_FLAGS_VALUE, true);
-  parser.ProcessFromenvLocked(FLAGS_tryfromenv, SET_FLAGS_VALUE, false);
-  registry->Unlock();
-
-  // Now get the flags specified on the commandline
-  const int r = parser.ParseNewCommandLineFlags(argc, argv, remove_flags);
-
-  if (do_report)
-    HandleCommandLineHelpFlags();   // may cause us to exit on --help, etc.
-
-  // See if any of the unset flags fail their validation checks
-  parser.ValidateAllFlags();
-
-  if (parser.ReportErrors())        // may cause us to exit on illegal flags
-    commandlineflags_exitfunc(1);   // almost certainly exit()
-  return r;
-}
-
-uint32 ParseCommandLineFlags(int* argc, char*** argv, bool remove_flags) {
-  return ParseCommandLineFlagsInternal(argc, argv, remove_flags, true);
-}
-
-uint32 ParseCommandLineNonHelpFlags(int* argc, char*** argv,
-                                    bool remove_flags) {
-  return ParseCommandLineFlagsInternal(argc, argv, remove_flags, false);
-}
-
-// --------------------------------------------------------------------
-// AllowCommandLineReparsing()
-// ReparseCommandLineNonHelpFlags()
-//    This is most useful for shared libraries.  The idea is if
-//    a flag is defined in a shared library that is dlopen'ed
-//    sometime after main(), you can ParseCommandLineFlags before
-//    the dlopen, then ReparseCommandLineNonHelpFlags() after the
-//    dlopen, to get the new flags.  But you have to explicitly
-//    Allow() it; otherwise, you get the normal default behavior
-//    of unrecognized flags calling a fatal error.
-// TODO(csilvers): this isn't used.  Just delete it?
-// --------------------------------------------------------------------
-
-void AllowCommandLineReparsing() {
-  allow_command_line_reparsing = true;
-}
-
-uint32 ReparseCommandLineNonHelpFlags() {
-  // We make a copy of argc and argv to pass in
-  const vector<string>& argvs = GetArgvs();
-  int tmp_argc = static_cast<int>(argvs.size());
-  char** tmp_argv = new char* [tmp_argc + 1];
-  for (int i = 0; i < tmp_argc; ++i)
-    tmp_argv[i] = strdup(argvs[i].c_str());   // TODO(csilvers): don't dup
-
-  const int retval = ParseCommandLineNonHelpFlags(&tmp_argc, &tmp_argv, false);
-
-  for (int i = 0; i < tmp_argc; ++i)
-    free(tmp_argv[i]);
-  delete[] tmp_argv;
-
-  return retval;
-}
-
-void ShutDownCommandLineFlags() {
-  FlagRegistry::DeleteGlobalRegistry();
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 585
Src/ThirdParty/gflags/src/gflags/gflags.h

@@ -1,585 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Ray Sidney
-// Revamped and reorganized by Craig Silverstein
-//
-// This is the file that should be included by any file which declares
-// or defines a command line flag or wants to parse command line flags
-// or print a program usage message (which will include information about
-// flags).  Executive summary, in the form of an example foo.cc file:
-//
-//    #include "foo.h"         // foo.h has a line "DECLARE_int32(start);"
-//    #include "validators.h"  // hypothetical file defining ValidateIsFile()
-//
-//    DEFINE_int32(end, 1000, "The last record to read");
-//
-//    DEFINE_string(filename, "my_file.txt", "The file to read");
-//    // Crash if the specified file does not exist.
-//    static bool dummy = RegisterFlagValidator(&FLAGS_filename,
-//                                              &ValidateIsFile);
-//
-//    DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
-//
-//    void MyFunc() {
-//      if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
-//    }
-//
-// Then, at the command-line:
-//    ./foo --noverbose --start=5 --end=100
-//
-// For more details, see
-//    doc/gflags.html
-//
-// --- A note about thread-safety:
-//
-// We describe many functions in this routine as being thread-hostile,
-// thread-compatible, or thread-safe.  Here are the meanings we use:
-//
-// thread-safe: it is safe for multiple threads to call this routine
-//   (or, when referring to a class, methods of this class)
-//   concurrently.
-// thread-hostile: it is not safe for multiple threads to call this
-//   routine (or methods of this class) concurrently.  In gflags,
-//   most thread-hostile routines are intended to be called early in,
-//   or even before, main() -- that is, before threads are spawned.
-// thread-compatible: it is safe for multiple threads to read from
-//   this variable (when applied to variables), or to call const
-//   methods of this class (when applied to classes), as long as no
-//   other thread is writing to the variable or calling non-const
-//   methods of this class.
-
-#ifndef GOOGLE_GFLAGS_H_
-#define GOOGLE_GFLAGS_H_
-
-#include <string>
-#include <vector>
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at gflags.h.in to see how they're calculated (based on your config).
-#if 1
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 1
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-namespace google {
-
-#if 1      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 1   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0     // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-// --------------------------------------------------------------------
-// To actually define a flag in a file, use DEFINE_bool,
-// DEFINE_string, etc. at the bottom of this file.  You may also find
-// it useful to register a validator with the flag.  This ensures that
-// when the flag is parsed from the commandline, or is later set via
-// SetCommandLineOption, we call the validation function. It is _not_
-// called when you assign the value to the flag directly using the = operator.
-//
-// The validation function should return true if the flag value is valid, and
-// false otherwise. If the function returns false for the new setting of the
-// flag, the flag will retain its current value. If it returns false for the
-// default value, ParseCommandLineFlags() will die.
-//
-// This function is safe to call at global construct time (as in the
-// example below).
-//
-// Example use:
-//    static bool ValidatePort(const char* flagname, int32 value) {
-//       if (value > 0 && value < 32768)   // value is ok
-//         return true;
-//       printf("Invalid value for --%s: %d\n", flagname, (int)value);
-//       return false;
-//    }
-//    DEFINE_int32(port, 0, "What port to listen on");
-//    static bool dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
-
-// Returns true if successfully registered, false if not (because the
-// first argument doesn't point to a command-line flag, or because a
-// validator is already registered for this flag).
-bool RegisterFlagValidator(const bool* flag,
-                           bool (*validate_fn)(const char*, bool));
-bool RegisterFlagValidator(const int32* flag,
-                           bool (*validate_fn)(const char*, int32));
-bool RegisterFlagValidator(const int64* flag,
-                           bool (*validate_fn)(const char*, int64));
-bool RegisterFlagValidator(const uint64* flag,
-                           bool (*validate_fn)(const char*, uint64));
-bool RegisterFlagValidator(const double* flag,
-                           bool (*validate_fn)(const char*, double));
-bool RegisterFlagValidator(const std::string* flag,
-                           bool (*validate_fn)(const char*, const std::string&));
-
-
-// --------------------------------------------------------------------
-// These methods are the best way to get access to info about the
-// list of commandline flags.  Note that these routines are pretty slow.
-//   GetAllFlags: mostly-complete info about the list, sorted by file.
-//   ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
-//   ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
-//
-// In addition to accessing flags, you can also access argv[0] (the program
-// name) and argv (the entire commandline), which we sock away a copy of.
-// These variables are static, so you should only set them once.
-
-struct CommandLineFlagInfo {
-  std::string name;           // the name of the flag
-  std::string type;           // the type of the flag: int32, etc
-  std::string description;    // the "help text" associated with the flag
-  std::string current_value;  // the current value, as a string
-  std::string default_value;  // the default value, as a string
-  std::string filename;       // 'cleaned' version of filename holding the flag
-  bool has_validator_fn;      // true if RegisterFlagValidator called on flag
-  bool is_default;            // true if the flag has the default value and
-                              // has not been set explicitly from the cmdline
-                              // or via SetCommandLineOption
-};
-
-// Using this inside of a validator is a recipe for a deadlock.
-// TODO(wojtekm) Fix locking when validators are running, to make it safe to
-// call validators during ParseAllFlags.
-// Also make sure then to uncomment the corresponding unit test in
-// commandlineflags_unittest.sh
-extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
-// These two are actually defined in commandlineflags_reporting.cc.
-extern void ShowUsageWithFlags(const char *argv0);  // what --help does
-extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
-
-// Create a descriptive string for a flag.
-// Goes to some trouble to make pretty line breaks.
-extern std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
-
-// Thread-hostile; meant to be called before any threads are spawned.
-extern void SetArgv(int argc, const char** argv);
-// The following functions are thread-safe as long as SetArgv() is
-// only called before any threads start.
-extern const std::vector<std::string>& GetArgvs();  // all of argv as a vector
-extern const char* GetArgv();                // all of argv as a string
-extern const char* GetArgv0();               // only argv0
-extern uint32 GetArgvSum();                  // simple checksum of argv
-extern const char* ProgramInvocationName();  // argv0, or "UNKNOWN" if not set
-extern const char* ProgramInvocationShortName();   // basename(argv0)
-// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
-// called before any threads start.
-extern const char* ProgramUsage();           // string set by SetUsageMessage()
-
-
-// --------------------------------------------------------------------
-// Normally you access commandline flags by just saying "if (FLAGS_foo)"
-// or whatever, and set them by calling "FLAGS_foo = bar" (or, more
-// commonly, via the DEFINE_foo macro).  But if you need a bit more
-// control, we have programmatic ways to get/set the flags as well.
-// These programmatic ways to access flags are thread-safe, but direct
-// access is only thread-compatible.
-
-// Return true iff the flagname was found.
-// OUTPUT is set to the flag's value, or unchanged if we return false.
-extern bool GetCommandLineOption(const char* name, std::string* OUTPUT);
-
-// Return true iff the flagname was found. OUTPUT is set to the flag's
-// CommandLineFlagInfo or unchanged if we return false.
-extern bool GetCommandLineFlagInfo(const char* name,
-                                   CommandLineFlagInfo* OUTPUT);
-
-// Return the CommandLineFlagInfo of the flagname.  exit() if name not found.
-// Example usage, to check if a flag's value is currently the default value:
-//   if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
-extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
-
-enum FlagSettingMode {
-  // update the flag's value (can call this multiple times).
-  SET_FLAGS_VALUE,
-  // update the flag's value, but *only if* it has not yet been updated
-  // with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef".
-  SET_FLAG_IF_DEFAULT,
-  // set the flag's default value to this.  If the flag has not yet updated
-  // yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef")
-  // change the flag's current value to the new default value as well.
-  SET_FLAGS_DEFAULT
-};
-
-// Set a particular flag ("command line option").  Returns a string
-// describing the new value that the option has been set to.  The
-// return value API is not well-specified, so basically just depend on
-// it to be empty if the setting failed for some reason -- the name is
-// not a valid flag name, or the value is not a valid value -- and
-// non-empty else.
-
-// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
-extern std::string SetCommandLineOption(const char* name, const char* value);
-extern std::string SetCommandLineOptionWithMode(const char* name, const char* value,
-                                                FlagSettingMode set_mode);
-
-
-// --------------------------------------------------------------------
-// Saves the states (value, default value, whether the user has set
-// the flag, registered validators, etc) of all flags, and restores
-// them when the FlagSaver is destroyed.  This is very useful in
-// tests, say, when you want to let your tests change the flags, but
-// make sure that they get reverted to the original states when your
-// test is complete.
-//
-// Example usage:
-//   void TestFoo() {
-//     FlagSaver s1;
-//     FLAG_foo = false;
-//     FLAG_bar = "some value";
-//
-//     // test happens here.  You can return at any time
-//     // without worrying about restoring the FLAG values.
-//   }
-//
-// Note: This class is marked with __attribute__((unused)) because all the
-// work is done in the constructor and destructor, so in the standard
-// usage example above, the compiler would complain that it's an
-// unused variable.
-//
-// This class is thread-safe.
-
-class FlagSaver {
- public:
-  FlagSaver();
-  ~FlagSaver();
-
- private:
-  class FlagSaverImpl* impl_;   // we use pimpl here to keep API steady
-
-  FlagSaver(const FlagSaver&);  // no copying!
-  void operator=(const FlagSaver&);
-} __attribute__ ((unused));
-
-// --------------------------------------------------------------------
-// Some deprecated or hopefully-soon-to-be-deprecated functions.
-
-// This is often used for logging.  TODO(csilvers): figure out a better way
-extern std::string CommandlineFlagsIntoString();
-// Usually where this is used, a FlagSaver should be used instead.
-extern bool ReadFlagsFromString(const std::string& flagfilecontents,
-                                const char* prog_name,
-                                bool errors_are_fatal); // uses SET_FLAGS_VALUE
-
-// These let you manually implement --flagfile functionality.
-// DEPRECATED.
-extern bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
-extern bool SaveCommandFlags();  // actually defined in google.cc !
-extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
-                              bool errors_are_fatal);   // uses SET_FLAGS_VALUE
-
-
-// --------------------------------------------------------------------
-// Useful routines for initializing flags from the environment.
-// In each case, if 'varname' does not exist in the environment
-// return defval.  If 'varname' does exist but is not valid
-// (e.g., not a number for an int32 flag), abort with an error.
-// Otherwise, return the value.  NOTE: for booleans, for true use
-// 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
-
-extern bool BoolFromEnv(const char *varname, bool defval);
-extern int32 Int32FromEnv(const char *varname, int32 defval);
-extern int64 Int64FromEnv(const char *varname, int64 defval);
-extern uint64 Uint64FromEnv(const char *varname, uint64 defval);
-extern double DoubleFromEnv(const char *varname, double defval);
-extern const char *StringFromEnv(const char *varname, const char *defval);
-
-
-// --------------------------------------------------------------------
-// The next two functions parse commandlineflags from main():
-
-// Set the "usage" message for this program.  For example:
-//   string usage("This program does nothing.  Sample usage:\n");
-//   usage += argv[0] + " <uselessarg1> <uselessarg2>";
-//   SetUsageMessage(usage);
-// Do not include commandline flags in the usage: we do that for you!
-// Thread-hostile; meant to be called before any threads are spawned.
-extern void SetUsageMessage(const std::string& usage);
-
-// Looks for flags in argv and parses them.  Rearranges argv to put
-// flags first, or removes them entirely if remove_flags is true.
-// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.  Returns the index (into argv)
-// of the first non-flag argument.
-// See top-of-file for more details on this function.
-#ifndef SWIG   // In swig, use ParseCommandLineFlagsScript() instead.
-extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
-                                    bool remove_flags);
-#endif
-
-
-// Calls to ParseCommandLineNonHelpFlags and then to
-// HandleCommandLineHelpFlags can be used instead of a call to
-// ParseCommandLineFlags during initialization, in order to allow for
-// changing default values for some FLAGS (via
-// e.g. SetCommandLineOptionWithMode calls) between the time of
-// command line parsing and the time of dumping help information for
-// the flags as a result of command line parsing.  If a flag is
-// defined more than once in the command line or flag file, the last
-// definition is used.  Returns the index (into argv) of the first
-// non-flag argument.  (If remove_flags is true, will always return 1.)
-extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
-                                           bool remove_flags);
-// This is actually defined in commandlineflags_reporting.cc.
-// This function is misnamed (it also handles --version, etc.), but
-// it's too late to change that now. :-(
-extern void HandleCommandLineHelpFlags();   // in commandlineflags_reporting.cc
-
-// Allow command line reparsing.  Disables the error normally
-// generated when an unknown flag is found, since it may be found in a
-// later parse.  Thread-hostile; meant to be called before any threads
-// are spawned.
-extern void AllowCommandLineReparsing();
-
-// Reparse the flags that have not yet been recognized.  Only flags
-// registered since the last parse will be recognized.  Any flag value
-// must be provided as part of the argument using "=", not as a
-// separate command line argument that follows the flag argument.
-// Intended for handling flags from dynamically loaded libraries,
-// since their flags are not registered until they are loaded.
-// Returns the index (into the original argv) of the first non-flag
-// argument.  (If remove_flags is true, will always return 1.)
-extern uint32 ReparseCommandLineNonHelpFlags();
-
-// Clean up memory allocated by flags.  This is only needed to reduce
-// the quantity of "potentially leaked" reports emitted by memory
-// debugging tools such as valgrind.  It is not required for normal
-// operation, or for the perftools heap-checker.  It must only be called
-// when the process is about to exit, and all threads that might
-// access flags are quiescent.  Referencing flags after this is called
-// will have unexpected consequences.  This is not safe to run when
-// multiple threads might be running: the function is thread-hostile.
-extern void ShutDownCommandLineFlags();
-
-
-// --------------------------------------------------------------------
-// Now come the command line flag declaration/definition macros that
-// will actually be used.  They're kind of hairy.  A major reason
-// for this is initialization: we want people to be able to access
-// variables in global constructors and have that not crash, even if
-// their global constructor runs before the global constructor here.
-// (Obviously, we can't guarantee the flags will have the correct
-// default value in that case, but at least accessing them is safe.)
-// The only way to do that is have flags point to a static buffer.
-// So we make one, using a union to ensure proper alignment, and
-// then use placement-new to actually set up the flag with the
-// correct default value.  In the same vein, we have to worry about
-// flag access in global destructors, so FlagRegisterer has to be
-// careful never to destroy the flag-values it constructs.
-//
-// Note that when we define a flag variable FLAGS_<name>, we also
-// preemptively define a junk variable, FLAGS_no<name>.  This is to
-// cause a link-time error if someone tries to define 2 flags with
-// names like "logging" and "nologging".  We do this because a bool
-// flag FLAG can be set from the command line to true with a "-FLAG"
-// argument, and to false with a "-noFLAG" argument, and so this can
-// potentially avert confusion.
-//
-// We also put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the current
-// namespace.  The net result is to force people to use DECLARE to get
-// access to a flag, rather than saying "extern bool FLAGS_whatever;"
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want, and
-// make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-
-class FlagRegisterer {
- public:
-  FlagRegisterer(const char* name, const char* type,
-                 const char* help, const char* filename,
-                 void* current_storage, void* defvalue_storage);
-};
-
-extern bool FlagsTypeWarn(const char *name);
-
-// If your application #defines STRIP_FLAG_HELP to a non-zero value
-// before #including this file, we remove the help message from the
-// binary file. This can reduce the size of the resulting binary
-// somewhat, and may also be useful for security reasons.
-
-extern const char kStrippedFlagHelp[];
-
-}
-
-#ifndef SWIG  // In swig, ignore the main flag declarations
-
-#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
-// Need this construct to avoid the 'defined but not used' warning.
-#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : ::google::kStrippedFlagHelp)
-#else
-#define MAYBE_STRIPPED_HELP(txt) txt
-#endif
-
-// Each command-line flag has two variables associated with it: one
-// with the current value, and one with the default value.  However,
-// we have a third variable, which is where value is assigned; it's a
-// constant.  This guarantees that FLAG_##value is initialized at
-// static initialization time (e.g. before program-start) rather than
-// than global construction time (which is after program-start but
-// before main), at least when 'value' is a compile-time constant.  We
-// use a small trick for the "default value" variable, and call it
-// FLAGS_no<name>.  This serves the second purpose of assuring a
-// compile error if someone tries to define a flag named no<name>
-// which is illegal (--foo and --nofoo both affect the "foo" flag).
-#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
-  namespace fL##shorttype {                                     \
-    static const type FLAGS_nono##name = value;                 \
-    type FLAGS_##name = FLAGS_nono##name;                       \
-    type FLAGS_no##name = FLAGS_nono##name;                     \
-    static ::google::FlagRegisterer o_##name(      \
-      #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__,        \
-      &FLAGS_##name, &FLAGS_no##name);                          \
-  }                                                             \
-  using fL##shorttype::FLAGS_##name
-
-#define DECLARE_VARIABLE(type, shorttype, name) \
-  namespace fL##shorttype {                     \
-    extern type FLAGS_##name;                   \
-  }                                             \
-  using fL##shorttype::FLAGS_##name
-
-// For DEFINE_bool, we want to do the extra check that the passed-in
-// value is actually a bool, and not a string or something that can be
-// coerced to a bool.  These declarations (no definition needed!) will
-// help us do that, and never evaluate From, which is important.
-// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
-// that the compiler have different sizes for bool & double. Since
-// this is not guaranteed by the standard, we check it with a
-// compile-time assert (msg[-1] will give a compile-time error).
-namespace fLB {
-struct CompileAssert {};
-typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
-                      (sizeof(double) != sizeof(bool)) ? 1 : -1];
-template<typename From> double IsBoolFlag(const From& from);
-bool IsBoolFlag(bool from);
-}  // namespace fLB
-
-#define DECLARE_bool(name)          DECLARE_VARIABLE(bool, B, name)
-#define DEFINE_bool(name, val, txt)                                       \
-  namespace fLB {                                                         \
-    typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[       \
-            (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
-  }                                                                       \
-  DEFINE_VARIABLE(bool, B, name, val, txt)
-
-#define DECLARE_int32(name)         DECLARE_VARIABLE(::google::int32, I, name)
-#define DEFINE_int32(name,val,txt)  DEFINE_VARIABLE(::google::int32, I, name, val, txt)
-
-#define DECLARE_int64(name)         DECLARE_VARIABLE(::google::int64, I64, name)
-#define DEFINE_int64(name,val,txt)  DEFINE_VARIABLE(::google::int64, I64, name, val, txt)
-
-#define DECLARE_uint64(name)        DECLARE_VARIABLE(::google::uint64, U64, name)
-#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt)
-
-#define DECLARE_double(name)          DECLARE_VARIABLE(double, D, name)
-#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
-
-// Strings are trickier, because they're not a POD, so we can't
-// construct them at static-initialization time (instead they get
-// constructed at global-constructor time, which is much later).  To
-// try to avoid crashes in that case, we use a char buffer to store
-// the string, which we can static-initialize, and then placement-new
-// into it later.  It's not perfect, but the best we can do.
-
-namespace fLS {
-// The meaning of "string" might be different between now and when the
-// macros below get invoked (e.g., if someone is experimenting with
-// other string implementations that get defined after this file is
-// included).  Save the current meaning now and use it in the macros.
-typedef std::string clstring;
-
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const char *value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const clstring &value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           int value);
-}  // namespace fLS
-
-#define DECLARE_string(name)  namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
-                              using fLS::FLAGS_##name
-
-// We need to define a var named FLAGS_no##name so people don't define
-// --string and --nostring.  And we need a temporary place to put val
-// so we don't have to evaluate it twice.  Two great needs that go
-// great together!
-// The weird 'using' + 'extern' inside the fLS namespace is to work around
-// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10.  See
-//    http://code.google.com/p/google-gflags/issues/detail?id=20
-#define DEFINE_string(name, val, txt)                                       \
-  namespace fLS {                                                           \
-    using ::fLS::clstring;                                                  \
-    static union { void* align; char s[sizeof(clstring)]; } s_##name[2];    \
-    clstring* const FLAGS_no##name = ::fLS::                                \
-                                   dont_pass0toDEFINE_string(s_##name[0].s, \
-                                                             val);          \
-    static ::google::FlagRegisterer o_##name(                  \
-        #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__,                \
-        s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name));      \
-    extern clstring& FLAGS_##name;                                          \
-    using fLS::FLAGS_##name;                                                \
-    clstring& FLAGS_##name = *FLAGS_no##name;                               \
-  }                                                                         \
-  using fLS::FLAGS_##name
-
-#endif  // SWIG
-
-#endif  // GOOGLE_GFLAGS_H_

+ 0 - 121
Src/ThirdParty/gflags/src/gflags/gflags_completions.h

@@ -1,121 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Dave Nicponski
-//
-// Implement helpful bash-style command line flag completions
-//
-// ** Functional API:
-// HandleCommandLineCompletions() should be called early during
-// program startup, but after command line flag code has been
-// initialized, such as the beginning of HandleCommandLineHelpFlags().
-// It checks the value of the flag --tab_completion_word.  If this
-// flag is empty, nothing happens here.  If it contains a string,
-// however, then HandleCommandLineCompletions() will hijack the
-// process, attempting to identify the intention behind this
-// completion.  Regardless of the outcome of this deduction, the
-// process will be terminated, similar to --helpshort flag
-// handling.
-//
-// ** Overview of Bash completions:
-// Bash can be told to programatically determine completions for the
-// current 'cursor word'.  It does this by (in this case) invoking a
-// command with some additional arguments identifying the command
-// being executed, the word being completed, and the previous word
-// (if any).  Bash then expects a sequence of output lines to be
-// printed to stdout.  If these lines all contain a common prefix
-// longer than the cursor word, bash will replace the cursor word
-// with that common prefix, and display nothing.  If there isn't such
-// a common prefix, bash will display the lines in pages using 'more'.
-//
-// ** Strategy taken for command line completions:
-// If we can deduce either the exact flag intended, or a common flag
-// prefix, we'll output exactly that.  Otherwise, if information
-// must be displayed to the user, we'll take the opportunity to add
-// some helpful information beyond just the flag name (specifically,
-// we'll include the default flag value and as much of the flag's
-// description as can fit on a single terminal line width, as specified
-// by the flag --tab_completion_columns).  Furthermore, we'll try to
-// make bash order the output such that the most useful or relevent
-// flags are the most likely to be shown at the top.
-//
-// ** Additional features:
-// To assist in finding that one really useful flag, substring matching
-// was implemented.  Before pressing a <TAB> to get completion for the
-// current word, you can append one or more '?' to the flag to do
-// substring matching.  Here's the semantics:
-//   --foo<TAB>     Show me all flags with names prefixed by 'foo'
-//   --foo?<TAB>    Show me all flags with 'foo' somewhere in the name
-//   --foo??<TAB>   Same as prior case, but also search in module
-//                  definition path for 'foo'
-//   --foo???<TAB>  Same as prior case, but also search in flag
-//                  descriptions for 'foo'
-// Finally, we'll trim the output to a relatively small number of
-// flags to keep bash quiet about the verbosity of output.  If one
-// really wanted to see all possible matches, appending a '+' to the
-// search word will force the exhaustive list of matches to be printed.
-//
-// ** How to have bash accept completions from a binary:
-// Bash requires that it be informed about each command that programmatic
-// completion should be enabled for.  Example addition to a .bashrc
-// file would be (your path to gflags_completions.sh file may differ):
-
-/*
-$ complete -o bashdefault -o default -o nospace -C                        \
- '/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \
-  time  env  binary_name  another_binary  [...]
-*/
-
-// This would allow the following to work:
-//   $ /path/to/binary_name --vmodule<TAB>
-// Or:
-//   $ ./bin/path/another_binary --gfs_u<TAB>
-// (etc)
-//
-// Sadly, it appears that bash gives no easy way to force this behavior for
-// all commands.  That's where the "time" in the above example comes in.
-// If you haven't specifically added a command to the list of completion
-// supported commands, you can still get completions by prefixing the
-// entire command with "env".
-//   $ env /some/brand/new/binary --vmod<TAB>
-// Assuming that "binary" is a newly compiled binary, this should still
-// produce the expected completion output.
-
-
-#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_
-#define GOOGLE_GFLAGS_COMPLETIONS_H_
-
-namespace google {
-
-void HandleCommandLineCompletions(void);
-
-}
-
-#endif  // GOOGLE_GFLAGS_COMPLETIONS_H_

+ 0 - 765
Src/ThirdParty/gflags/src/gflags_completions.cc

@@ -1,765 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Dave Nicponski
-//
-// Bash-style command line flag completion for C++ binaries
-//
-// This module implements bash-style completions.  It achieves this
-// goal in the following broad chunks:
-//
-//  1) Take a to-be-completed word, and examine it for search hints
-//  2) Identify all potentially matching flags
-//     2a) If there are no matching flags, do nothing.
-//     2b) If all matching flags share a common prefix longer than the
-//         completion word, output just that matching prefix
-//  3) Categorize those flags to produce a rough ordering of relevence.
-//  4) Potentially trim the set of flags returned to a smaller number
-//     that bash is happier with
-//  5) Output the matching flags in groups ordered by relevence.
-//     5a) Force bash to place most-relevent groups at the top of the list
-//     5b) Trim most flag's descriptions to fit on a single terminal line
-
-
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>   // for strlen
-
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <gflags/gflags.h>
-
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR  '/'
-#endif
-
-DEFINE_string(tab_completion_word, "",
-              "If non-empty, HandleCommandLineCompletions() will hijack the "
-              "process and attempt to do bash-style command line flag "
-              "completion on this value.");
-DEFINE_int32(tab_completion_columns, 80,
-             "Number of columns to use in output for tab completion");
-
-_START_GOOGLE_NAMESPACE_
-
-namespace {
-
-using std::set;
-using std::string;
-using std::vector;
-
-// Function prototypes and Type forward declarations.  Code may be
-// more easily understood if it is roughly ordered according to
-// control flow, rather than by C's "declare before use" ordering
-struct CompletionOptions;
-struct NotableFlags;
-
-// The entry point if flag completion is to be used.
-static void PrintFlagCompletionInfo(void);
-
-
-// 1) Examine search word
-static void CanonicalizeCursorWordAndSearchOptions(
-    const string &cursor_word,
-    string *canonical_search_token,
-    CompletionOptions *options);
-
-static bool RemoveTrailingChar(string *str, char c);
-
-
-// 2) Find all matches
-static void FindMatchingFlags(
-    const vector<CommandLineFlagInfo> &all_flags,
-    const CompletionOptions &options,
-    const string &match_token,
-    set<const CommandLineFlagInfo *> *all_matches,
-    string *longest_common_prefix);
-
-static bool DoesSingleFlagMatch(
-    const CommandLineFlagInfo &flag,
-    const CompletionOptions &options,
-    const string &match_token);
-
-
-// 3) Categorize matches
-static void CategorizeAllMatchingFlags(
-    const set<const CommandLineFlagInfo *> &all_matches,
-    const string &search_token,
-    const string &module,
-    const string &package_dir,
-    NotableFlags *notable_flags);
-
-static void TryFindModuleAndPackageDir(
-    const vector<CommandLineFlagInfo> all_flags,
-    string *module,
-    string *package_dir);
-
-
-// 4) Decide which flags to use
-static void FinalizeCompletionOutput(
-    const set<const CommandLineFlagInfo *> &matching_flags,
-    CompletionOptions *options,
-    NotableFlags *notable_flags,
-    vector<string> *completions);
-
-static void RetrieveUnusedFlags(
-    const set<const CommandLineFlagInfo *> &matching_flags,
-    const NotableFlags &notable_flags,
-    set<const CommandLineFlagInfo *> *unused_flags);
-
-
-// 5) Output matches
-static void OutputSingleGroupWithLimit(
-    const set<const CommandLineFlagInfo *> &group,
-    const string &line_indentation,
-    const string &header,
-    const string &footer,
-    bool long_output_format,
-    int *remaining_line_limit,
-    size_t *completion_elements_added,
-    vector<string> *completions);
-
-// (helpers for #5)
-static string GetShortFlagLine(
-    const string &line_indentation,
-    const CommandLineFlagInfo &info);
-
-static string GetLongFlagLine(
-    const string &line_indentation,
-    const CommandLineFlagInfo &info);
-
-
-//
-// Useful types
-
-// Try to deduce the intentions behind this completion attempt.  Return the
-// canonical search term in 'canonical_search_token'.  Binary search options
-// are returned in the various booleans, which should all have intuitive
-// semantics, possibly except:
-//  - return_all_matching_flags: Generally, we'll trim the number of
-//    returned candidates to some small number, showing those that are
-//    most likely to be useful first.  If this is set, however, the user
-//    really does want us to return every single flag as an option.
-//  - force_no_update: Any time we output lines, all of which share a
-//    common prefix, bash will 'helpfully' not even bother to show the
-//    output, instead changing the current word to be that common prefix.
-//    If it's clear this shouldn't happen, we'll set this boolean
-struct CompletionOptions {
-  bool flag_name_substring_search;
-  bool flag_location_substring_search;
-  bool flag_description_substring_search;
-  bool return_all_matching_flags;
-  bool force_no_update;
-};
-
-// Notable flags are flags that are special or preferred for some
-// reason.  For example, flags that are defined in the binary's module
-// are expected to be much more relevent than flags defined in some
-// other random location.  These sets are specified roughly in precedence
-// order.  Once a flag is placed in one of these 'higher' sets, it won't
-// be placed in any of the 'lower' sets.
-struct NotableFlags {
-  typedef set<const CommandLineFlagInfo *> FlagSet;
-  FlagSet perfect_match_flag;
-  FlagSet module_flags;       // Found in module file
-  FlagSet package_flags;      // Found in same directory as module file
-  FlagSet most_common_flags;  // One of the XXX most commonly supplied flags
-  FlagSet subpackage_flags;   // Found in subdirectories of package
-};
-
-
-//
-// Tab completion implementation - entry point
-static void PrintFlagCompletionInfo(void) {
-  string cursor_word = FLAGS_tab_completion_word;
-  string canonical_token;
-  CompletionOptions options = { };
-  CanonicalizeCursorWordAndSearchOptions(
-      cursor_word,
-      &canonical_token,
-      &options);
-
-  //VLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
-
-  vector<CommandLineFlagInfo> all_flags;
-  set<const CommandLineFlagInfo *> matching_flags;
-  GetAllFlags(&all_flags);
-  //VLOG(2) << "Found " << all_flags.size() << " flags overall";
-
-  string longest_common_prefix;
-  FindMatchingFlags(
-      all_flags,
-      options,
-      canonical_token,
-      &matching_flags,
-      &longest_common_prefix);
-  //VLOG(1) << "Identified " << matching_flags.size() << " matching flags";
-  //VLOG(1) << "Identified " << longest_common_prefix
-  //        << " as longest common prefix.";
-  if (longest_common_prefix.size() > canonical_token.size()) {
-    // There's actually a shared common prefix to all matching flags,
-    // so may as well output that and quit quickly.
-    //VLOG(1) << "The common prefix '" << longest_common_prefix
-    //        << "' was longer than the token '" << canonical_token
-    //        << "'.  Returning just this prefix for completion.";
-    fprintf(stdout, "--%s", longest_common_prefix.c_str());
-    return;
-  }
-  if (matching_flags.empty()) {
-    //VLOG(1) << "There were no matching flags, returning nothing.";
-    return;
-  }
-
-  string module;
-  string package_dir;
-  TryFindModuleAndPackageDir(all_flags, &module, &package_dir);
-  //VLOG(1) << "Identified module: '" << module << "'";
-  //VLOG(1) << "Identified package_dir: '" << package_dir << "'";
-
-  NotableFlags notable_flags;
-  CategorizeAllMatchingFlags(
-      matching_flags,
-      canonical_token,
-      module,
-      package_dir,
-      &notable_flags);
-  //VLOG(2) << "Categorized matching flags:";
-  //VLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
-  //VLOG(2) << " module: " << notable_flags.module_flags.size();
-  //VLOG(2) << " package: " << notable_flags.package_flags.size();
-  //VLOG(2) << " most common: " << notable_flags.most_common_flags.size();
-  //VLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
-
-  vector<string> completions;
-  FinalizeCompletionOutput(
-      matching_flags,
-      &options,
-      &notable_flags,
-      &completions);
-
-  if (options.force_no_update)
-    completions.push_back("~");
-
-  //VLOG(1) << "Finalized with " << completions.size()
-  //        << " chosen completions";
-
-  for (vector<string>::const_iterator it = completions.begin();
-      it != completions.end();
-      ++it) {
-    //VLOG(9) << "  Completion entry: '" << *it << "'";
-    fprintf(stdout, "%s\n", it->c_str());
-  }
-}
-
-
-// 1) Examine search word (and helper method)
-static void CanonicalizeCursorWordAndSearchOptions(
-    const string &cursor_word,
-    string *canonical_search_token,
-    CompletionOptions *options) {
-  *canonical_search_token = cursor_word;
-  if (canonical_search_token->empty()) return;
-
-  // Get rid of leading quotes and dashes in the search term
-  if ((*canonical_search_token)[0] == '"')
-    *canonical_search_token = canonical_search_token->substr(1);
-  while ((*canonical_search_token)[0] == '-')
-    *canonical_search_token = canonical_search_token->substr(1);
-
-  options->flag_name_substring_search = false;
-  options->flag_location_substring_search = false;
-  options->flag_description_substring_search = false;
-  options->return_all_matching_flags = false;
-  options->force_no_update = false;
-
-  // Look for all search options we can deduce now.  Do this by walking
-  // backwards through the term, looking for up to three '?' and up to
-  // one '+' as suffixed characters.  Consume them if found, and remove
-  // them from the canonical search token.
-  int found_question_marks = 0;
-  int found_plusses = 0;
-  while (true) {
-    if (found_question_marks < 3 &&
-        RemoveTrailingChar(canonical_search_token, '?')) {
-      ++found_question_marks;
-      continue;
-    }
-    if (found_plusses < 1 &&
-        RemoveTrailingChar(canonical_search_token, '+')) {
-      ++found_plusses;
-      continue;
-    }
-    break;
-  }
-
-  switch (found_question_marks) {  // all fallthroughs
-    case 3: options->flag_description_substring_search = true;
-    case 2: options->flag_location_substring_search = true;
-    case 1: options->flag_name_substring_search = true;
-  };
-
-  options->return_all_matching_flags = (found_plusses > 0);
-}
-
-// Returns true if a char was removed
-static bool RemoveTrailingChar(string *str, char c) {
-  if (str->empty()) return false;
-  if ((*str)[str->size() - 1] == c) {
-    *str = str->substr(0, str->size() - 1);
-    return true;
-  }
-  return false;
-}
-
-
-// 2) Find all matches (and helper methods)
-static void FindMatchingFlags(
-    const vector<CommandLineFlagInfo> &all_flags,
-    const CompletionOptions &options,
-    const string &match_token,
-    set<const CommandLineFlagInfo *> *all_matches,
-    string *longest_common_prefix) {
-  all_matches->clear();
-  bool first_match = true;
-  for (vector<CommandLineFlagInfo>::const_iterator it = all_flags.begin();
-      it != all_flags.end();
-      ++it) {
-    if (DoesSingleFlagMatch(*it, options, match_token)) {
-      all_matches->insert(&*it);
-      if (first_match) {
-        first_match = false;
-        *longest_common_prefix = it->name;
-      } else {
-        if (longest_common_prefix->empty() || it->name.empty()) {
-          longest_common_prefix->clear();
-          continue;
-        }
-        string::size_type pos = 0;
-        while (pos < longest_common_prefix->size() &&
-            pos < it->name.size() &&
-            (*longest_common_prefix)[pos] == it->name[pos])
-          ++pos;
-        longest_common_prefix->erase(pos);
-      }
-    }
-  }
-}
-
-// Given the set of all flags, the parsed match options, and the
-// canonical search token, produce the set of all candidate matching
-// flags for subsequent analysis or filtering.
-static bool DoesSingleFlagMatch(
-    const CommandLineFlagInfo &flag,
-    const CompletionOptions &options,
-    const string &match_token) {
-  // Is there a prefix match?
-  string::size_type pos = flag.name.find(match_token);
-  if (pos == 0) return true;
-
-  // Is there a substring match if we want it?
-  if (options.flag_name_substring_search &&
-      pos != string::npos)
-    return true;
-
-  // Is there a location match if we want it?
-  if (options.flag_location_substring_search &&
-      flag.filename.find(match_token) != string::npos)
-    return true;
-
-  // TODO(daven): All searches should probably be case-insensitive
-  // (especially this one...)
-  if (options.flag_description_substring_search &&
-      flag.description.find(match_token) != string::npos)
-    return true;
-
-  return false;
-}
-
-// 3) Categorize matches (and helper method)
-
-// Given a set of matching flags, categorize them by
-// likely relevence to this specific binary
-static void CategorizeAllMatchingFlags(
-    const set<const CommandLineFlagInfo *> &all_matches,
-    const string &search_token,
-    const string &module,  // empty if we couldn't find any
-    const string &package_dir,  // empty if we couldn't find any
-    NotableFlags *notable_flags) {
-  notable_flags->perfect_match_flag.clear();
-  notable_flags->module_flags.clear();
-  notable_flags->package_flags.clear();
-  notable_flags->most_common_flags.clear();
-  notable_flags->subpackage_flags.clear();
-
-  for (set<const CommandLineFlagInfo *>::const_iterator it =
-        all_matches.begin();
-      it != all_matches.end();
-      ++it) {
-    //VLOG(2) << "Examining match '" << (*it)->name << "'";
-    //VLOG(7) << "  filename: '" << (*it)->filename << "'";
-    string::size_type pos = string::npos;
-    if (!package_dir.empty())
-      pos = (*it)->filename.find(package_dir);
-    string::size_type slash = string::npos;
-    if (pos != string::npos)  // candidate for package or subpackage match
-      slash = (*it)->filename.find(
-          PATH_SEPARATOR,
-          pos + package_dir.size() + 1);
-
-    if ((*it)->name == search_token) {
-      // Exact match on some flag's name
-      notable_flags->perfect_match_flag.insert(*it);
-      //VLOG(3) << "Result: perfect match";
-    } else if (!module.empty() && (*it)->filename == module) {
-      // Exact match on module filename
-      notable_flags->module_flags.insert(*it);
-      //VLOG(3) << "Result: module match";
-    } else if (!package_dir.empty() &&
-        pos != string::npos && slash == string::npos) {
-      // In the package, since there was no slash after the package portion
-      notable_flags->package_flags.insert(*it);
-      //VLOG(3) << "Result: package match";
-    } else if (false) {
-      // In the list of the XXX most commonly supplied flags overall
-      // TODO(daven): Compile this list.
-      //VLOG(3) << "Result: most-common match";
-    } else if (!package_dir.empty() &&
-        pos != string::npos && slash != string::npos) {
-      // In a subdirectory of the package
-      notable_flags->subpackage_flags.insert(*it);
-      //VLOG(3) << "Result: subpackage match";
-    }
-
-    //VLOG(3) << "Result: not special match";
-  }
-}
-
-static void PushNameWithSuffix(vector<string>* suffixes, const char* suffix) {
-  string s("/");
-  s += ProgramInvocationShortName();
-  s += suffix;
-  suffixes->push_back(s);
-}
-
-static void TryFindModuleAndPackageDir(
-    const vector<CommandLineFlagInfo> all_flags,
-    string *module,
-    string *package_dir) {
-  module->clear();
-  package_dir->clear();
-
-  vector<string> suffixes;
-  // TODO(daven): There's some inherant ambiguity here - multiple directories
-  // could share the same trailing folder and file structure (and even worse,
-  // same file names), causing us to be unsure as to which of the two is the
-  // actual package for this binary.  In this case, we'll arbitrarily choose.
-  PushNameWithSuffix(&suffixes, ".");
-  PushNameWithSuffix(&suffixes, "-main.");
-  PushNameWithSuffix(&suffixes, "_main.");
-  // These four are new but probably merited?
-  PushNameWithSuffix(&suffixes, "-test.");
-  PushNameWithSuffix(&suffixes, "_test.");
-  PushNameWithSuffix(&suffixes, "-unittest.");
-  PushNameWithSuffix(&suffixes, "_unittest.");
-
-  for (vector<CommandLineFlagInfo>::const_iterator it = all_flags.begin();
-      it != all_flags.end();
-      ++it) {
-    for (vector<string>::const_iterator suffix = suffixes.begin();
-        suffix != suffixes.end();
-        ++suffix) {
-      // TODO(daven): Make sure the match is near the end of the string
-      if (it->filename.find(*suffix) != string::npos) {
-        *module = it->filename;
-        string::size_type sep = it->filename.rfind(PATH_SEPARATOR);
-        *package_dir = it->filename.substr(0, (sep == string::npos) ? 0 : sep);
-        return;
-      }
-    }
-  }
-}
-
-// Can't specialize template type on a locally defined type.  Silly C++...
-struct DisplayInfoGroup {
-  const char* header;
-  const char* footer;
-  set<const CommandLineFlagInfo *> *group;
-
-  int SizeInLines() const {
-    int size_in_lines = static_cast<int>(group->size()) + 1;
-    if (strlen(header) > 0) {
-      size_in_lines++;
-    }
-    if (strlen(footer) > 0) {
-      size_in_lines++;
-    }
-    return size_in_lines;
-  }
-};
-
-// 4) Finalize and trim output flag set
-static void FinalizeCompletionOutput(
-    const set<const CommandLineFlagInfo *> &matching_flags,
-    CompletionOptions *options,
-    NotableFlags *notable_flags,
-    vector<string> *completions) {
-
-  // We want to output lines in groups.  Each group needs to be indented
-  // the same to keep its lines together.  Unless otherwise required,
-  // only 99 lines should be output to prevent bash from harassing the
-  // user.
-
-  // First, figure out which output groups we'll actually use.  For each
-  // nonempty group, there will be ~3 lines of header & footer, plus all
-  // output lines themselves.
-  int max_desired_lines =  // "999999 flags should be enough for anyone.  -dave"
-    (options->return_all_matching_flags ? 999999 : 98);
-  int lines_so_far = 0;
-
-  vector<DisplayInfoGroup> output_groups;
-  bool perfect_match_found = false;
-  if (lines_so_far < max_desired_lines &&
-      !notable_flags->perfect_match_flag.empty()) {
-    perfect_match_found = true;
-    DisplayInfoGroup group =
-        { "",
-          "==========",
-          &notable_flags->perfect_match_flag };
-    lines_so_far += group.SizeInLines();
-    output_groups.push_back(group);
-  }
-  if (lines_so_far < max_desired_lines &&
-      !notable_flags->module_flags.empty()) {
-    DisplayInfoGroup group = {
-        "-* Matching module flags *-",
-        "===========================",
-        &notable_flags->module_flags };
-    lines_so_far += group.SizeInLines();
-    output_groups.push_back(group);
-  }
-  if (lines_so_far < max_desired_lines &&
-      !notable_flags->package_flags.empty()) {
-    DisplayInfoGroup group = {
-        "-* Matching package flags *-",
-        "============================",
-        &notable_flags->package_flags };
-    lines_so_far += group.SizeInLines();
-    output_groups.push_back(group);
-  }
-  if (lines_so_far < max_desired_lines &&
-      !notable_flags->most_common_flags.empty()) {
-    DisplayInfoGroup group = {
-        "-* Commonly used flags *-",
-        "=========================",
-        &notable_flags->most_common_flags };
-    lines_so_far += group.SizeInLines();
-    output_groups.push_back(group);
-  }
-  if (lines_so_far < max_desired_lines &&
-      !notable_flags->subpackage_flags.empty()) {
-    DisplayInfoGroup group = {
-        "-* Matching sub-package flags *-",
-        "================================",
-        &notable_flags->subpackage_flags };
-    lines_so_far += group.SizeInLines();
-    output_groups.push_back(group);
-  }
-
-  set<const CommandLineFlagInfo *> obscure_flags;  // flags not notable
-  if (lines_so_far < max_desired_lines) {
-    RetrieveUnusedFlags(matching_flags, *notable_flags, &obscure_flags);
-    if (!obscure_flags.empty()) {
-      DisplayInfoGroup group = {
-          "-* Other flags *-",
-          "",
-          &obscure_flags };
-      lines_so_far += group.SizeInLines();
-      output_groups.push_back(group);
-    }
-  }
-
-  // Second, go through each of the chosen output groups and output
-  // as many of those flags as we can, while remaining below our limit
-  int remaining_lines = max_desired_lines;
-  size_t completions_output = 0;
-  int indent = static_cast<int>(output_groups.size()) - 1;
-  for (vector<DisplayInfoGroup>::const_iterator it =
-        output_groups.begin();
-      it != output_groups.end();
-      ++it, --indent) {
-    OutputSingleGroupWithLimit(
-        *it->group,  // group
-        string(indent, ' '),  // line indentation
-        string(it->header),  // header
-        string(it->footer),  // footer
-        perfect_match_found,  // long format
-        &remaining_lines,  // line limit - reduces this by number printed
-        &completions_output,  // completions (not lines) added
-        completions);  // produced completions
-    perfect_match_found = false;
-  }
-
-  if (completions_output != matching_flags.size()) {
-    options->force_no_update = false;
-    completions->push_back("~ (Remaining flags hidden) ~");
-  } else {
-    options->force_no_update = true;
-  }
-}
-
-static void RetrieveUnusedFlags(
-    const set<const CommandLineFlagInfo *> &matching_flags,
-    const NotableFlags &notable_flags,
-    set<const CommandLineFlagInfo *> *unused_flags) {
-  // Remove from 'matching_flags' set all members of the sets of
-  // flags we've already printed (specifically, those in notable_flags)
-  for (set<const CommandLineFlagInfo *>::const_iterator it =
-        matching_flags.begin();
-      it != matching_flags.end();
-      ++it) {
-    if (notable_flags.perfect_match_flag.count(*it) ||
-        notable_flags.module_flags.count(*it) ||
-        notable_flags.package_flags.count(*it) ||
-        notable_flags.most_common_flags.count(*it) ||
-        notable_flags.subpackage_flags.count(*it))
-      continue;
-    unused_flags->insert(*it);
-  }
-}
-
-// 5) Output matches (and helper methods)
-
-static void OutputSingleGroupWithLimit(
-    const set<const CommandLineFlagInfo *> &group,
-    const string &line_indentation,
-    const string &header,
-    const string &footer,
-    bool long_output_format,
-    int *remaining_line_limit,
-    size_t *completion_elements_output,
-    vector<string> *completions) {
-  if (group.empty()) return;
-  if (!header.empty()) {
-    if (*remaining_line_limit < 2) return;
-    *remaining_line_limit -= 2;
-    completions->push_back(line_indentation + header);
-    completions->push_back(line_indentation + string(header.size(), '-'));
-  }
-  for (set<const CommandLineFlagInfo *>::const_iterator it = group.begin();
-      it != group.end() && *remaining_line_limit > 0;
-      ++it) {
-    --*remaining_line_limit;
-    ++*completion_elements_output;
-    completions->push_back(
-        (long_output_format
-          ? GetLongFlagLine(line_indentation, **it)
-          : GetShortFlagLine(line_indentation, **it)));
-  }
-  if (!footer.empty()) {
-    if (*remaining_line_limit < 1) return;
-    --*remaining_line_limit;
-    completions->push_back(line_indentation + footer);
-  }
-}
-
-static string GetShortFlagLine(
-    const string &line_indentation,
-    const CommandLineFlagInfo &info) {
-  string prefix =
-    line_indentation + "--" + info.name + " [" +
-    (info.type == "string" ?
-       ("'" + info.default_value + "'") :
-       info.default_value)
-    + "] ";
-  int remainder =
-      FLAGS_tab_completion_columns - static_cast<int>(prefix.size());
-  string suffix;
-  if (remainder > 0)
-    suffix =
-        (static_cast<int>(info.description.size()) > remainder ?
-         (info.description.substr(0, remainder - 3) + "...").c_str() :
-         info.description.c_str());
-  return prefix + suffix;
-}
-
-static string GetLongFlagLine(
-    const string &line_indentation,
-    const CommandLineFlagInfo &info) {
-
-  string output = DescribeOneFlag(info);
-
-  // Replace '-' with '--', and remove trailing newline before appending
-  // the module definition location.
-  string old_flagname = "-" + info.name;
-  output.replace(
-      output.find(old_flagname),
-      old_flagname.size(),
-      "-" + old_flagname);
-  // Stick a newline and indentation in front of the type and default
-  // portions of DescribeOneFlag()s description
-  static const char kNewlineWithIndent[] = "\n    ";
-  output.replace(output.find(" type:"), 1, string(kNewlineWithIndent));
-  output.replace(output.find(" default:"), 1, string(kNewlineWithIndent));
-  output = line_indentation + " Details for '--" + info.name + "':\n" +
-     output + "    defined: " + info.filename;
-
-  // Eliminate any doubled newlines that crept in.  Specifically, if
-  // DescribeOneFlag() decided to break the line just before "type"
-  // or "default", we don't want to introduce an extra blank line
-  static const string line_of_spaces(FLAGS_tab_completion_columns, ' ');
-  static const char kDoubledNewlines[] = "\n     \n";
-  for (string::size_type newlines = output.find(kDoubledNewlines);
-      newlines != string::npos;
-      newlines = output.find(kDoubledNewlines))
-    // Replace each 'doubled newline' with a single newline
-    output.replace(newlines, sizeof(kDoubledNewlines) - 1, string("\n"));
-
-  for (string::size_type newline = output.find('\n');
-      newline != string::npos;
-      newline = output.find('\n')) {
-    int newline_pos = static_cast<int>(newline) % FLAGS_tab_completion_columns;
-    int missing_spaces = FLAGS_tab_completion_columns - newline_pos;
-    output.replace(newline, 1, line_of_spaces, 1, missing_spaces);
-  }
-  return output;
-}
-}  // anonymous
-
-void HandleCommandLineCompletions(void) {
-  if (FLAGS_tab_completion_word.empty()) return;
-  PrintFlagCompletionInfo();
-  exit(0);
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 69
Src/ThirdParty/gflags/src/gflags_nc.cc

@@ -1,69 +0,0 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Roberto Bayardo
-//
-// A negative compile test for commandlineflags.
-
-#include <gflags/gflags.h>
-
-#if defined(TEST_SWAPPED_ARGS)
-
-DEFINE_bool(some_bool_flag,
-            "the default value should go here, not the description",
-            false);
-
-
-#elif defined(TEST_INT_INSTEAD_OF_BOOL)
-
-DEFINE_bool(some_bool_flag_2,
-            0,
-            "should have been an int32 flag but mistakenly used bool instead");
-
-#elif defined(TEST_BOOL_IN_QUOTES)
-
-
-DEFINE_bool(some_bool_flag_3,
-            "false",
-            "false in in quotes, which is wrong");
-
-#elif defined(SANITY)
-
-DEFINE_bool(some_bool_flag_4,
-            true,
-            "this is the correct usage of DEFINE_bool");
-
-#elif defined(TEST_DEFINE_STRING_WITH_0)
-
-DEFINE_string(some_string_flag,
-              0,
-              "Trying to construct a string by passing 0 would cause a crash.");
-
-#endif

+ 0 - 446
Src/ThirdParty/gflags/src/gflags_reporting.cc

@@ -1,446 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Ray Sidney
-// Revamped and reorganized by Craig Silverstein
-//
-// This file contains code for handling the 'reporting' flags.  These
-// are flags that, when present, cause the program to report some
-// information and then exit.  --help and --version are the canonical
-// reporting flags, but we also have flags like --helpxml, etc.
-//
-// There's only one function that's meant to be called externally:
-// HandleCommandLineHelpFlags().  (Well, actually, ShowUsageWithFlags(),
-// ShowUsageWithFlagsRestrict(), and DescribeOneFlag() can be called
-// externally too, but there's little need for it.)  These are all
-// declared in the main commandlineflags.h header file.
-//
-// HandleCommandLineHelpFlags() will check what 'reporting' flags have
-// been defined, if any -- the "help" part of the function name is a
-// bit misleading -- and do the relevant reporting.  It should be
-// called after all flag-values have been assigned, that is, after
-// parsing the command-line.
-
-#include "config.h"
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string>
-#include <vector>
-#include <gflags/gflags.h>
-#include <gflags/gflags_completions.h>
-
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR  '/'
-#endif
-
-// The 'reporting' flags.  They all call exit().
-DEFINE_bool(help, false,
-            "show help on all flags [tip: all flags can have two dashes]");
-DEFINE_bool(helpfull, false,
-            "show help on all flags -- same as -help");
-DEFINE_bool(helpshort, false,
-            "show help on only the main module for this program");
-DEFINE_string(helpon, "",
-              "show help on the modules named by this flag value");
-DEFINE_string(helpmatch, "",
-              "show help on modules whose name contains the specified substr");
-DEFINE_bool(helppackage, false,
-            "show help on all modules in the main package");
-DEFINE_bool(helpxml, false,
-            "produce an xml version of help");
-DEFINE_bool(version, false,
-            "show version and build info and exit");
-
-_START_GOOGLE_NAMESPACE_
-
-using std::string;
-using std::vector;
-
-// --------------------------------------------------------------------
-// DescribeOneFlag()
-// DescribeOneFlagInXML()
-//    Routines that pretty-print info about a flag.  These use
-//    a CommandLineFlagInfo, which is the way the commandlineflags
-//    API exposes static info about a flag.
-// --------------------------------------------------------------------
-
-static const int kLineLength = 80;
-
-static void AddString(const string& s,
-                      string* final_string, int* chars_in_line) {
-  const int slen = static_cast<int>(s.length());
-  if (*chars_in_line + 1 + slen >= kLineLength) {  // < 80 chars/line
-    *final_string += "\n      ";
-    *chars_in_line = 6;
-  } else {
-    *final_string += " ";
-    *chars_in_line += 1;
-  }
-  *final_string += s;
-  *chars_in_line += slen;
-}
-
-static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag,
-                                         const string& text, bool current) {
-  const char* c_string = (current ? flag.current_value.c_str() :
-                          flag.default_value.c_str());
-  if (strcmp(flag.type.c_str(), "string") == 0) {  // add quotes for strings
-    return text + ": \"" + c_string + "\"";
-  } else {
-    return text + ": " + c_string;
-  }
-}
-
-// Create a descriptive string for a flag.
-// Goes to some trouble to make pretty line breaks.
-string DescribeOneFlag(const CommandLineFlagInfo& flag) {
-  string main_part = (string("    -") + flag.name +
-                      " (" + flag.description + ')');
-  const char* c_string = main_part.c_str();
-  int chars_left = static_cast<int>(main_part.length());
-  string final_string = "";
-  int chars_in_line = 0;  // how many chars in current line so far?
-  while (1) {
-    assert(chars_left == strlen(c_string));  // Unless there's a \0 in there?
-    const char* newline = strchr(c_string, '\n');
-    if (newline == NULL && chars_in_line+chars_left < kLineLength) {
-      // The whole remainder of the string fits on this line
-      final_string += c_string;
-      chars_in_line += chars_left;
-      break;
-    }
-    if (newline != NULL && newline - c_string < kLineLength - chars_in_line) {
-      int n = static_cast<int>(newline - c_string);
-      final_string.append(c_string, n);
-      chars_left -= n + 1;
-      c_string += n + 1;
-    } else {
-      // Find the last whitespace on this 80-char line
-      int whitespace = kLineLength-chars_in_line-1;  // < 80 chars/line
-      while ( whitespace > 0 && !isspace(c_string[whitespace]) ) {
-        --whitespace;
-      }
-      if (whitespace <= 0) {
-        // Couldn't find any whitespace to make a line break.  Just dump the
-        // rest out!
-        final_string += c_string;
-        chars_in_line = kLineLength;  // next part gets its own line for sure!
-        break;
-      }
-      final_string += string(c_string, whitespace);
-      chars_in_line += whitespace;
-      while (isspace(c_string[whitespace]))  ++whitespace;
-      c_string += whitespace;
-      chars_left -= whitespace;
-    }
-    if (*c_string == '\0')
-      break;
-    final_string += "\n      ";
-    chars_in_line = 6;
-  }
-
-  // Append data type
-  AddString(string("type: ") + flag.type, &final_string, &chars_in_line);
-  // The listed default value will be the actual default from the flag
-  // definition in the originating source file, unless the value has
-  // subsequently been modified using SetCommandLineOptionWithMode() with mode
-  // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before initializing.
-  AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string,
-            &chars_in_line);
-  if (!flag.is_default) {
-    AddString(PrintStringFlagsWithQuotes(flag, "currently", true),
-              &final_string, &chars_in_line);
-  }
-
-  final_string += '\n';
-  return final_string;
-}
-
-// Simple routine to xml-escape a string: escape & and < only.
-static string XMLText(const string& txt) {
-  string ans = txt;
-  for (string::size_type pos = 0; (pos = ans.find("&", pos)) != string::npos; )
-    ans.replace(pos++, 1, "&amp;");
-  for (string::size_type pos = 0; (pos = ans.find("<", pos)) != string::npos; )
-    ans.replace(pos++, 1, "&lt;");
-  return ans;
-}
-
-static void AddXMLTag(string* r, const char* tag, const string& txt) {
-  *r += ('<');
-  *r += (tag);
-  *r += ('>');
-  *r += (XMLText(txt));
-  *r += ("</");
-  *r += (tag);
-  *r += ('>');
-}
-
-static string DescribeOneFlagInXML(const CommandLineFlagInfo& flag) {
-  // The file and flagname could have been attributes, but default
-  // and meaning need to avoid attribute normalization.  This way it
-  // can be parsed by simple programs, in addition to xml parsers.
-  string r("<flag>");
-  AddXMLTag(&r, "file", flag.filename);
-  AddXMLTag(&r, "name", flag.name);
-  AddXMLTag(&r, "meaning", flag.description);
-  AddXMLTag(&r, "default", flag.default_value);
-  AddXMLTag(&r, "current", flag.current_value);
-  AddXMLTag(&r, "type", flag.type);
-  r += "</flag>";
-  return r;
-}
-
-// --------------------------------------------------------------------
-// ShowUsageWithFlags()
-// ShowUsageWithFlagsRestrict()
-// ShowXMLOfFlags()
-//    These routines variously expose the registry's list of flag
-//    values.  ShowUsage*() prints the flag-value information
-//    to stdout in a user-readable format (that's what --help uses).
-//    The Restrict() version limits what flags are shown.
-//    ShowXMLOfFlags() prints the flag-value information to stdout
-//    in a machine-readable format.  In all cases, the flags are
-//    sorted: first by filename they are defined in, then by flagname.
-// --------------------------------------------------------------------
-
-static const char* Basename(const char* filename) {
-  const char* sep = strrchr(filename, PATH_SEPARATOR);
-  return sep ? sep + 1 : filename;
-}
-
-static string Dirname(const string& filename) {
-  string::size_type sep = filename.rfind(PATH_SEPARATOR);
-  return filename.substr(0, (sep == string::npos) ? 0 : sep);
-}
-
-// Test whether a filename contains at least one of the substrings.
-static bool FileMatchesSubstring(const string& filename,
-                                 const vector<string>& substrings) {
-  for (vector<string>::const_iterator target = substrings.begin();
-       target != substrings.end();
-       ++target) {
-    if (strstr(filename.c_str(), target->c_str()) != NULL)
-      return true;
-    // If the substring starts with a '/', that means that we want
-    // the string to be at the beginning of a directory component.
-    // That should match the first directory component as well, so
-    // we allow '/foo' to match a filename of 'foo'.
-    if (!target->empty() && (*target)[0] == '/' &&
-        strncmp(filename.c_str(), target->c_str() + 1,
-                strlen(target->c_str() + 1)) == 0)
-      return true;
-  }
-  return false;
-}
-
-// Show help for every filename which matches any of the target substrings.
-// If substrings is empty, shows help for every file. If a flag's help message
-// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' before
-// including gflags/gflags.h), then this flag will not be displayed by
-// '--help' and its variants.
-static void ShowUsageWithFlagsMatching(const char *argv0,
-                                       const vector<string> &substrings) {
-  fprintf(stdout, "%s: %s\n", Basename(argv0), ProgramUsage());
-
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);           // flags are sorted by filename, then flagname
-
-  string last_filename;          // so we know when we're at a new file
-  bool first_directory = true;   // controls blank lines between dirs
-  bool found_match = false;      // stays false iff no dir matches restrict
-  for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin();
-       flag != flags.end();
-       ++flag) {
-    if (substrings.empty() ||
-        FileMatchesSubstring(flag->filename, substrings)) {
-      // If the flag has been stripped, pretend that it doesn't exist.
-      if (flag->description == kStrippedFlagHelp) continue;
-      found_match = true;     // this flag passed the match!
-      if (flag->filename != last_filename) {                      // new file
-        if (Dirname(flag->filename) != Dirname(last_filename)) {  // new dir!
-          if (!first_directory)
-            fprintf(stdout, "\n\n");   // put blank lines between directories
-          first_directory = false;
-        }
-        fprintf(stdout, "\n  Flags from %s:\n", flag->filename.c_str());
-        last_filename = flag->filename;
-      }
-      // Now print this flag
-      fprintf(stdout, "%s", DescribeOneFlag(*flag).c_str());
-    }
-  }
-  if (!found_match && !substrings.empty()) {
-    fprintf(stdout, "\n  No modules matched: use -help\n");
-  }
-}
-
-void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict) {
-  vector<string> substrings;
-  if (restrict != NULL && *restrict != '\0') {
-    substrings.push_back(restrict);
-  }
-  ShowUsageWithFlagsMatching(argv0, substrings);
-}
-
-void ShowUsageWithFlags(const char *argv0) {
-  ShowUsageWithFlagsRestrict(argv0, "");
-}
-
-// Convert the help, program, and usage to xml.
-static void ShowXMLOfFlags(const char *prog_name) {
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);   // flags are sorted: by filename, then flagname
-
-  // XML.  There is no corresponding schema yet
-  fprintf(stdout, "<?xml version=\"1.0\"?>\n");
-  // The document
-  fprintf(stdout, "<AllFlags>\n");
-  // the program name and usage
-  fprintf(stdout, "<program>%s</program>\n",
-          XMLText(Basename(prog_name)).c_str());
-  fprintf(stdout, "<usage>%s</usage>\n",
-          XMLText(ProgramUsage()).c_str());
-  // All the flags
-  for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin();
-       flag != flags.end();
-       ++flag) {
-    if (flag->description != kStrippedFlagHelp)
-      fprintf(stdout, "%s\n", DescribeOneFlagInXML(*flag).c_str());
-  }
-  // The end of the document
-  fprintf(stdout, "</AllFlags>\n");
-}
-
-// --------------------------------------------------------------------
-// ShowVersion()
-//    Called upon --version.  Prints build-related info.
-// --------------------------------------------------------------------
-
-static void ShowVersion() {
-  fprintf(stdout, "%s\n", ProgramInvocationShortName());
-  // TODO: add other stuff, like a timestamp, who built it, what
-  //       target they built, etc.
-
-# if !defined(NDEBUG)
-  fprintf(stdout, "Debug build (NDEBUG not #defined)\n");
-# endif
-}
-
-static void AppendPrognameStrings(vector<string>* substrings,
-                                  const char* progname) {
-  string r("/");
-  r += progname;
-  substrings->push_back(r + ".");
-  substrings->push_back(r + "-main.");
-  substrings->push_back(r + "_main.");
-}
-
-// --------------------------------------------------------------------
-// HandleCommandLineHelpFlags()
-//    Checks all the 'reporting' commandline flags to see if any
-//    have been set.  If so, handles them appropriately.  Note
-//    that all of them, by definition, cause the program to exit
-//    if they trigger.
-// --------------------------------------------------------------------
-
-void HandleCommandLineHelpFlags() {
-  const char* progname = ProgramInvocationShortName();
-  extern void (*commandlineflags_exitfunc)(int);   // in gflags.cc
-
-  HandleCommandLineCompletions();
-
-  vector<string> substrings;
-  AppendPrognameStrings(&substrings, progname);
-
-  if (FLAGS_helpshort) {
-    // show only flags related to this binary:
-    // E.g. for fileutil.cc, want flags containing   ... "/fileutil." cc
-    ShowUsageWithFlagsMatching(progname, substrings);
-    commandlineflags_exitfunc(1);   // almost certainly exit()
-
-  } else if (FLAGS_help || FLAGS_helpfull) {
-    // show all options
-    ShowUsageWithFlagsRestrict(progname, "");   // empty restrict
-    commandlineflags_exitfunc(1);
-
-  } else if (!FLAGS_helpon.empty()) {
-    string restrict = "/" + FLAGS_helpon + ".";
-    ShowUsageWithFlagsRestrict(progname, restrict.c_str());
-    commandlineflags_exitfunc(1);
-
-  } else if (!FLAGS_helpmatch.empty()) {
-    ShowUsageWithFlagsRestrict(progname, FLAGS_helpmatch.c_str());
-    commandlineflags_exitfunc(1);
-
-  } else if (FLAGS_helppackage) {
-    // Shows help for all files in the same directory as main().  We
-    // don't want to resort to looking at dirname(progname), because
-    // the user can pick progname, and it may not relate to the file
-    // where main() resides.  So instead, we search the flags for a
-    // filename like "/progname.cc", and take the dirname of that.
-    vector<CommandLineFlagInfo> flags;
-    GetAllFlags(&flags);
-    string last_package;
-    for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin();
-         flag != flags.end();
-         ++flag) {
-      if (!FileMatchesSubstring(flag->filename, substrings))
-        continue;
-      const string package = Dirname(flag->filename) + "/";
-      if (package != last_package) {
-        ShowUsageWithFlagsRestrict(progname, package.c_str());
-        if (!last_package.empty()) {      // means this isn't our first pkg
-          fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n",
-                  progname);
-        }
-        last_package = package;
-      }
-    }
-    if (last_package.empty()) {   // never found a package to print
-      fprintf(stderr, "WARNING: Unable to find a package for file=%s\n",
-              progname);
-    }
-    commandlineflags_exitfunc(1);
-
-  } else if (FLAGS_helpxml) {
-    ShowXMLOfFlags(progname);
-    commandlineflags_exitfunc(1);
-
-  } else if (FLAGS_version) {
-    ShowVersion();
-    // Unlike help, we may be asking for version in a script, so return 0
-    commandlineflags_exitfunc(0);
-  }
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 58
Src/ThirdParty/gflags/src/gflags_strip_flags_test.cc

@@ -1,58 +0,0 @@
-// Copyright (c) 2011, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Craig Silverstein
-//
-// A simple program that uses STRIP_FLAG_HELP.  We'll have a shell
-// script that runs 'strings' over this program and makes sure
-// that the help string is not in there.
-
-#include "config_for_unittests.h"
-#include <stdio.h>
-#define STRIP_FLAG_HELP 1
-#include "gflags/gflags.h"
-
-using GOOGLE_NAMESPACE::SetUsageMessage;
-using GOOGLE_NAMESPACE::ParseCommandLineFlags;
-
-DEFINE_bool(test, true, "This text should be stripped out");
-
-int main(int argc, char** argv) {
-  SetUsageMessage("Usage message");
-  ParseCommandLineFlags(&argc, &argv, false);
-
-  // Unfortunately, for us, libtool can replace executables with a shell
-  // script that does some work before calling the 'real' executable
-  // under a different name.  We need the 'real' executable name to run
-  // 'strings' on it, so we construct this binary to print the real
-  // name (argv[0]) on stdout when run.
-  printf("%s\n", argv[0]);
-  return 0;
-}

+ 0 - 1591
Src/ThirdParty/gflags/src/gflags_unittest-main.cc

@@ -1,1591 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Marius Eriksen
-//
-// For now, this unit test does not cover all features of
-// gflags.cc
-
-#include "config_for_unittests.h"
-#include <stdio.h>
-#include <stdlib.h>     // for &exit
-#include <assert.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>     // for unlink()
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>   // for mkdir()
-#endif
-#include <math.h>       // for isinf() and isnan()
-#include <vector>
-#include <string>
-
-#include <gflags/gflags.h>
-// I don't actually use this header file, but #include it under the
-// old location to make sure that the include-header-forwarding
-// works.  But don't bother on windows; the windows port is so new
-// it never had the old location-names.
-#ifndef _MSC_VER
-#include <google/gflags_completions.h>
-void (*unused_fn)() = &GOOGLE_NAMESPACE::HandleCommandLineCompletions;
-#endif
-
-using GOOGLE_NAMESPACE::int32;
-using GOOGLE_NAMESPACE::FlagRegisterer;
-using GOOGLE_NAMESPACE::StringFromEnv;
-using GOOGLE_NAMESPACE::RegisterFlagValidator;
-using GOOGLE_NAMESPACE::CommandLineFlagInfo;
-using GOOGLE_NAMESPACE::GetAllFlags;
-
-// Returns the number of elements in an array.
-#define GET_ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
-
-#if !defined(HAVE_SETENV) && defined(HAVE_PUTENV)   // mingw, at least
-void setenv(const char* name, const char* value, int) {
-  // In windows, it's impossible to set a variable to the empty string.
-  // We handle this by setting it to "0" and the NUL-ing out the \0.
-  // cf http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/environ.cpp?r1=611451&r2=637508&pathrev=637508
-  static const char* const kFakeZero = "0";
-  if (*value == '\0')
-    value = kFakeZero;
-  // Apparently the semantics of putenv() is that the input
-  // must live forever, so we leak memory here. :-(
-  const int nameval_len = strlen(name) + 1 + strlen(value) + 1;
-  char* nameval = reinterpret_cast<char*>(malloc(nameval_len));
-  snprintf(nameval, nameval_len, "%s=%s", name, value);
-  putenv(nameval);
-  if (value == kFakeZero) {
-    nameval[nameval_len - 2] = '\0';   // works when putenv() makes no copy
-    if (*getenv(name) != '\0')
-      *getenv(name) = '\0';            // works when putenv() copies nameval
-  }
-}
-#endif
-
-DECLARE_string(tryfromenv);   // in gflags.cc
-
-DEFINE_string(test_tmpdir, "/tmp/gflags_unittest", "Dir we use for temp files");
-#ifdef _MSC_VER  // in MSVC, we run from the vsprojects directory
-DEFINE_string(srcdir, "..\\..",
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#else
-DEFINE_string(srcdir, StringFromEnv("SRCDIR", "."),
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#endif
-
-DEFINE_bool(test_bool, false, "tests bool-ness");
-DEFINE_int32(test_int32, -1, "");
-DEFINE_int64(test_int64, -2, "");
-DEFINE_uint64(test_uint64, 2, "");
-DEFINE_double(test_double, -1.0, "");
-DEFINE_string(test_string, "initial", "");
-
-//
-// The below ugliness gets some additional code coverage in the -helpxml
-// and -helpmatch test cases having to do with string lengths and formatting
-//
-DEFINE_bool(test_bool_with_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_long_name,
-            false,
-            "extremely_extremely_extremely_extremely_extremely_extremely_extremely_extremely_long_meaning");
-
-DEFINE_string(test_str1, "initial", "");
-DEFINE_string(test_str2, "initial", "");
-DEFINE_string(test_str3, "initial", "");
-
-// This is used to test setting tryfromenv manually
-DEFINE_string(test_tryfromenv, "initial", "");
-
-// Don't try this at home!
-static int changeable_var = 12;
-DEFINE_int32(changeable_var, ++changeable_var, "");
-
-static int changeable_bool_var = 8008;
-DEFINE_bool(changeable_bool_var, ++changeable_bool_var == 8009, "");
-
-static int changeable_string_var = 0;
-static std::string ChangeableString() {
-  char r[] = {static_cast<char>('0' + ++changeable_string_var), '\0'};
-  return r;
-}
-DEFINE_string(changeable_string_var, ChangeableString(), "");
-
-// These are never used in this unittest, but can be used by
-// gflags_unittest.sh when it needs to specify flags
-// that are legal for gflags_unittest but don't need to
-// be a particular value.
-DEFINE_bool(unused_bool, true, "unused bool-ness");
-DEFINE_int32(unused_int32, -1001, "");
-DEFINE_int64(unused_int64, -2001, "");
-DEFINE_uint64(unused_uint64, 2000, "");
-DEFINE_double(unused_double, -1000.0, "");
-DEFINE_string(unused_string, "unused", "");
-
-// These flags are used by gflags_unittest.sh
-DEFINE_bool(changed_bool1, false, "changed");
-DEFINE_bool(changed_bool2, false, "changed");
-
-static bool AlwaysFail(const char* flag, bool value) { return value == false; }
-DEFINE_bool(always_fail, false, "will fail to validate when you set it");
-static bool dummy = RegisterFlagValidator(&FLAGS_always_fail, AlwaysFail);
-
-// See the comment by GetAllFlags in commandlineflags.h
-static bool DeadlockIfCantLockInValidators(const char* flag, bool value) {
-  if (!value) {
-    return true;
-  }
-  std::vector<CommandLineFlagInfo> dummy;
-  GetAllFlags(&dummy);
-  return true;
-}
-DEFINE_bool(deadlock_if_cant_lock,
-            false,
-            "will deadlock if set to true and "
-            "if locking of registry in validators fails.");
-static bool dummy1 = RegisterFlagValidator(&FLAGS_deadlock_if_cant_lock,
-                                           DeadlockIfCantLockInValidators);
-
-// This is a pseudo-flag -- we want to register a flag with a filename
-// at the top level, but there is no way to do this except by faking
-// the filename.
-namespace fLI {
-  static const int32 FLAGS_nonotldflag1 = 12;
-  int32 FLAGS_tldflag1 = FLAGS_nonotldflag1;
-  int32 FLAGS_notldflag1 = FLAGS_nonotldflag1;
-  static FlagRegisterer o_tldflag1(
-    "tldflag1", "int32",
-    "should show up in --helpshort", "gflags_unittest.cc",
-    &FLAGS_tldflag1, &FLAGS_notldflag1);
-}
-using fLI::FLAGS_tldflag1;
-
-namespace fLI {
-  static const int32 FLAGS_nonotldflag2 = 23;
-  int32 FLAGS_tldflag2 = FLAGS_nonotldflag2;
-  int32 FLAGS_notldflag2 = FLAGS_nonotldflag2;
-  static FlagRegisterer o_tldflag2(
-    "tldflag2", "int32",
-    "should show up in --helpshort", "gflags_unittest.",
-    &FLAGS_tldflag2, &FLAGS_notldflag2);
-}
-using fLI::FLAGS_tldflag2;
-
-_START_GOOGLE_NAMESPACE_
-
-using std::string;
-using std::vector;
-
-// The following is some bare-bones testing infrastructure
-
-#define EXPECT_TRUE(cond)                               \
-  do {                                                  \
-    if (!(cond)) {                                      \
-      fprintf(stderr, "Check failed: %s\n", #cond);     \
-      exit(1);                                          \
-    }                                                   \
-  } while (0)
-
-#define EXPECT_FALSE(cond)  EXPECT_TRUE(!(cond))
-
-#define EXPECT_OP(op, val1, val2)                                       \
-  do {                                                                  \
-    if (!((val1) op (val2))) {                                          \
-      fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_EQ(val1, val2)  EXPECT_OP(==, val1, val2)
-#define EXPECT_NE(val1, val2)  EXPECT_OP(!=, val1, val2)
-#define EXPECT_GT(val1, val2)  EXPECT_OP(>, val1, val2)
-#define EXPECT_LT(val1, val2)  EXPECT_OP(<, val1, val2)
-
-// C99 declares isnan and isinf should be macros, so the #ifdef test
-// should be reliable everywhere.  Of course, it's not, but these
-// are testing pertty marginal functionality anyway, so it's ok to
-// not-run them even in situations they might, with effort, be made to work.
-#ifdef isnan  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_NAN(arg)                                         \
-  do {                                                          \
-    if (!isnan(arg)) {                                          \
-      fprintf(stderr, "Check failed: isnan(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_NAN(arg)
-#endif
-
-#ifdef isinf  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_INF(arg)                                         \
-  do {                                                          \
-    if (!isinf(arg)) {                                          \
-      fprintf(stderr, "Check failed: isinf(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_INF(arg)
-#endif
-
-#define EXPECT_DOUBLE_EQ(val1, val2)                                    \
-  do {                                                                  \
-    if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) {         \
-      fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2);        \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_STREQ(val1, val2)                                        \
-  do {                                                                  \
-    if (strcmp((val1), (val2)) != 0) {                                  \
-      fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-static bool g_called_exit;
-static void CalledExit(int) { g_called_exit = true; }
-extern GFLAGS_DLL_DECL void (*commandlineflags_exitfunc)(int);  // in gflags.cc
-
-#define EXPECT_DEATH(fn, msg)                                           \
-  do {                                                                  \
-    g_called_exit = false;                                              \
-    commandlineflags_exitfunc = &CalledExit;                            \
-    fn;                                                                 \
-    commandlineflags_exitfunc = &exit;    /* set back to its default */ \
-    if (!g_called_exit) {                                               \
-      fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn);      \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-
-vector<void (*)()> g_testlist;  // the tests to run
-
-#define TEST(a, b)                                      \
-  struct Test_##a##_##b {                               \
-    Test_##a##_##b() { g_testlist.push_back(&Run); }    \
-    static void Run() {                                 \
-      FlagSaver fs;                                     \
-      fprintf(stderr, "Running test %s/%s\n", #a, #b);  \
-      RunTest();                                        \
-    }                                                   \
-    static void RunTest();                              \
-  };                                                    \
-  static Test_##a##_##b g_test_##a##_##b;               \
-  void Test_##a##_##b::RunTest()
-
-
-static int RUN_ALL_TESTS() {
-  vector<void (*)()>::const_iterator it;
-  for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
-    (*it)();
-  }
-  fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
-  return 0;
-}
-
-
-static string TmpFile(const string& basename) {
-#ifdef _MSC_VER
-  return FLAGS_test_tmpdir + "\\" + basename;
-#else
-  return FLAGS_test_tmpdir + "/" + basename;
-#endif
-}
-
-// Returns the definition of the --flagfile flag to be used in the tests.
-static const char* GetFlagFileFlag() {
-#ifdef _MSC_VER
-  static const string flagfile = FLAGS_srcdir + "\\src\\gflags_unittest_flagfile";
-#else
-  static const string flagfile = FLAGS_srcdir + "/src/gflags_unittest_flagfile";
-#endif
-  static const string flagfile_flag = string("--flagfile=") + flagfile;
-  return flagfile_flag.c_str();
-}
-
-
-// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
-// compiler error iff T1 and T2 are different types.
-template <typename T1, typename T2>
-struct CompileAssertTypesEqual;
-
-template <typename T>
-struct CompileAssertTypesEqual<T, T> {
-};
-
-
-template <typename Expected, typename Actual>
-void AssertIsType(Actual& x) {
-  CompileAssertTypesEqual<Expected, Actual>();
-}
-
-// Verify all the flags are the right type.
-TEST(FlagTypes, FlagTypes) {
-  AssertIsType<bool>(FLAGS_test_bool);
-  AssertIsType<int32>(FLAGS_test_int32);
-  AssertIsType<int64>(FLAGS_test_int64);
-  AssertIsType<uint64>(FLAGS_test_uint64);
-  AssertIsType<double>(FLAGS_test_double);
-  AssertIsType<string>(FLAGS_test_string);
-}
-
-// Death tests for "help" options.
-//
-// The help system automatically calls exit(1) when you specify any of
-// the help-related flags ("-helpmatch", "-helpxml") so we can't test
-// those mainline.
-
-// Tests that "-helpmatch" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpMatch) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpmatch=base", GetArgv0(), true),
-               "");
-}
-
-
-// Tests that "-helpxml" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpXml) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpxml", GetArgv0(), true),
-               "");
-}
-
-
-// A subroutine needed for testing reading flags from a string.
-void TestFlagString(const string& flags,
-                    const string& expected_string,
-                    bool expected_bool,
-                    int32 expected_int32,
-                    double expected_double) {
-  EXPECT_TRUE(ReadFlagsFromString(flags,
-                                  GetArgv0(),
-                                  // errors are fatal
-                                  true));
-
-  EXPECT_EQ(expected_string, FLAGS_test_string);
-  EXPECT_EQ(expected_bool, FLAGS_test_bool);
-  EXPECT_EQ(expected_int32, FLAGS_test_int32);
-  EXPECT_DOUBLE_EQ(expected_double, FLAGS_test_double);
-}
-
-
-// Tests reading flags from a string.
-TEST(FlagFileTest, ReadFlagsFromString) {
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "-test_double=0.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      0.0);
-
-  TestFlagString(
-      // Flag string
-      "# let's make sure it can update values\n"
-      "-test_string=initial\n"
-      "-test_bool=false\n"
-      "-test_int32=123\n"
-      "-test_double=123.0\n",
-      // Expected values
-      "initial",
-      false,
-      123,
-      123.0);
-}
-
-// Tests the filename part of the flagfile
-TEST(FlagFileTest, FilenamesOurfileLast) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "not_our_filename\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "gflags_unittest\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      false,
-      -1,
-      1000.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileFirst) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "gflags_unittest\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "not_our_filename\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-#ifdef HAVE_FNMATCH_H   // otherwise glob isn't supported
-TEST(FlagFileTest, FilenamesOurfileGlob) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*flags*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileInBigList) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*first* *flags* *third*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-#endif
-
-// Tests that a failed flag-from-string read keeps flags at default values
-TEST(FlagFileTest, FailReadFlagsFromString) {
-  FLAGS_test_int32 = 119;
-  string flags("# let's make sure it can update values\n"
-               "-test_string=non_initial\n"
-               "-test_bool=false\n"
-               "-test_int32=123\n"
-               "-test_double=illegal\n");
-
-  EXPECT_FALSE(ReadFlagsFromString(flags,
-                                   GetArgv0(),
-                                   // errors are fatal
-                                   false));
-
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ("initial", FLAGS_test_string);
-}
-
-// Tests that flags can be set to ordinary values.
-TEST(SetFlagValueTest, OrdinaryValues) {
-  EXPECT_EQ("initial", FLAGS_test_str1);
-
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // set; was default
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // already set once
-
-  FLAGS_test_str1 = "initial";
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("initial", FLAGS_test_str1);  // still already set before
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAGS_VALUE);
-  EXPECT_EQ("third", FLAGS_test_str1);  // changed value
-
-  SetCommandLineOptionWithMode("test_str1", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str1);
-  // value not changed (already set before)
-
-  EXPECT_EQ("initial", FLAGS_test_str2);
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);  // changed (was default)
-
-  FLAGS_test_str2 = "extra";
-  EXPECT_EQ("extra", FLAGS_test_str2);
-
-  FLAGS_test_str2 = "second";
-  SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str2);  // still changed (was equal to default)
-
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str2);  // changed (was default)
-
-  EXPECT_EQ("initial", FLAGS_test_str3);
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str3);  // changed
-
-  FLAGS_test_str3 = "third";
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_VALUE);
-  EXPECT_EQ("fourth", FLAGS_test_str3);  // changed value
-}
-
-
-// Tests that flags can be set to exceptional values.
-// Note: apparently MINGW doesn't parse inf and nan correctly:
-//    http://www.mail-archive.com/bug-gnulib@gnu.org/msg09573.html
-// This url says FreeBSD also has a problem, but I didn't see that.
-TEST(SetFlagValueTest, ExceptionalValues) {
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "inf"));
-  EXPECT_INF(FLAGS_test_double);
-
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "INF"));
-  EXPECT_INF(FLAGS_test_double);
-#endif
-
-  // set some bad values
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", "0.1xxx"));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", " "));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", ""));
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to -inf\n",
-            SetCommandLineOption("test_double", "-inf"));
-  EXPECT_INF(FLAGS_test_double);
-  EXPECT_GT(0, FLAGS_test_double);
-#endif
-
-#if defined(isnan) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to nan\n",
-            SetCommandLineOption("test_double", "NaN"));
-  EXPECT_NAN(FLAGS_test_double);
-#endif
-}
-
-// Tests that integer flags can be specified in many ways
-TEST(SetFlagValueTest, DifferentRadices) {
-  EXPECT_EQ("test_int32 set to 12\n",
-            SetCommandLineOption("test_int32", "12"));
-
-  EXPECT_EQ("test_int32 set to 16\n",
-            SetCommandLineOption("test_int32", "0x10"));
-
-  EXPECT_EQ("test_int32 set to 34\n",
-            SetCommandLineOption("test_int32", "0X22"));
-
-  // Leading 0 is *not* octal; it's still decimal
-  EXPECT_EQ("test_int32 set to 10\n",
-            SetCommandLineOption("test_int32", "010"));
-}
-
-// Tests what happens when you try to set a flag to an illegal value
-TEST(SetFlagValueTest, IllegalValues) {
-  FLAGS_test_bool = true;
-  FLAGS_test_int32 = 119;
-  FLAGS_test_int64 = 1191;
-  FLAGS_test_uint64 = 11911;
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_bool", "12"));
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int32", "7000000000000"));
-
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_EQ("",
-            SetCommandLineOption("test_uint64", "-1"));
-#endif
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int64", "not a number!"));
-
-  // Test the empty string with each type of input
-  EXPECT_EQ("", SetCommandLineOption("test_bool", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int32", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_uint64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_double", ""));
-  EXPECT_EQ("test_string set to \n", SetCommandLineOption("test_string", ""));
-
-  EXPECT_TRUE(FLAGS_test_bool);
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ(1191, FLAGS_test_int64);
-  EXPECT_EQ(11911, FLAGS_test_uint64);
-}
-
-
-// Tests that we only evaluate macro args once
-TEST(MacroArgs, EvaluateOnce) {
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure we don't ++ the value somehow, when evaluating the flag.
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure the macro only evaluated this var once.
-  EXPECT_EQ(13, changeable_var);
-  // Make sure the actual value and default value are the same
-  SetCommandLineOptionWithMode("changeable_var", "21", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ(21, FLAGS_changeable_var);
-}
-
-TEST(MacroArgs, EvaluateOnceBool) {
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_EQ(8009, changeable_bool_var);
-  SetCommandLineOptionWithMode("changeable_bool_var", "false",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_FALSE(FLAGS_changeable_bool_var);
-}
-
-TEST(MacroArgs, EvaluateOnceStrings) {
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ(1, changeable_string_var);
-  SetCommandLineOptionWithMode("changeable_string_var", "different",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("different", FLAGS_changeable_string_var);
-}
-
-// Tests that the FooFromEnv does the right thing
-TEST(FromEnvTest, LegalValues) {
-  setenv("BOOL_VAL1", "true", 1);
-  setenv("BOOL_VAL2", "false", 1);
-  setenv("BOOL_VAL3", "1", 1);
-  setenv("BOOL_VAL4", "F", 1);
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL1", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL2", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL3", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL4", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL_UNKNOWN", true));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL_UNKNOWN", false));
-
-  setenv("INT_VAL1", "1", 1);
-  setenv("INT_VAL2", "-1", 1);
-  EXPECT_EQ(1, Int32FromEnv("INT_VAL1", 10));
-  EXPECT_EQ(-1, Int32FromEnv("INT_VAL2", 10));
-  EXPECT_EQ(10, Int32FromEnv("INT_VAL_UNKNOWN", 10));
-
-  setenv("INT_VAL3", "1099511627776", 1);
-  EXPECT_EQ(1, Int64FromEnv("INT_VAL1", 20));
-  EXPECT_EQ(-1, Int64FromEnv("INT_VAL2", 20));
-  EXPECT_EQ(1099511627776LL, Int64FromEnv("INT_VAL3", 20));
-  EXPECT_EQ(20, Int64FromEnv("INT_VAL_UNKNOWN", 20));
-
-  EXPECT_EQ(1, Uint64FromEnv("INT_VAL1", 30));
-  EXPECT_EQ(1099511627776ULL, Uint64FromEnv("INT_VAL3", 30));
-  EXPECT_EQ(30, Uint64FromEnv("INT_VAL_UNKNOWN", 30));
-
-  // I pick values here that can be easily represented exactly in floating-point
-  setenv("DOUBLE_VAL1", "0.0", 1);
-  setenv("DOUBLE_VAL2", "1.0", 1);
-  setenv("DOUBLE_VAL3", "-1.0", 1);
-  EXPECT_EQ(0.0, DoubleFromEnv("DOUBLE_VAL1", 40.0));
-  EXPECT_EQ(1.0, DoubleFromEnv("DOUBLE_VAL2", 40.0));
-  EXPECT_EQ(-1.0, DoubleFromEnv("DOUBLE_VAL3", 40.0));
-  EXPECT_EQ(40.0, DoubleFromEnv("DOUBLE_VAL_UNKNOWN", 40.0));
-
-  setenv("STRING_VAL1", "", 1);
-  setenv("STRING_VAL2", "my happy string!", 1);
-  EXPECT_STREQ("", StringFromEnv("STRING_VAL1", "unknown"));
-  EXPECT_STREQ("my happy string!", StringFromEnv("STRING_VAL2", "unknown"));
-  EXPECT_STREQ("unknown", StringFromEnv("STRING_VAL_UNKNOWN", "unknown"));
-}
-
-// Tests that the FooFromEnv dies on parse-error
-TEST(FromEnvDeathTest, IllegalValues) {
-  setenv("BOOL_BAD1", "so true!", 1);
-  setenv("BOOL_BAD2", "", 1);
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD1", false), "error parsing env variable");
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD2", true), "error parsing env variable");
-
-  setenv("INT_BAD1", "one", 1);
-  setenv("INT_BAD2", "100000000000000000", 1);
-  setenv("INT_BAD3", "0xx10", 1);
-  setenv("INT_BAD4", "", 1);
-  EXPECT_DEATH(Int32FromEnv("INT_BAD1", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD2", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD3", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD4", 10), "error parsing env variable");
-
-  setenv("BIGINT_BAD1", "18446744073709551616000", 1);
-  EXPECT_DEATH(Int64FromEnv("INT_BAD1", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD3", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD4", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("BIGINT_BAD1", 200), "error parsing env variable");
-
-  setenv("BIGINT_BAD2", "-1", 1);
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD1", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD3", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD4", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD1", 30), "error parsing env variable");
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD2", 30), "error parsing env variable");
-#endif
-
-  setenv("DOUBLE_BAD1", "0.0.0", 1);
-  setenv("DOUBLE_BAD2", "", 1);
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD1", 40.0), "error parsing env variable");
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD2", 40.0), "error parsing env variable");
-}
-
-// Tests that FlagSaver can save the states of string flags.
-TEST(FlagSaverTest, CanSaveStringFlagStates) {
-  // 1. Initializes the flags.
-
-  // State of flag test_str1:
-  //   default value - "initial"
-  //   current value - "initial"
-  //   not set       - true
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_VALUE);
-  // State of flag test_str2:
-  //   default value - "initial"
-  //   current value - "second"
-  //   not set       - false
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  // State of flag test_str3:
-  //   default value - "second"
-  //   current value - "second"
-  //   not set       - true
-
-  // 2. Saves the flag states.
-
-  {
-    FlagSaver fs;
-
-    // 3. Modifies the flag states.
-
-    SetCommandLineOptionWithMode("test_str1", "second", SET_FLAGS_VALUE);
-    EXPECT_EQ("second", FLAGS_test_str1);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "second"
-    //   not set       - true
-
-    SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-    EXPECT_EQ("second", FLAGS_test_str2);
-    // State of flag test_str2:
-    //   default value - "third"
-    //   current value - "second"
-    //   not set       - false
-
-    SetCommandLineOptionWithMode("test_str3", "third", SET_FLAGS_VALUE);
-    EXPECT_EQ("third", FLAGS_test_str3);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "third"
-    //   not set       - false
-
-    // 4. Restores the flag states.
-  }
-
-  // 5. Verifies that the states were restored.
-
-  // Verifies that the value of test_str1 was restored.
-  EXPECT_EQ("initial", FLAGS_test_str1);
-  // Verifies that the "not set" attribute of test_str1 was restored to true.
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);
-
-  // Verifies that the value of test_str2 was restored.
-  EXPECT_EQ("second", FLAGS_test_str2);
-  // Verifies that the "not set" attribute of test_str2 was restored to false.
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);
-
-  // Verifies that the value of test_str3 was restored.
-  EXPECT_EQ("second", FLAGS_test_str3);
-  // Verifies that the "not set" attribute of test_str3 was restored to true.
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str3);
-}
-
-
-// Tests that FlagSaver can save the values of various-typed flags.
-TEST(FlagSaverTest, CanSaveVariousTypedFlagValues) {
-  // Initializes the flags.
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_int64 = -2;
-  FLAGS_test_uint64 = 3;
-  FLAGS_test_double = 4.0;
-  FLAGS_test_string = "good";
-
-  // Saves the flag states.
-  {
-    FlagSaver fs;
-
-    // Modifies the flags.
-    FLAGS_test_bool = true;
-    FLAGS_test_int32 = -5;
-    FLAGS_test_int64 = -6;
-    FLAGS_test_uint64 = 7;
-    FLAGS_test_double = 8.0;
-    FLAGS_test_string = "bad";
-
-    // Restores the flag states.
-  }
-
-  // Verifies the flag values were restored.
-  EXPECT_FALSE(FLAGS_test_bool);
-  EXPECT_EQ(-1, FLAGS_test_int32);
-  EXPECT_EQ(-2, FLAGS_test_int64);
-  EXPECT_EQ(3, FLAGS_test_uint64);
-  EXPECT_DOUBLE_EQ(4.0, FLAGS_test_double);
-  EXPECT_EQ("good", FLAGS_test_string);
-}
-
-TEST(GetAllFlagsTest, BaseTest) {
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);
-  bool found_test_bool = false;
-  vector<CommandLineFlagInfo>::const_iterator i;
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    if (i->name == "test_bool") {
-      found_test_bool = true;
-      EXPECT_EQ(i->type, "bool");
-      EXPECT_EQ(i->default_value, "false");
-      break;
-    }
-  }
-  EXPECT_TRUE(found_test_bool);
-}
-
-TEST(ShowUsageWithFlagsTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --help.
-}
-
-TEST(ShowUsageWithFlagsRestrictTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --helpmatch.
-}
-
-// Note: all these argv-based tests depend on SetArgv being called
-// before ParseCommandLineFlags() in Main(), below.
-TEST(GetArgvsTest, BaseTest) {
-  vector<string> argvs = GetArgvs();
-  EXPECT_EQ(4, argvs.size());
-  EXPECT_EQ("/test/argv/for/gflags_unittest", argvs[0]);
-  EXPECT_EQ("argv 2", argvs[1]);
-  EXPECT_EQ("3rd argv", argvs[2]);
-  EXPECT_EQ("argv #4", argvs[3]);
-}
-
-TEST(GetArgvTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest "
-               "argv 2 3rd argv argv #4", GetArgv());
-}
-
-TEST(GetArgv0Test, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest", GetArgv0());
-}
-
-TEST(GetArgvSumTest, BaseTest) {
-  // This number is just the sum of the ASCII values of all the chars
-  // in GetArgv().
-  EXPECT_EQ(4904, GetArgvSum());
-}
-
-TEST(ProgramInvocationNameTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest",
-               ProgramInvocationName());
-}
-
-TEST(ProgramInvocationShortNameTest, BaseTest) {
-  EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName());
-}
-
-TEST(ProgramUsageTest, BaseTest) {  // Depends on arg to SetUsageMessage()
-  EXPECT_STREQ("/test/argv/for/gflags_unittest: "
-               "<useless flag> [...]\nDoes something useless.\n",
-               ProgramUsage());
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndIsDefault) {
-  string value("will be changed");
-  bool r = GetCommandLineOption("test_bool", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("false", value);
-
-  r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("-1", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("400", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasSet) {
-  SetCommandLineOption("test_int32", "700");
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("700", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasNotSet) {
-  // This doesn't set the flag's value, but rather its default value.
-  // is_default is still true, but the 'default' value returned has changed!
-  SetCommandLineOptionWithMode("test_int32", "800", SET_FLAGS_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("800", value);
-  EXPECT_TRUE(GetCommandLineFlagInfoOrDie("test_int32").is_default);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasConditionallySet) {
-  SetCommandLineOptionWithMode("test_int32", "900", SET_FLAG_IF_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("900", value);
-}
-
-TEST(GetCommandLineOptionTest, NameDoesNotExist) {
-  string value("will not be changed");
-  const bool r = GetCommandLineOption("test_int3210", &value);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("will not be changed", value);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagExists) {
-  CommandLineFlagInfo info;
-  bool r = GetCommandLineFlagInfo("test_int32", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = true;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = false;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);  // value is same, but flag *was* modified
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) {
-  CommandLineFlagInfo info;
-  // Set to some random values that GetCommandLineFlagInfo should not change
-  info.name = "name";
-  info.type = "type";
-  info.current_value = "curr";
-  info.default_value = "def";
-  info.filename = "/";
-  info.is_default = false;
-  info.has_validator_fn = true;
-  bool r = GetCommandLineFlagInfo("test_int3210", &info);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("name", info.name);
-  EXPECT_EQ("type", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("curr", info.current_value);
-  EXPECT_EQ("def", info.default_value);
-  EXPECT_EQ("/", info.filename);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_TRUE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndIsDefault) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("400", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  FLAGS_test_bool = true;
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieDeathTest, FlagDoesNotExist) {
-  EXPECT_DEATH(GetCommandLineFlagInfoOrDie("test_int3210"),
-               ".*: flag test_int3210 does not exist");
-}
-
-
-// These are lightly tested because they're deprecated.  Basically,
-// the tests are meant to cover how existing users use these functions,
-// but not necessarily how new users could use them.
-TEST(DeprecatedFunctionsTest, CommandlineFlagsIntoString) {
-  string s = CommandlineFlagsIntoString();
-  EXPECT_NE(string::npos, s.find("--test_bool="));
-}
-
-TEST(DeprecatedFunctionsTest, AppendFlagsIntoFile) {
-  FLAGS_test_int32 = 10;     // just to make the test more interesting
-  string filename(TmpFile("flagfile"));
-  unlink(filename.c_str());  // just to be safe
-  const bool r = AppendFlagsIntoFile(filename, "not the real argv0");
-  EXPECT_TRUE(r);
-
-  FILE* fp = fopen(filename.c_str(), "r");
-  EXPECT_TRUE(fp != NULL);
-  char line[8192];
-  EXPECT_TRUE(fgets(line, sizeof(line)-1, fp) != NULL);  // get the first line
-  // First line should be progname.
-  EXPECT_STREQ("not the real argv0\n", line);
-
-  bool found_bool = false, found_int32 = false;
-  while (fgets(line, sizeof(line)-1, fp)) {
-    line[sizeof(line)-1] = '\0';    // just to be safe
-    if (strcmp(line, "--test_bool=false\n") == 0)
-      found_bool = true;
-    if (strcmp(line, "--test_int32=10\n") == 0)
-      found_int32 = true;
-  }
-  EXPECT_TRUE(found_int32);
-  EXPECT_TRUE(found_bool);
-  fclose(fp);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFile) {
-  FLAGS_test_int32 = -10;    // just to make the test more interesting
-  string filename(TmpFile("flagfile2"));
-  unlink(filename.c_str());  // just to be safe
-  bool r = AppendFlagsIntoFile(filename, GetArgv0());
-  EXPECT_TRUE(r);
-
-  FLAGS_test_int32 = -11;
-  r = ReadFromFlagsFile(filename, GetArgv0(), true);
-  EXPECT_TRUE(r);
-  EXPECT_EQ(-10, FLAGS_test_int32);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) {
-  FLAGS_test_int32 = -20;
-  string filename(TmpFile("flagfile3"));
-  FILE* fp = fopen(filename.c_str(), "w");
-  EXPECT_TRUE(fp != NULL);
-  // Note the error in the bool assignment below...
-  fprintf(fp, "%s\n--test_int32=-21\n--test_bool=not_a_bool!\n", GetArgv0());
-  fclose(fp);
-
-  FLAGS_test_int32 = -22;
-  const bool r = ReadFromFlagsFile(filename, GetArgv0(), false);
-  EXPECT_FALSE(r);
-  EXPECT_EQ(-22, FLAGS_test_int32);   // the -21 from the flagsfile didn't take
-}
-
-TEST(FlagsSetBeforeInitTest, TryFromEnv) {
-  EXPECT_EQ("pre-set", FLAGS_test_tryfromenv);
-}
-
-// The following test case verifies that ParseCommandLineFlags() and
-// ParseCommandLineNonHelpFlags() uses the last definition of a flag
-// in case it's defined more than once.
-
-DEFINE_int32(test_flag, -1, "used for testing commandlineflags.cc");
-
-// Parses and returns the --test_flag flag.
-// If with_help is true, calls ParseCommandLineFlags; otherwise calls
-// ParseCommandLineNonHelpFlags.
-int32 ParseTestFlag(bool with_help, int argc, const char** const_argv) {
-  FlagSaver fs;  // Restores the flags before returning.
-
-  // Makes a copy of the input array s.t. it can be reused
-  // (ParseCommandLineFlags() will alter the array).
-  char** const argv_save = new char*[argc + 1];
-  char** argv = argv_save;
-  memcpy(argv, const_argv, sizeof(*argv)*(argc + 1));
-
-  if (with_help) {
-    ParseCommandLineFlags(&argc, &argv, true);
-  } else {
-    ParseCommandLineNonHelpFlags(&argc, &argv, true);
-  }
-
-  delete[] argv_save;
-  return FLAGS_test_flag;
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceOnCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=1",
-    "--test_flag=2",
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceInFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndThenFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgFirst) {
-  const char* argv[] = {
-    "my_test",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(-1, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(-1, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgMiddle) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=7",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(7, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(7, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, OneDashArg) {
-  const char* argv[] = {
-    "my_test",
-    "-",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(0, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(0, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--this_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     BoolFlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--nothis_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsNotABool) {
-  const char* argv[] = {
-    "my_test",
-    "--notest_string",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-}
-
-TEST(ParseCommandLineFlagsWrongFields,
-     DescriptionIsInvalid) {
-  // These must not be automatic variables, since command line flags
-  // aren't unregistered and gUnit uses FlagSaver to save and restore
-  // command line flags' values.  If these are on the stack, then when
-  // later tests attempt to save and restore their values, the stack
-  // addresses of these variables will be overwritten...  Stack smash!
-  static bool current_storage;
-  static bool defvalue_storage;
-  FlagRegisterer fr("flag_name", "bool", 0, "filename",
-                    &current_storage, &defvalue_storage);
-  CommandLineFlagInfo fi;
-  EXPECT_TRUE(GetCommandLineFlagInfo("flag_name", &fi));
-  EXPECT_EQ("", fi.description);
-}
-
-static bool ValidateTestFlagIs5(const char* flagname, int32 flagval) {
-  if (flagval == 5)
-    return true;
-  printf("%s isn't 5!\n", flagname);
-  return false;
-}
-
-static bool ValidateTestFlagIs10(const char* flagname, int32 flagval) {
-  return flagval == 10;
-}
-
-
-TEST(FlagsValidator, ValidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=5",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_EQ(5, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  // Undo the flag validator setting
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_VALUE));
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_NE("", SetCommandLineOption("test_flag", "5"));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=50",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: failed validation of new value '50' for flag 'test_flag'");
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_EQ(-1, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_VALUE));
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));
-  EXPECT_EQ(100, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagNeverSet) {
-  // If a flag keeps its default value, and that default value is
-  // invalid, we should die at argv-parse time.
-  const char* argv[] = {
-    "my_test",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: --test_flag must be set on the commandline");
-}
-
-TEST(FlagsValidator, InvalidFlagPtr) {
-  int32 dummy;
-  EXPECT_FALSE(RegisterFlagValidator(NULL, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&dummy, &ValidateTestFlagIs5));
-}
-
-TEST(FlagsValidator, RegisterValidatorTwice) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, CommandLineFlagInfo) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_TRUE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(FlagsValidator, FlagSaver) {
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-    EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // fails validation
-  }
-  EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // validator is gone
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-    EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // no validator
-  }
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // validator is back
-}
-
-
-static int Main(int argc, char **argv) {
-  // We need to call SetArgv before SetUsage, so our "test" argv will
-  // win out over this executable's real argv.  That makes running this
-  // test with a real --help flag kinda annoying, unfortunately.
-  const char* test_argv[] = { "/test/argv/for/gflags_unittest",
-                              "argv 2", "3rd argv", "argv #4" };
-  SetArgv(GET_ARRAY_SIZE(test_argv), test_argv);
-
-  // The first arg is the usage message, also important for testing.
-  string usage_message = (string(GetArgv0()) +
-                          ": <useless flag> [...]\nDoes something useless.\n");
-
-  // We test setting tryfromenv manually, and making sure
-  // ParseCommandLineFlags still evaluates it.
-  FLAGS_tryfromenv = "test_tryfromenv";
-  setenv("FLAGS_test_tryfromenv", "pre-set", 1);
-
-  // Modify flag values from declared default value in two ways.
-  // The recommended way:
-  SetCommandLineOptionWithMode("changed_bool1", "true", SET_FLAGS_DEFAULT);
-  // The non-recommended way:
-  FLAGS_changed_bool2 = true;
-
-  SetUsageMessage(usage_message.c_str());
-  ParseCommandLineFlags(&argc, &argv, true);
-
-#if defined(__MINGW32__)
-  // I had trouble creating a directory in /tmp from mingw
-  FLAGS_test_tmpdir = "./gflags_unittest_testdir";
-  mkdir(FLAGS_test_tmpdir.c_str());   // mingw has a weird one-arg mkdir
-#elif defined(_MSC_VER)
-  char tmppath_buffer[1024];
-  int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
-  assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer));
-  assert(tmppath_buffer[tmppath_len - 1] == '\\');   // API guarantees it
-  FLAGS_test_tmpdir = string(tmppath_buffer) + "gflags_unittest_testdir";
-  _mkdir(FLAGS_test_tmpdir.c_str());
-#else
-  mkdir(FLAGS_test_tmpdir.c_str(), 0755);
-#endif
-
-  return RUN_ALL_TESTS();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-int main(int argc, char** argv) {
-  const int exit_status = GOOGLE_NAMESPACE::Main(argc, argv);
-  GOOGLE_NAMESPACE::ShutDownCommandLineFlags();
-  return exit_status;
-}

+ 0 - 1591
Src/ThirdParty/gflags/src/gflags_unittest.cc

@@ -1,1591 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Marius Eriksen
-//
-// For now, this unit test does not cover all features of
-// gflags.cc
-
-#include "config_for_unittests.h"
-#include <stdio.h>
-#include <stdlib.h>     // for &exit
-#include <assert.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>     // for unlink()
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>   // for mkdir()
-#endif
-#include <math.h>       // for isinf() and isnan()
-#include <vector>
-#include <string>
-
-#include <gflags/gflags.h>
-// I don't actually use this header file, but #include it under the
-// old location to make sure that the include-header-forwarding
-// works.  But don't bother on windows; the windows port is so new
-// it never had the old location-names.
-#ifndef _MSC_VER
-#include <google/gflags_completions.h>
-void (*unused_fn)() = &GOOGLE_NAMESPACE::HandleCommandLineCompletions;
-#endif
-
-using GOOGLE_NAMESPACE::int32;
-using GOOGLE_NAMESPACE::FlagRegisterer;
-using GOOGLE_NAMESPACE::StringFromEnv;
-using GOOGLE_NAMESPACE::RegisterFlagValidator;
-using GOOGLE_NAMESPACE::CommandLineFlagInfo;
-using GOOGLE_NAMESPACE::GetAllFlags;
-
-// Returns the number of elements in an array.
-#define GET_ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
-
-#if !defined(HAVE_SETENV) && defined(HAVE_PUTENV)   // mingw, at least
-void setenv(const char* name, const char* value, int) {
-  // In windows, it's impossible to set a variable to the empty string.
-  // We handle this by setting it to "0" and the NUL-ing out the \0.
-  // cf http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/environ.cpp?r1=611451&r2=637508&pathrev=637508
-  static const char* const kFakeZero = "0";
-  if (*value == '\0')
-    value = kFakeZero;
-  // Apparently the semantics of putenv() is that the input
-  // must live forever, so we leak memory here. :-(
-  const int nameval_len = strlen(name) + 1 + strlen(value) + 1;
-  char* nameval = reinterpret_cast<char*>(malloc(nameval_len));
-  snprintf(nameval, nameval_len, "%s=%s", name, value);
-  putenv(nameval);
-  if (value == kFakeZero) {
-    nameval[nameval_len - 2] = '\0';   // works when putenv() makes no copy
-    if (*getenv(name) != '\0')
-      *getenv(name) = '\0';            // works when putenv() copies nameval
-  }
-}
-#endif
-
-DECLARE_string(tryfromenv);   // in gflags.cc
-
-DEFINE_string(test_tmpdir, "/tmp/gflags_unittest", "Dir we use for temp files");
-#ifdef _MSC_VER  // in MSVC, we run from the vsprojects directory
-DEFINE_string(srcdir, "..\\..",
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#else
-DEFINE_string(srcdir, StringFromEnv("SRCDIR", "."),
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#endif
-
-DEFINE_bool(test_bool, false, "tests bool-ness");
-DEFINE_int32(test_int32, -1, "");
-DEFINE_int64(test_int64, -2, "");
-DEFINE_uint64(test_uint64, 2, "");
-DEFINE_double(test_double, -1.0, "");
-DEFINE_string(test_string, "initial", "");
-
-//
-// The below ugliness gets some additional code coverage in the -helpxml
-// and -helpmatch test cases having to do with string lengths and formatting
-//
-DEFINE_bool(test_bool_with_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_long_name,
-            false,
-            "extremely_extremely_extremely_extremely_extremely_extremely_extremely_extremely_long_meaning");
-
-DEFINE_string(test_str1, "initial", "");
-DEFINE_string(test_str2, "initial", "");
-DEFINE_string(test_str3, "initial", "");
-
-// This is used to test setting tryfromenv manually
-DEFINE_string(test_tryfromenv, "initial", "");
-
-// Don't try this at home!
-static int changeable_var = 12;
-DEFINE_int32(changeable_var, ++changeable_var, "");
-
-static int changeable_bool_var = 8008;
-DEFINE_bool(changeable_bool_var, ++changeable_bool_var == 8009, "");
-
-static int changeable_string_var = 0;
-static std::string ChangeableString() {
-  char r[] = {static_cast<char>('0' + ++changeable_string_var), '\0'};
-  return r;
-}
-DEFINE_string(changeable_string_var, ChangeableString(), "");
-
-// These are never used in this unittest, but can be used by
-// gflags_unittest.sh when it needs to specify flags
-// that are legal for gflags_unittest but don't need to
-// be a particular value.
-DEFINE_bool(unused_bool, true, "unused bool-ness");
-DEFINE_int32(unused_int32, -1001, "");
-DEFINE_int64(unused_int64, -2001, "");
-DEFINE_uint64(unused_uint64, 2000, "");
-DEFINE_double(unused_double, -1000.0, "");
-DEFINE_string(unused_string, "unused", "");
-
-// These flags are used by gflags_unittest.sh
-DEFINE_bool(changed_bool1, false, "changed");
-DEFINE_bool(changed_bool2, false, "changed");
-
-static bool AlwaysFail(const char* flag, bool value) { return value == false; }
-DEFINE_bool(always_fail, false, "will fail to validate when you set it");
-static bool dummy = RegisterFlagValidator(&FLAGS_always_fail, AlwaysFail);
-
-// See the comment by GetAllFlags in commandlineflags.h
-static bool DeadlockIfCantLockInValidators(const char* flag, bool value) {
-  if (!value) {
-    return true;
-  }
-  std::vector<CommandLineFlagInfo> dummy;
-  GetAllFlags(&dummy);
-  return true;
-}
-DEFINE_bool(deadlock_if_cant_lock,
-            false,
-            "will deadlock if set to true and "
-            "if locking of registry in validators fails.");
-static bool dummy1 = RegisterFlagValidator(&FLAGS_deadlock_if_cant_lock,
-                                           DeadlockIfCantLockInValidators);
-
-// This is a pseudo-flag -- we want to register a flag with a filename
-// at the top level, but there is no way to do this except by faking
-// the filename.
-namespace fLI {
-  static const int32 FLAGS_nonotldflag1 = 12;
-  int32 FLAGS_tldflag1 = FLAGS_nonotldflag1;
-  int32 FLAGS_notldflag1 = FLAGS_nonotldflag1;
-  static FlagRegisterer o_tldflag1(
-    "tldflag1", "int32",
-    "should show up in --helpshort", "gflags_unittest.cc",
-    &FLAGS_tldflag1, &FLAGS_notldflag1);
-}
-using fLI::FLAGS_tldflag1;
-
-namespace fLI {
-  static const int32 FLAGS_nonotldflag2 = 23;
-  int32 FLAGS_tldflag2 = FLAGS_nonotldflag2;
-  int32 FLAGS_notldflag2 = FLAGS_nonotldflag2;
-  static FlagRegisterer o_tldflag2(
-    "tldflag2", "int32",
-    "should show up in --helpshort", "gflags_unittest.",
-    &FLAGS_tldflag2, &FLAGS_notldflag2);
-}
-using fLI::FLAGS_tldflag2;
-
-_START_GOOGLE_NAMESPACE_
-
-using std::string;
-using std::vector;
-
-// The following is some bare-bones testing infrastructure
-
-#define EXPECT_TRUE(cond)                               \
-  do {                                                  \
-    if (!(cond)) {                                      \
-      fprintf(stderr, "Check failed: %s\n", #cond);     \
-      exit(1);                                          \
-    }                                                   \
-  } while (0)
-
-#define EXPECT_FALSE(cond)  EXPECT_TRUE(!(cond))
-
-#define EXPECT_OP(op, val1, val2)                                       \
-  do {                                                                  \
-    if (!((val1) op (val2))) {                                          \
-      fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_EQ(val1, val2)  EXPECT_OP(==, val1, val2)
-#define EXPECT_NE(val1, val2)  EXPECT_OP(!=, val1, val2)
-#define EXPECT_GT(val1, val2)  EXPECT_OP(>, val1, val2)
-#define EXPECT_LT(val1, val2)  EXPECT_OP(<, val1, val2)
-
-// C99 declares isnan and isinf should be macros, so the #ifdef test
-// should be reliable everywhere.  Of course, it's not, but these
-// are testing pertty marginal functionality anyway, so it's ok to
-// not-run them even in situations they might, with effort, be made to work.
-#ifdef isnan  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_NAN(arg)                                         \
-  do {                                                          \
-    if (!isnan(arg)) {                                          \
-      fprintf(stderr, "Check failed: isnan(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_NAN(arg)
-#endif
-
-#ifdef isinf  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_INF(arg)                                         \
-  do {                                                          \
-    if (!isinf(arg)) {                                          \
-      fprintf(stderr, "Check failed: isinf(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_INF(arg)
-#endif
-
-#define EXPECT_DOUBLE_EQ(val1, val2)                                    \
-  do {                                                                  \
-    if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) {         \
-      fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2);        \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_STREQ(val1, val2)                                        \
-  do {                                                                  \
-    if (strcmp((val1), (val2)) != 0) {                                  \
-      fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-static bool g_called_exit;
-static void CalledExit(int) { g_called_exit = true; }
-extern GFLAGS_DLL_DECL void (*commandlineflags_exitfunc)(int);  // in gflags.cc
-
-#define EXPECT_DEATH(fn, msg)                                           \
-  do {                                                                  \
-    g_called_exit = false;                                              \
-    commandlineflags_exitfunc = &CalledExit;                            \
-    fn;                                                                 \
-    commandlineflags_exitfunc = &exit;    /* set back to its default */ \
-    if (!g_called_exit) {                                               \
-      fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn);      \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-
-vector<void (*)()> g_testlist;  // the tests to run
-
-#define TEST(a, b)                                      \
-  struct Test_##a##_##b {                               \
-    Test_##a##_##b() { g_testlist.push_back(&Run); }    \
-    static void Run() {                                 \
-      FlagSaver fs;                                     \
-      fprintf(stderr, "Running test %s/%s\n", #a, #b);  \
-      RunTest();                                        \
-    }                                                   \
-    static void RunTest();                              \
-  };                                                    \
-  static Test_##a##_##b g_test_##a##_##b;               \
-  void Test_##a##_##b::RunTest()
-
-
-static int RUN_ALL_TESTS() {
-  vector<void (*)()>::const_iterator it;
-  for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
-    (*it)();
-  }
-  fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
-  return 0;
-}
-
-
-static string TmpFile(const string& basename) {
-#ifdef _MSC_VER
-  return FLAGS_test_tmpdir + "\\" + basename;
-#else
-  return FLAGS_test_tmpdir + "/" + basename;
-#endif
-}
-
-// Returns the definition of the --flagfile flag to be used in the tests.
-static const char* GetFlagFileFlag() {
-#ifdef _MSC_VER
-  static const string flagfile = FLAGS_srcdir + "\\src\\gflags_unittest_flagfile";
-#else
-  static const string flagfile = FLAGS_srcdir + "/src/gflags_unittest_flagfile";
-#endif
-  static const string flagfile_flag = string("--flagfile=") + flagfile;
-  return flagfile_flag.c_str();
-}
-
-
-// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
-// compiler error iff T1 and T2 are different types.
-template <typename T1, typename T2>
-struct CompileAssertTypesEqual;
-
-template <typename T>
-struct CompileAssertTypesEqual<T, T> {
-};
-
-
-template <typename Expected, typename Actual>
-void AssertIsType(Actual& x) {
-  CompileAssertTypesEqual<Expected, Actual>();
-}
-
-// Verify all the flags are the right type.
-TEST(FlagTypes, FlagTypes) {
-  AssertIsType<bool>(FLAGS_test_bool);
-  AssertIsType<int32>(FLAGS_test_int32);
-  AssertIsType<int64>(FLAGS_test_int64);
-  AssertIsType<uint64>(FLAGS_test_uint64);
-  AssertIsType<double>(FLAGS_test_double);
-  AssertIsType<string>(FLAGS_test_string);
-}
-
-// Death tests for "help" options.
-//
-// The help system automatically calls exit(1) when you specify any of
-// the help-related flags ("-helpmatch", "-helpxml") so we can't test
-// those mainline.
-
-// Tests that "-helpmatch" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpMatch) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpmatch=base", GetArgv0(), true),
-               "");
-}
-
-
-// Tests that "-helpxml" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpXml) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpxml", GetArgv0(), true),
-               "");
-}
-
-
-// A subroutine needed for testing reading flags from a string.
-void TestFlagString(const string& flags,
-                    const string& expected_string,
-                    bool expected_bool,
-                    int32 expected_int32,
-                    double expected_double) {
-  EXPECT_TRUE(ReadFlagsFromString(flags,
-                                  GetArgv0(),
-                                  // errors are fatal
-                                  true));
-
-  EXPECT_EQ(expected_string, FLAGS_test_string);
-  EXPECT_EQ(expected_bool, FLAGS_test_bool);
-  EXPECT_EQ(expected_int32, FLAGS_test_int32);
-  EXPECT_DOUBLE_EQ(expected_double, FLAGS_test_double);
-}
-
-
-// Tests reading flags from a string.
-TEST(FlagFileTest, ReadFlagsFromString) {
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "-test_double=0.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      0.0);
-
-  TestFlagString(
-      // Flag string
-      "# let's make sure it can update values\n"
-      "-test_string=initial\n"
-      "-test_bool=false\n"
-      "-test_int32=123\n"
-      "-test_double=123.0\n",
-      // Expected values
-      "initial",
-      false,
-      123,
-      123.0);
-}
-
-// Tests the filename part of the flagfile
-TEST(FlagFileTest, FilenamesOurfileLast) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "not_our_filename\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "gflags_unittest\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      false,
-      -1,
-      1000.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileFirst) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "gflags_unittest\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "not_our_filename\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-#ifdef HAVE_FNMATCH_H   // otherwise glob isn't supported
-TEST(FlagFileTest, FilenamesOurfileGlob) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*flags*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileInBigList) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*first* *flags* *third*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-#endif
-
-// Tests that a failed flag-from-string read keeps flags at default values
-TEST(FlagFileTest, FailReadFlagsFromString) {
-  FLAGS_test_int32 = 119;
-  string flags("# let's make sure it can update values\n"
-               "-test_string=non_initial\n"
-               "-test_bool=false\n"
-               "-test_int32=123\n"
-               "-test_double=illegal\n");
-
-  EXPECT_FALSE(ReadFlagsFromString(flags,
-                                   GetArgv0(),
-                                   // errors are fatal
-                                   false));
-
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ("initial", FLAGS_test_string);
-}
-
-// Tests that flags can be set to ordinary values.
-TEST(SetFlagValueTest, OrdinaryValues) {
-  EXPECT_EQ("initial", FLAGS_test_str1);
-
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // set; was default
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // already set once
-
-  FLAGS_test_str1 = "initial";
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("initial", FLAGS_test_str1);  // still already set before
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAGS_VALUE);
-  EXPECT_EQ("third", FLAGS_test_str1);  // changed value
-
-  SetCommandLineOptionWithMode("test_str1", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str1);
-  // value not changed (already set before)
-
-  EXPECT_EQ("initial", FLAGS_test_str2);
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);  // changed (was default)
-
-  FLAGS_test_str2 = "extra";
-  EXPECT_EQ("extra", FLAGS_test_str2);
-
-  FLAGS_test_str2 = "second";
-  SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str2);  // still changed (was equal to default)
-
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str2);  // changed (was default)
-
-  EXPECT_EQ("initial", FLAGS_test_str3);
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str3);  // changed
-
-  FLAGS_test_str3 = "third";
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_VALUE);
-  EXPECT_EQ("fourth", FLAGS_test_str3);  // changed value
-}
-
-
-// Tests that flags can be set to exceptional values.
-// Note: apparently MINGW doesn't parse inf and nan correctly:
-//    http://www.mail-archive.com/bug-gnulib@gnu.org/msg09573.html
-// This url says FreeBSD also has a problem, but I didn't see that.
-TEST(SetFlagValueTest, ExceptionalValues) {
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "inf"));
-  EXPECT_INF(FLAGS_test_double);
-
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "INF"));
-  EXPECT_INF(FLAGS_test_double);
-#endif
-
-  // set some bad values
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", "0.1xxx"));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", " "));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", ""));
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to -inf\n",
-            SetCommandLineOption("test_double", "-inf"));
-  EXPECT_INF(FLAGS_test_double);
-  EXPECT_GT(0, FLAGS_test_double);
-#endif
-
-#if defined(isnan) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to nan\n",
-            SetCommandLineOption("test_double", "NaN"));
-  EXPECT_NAN(FLAGS_test_double);
-#endif
-}
-
-// Tests that integer flags can be specified in many ways
-TEST(SetFlagValueTest, DifferentRadices) {
-  EXPECT_EQ("test_int32 set to 12\n",
-            SetCommandLineOption("test_int32", "12"));
-
-  EXPECT_EQ("test_int32 set to 16\n",
-            SetCommandLineOption("test_int32", "0x10"));
-
-  EXPECT_EQ("test_int32 set to 34\n",
-            SetCommandLineOption("test_int32", "0X22"));
-
-  // Leading 0 is *not* octal; it's still decimal
-  EXPECT_EQ("test_int32 set to 10\n",
-            SetCommandLineOption("test_int32", "010"));
-}
-
-// Tests what happens when you try to set a flag to an illegal value
-TEST(SetFlagValueTest, IllegalValues) {
-  FLAGS_test_bool = true;
-  FLAGS_test_int32 = 119;
-  FLAGS_test_int64 = 1191;
-  FLAGS_test_uint64 = 11911;
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_bool", "12"));
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int32", "7000000000000"));
-
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_EQ("",
-            SetCommandLineOption("test_uint64", "-1"));
-#endif
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int64", "not a number!"));
-
-  // Test the empty string with each type of input
-  EXPECT_EQ("", SetCommandLineOption("test_bool", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int32", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_uint64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_double", ""));
-  EXPECT_EQ("test_string set to \n", SetCommandLineOption("test_string", ""));
-
-  EXPECT_TRUE(FLAGS_test_bool);
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ(1191, FLAGS_test_int64);
-  EXPECT_EQ(11911, FLAGS_test_uint64);
-}
-
-
-// Tests that we only evaluate macro args once
-TEST(MacroArgs, EvaluateOnce) {
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure we don't ++ the value somehow, when evaluating the flag.
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure the macro only evaluated this var once.
-  EXPECT_EQ(13, changeable_var);
-  // Make sure the actual value and default value are the same
-  SetCommandLineOptionWithMode("changeable_var", "21", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ(21, FLAGS_changeable_var);
-}
-
-TEST(MacroArgs, EvaluateOnceBool) {
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_EQ(8009, changeable_bool_var);
-  SetCommandLineOptionWithMode("changeable_bool_var", "false",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_FALSE(FLAGS_changeable_bool_var);
-}
-
-TEST(MacroArgs, EvaluateOnceStrings) {
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ(1, changeable_string_var);
-  SetCommandLineOptionWithMode("changeable_string_var", "different",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("different", FLAGS_changeable_string_var);
-}
-
-// Tests that the FooFromEnv does the right thing
-TEST(FromEnvTest, LegalValues) {
-  setenv("BOOL_VAL1", "true", 1);
-  setenv("BOOL_VAL2", "false", 1);
-  setenv("BOOL_VAL3", "1", 1);
-  setenv("BOOL_VAL4", "F", 1);
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL1", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL2", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL3", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL4", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL_UNKNOWN", true));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL_UNKNOWN", false));
-
-  setenv("INT_VAL1", "1", 1);
-  setenv("INT_VAL2", "-1", 1);
-  EXPECT_EQ(1, Int32FromEnv("INT_VAL1", 10));
-  EXPECT_EQ(-1, Int32FromEnv("INT_VAL2", 10));
-  EXPECT_EQ(10, Int32FromEnv("INT_VAL_UNKNOWN", 10));
-
-  setenv("INT_VAL3", "1099511627776", 1);
-  EXPECT_EQ(1, Int64FromEnv("INT_VAL1", 20));
-  EXPECT_EQ(-1, Int64FromEnv("INT_VAL2", 20));
-  EXPECT_EQ(1099511627776LL, Int64FromEnv("INT_VAL3", 20));
-  EXPECT_EQ(20, Int64FromEnv("INT_VAL_UNKNOWN", 20));
-
-  EXPECT_EQ(1, Uint64FromEnv("INT_VAL1", 30));
-  EXPECT_EQ(1099511627776ULL, Uint64FromEnv("INT_VAL3", 30));
-  EXPECT_EQ(30, Uint64FromEnv("INT_VAL_UNKNOWN", 30));
-
-  // I pick values here that can be easily represented exactly in floating-point
-  setenv("DOUBLE_VAL1", "0.0", 1);
-  setenv("DOUBLE_VAL2", "1.0", 1);
-  setenv("DOUBLE_VAL3", "-1.0", 1);
-  EXPECT_EQ(0.0, DoubleFromEnv("DOUBLE_VAL1", 40.0));
-  EXPECT_EQ(1.0, DoubleFromEnv("DOUBLE_VAL2", 40.0));
-  EXPECT_EQ(-1.0, DoubleFromEnv("DOUBLE_VAL3", 40.0));
-  EXPECT_EQ(40.0, DoubleFromEnv("DOUBLE_VAL_UNKNOWN", 40.0));
-
-  setenv("STRING_VAL1", "", 1);
-  setenv("STRING_VAL2", "my happy string!", 1);
-  EXPECT_STREQ("", StringFromEnv("STRING_VAL1", "unknown"));
-  EXPECT_STREQ("my happy string!", StringFromEnv("STRING_VAL2", "unknown"));
-  EXPECT_STREQ("unknown", StringFromEnv("STRING_VAL_UNKNOWN", "unknown"));
-}
-
-// Tests that the FooFromEnv dies on parse-error
-TEST(FromEnvDeathTest, IllegalValues) {
-  setenv("BOOL_BAD1", "so true!", 1);
-  setenv("BOOL_BAD2", "", 1);
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD1", false), "error parsing env variable");
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD2", true), "error parsing env variable");
-
-  setenv("INT_BAD1", "one", 1);
-  setenv("INT_BAD2", "100000000000000000", 1);
-  setenv("INT_BAD3", "0xx10", 1);
-  setenv("INT_BAD4", "", 1);
-  EXPECT_DEATH(Int32FromEnv("INT_BAD1", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD2", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD3", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD4", 10), "error parsing env variable");
-
-  setenv("BIGINT_BAD1", "18446744073709551616000", 1);
-  EXPECT_DEATH(Int64FromEnv("INT_BAD1", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD3", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD4", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("BIGINT_BAD1", 200), "error parsing env variable");
-
-  setenv("BIGINT_BAD2", "-1", 1);
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD1", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD3", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD4", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD1", 30), "error parsing env variable");
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD2", 30), "error parsing env variable");
-#endif
-
-  setenv("DOUBLE_BAD1", "0.0.0", 1);
-  setenv("DOUBLE_BAD2", "", 1);
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD1", 40.0), "error parsing env variable");
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD2", 40.0), "error parsing env variable");
-}
-
-// Tests that FlagSaver can save the states of string flags.
-TEST(FlagSaverTest, CanSaveStringFlagStates) {
-  // 1. Initializes the flags.
-
-  // State of flag test_str1:
-  //   default value - "initial"
-  //   current value - "initial"
-  //   not set       - true
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_VALUE);
-  // State of flag test_str2:
-  //   default value - "initial"
-  //   current value - "second"
-  //   not set       - false
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  // State of flag test_str3:
-  //   default value - "second"
-  //   current value - "second"
-  //   not set       - true
-
-  // 2. Saves the flag states.
-
-  {
-    FlagSaver fs;
-
-    // 3. Modifies the flag states.
-
-    SetCommandLineOptionWithMode("test_str1", "second", SET_FLAGS_VALUE);
-    EXPECT_EQ("second", FLAGS_test_str1);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "second"
-    //   not set       - true
-
-    SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-    EXPECT_EQ("second", FLAGS_test_str2);
-    // State of flag test_str2:
-    //   default value - "third"
-    //   current value - "second"
-    //   not set       - false
-
-    SetCommandLineOptionWithMode("test_str3", "third", SET_FLAGS_VALUE);
-    EXPECT_EQ("third", FLAGS_test_str3);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "third"
-    //   not set       - false
-
-    // 4. Restores the flag states.
-  }
-
-  // 5. Verifies that the states were restored.
-
-  // Verifies that the value of test_str1 was restored.
-  EXPECT_EQ("initial", FLAGS_test_str1);
-  // Verifies that the "not set" attribute of test_str1 was restored to true.
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);
-
-  // Verifies that the value of test_str2 was restored.
-  EXPECT_EQ("second", FLAGS_test_str2);
-  // Verifies that the "not set" attribute of test_str2 was restored to false.
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);
-
-  // Verifies that the value of test_str3 was restored.
-  EXPECT_EQ("second", FLAGS_test_str3);
-  // Verifies that the "not set" attribute of test_str3 was restored to true.
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str3);
-}
-
-
-// Tests that FlagSaver can save the values of various-typed flags.
-TEST(FlagSaverTest, CanSaveVariousTypedFlagValues) {
-  // Initializes the flags.
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_int64 = -2;
-  FLAGS_test_uint64 = 3;
-  FLAGS_test_double = 4.0;
-  FLAGS_test_string = "good";
-
-  // Saves the flag states.
-  {
-    FlagSaver fs;
-
-    // Modifies the flags.
-    FLAGS_test_bool = true;
-    FLAGS_test_int32 = -5;
-    FLAGS_test_int64 = -6;
-    FLAGS_test_uint64 = 7;
-    FLAGS_test_double = 8.0;
-    FLAGS_test_string = "bad";
-
-    // Restores the flag states.
-  }
-
-  // Verifies the flag values were restored.
-  EXPECT_FALSE(FLAGS_test_bool);
-  EXPECT_EQ(-1, FLAGS_test_int32);
-  EXPECT_EQ(-2, FLAGS_test_int64);
-  EXPECT_EQ(3, FLAGS_test_uint64);
-  EXPECT_DOUBLE_EQ(4.0, FLAGS_test_double);
-  EXPECT_EQ("good", FLAGS_test_string);
-}
-
-TEST(GetAllFlagsTest, BaseTest) {
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);
-  bool found_test_bool = false;
-  vector<CommandLineFlagInfo>::const_iterator i;
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    if (i->name == "test_bool") {
-      found_test_bool = true;
-      EXPECT_EQ(i->type, "bool");
-      EXPECT_EQ(i->default_value, "false");
-      break;
-    }
-  }
-  EXPECT_TRUE(found_test_bool);
-}
-
-TEST(ShowUsageWithFlagsTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --help.
-}
-
-TEST(ShowUsageWithFlagsRestrictTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --helpmatch.
-}
-
-// Note: all these argv-based tests depend on SetArgv being called
-// before ParseCommandLineFlags() in Main(), below.
-TEST(GetArgvsTest, BaseTest) {
-  vector<string> argvs = GetArgvs();
-  EXPECT_EQ(4, argvs.size());
-  EXPECT_EQ("/test/argv/for/gflags_unittest", argvs[0]);
-  EXPECT_EQ("argv 2", argvs[1]);
-  EXPECT_EQ("3rd argv", argvs[2]);
-  EXPECT_EQ("argv #4", argvs[3]);
-}
-
-TEST(GetArgvTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest "
-               "argv 2 3rd argv argv #4", GetArgv());
-}
-
-TEST(GetArgv0Test, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest", GetArgv0());
-}
-
-TEST(GetArgvSumTest, BaseTest) {
-  // This number is just the sum of the ASCII values of all the chars
-  // in GetArgv().
-  EXPECT_EQ(4904, GetArgvSum());
-}
-
-TEST(ProgramInvocationNameTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest",
-               ProgramInvocationName());
-}
-
-TEST(ProgramInvocationShortNameTest, BaseTest) {
-  EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName());
-}
-
-TEST(ProgramUsageTest, BaseTest) {  // Depends on arg to SetUsageMessage()
-  EXPECT_STREQ("/test/argv/for/gflags_unittest: "
-               "<useless flag> [...]\nDoes something useless.\n",
-               ProgramUsage());
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndIsDefault) {
-  string value("will be changed");
-  bool r = GetCommandLineOption("test_bool", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("false", value);
-
-  r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("-1", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("400", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasSet) {
-  SetCommandLineOption("test_int32", "700");
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("700", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasNotSet) {
-  // This doesn't set the flag's value, but rather its default value.
-  // is_default is still true, but the 'default' value returned has changed!
-  SetCommandLineOptionWithMode("test_int32", "800", SET_FLAGS_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("800", value);
-  EXPECT_TRUE(GetCommandLineFlagInfoOrDie("test_int32").is_default);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasConditionallySet) {
-  SetCommandLineOptionWithMode("test_int32", "900", SET_FLAG_IF_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("900", value);
-}
-
-TEST(GetCommandLineOptionTest, NameDoesNotExist) {
-  string value("will not be changed");
-  const bool r = GetCommandLineOption("test_int3210", &value);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("will not be changed", value);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagExists) {
-  CommandLineFlagInfo info;
-  bool r = GetCommandLineFlagInfo("test_int32", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = true;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = false;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);  // value is same, but flag *was* modified
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) {
-  CommandLineFlagInfo info;
-  // Set to some random values that GetCommandLineFlagInfo should not change
-  info.name = "name";
-  info.type = "type";
-  info.current_value = "curr";
-  info.default_value = "def";
-  info.filename = "/";
-  info.is_default = false;
-  info.has_validator_fn = true;
-  bool r = GetCommandLineFlagInfo("test_int3210", &info);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("name", info.name);
-  EXPECT_EQ("type", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("curr", info.current_value);
-  EXPECT_EQ("def", info.default_value);
-  EXPECT_EQ("/", info.filename);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_TRUE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndIsDefault) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("400", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  FLAGS_test_bool = true;
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieDeathTest, FlagDoesNotExist) {
-  EXPECT_DEATH(GetCommandLineFlagInfoOrDie("test_int3210"),
-               ".*: flag test_int3210 does not exist");
-}
-
-
-// These are lightly tested because they're deprecated.  Basically,
-// the tests are meant to cover how existing users use these functions,
-// but not necessarily how new users could use them.
-TEST(DeprecatedFunctionsTest, CommandlineFlagsIntoString) {
-  string s = CommandlineFlagsIntoString();
-  EXPECT_NE(string::npos, s.find("--test_bool="));
-}
-
-TEST(DeprecatedFunctionsTest, AppendFlagsIntoFile) {
-  FLAGS_test_int32 = 10;     // just to make the test more interesting
-  string filename(TmpFile("flagfile"));
-  unlink(filename.c_str());  // just to be safe
-  const bool r = AppendFlagsIntoFile(filename, "not the real argv0");
-  EXPECT_TRUE(r);
-
-  FILE* fp = fopen(filename.c_str(), "r");
-  EXPECT_TRUE(fp != NULL);
-  char line[8192];
-  EXPECT_TRUE(fgets(line, sizeof(line)-1, fp) != NULL);  // get the first line
-  // First line should be progname.
-  EXPECT_STREQ("not the real argv0\n", line);
-
-  bool found_bool = false, found_int32 = false;
-  while (fgets(line, sizeof(line)-1, fp)) {
-    line[sizeof(line)-1] = '\0';    // just to be safe
-    if (strcmp(line, "--test_bool=false\n") == 0)
-      found_bool = true;
-    if (strcmp(line, "--test_int32=10\n") == 0)
-      found_int32 = true;
-  }
-  EXPECT_TRUE(found_int32);
-  EXPECT_TRUE(found_bool);
-  fclose(fp);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFile) {
-  FLAGS_test_int32 = -10;    // just to make the test more interesting
-  string filename(TmpFile("flagfile2"));
-  unlink(filename.c_str());  // just to be safe
-  bool r = AppendFlagsIntoFile(filename, GetArgv0());
-  EXPECT_TRUE(r);
-
-  FLAGS_test_int32 = -11;
-  r = ReadFromFlagsFile(filename, GetArgv0(), true);
-  EXPECT_TRUE(r);
-  EXPECT_EQ(-10, FLAGS_test_int32);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) {
-  FLAGS_test_int32 = -20;
-  string filename(TmpFile("flagfile3"));
-  FILE* fp = fopen(filename.c_str(), "w");
-  EXPECT_TRUE(fp != NULL);
-  // Note the error in the bool assignment below...
-  fprintf(fp, "%s\n--test_int32=-21\n--test_bool=not_a_bool!\n", GetArgv0());
-  fclose(fp);
-
-  FLAGS_test_int32 = -22;
-  const bool r = ReadFromFlagsFile(filename, GetArgv0(), false);
-  EXPECT_FALSE(r);
-  EXPECT_EQ(-22, FLAGS_test_int32);   // the -21 from the flagsfile didn't take
-}
-
-TEST(FlagsSetBeforeInitTest, TryFromEnv) {
-  EXPECT_EQ("pre-set", FLAGS_test_tryfromenv);
-}
-
-// The following test case verifies that ParseCommandLineFlags() and
-// ParseCommandLineNonHelpFlags() uses the last definition of a flag
-// in case it's defined more than once.
-
-DEFINE_int32(test_flag, -1, "used for testing commandlineflags.cc");
-
-// Parses and returns the --test_flag flag.
-// If with_help is true, calls ParseCommandLineFlags; otherwise calls
-// ParseCommandLineNonHelpFlags.
-int32 ParseTestFlag(bool with_help, int argc, const char** const_argv) {
-  FlagSaver fs;  // Restores the flags before returning.
-
-  // Makes a copy of the input array s.t. it can be reused
-  // (ParseCommandLineFlags() will alter the array).
-  char** const argv_save = new char*[argc + 1];
-  char** argv = argv_save;
-  memcpy(argv, const_argv, sizeof(*argv)*(argc + 1));
-
-  if (with_help) {
-    ParseCommandLineFlags(&argc, &argv, true);
-  } else {
-    ParseCommandLineNonHelpFlags(&argc, &argv, true);
-  }
-
-  delete[] argv_save;
-  return FLAGS_test_flag;
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceOnCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=1",
-    "--test_flag=2",
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceInFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndThenFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgFirst) {
-  const char* argv[] = {
-    "my_test",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(-1, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(-1, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgMiddle) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=7",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(7, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(7, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, OneDashArg) {
-  const char* argv[] = {
-    "my_test",
-    "-",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(0, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(0, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--this_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     BoolFlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--nothis_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsNotABool) {
-  const char* argv[] = {
-    "my_test",
-    "--notest_string",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-}
-
-TEST(ParseCommandLineFlagsWrongFields,
-     DescriptionIsInvalid) {
-  // These must not be automatic variables, since command line flags
-  // aren't unregistered and gUnit uses FlagSaver to save and restore
-  // command line flags' values.  If these are on the stack, then when
-  // later tests attempt to save and restore their values, the stack
-  // addresses of these variables will be overwritten...  Stack smash!
-  static bool current_storage;
-  static bool defvalue_storage;
-  FlagRegisterer fr("flag_name", "bool", 0, "filename",
-                    &current_storage, &defvalue_storage);
-  CommandLineFlagInfo fi;
-  EXPECT_TRUE(GetCommandLineFlagInfo("flag_name", &fi));
-  EXPECT_EQ("", fi.description);
-}
-
-static bool ValidateTestFlagIs5(const char* flagname, int32 flagval) {
-  if (flagval == 5)
-    return true;
-  printf("%s isn't 5!\n", flagname);
-  return false;
-}
-
-static bool ValidateTestFlagIs10(const char* flagname, int32 flagval) {
-  return flagval == 10;
-}
-
-
-TEST(FlagsValidator, ValidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=5",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_EQ(5, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  // Undo the flag validator setting
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_VALUE));
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_NE("", SetCommandLineOption("test_flag", "5"));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=50",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: failed validation of new value '50' for flag 'test_flag'");
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_EQ(-1, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_VALUE));
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));
-  EXPECT_EQ(100, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagNeverSet) {
-  // If a flag keeps its default value, and that default value is
-  // invalid, we should die at argv-parse time.
-  const char* argv[] = {
-    "my_test",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: --test_flag must be set on the commandline");
-}
-
-TEST(FlagsValidator, InvalidFlagPtr) {
-  int32 dummy;
-  EXPECT_FALSE(RegisterFlagValidator(NULL, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&dummy, &ValidateTestFlagIs5));
-}
-
-TEST(FlagsValidator, RegisterValidatorTwice) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, CommandLineFlagInfo) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_TRUE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(FlagsValidator, FlagSaver) {
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-    EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // fails validation
-  }
-  EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // validator is gone
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-    EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // no validator
-  }
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // validator is back
-}
-
-
-static int Main(int argc, char **argv) {
-  // We need to call SetArgv before SetUsage, so our "test" argv will
-  // win out over this executable's real argv.  That makes running this
-  // test with a real --help flag kinda annoying, unfortunately.
-  const char* test_argv[] = { "/test/argv/for/gflags_unittest",
-                              "argv 2", "3rd argv", "argv #4" };
-  SetArgv(GET_ARRAY_SIZE(test_argv), test_argv);
-
-  // The first arg is the usage message, also important for testing.
-  string usage_message = (string(GetArgv0()) +
-                          ": <useless flag> [...]\nDoes something useless.\n");
-
-  // We test setting tryfromenv manually, and making sure
-  // ParseCommandLineFlags still evaluates it.
-  FLAGS_tryfromenv = "test_tryfromenv";
-  setenv("FLAGS_test_tryfromenv", "pre-set", 1);
-
-  // Modify flag values from declared default value in two ways.
-  // The recommended way:
-  SetCommandLineOptionWithMode("changed_bool1", "true", SET_FLAGS_DEFAULT);
-  // The non-recommended way:
-  FLAGS_changed_bool2 = true;
-
-  SetUsageMessage(usage_message.c_str());
-  ParseCommandLineFlags(&argc, &argv, true);
-
-#if defined(__MINGW32__)
-  // I had trouble creating a directory in /tmp from mingw
-  FLAGS_test_tmpdir = "./gflags_unittest_testdir";
-  mkdir(FLAGS_test_tmpdir.c_str());   // mingw has a weird one-arg mkdir
-#elif defined(_MSC_VER)
-  char tmppath_buffer[1024];
-  int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
-  assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer));
-  assert(tmppath_buffer[tmppath_len - 1] == '\\');   // API guarantees it
-  FLAGS_test_tmpdir = string(tmppath_buffer) + "gflags_unittest_testdir";
-  _mkdir(FLAGS_test_tmpdir.c_str());
-#else
-  mkdir(FLAGS_test_tmpdir.c_str(), 0755);
-#endif
-
-  return RUN_ALL_TESTS();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-int main(int argc, char** argv) {
-  const int exit_status = GOOGLE_NAMESPACE::Main(argc, argv);
-  GOOGLE_NAMESPACE::ShutDownCommandLineFlags();
-  return exit_status;
-}

+ 0 - 1591
Src/ThirdParty/gflags/src/gflags_unittest_main.cc

@@ -1,1591 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Marius Eriksen
-//
-// For now, this unit test does not cover all features of
-// gflags.cc
-
-#include "config_for_unittests.h"
-#include <stdio.h>
-#include <stdlib.h>     // for &exit
-#include <assert.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>     // for unlink()
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>   // for mkdir()
-#endif
-#include <math.h>       // for isinf() and isnan()
-#include <vector>
-#include <string>
-
-#include <gflags/gflags.h>
-// I don't actually use this header file, but #include it under the
-// old location to make sure that the include-header-forwarding
-// works.  But don't bother on windows; the windows port is so new
-// it never had the old location-names.
-#ifndef _MSC_VER
-#include <google/gflags_completions.h>
-void (*unused_fn)() = &GOOGLE_NAMESPACE::HandleCommandLineCompletions;
-#endif
-
-using GOOGLE_NAMESPACE::int32;
-using GOOGLE_NAMESPACE::FlagRegisterer;
-using GOOGLE_NAMESPACE::StringFromEnv;
-using GOOGLE_NAMESPACE::RegisterFlagValidator;
-using GOOGLE_NAMESPACE::CommandLineFlagInfo;
-using GOOGLE_NAMESPACE::GetAllFlags;
-
-// Returns the number of elements in an array.
-#define GET_ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*(arr)))
-
-#if !defined(HAVE_SETENV) && defined(HAVE_PUTENV)   // mingw, at least
-void setenv(const char* name, const char* value, int) {
-  // In windows, it's impossible to set a variable to the empty string.
-  // We handle this by setting it to "0" and the NUL-ing out the \0.
-  // cf http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/environ.cpp?r1=611451&r2=637508&pathrev=637508
-  static const char* const kFakeZero = "0";
-  if (*value == '\0')
-    value = kFakeZero;
-  // Apparently the semantics of putenv() is that the input
-  // must live forever, so we leak memory here. :-(
-  const int nameval_len = strlen(name) + 1 + strlen(value) + 1;
-  char* nameval = reinterpret_cast<char*>(malloc(nameval_len));
-  snprintf(nameval, nameval_len, "%s=%s", name, value);
-  putenv(nameval);
-  if (value == kFakeZero) {
-    nameval[nameval_len - 2] = '\0';   // works when putenv() makes no copy
-    if (*getenv(name) != '\0')
-      *getenv(name) = '\0';            // works when putenv() copies nameval
-  }
-}
-#endif
-
-DECLARE_string(tryfromenv);   // in gflags.cc
-
-DEFINE_string(test_tmpdir, "/tmp/gflags_unittest", "Dir we use for temp files");
-#ifdef _MSC_VER  // in MSVC, we run from the vsprojects directory
-DEFINE_string(srcdir, "..\\..",
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#else
-DEFINE_string(srcdir, StringFromEnv("SRCDIR", "."),
-              "Source-dir root, needed to find gflags_unittest_flagfile");
-#endif
-
-DEFINE_bool(test_bool, false, "tests bool-ness");
-DEFINE_int32(test_int32, -1, "");
-DEFINE_int64(test_int64, -2, "");
-DEFINE_uint64(test_uint64, 2, "");
-DEFINE_double(test_double, -1.0, "");
-DEFINE_string(test_string, "initial", "");
-
-//
-// The below ugliness gets some additional code coverage in the -helpxml
-// and -helpmatch test cases having to do with string lengths and formatting
-//
-DEFINE_bool(test_bool_with_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_quite_long_name,
-            false,
-            "extremely_extremely_extremely_extremely_extremely_extremely_extremely_extremely_long_meaning");
-
-DEFINE_string(test_str1, "initial", "");
-DEFINE_string(test_str2, "initial", "");
-DEFINE_string(test_str3, "initial", "");
-
-// This is used to test setting tryfromenv manually
-DEFINE_string(test_tryfromenv, "initial", "");
-
-// Don't try this at home!
-static int changeable_var = 12;
-DEFINE_int32(changeable_var, ++changeable_var, "");
-
-static int changeable_bool_var = 8008;
-DEFINE_bool(changeable_bool_var, ++changeable_bool_var == 8009, "");
-
-static int changeable_string_var = 0;
-static std::string ChangeableString() {
-  char r[] = {static_cast<char>('0' + ++changeable_string_var), '\0'};
-  return r;
-}
-DEFINE_string(changeable_string_var, ChangeableString(), "");
-
-// These are never used in this unittest, but can be used by
-// gflags_unittest.sh when it needs to specify flags
-// that are legal for gflags_unittest but don't need to
-// be a particular value.
-DEFINE_bool(unused_bool, true, "unused bool-ness");
-DEFINE_int32(unused_int32, -1001, "");
-DEFINE_int64(unused_int64, -2001, "");
-DEFINE_uint64(unused_uint64, 2000, "");
-DEFINE_double(unused_double, -1000.0, "");
-DEFINE_string(unused_string, "unused", "");
-
-// These flags are used by gflags_unittest.sh
-DEFINE_bool(changed_bool1, false, "changed");
-DEFINE_bool(changed_bool2, false, "changed");
-
-static bool AlwaysFail(const char* flag, bool value) { return value == false; }
-DEFINE_bool(always_fail, false, "will fail to validate when you set it");
-static bool dummy = RegisterFlagValidator(&FLAGS_always_fail, AlwaysFail);
-
-// See the comment by GetAllFlags in commandlineflags.h
-static bool DeadlockIfCantLockInValidators(const char* flag, bool value) {
-  if (!value) {
-    return true;
-  }
-  std::vector<CommandLineFlagInfo> dummy;
-  GetAllFlags(&dummy);
-  return true;
-}
-DEFINE_bool(deadlock_if_cant_lock,
-            false,
-            "will deadlock if set to true and "
-            "if locking of registry in validators fails.");
-static bool dummy1 = RegisterFlagValidator(&FLAGS_deadlock_if_cant_lock,
-                                           DeadlockIfCantLockInValidators);
-
-// This is a pseudo-flag -- we want to register a flag with a filename
-// at the top level, but there is no way to do this except by faking
-// the filename.
-namespace fLI {
-  static const int32 FLAGS_nonotldflag1 = 12;
-  int32 FLAGS_tldflag1 = FLAGS_nonotldflag1;
-  int32 FLAGS_notldflag1 = FLAGS_nonotldflag1;
-  static FlagRegisterer o_tldflag1(
-    "tldflag1", "int32",
-    "should show up in --helpshort", "gflags_unittest.cc",
-    &FLAGS_tldflag1, &FLAGS_notldflag1);
-}
-using fLI::FLAGS_tldflag1;
-
-namespace fLI {
-  static const int32 FLAGS_nonotldflag2 = 23;
-  int32 FLAGS_tldflag2 = FLAGS_nonotldflag2;
-  int32 FLAGS_notldflag2 = FLAGS_nonotldflag2;
-  static FlagRegisterer o_tldflag2(
-    "tldflag2", "int32",
-    "should show up in --helpshort", "gflags_unittest.",
-    &FLAGS_tldflag2, &FLAGS_notldflag2);
-}
-using fLI::FLAGS_tldflag2;
-
-_START_GOOGLE_NAMESPACE_
-
-using std::string;
-using std::vector;
-
-// The following is some bare-bones testing infrastructure
-
-#define EXPECT_TRUE(cond)                               \
-  do {                                                  \
-    if (!(cond)) {                                      \
-      fprintf(stderr, "Check failed: %s\n", #cond);     \
-      exit(1);                                          \
-    }                                                   \
-  } while (0)
-
-#define EXPECT_FALSE(cond)  EXPECT_TRUE(!(cond))
-
-#define EXPECT_OP(op, val1, val2)                                       \
-  do {                                                                  \
-    if (!((val1) op (val2))) {                                          \
-      fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_EQ(val1, val2)  EXPECT_OP(==, val1, val2)
-#define EXPECT_NE(val1, val2)  EXPECT_OP(!=, val1, val2)
-#define EXPECT_GT(val1, val2)  EXPECT_OP(>, val1, val2)
-#define EXPECT_LT(val1, val2)  EXPECT_OP(<, val1, val2)
-
-// C99 declares isnan and isinf should be macros, so the #ifdef test
-// should be reliable everywhere.  Of course, it's not, but these
-// are testing pertty marginal functionality anyway, so it's ok to
-// not-run them even in situations they might, with effort, be made to work.
-#ifdef isnan  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_NAN(arg)                                         \
-  do {                                                          \
-    if (!isnan(arg)) {                                          \
-      fprintf(stderr, "Check failed: isnan(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_NAN(arg)
-#endif
-
-#ifdef isinf  // Some compilers, like sun's for Solaris 10, don't define this
-#define EXPECT_INF(arg)                                         \
-  do {                                                          \
-    if (!isinf(arg)) {                                          \
-      fprintf(stderr, "Check failed: isinf(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-#else
-#define EXPECT_INF(arg)
-#endif
-
-#define EXPECT_DOUBLE_EQ(val1, val2)                                    \
-  do {                                                                  \
-    if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) {         \
-      fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2);        \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_STREQ(val1, val2)                                        \
-  do {                                                                  \
-    if (strcmp((val1), (val2)) != 0) {                                  \
-      fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-static bool g_called_exit;
-static void CalledExit(int) { g_called_exit = true; }
-extern GFLAGS_DLL_DECL void (*commandlineflags_exitfunc)(int);  // in gflags.cc
-
-#define EXPECT_DEATH(fn, msg)                                           \
-  do {                                                                  \
-    g_called_exit = false;                                              \
-    commandlineflags_exitfunc = &CalledExit;                            \
-    fn;                                                                 \
-    commandlineflags_exitfunc = &exit;    /* set back to its default */ \
-    if (!g_called_exit) {                                               \
-      fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn);      \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-
-vector<void (*)()> g_testlist;  // the tests to run
-
-#define TEST(a, b)                                      \
-  struct Test_##a##_##b {                               \
-    Test_##a##_##b() { g_testlist.push_back(&Run); }    \
-    static void Run() {                                 \
-      FlagSaver fs;                                     \
-      fprintf(stderr, "Running test %s/%s\n", #a, #b);  \
-      RunTest();                                        \
-    }                                                   \
-    static void RunTest();                              \
-  };                                                    \
-  static Test_##a##_##b g_test_##a##_##b;               \
-  void Test_##a##_##b::RunTest()
-
-
-static int RUN_ALL_TESTS() {
-  vector<void (*)()>::const_iterator it;
-  for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
-    (*it)();
-  }
-  fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
-  return 0;
-}
-
-
-static string TmpFile(const string& basename) {
-#ifdef _MSC_VER
-  return FLAGS_test_tmpdir + "\\" + basename;
-#else
-  return FLAGS_test_tmpdir + "/" + basename;
-#endif
-}
-
-// Returns the definition of the --flagfile flag to be used in the tests.
-static const char* GetFlagFileFlag() {
-#ifdef _MSC_VER
-  static const string flagfile = FLAGS_srcdir + "\\src\\gflags_unittest_flagfile";
-#else
-  static const string flagfile = FLAGS_srcdir + "/src/gflags_unittest_flagfile";
-#endif
-  static const string flagfile_flag = string("--flagfile=") + flagfile;
-  return flagfile_flag.c_str();
-}
-
-
-// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
-// compiler error iff T1 and T2 are different types.
-template <typename T1, typename T2>
-struct CompileAssertTypesEqual;
-
-template <typename T>
-struct CompileAssertTypesEqual<T, T> {
-};
-
-
-template <typename Expected, typename Actual>
-void AssertIsType(Actual& x) {
-  CompileAssertTypesEqual<Expected, Actual>();
-}
-
-// Verify all the flags are the right type.
-TEST(FlagTypes, FlagTypes) {
-  AssertIsType<bool>(FLAGS_test_bool);
-  AssertIsType<int32>(FLAGS_test_int32);
-  AssertIsType<int64>(FLAGS_test_int64);
-  AssertIsType<uint64>(FLAGS_test_uint64);
-  AssertIsType<double>(FLAGS_test_double);
-  AssertIsType<string>(FLAGS_test_string);
-}
-
-// Death tests for "help" options.
-//
-// The help system automatically calls exit(1) when you specify any of
-// the help-related flags ("-helpmatch", "-helpxml") so we can't test
-// those mainline.
-
-// Tests that "-helpmatch" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpMatch) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpmatch=base", GetArgv0(), true),
-               "");
-}
-
-
-// Tests that "-helpxml" causes the process to die.
-TEST(ReadFlagsFromStringDeathTest, HelpXml) {
-  EXPECT_DEATH(ReadFlagsFromString("-helpxml", GetArgv0(), true),
-               "");
-}
-
-
-// A subroutine needed for testing reading flags from a string.
-void TestFlagString(const string& flags,
-                    const string& expected_string,
-                    bool expected_bool,
-                    int32 expected_int32,
-                    double expected_double) {
-  EXPECT_TRUE(ReadFlagsFromString(flags,
-                                  GetArgv0(),
-                                  // errors are fatal
-                                  true));
-
-  EXPECT_EQ(expected_string, FLAGS_test_string);
-  EXPECT_EQ(expected_bool, FLAGS_test_bool);
-  EXPECT_EQ(expected_int32, FLAGS_test_int32);
-  EXPECT_DOUBLE_EQ(expected_double, FLAGS_test_double);
-}
-
-
-// Tests reading flags from a string.
-TEST(FlagFileTest, ReadFlagsFromString) {
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "-test_double=0.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      0.0);
-
-  TestFlagString(
-      // Flag string
-      "# let's make sure it can update values\n"
-      "-test_string=initial\n"
-      "-test_bool=false\n"
-      "-test_int32=123\n"
-      "-test_double=123.0\n",
-      // Expected values
-      "initial",
-      false,
-      123,
-      123.0);
-}
-
-// Tests the filename part of the flagfile
-TEST(FlagFileTest, FilenamesOurfileLast) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "not_our_filename\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "gflags_unittest\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      false,
-      -1,
-      1000.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileFirst) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "gflags_unittest\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "not_our_filename\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-#ifdef HAVE_FNMATCH_H   // otherwise glob isn't supported
-TEST(FlagFileTest, FilenamesOurfileGlob) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*flags*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-
-TEST(FlagFileTest, FilenamesOurfileInBigList) {
-  FLAGS_test_string = "initial";
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_double = -1.0;
-  TestFlagString(
-      // Flag string
-      "-test_string=continued\n"
-      "# some comments are in order\n"
-      "# some\n"
-      "  # comments\n"
-      "#are\n"
-      "                  #trickier\n"
-      "# than others\n"
-      "*first* *flags* *third*\n"
-      "-test_bool=true\n"
-      "     -test_int32=1\n"
-      "flags\n"
-      "-test_double=1000.0\n",
-      // Expected values
-      "continued",
-      true,
-      1,
-      -1.0);
-}
-#endif
-
-// Tests that a failed flag-from-string read keeps flags at default values
-TEST(FlagFileTest, FailReadFlagsFromString) {
-  FLAGS_test_int32 = 119;
-  string flags("# let's make sure it can update values\n"
-               "-test_string=non_initial\n"
-               "-test_bool=false\n"
-               "-test_int32=123\n"
-               "-test_double=illegal\n");
-
-  EXPECT_FALSE(ReadFlagsFromString(flags,
-                                   GetArgv0(),
-                                   // errors are fatal
-                                   false));
-
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ("initial", FLAGS_test_string);
-}
-
-// Tests that flags can be set to ordinary values.
-TEST(SetFlagValueTest, OrdinaryValues) {
-  EXPECT_EQ("initial", FLAGS_test_str1);
-
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // set; was default
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);  // already set once
-
-  FLAGS_test_str1 = "initial";
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("initial", FLAGS_test_str1);  // still already set before
-
-  SetCommandLineOptionWithMode("test_str1", "third", SET_FLAGS_VALUE);
-  EXPECT_EQ("third", FLAGS_test_str1);  // changed value
-
-  SetCommandLineOptionWithMode("test_str1", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str1);
-  // value not changed (already set before)
-
-  EXPECT_EQ("initial", FLAGS_test_str2);
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);  // changed (was default)
-
-  FLAGS_test_str2 = "extra";
-  EXPECT_EQ("extra", FLAGS_test_str2);
-
-  FLAGS_test_str2 = "second";
-  SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str2);  // still changed (was equal to default)
-
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str2);  // changed (was default)
-
-  EXPECT_EQ("initial", FLAGS_test_str3);
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str3);  // changed
-
-  FLAGS_test_str3 = "third";
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("third", FLAGS_test_str3);  // not changed (was set)
-
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAGS_VALUE);
-  EXPECT_EQ("fourth", FLAGS_test_str3);  // changed value
-}
-
-
-// Tests that flags can be set to exceptional values.
-// Note: apparently MINGW doesn't parse inf and nan correctly:
-//    http://www.mail-archive.com/bug-gnulib@gnu.org/msg09573.html
-// This url says FreeBSD also has a problem, but I didn't see that.
-TEST(SetFlagValueTest, ExceptionalValues) {
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "inf"));
-  EXPECT_INF(FLAGS_test_double);
-
-  EXPECT_EQ("test_double set to inf\n",
-            SetCommandLineOption("test_double", "INF"));
-  EXPECT_INF(FLAGS_test_double);
-#endif
-
-  // set some bad values
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", "0.1xxx"));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", " "));
-  EXPECT_EQ("",
-            SetCommandLineOption("test_double", ""));
-#if defined(isinf) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to -inf\n",
-            SetCommandLineOption("test_double", "-inf"));
-  EXPECT_INF(FLAGS_test_double);
-  EXPECT_GT(0, FLAGS_test_double);
-#endif
-
-#if defined(isnan) && !defined(__MINGW32__)
-  EXPECT_EQ("test_double set to nan\n",
-            SetCommandLineOption("test_double", "NaN"));
-  EXPECT_NAN(FLAGS_test_double);
-#endif
-}
-
-// Tests that integer flags can be specified in many ways
-TEST(SetFlagValueTest, DifferentRadices) {
-  EXPECT_EQ("test_int32 set to 12\n",
-            SetCommandLineOption("test_int32", "12"));
-
-  EXPECT_EQ("test_int32 set to 16\n",
-            SetCommandLineOption("test_int32", "0x10"));
-
-  EXPECT_EQ("test_int32 set to 34\n",
-            SetCommandLineOption("test_int32", "0X22"));
-
-  // Leading 0 is *not* octal; it's still decimal
-  EXPECT_EQ("test_int32 set to 10\n",
-            SetCommandLineOption("test_int32", "010"));
-}
-
-// Tests what happens when you try to set a flag to an illegal value
-TEST(SetFlagValueTest, IllegalValues) {
-  FLAGS_test_bool = true;
-  FLAGS_test_int32 = 119;
-  FLAGS_test_int64 = 1191;
-  FLAGS_test_uint64 = 11911;
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_bool", "12"));
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int32", "7000000000000"));
-
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_EQ("",
-            SetCommandLineOption("test_uint64", "-1"));
-#endif
-
-  EXPECT_EQ("",
-            SetCommandLineOption("test_int64", "not a number!"));
-
-  // Test the empty string with each type of input
-  EXPECT_EQ("", SetCommandLineOption("test_bool", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int32", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_int64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_uint64", ""));
-  EXPECT_EQ("", SetCommandLineOption("test_double", ""));
-  EXPECT_EQ("test_string set to \n", SetCommandLineOption("test_string", ""));
-
-  EXPECT_TRUE(FLAGS_test_bool);
-  EXPECT_EQ(119, FLAGS_test_int32);
-  EXPECT_EQ(1191, FLAGS_test_int64);
-  EXPECT_EQ(11911, FLAGS_test_uint64);
-}
-
-
-// Tests that we only evaluate macro args once
-TEST(MacroArgs, EvaluateOnce) {
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure we don't ++ the value somehow, when evaluating the flag.
-  EXPECT_EQ(13, FLAGS_changeable_var);
-  // Make sure the macro only evaluated this var once.
-  EXPECT_EQ(13, changeable_var);
-  // Make sure the actual value and default value are the same
-  SetCommandLineOptionWithMode("changeable_var", "21", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ(21, FLAGS_changeable_var);
-}
-
-TEST(MacroArgs, EvaluateOnceBool) {
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_TRUE(FLAGS_changeable_bool_var);
-  EXPECT_EQ(8009, changeable_bool_var);
-  SetCommandLineOptionWithMode("changeable_bool_var", "false",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_FALSE(FLAGS_changeable_bool_var);
-}
-
-TEST(MacroArgs, EvaluateOnceStrings) {
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ("1", FLAGS_changeable_string_var);
-  EXPECT_EQ(1, changeable_string_var);
-  SetCommandLineOptionWithMode("changeable_string_var", "different",
-                               SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("different", FLAGS_changeable_string_var);
-}
-
-// Tests that the FooFromEnv does the right thing
-TEST(FromEnvTest, LegalValues) {
-  setenv("BOOL_VAL1", "true", 1);
-  setenv("BOOL_VAL2", "false", 1);
-  setenv("BOOL_VAL3", "1", 1);
-  setenv("BOOL_VAL4", "F", 1);
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL1", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL2", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL3", false));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL4", true));
-  EXPECT_TRUE(BoolFromEnv("BOOL_VAL_UNKNOWN", true));
-  EXPECT_FALSE(BoolFromEnv("BOOL_VAL_UNKNOWN", false));
-
-  setenv("INT_VAL1", "1", 1);
-  setenv("INT_VAL2", "-1", 1);
-  EXPECT_EQ(1, Int32FromEnv("INT_VAL1", 10));
-  EXPECT_EQ(-1, Int32FromEnv("INT_VAL2", 10));
-  EXPECT_EQ(10, Int32FromEnv("INT_VAL_UNKNOWN", 10));
-
-  setenv("INT_VAL3", "1099511627776", 1);
-  EXPECT_EQ(1, Int64FromEnv("INT_VAL1", 20));
-  EXPECT_EQ(-1, Int64FromEnv("INT_VAL2", 20));
-  EXPECT_EQ(1099511627776LL, Int64FromEnv("INT_VAL3", 20));
-  EXPECT_EQ(20, Int64FromEnv("INT_VAL_UNKNOWN", 20));
-
-  EXPECT_EQ(1, Uint64FromEnv("INT_VAL1", 30));
-  EXPECT_EQ(1099511627776ULL, Uint64FromEnv("INT_VAL3", 30));
-  EXPECT_EQ(30, Uint64FromEnv("INT_VAL_UNKNOWN", 30));
-
-  // I pick values here that can be easily represented exactly in floating-point
-  setenv("DOUBLE_VAL1", "0.0", 1);
-  setenv("DOUBLE_VAL2", "1.0", 1);
-  setenv("DOUBLE_VAL3", "-1.0", 1);
-  EXPECT_EQ(0.0, DoubleFromEnv("DOUBLE_VAL1", 40.0));
-  EXPECT_EQ(1.0, DoubleFromEnv("DOUBLE_VAL2", 40.0));
-  EXPECT_EQ(-1.0, DoubleFromEnv("DOUBLE_VAL3", 40.0));
-  EXPECT_EQ(40.0, DoubleFromEnv("DOUBLE_VAL_UNKNOWN", 40.0));
-
-  setenv("STRING_VAL1", "", 1);
-  setenv("STRING_VAL2", "my happy string!", 1);
-  EXPECT_STREQ("", StringFromEnv("STRING_VAL1", "unknown"));
-  EXPECT_STREQ("my happy string!", StringFromEnv("STRING_VAL2", "unknown"));
-  EXPECT_STREQ("unknown", StringFromEnv("STRING_VAL_UNKNOWN", "unknown"));
-}
-
-// Tests that the FooFromEnv dies on parse-error
-TEST(FromEnvDeathTest, IllegalValues) {
-  setenv("BOOL_BAD1", "so true!", 1);
-  setenv("BOOL_BAD2", "", 1);
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD1", false), "error parsing env variable");
-  EXPECT_DEATH(BoolFromEnv("BOOL_BAD2", true), "error parsing env variable");
-
-  setenv("INT_BAD1", "one", 1);
-  setenv("INT_BAD2", "100000000000000000", 1);
-  setenv("INT_BAD3", "0xx10", 1);
-  setenv("INT_BAD4", "", 1);
-  EXPECT_DEATH(Int32FromEnv("INT_BAD1", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD2", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD3", 10), "error parsing env variable");
-  EXPECT_DEATH(Int32FromEnv("INT_BAD4", 10), "error parsing env variable");
-
-  setenv("BIGINT_BAD1", "18446744073709551616000", 1);
-  EXPECT_DEATH(Int64FromEnv("INT_BAD1", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD3", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("INT_BAD4", 20), "error parsing env variable");
-  EXPECT_DEATH(Int64FromEnv("BIGINT_BAD1", 200), "error parsing env variable");
-
-  setenv("BIGINT_BAD2", "-1", 1);
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD1", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD3", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("INT_BAD4", 30), "error parsing env variable");
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD1", 30), "error parsing env variable");
-  // TODO(csilvers): uncomment this when we disallow negative numbers for uint64
-#if 0
-  EXPECT_DEATH(Uint64FromEnv("BIGINT_BAD2", 30), "error parsing env variable");
-#endif
-
-  setenv("DOUBLE_BAD1", "0.0.0", 1);
-  setenv("DOUBLE_BAD2", "", 1);
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD1", 40.0), "error parsing env variable");
-  EXPECT_DEATH(DoubleFromEnv("DOUBLE_BAD2", 40.0), "error parsing env variable");
-}
-
-// Tests that FlagSaver can save the states of string flags.
-TEST(FlagSaverTest, CanSaveStringFlagStates) {
-  // 1. Initializes the flags.
-
-  // State of flag test_str1:
-  //   default value - "initial"
-  //   current value - "initial"
-  //   not set       - true
-
-  SetCommandLineOptionWithMode("test_str2", "second", SET_FLAGS_VALUE);
-  // State of flag test_str2:
-  //   default value - "initial"
-  //   current value - "second"
-  //   not set       - false
-
-  SetCommandLineOptionWithMode("test_str3", "second", SET_FLAGS_DEFAULT);
-  // State of flag test_str3:
-  //   default value - "second"
-  //   current value - "second"
-  //   not set       - true
-
-  // 2. Saves the flag states.
-
-  {
-    FlagSaver fs;
-
-    // 3. Modifies the flag states.
-
-    SetCommandLineOptionWithMode("test_str1", "second", SET_FLAGS_VALUE);
-    EXPECT_EQ("second", FLAGS_test_str1);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "second"
-    //   not set       - true
-
-    SetCommandLineOptionWithMode("test_str2", "third", SET_FLAGS_DEFAULT);
-    EXPECT_EQ("second", FLAGS_test_str2);
-    // State of flag test_str2:
-    //   default value - "third"
-    //   current value - "second"
-    //   not set       - false
-
-    SetCommandLineOptionWithMode("test_str3", "third", SET_FLAGS_VALUE);
-    EXPECT_EQ("third", FLAGS_test_str3);
-    // State of flag test_str1:
-    //   default value - "second"
-    //   current value - "third"
-    //   not set       - false
-
-    // 4. Restores the flag states.
-  }
-
-  // 5. Verifies that the states were restored.
-
-  // Verifies that the value of test_str1 was restored.
-  EXPECT_EQ("initial", FLAGS_test_str1);
-  // Verifies that the "not set" attribute of test_str1 was restored to true.
-  SetCommandLineOptionWithMode("test_str1", "second", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str1);
-
-  // Verifies that the value of test_str2 was restored.
-  EXPECT_EQ("second", FLAGS_test_str2);
-  // Verifies that the "not set" attribute of test_str2 was restored to false.
-  SetCommandLineOptionWithMode("test_str2", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("second", FLAGS_test_str2);
-
-  // Verifies that the value of test_str3 was restored.
-  EXPECT_EQ("second", FLAGS_test_str3);
-  // Verifies that the "not set" attribute of test_str3 was restored to true.
-  SetCommandLineOptionWithMode("test_str3", "fourth", SET_FLAG_IF_DEFAULT);
-  EXPECT_EQ("fourth", FLAGS_test_str3);
-}
-
-
-// Tests that FlagSaver can save the values of various-typed flags.
-TEST(FlagSaverTest, CanSaveVariousTypedFlagValues) {
-  // Initializes the flags.
-  FLAGS_test_bool = false;
-  FLAGS_test_int32 = -1;
-  FLAGS_test_int64 = -2;
-  FLAGS_test_uint64 = 3;
-  FLAGS_test_double = 4.0;
-  FLAGS_test_string = "good";
-
-  // Saves the flag states.
-  {
-    FlagSaver fs;
-
-    // Modifies the flags.
-    FLAGS_test_bool = true;
-    FLAGS_test_int32 = -5;
-    FLAGS_test_int64 = -6;
-    FLAGS_test_uint64 = 7;
-    FLAGS_test_double = 8.0;
-    FLAGS_test_string = "bad";
-
-    // Restores the flag states.
-  }
-
-  // Verifies the flag values were restored.
-  EXPECT_FALSE(FLAGS_test_bool);
-  EXPECT_EQ(-1, FLAGS_test_int32);
-  EXPECT_EQ(-2, FLAGS_test_int64);
-  EXPECT_EQ(3, FLAGS_test_uint64);
-  EXPECT_DOUBLE_EQ(4.0, FLAGS_test_double);
-  EXPECT_EQ("good", FLAGS_test_string);
-}
-
-TEST(GetAllFlagsTest, BaseTest) {
-  vector<CommandLineFlagInfo> flags;
-  GetAllFlags(&flags);
-  bool found_test_bool = false;
-  vector<CommandLineFlagInfo>::const_iterator i;
-  for (i = flags.begin(); i != flags.end(); ++i) {
-    if (i->name == "test_bool") {
-      found_test_bool = true;
-      EXPECT_EQ(i->type, "bool");
-      EXPECT_EQ(i->default_value, "false");
-      break;
-    }
-  }
-  EXPECT_TRUE(found_test_bool);
-}
-
-TEST(ShowUsageWithFlagsTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --help.
-}
-
-TEST(ShowUsageWithFlagsRestrictTest, BaseTest) {
-  // TODO(csilvers): test this by allowing output other than to stdout.
-  // Not urgent since this functionality is tested via
-  // gflags_unittest.sh, though only through use of --helpmatch.
-}
-
-// Note: all these argv-based tests depend on SetArgv being called
-// before ParseCommandLineFlags() in Main(), below.
-TEST(GetArgvsTest, BaseTest) {
-  vector<string> argvs = GetArgvs();
-  EXPECT_EQ(4, argvs.size());
-  EXPECT_EQ("/test/argv/for/gflags_unittest", argvs[0]);
-  EXPECT_EQ("argv 2", argvs[1]);
-  EXPECT_EQ("3rd argv", argvs[2]);
-  EXPECT_EQ("argv #4", argvs[3]);
-}
-
-TEST(GetArgvTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest "
-               "argv 2 3rd argv argv #4", GetArgv());
-}
-
-TEST(GetArgv0Test, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest", GetArgv0());
-}
-
-TEST(GetArgvSumTest, BaseTest) {
-  // This number is just the sum of the ASCII values of all the chars
-  // in GetArgv().
-  EXPECT_EQ(4904, GetArgvSum());
-}
-
-TEST(ProgramInvocationNameTest, BaseTest) {
-  EXPECT_STREQ("/test/argv/for/gflags_unittest",
-               ProgramInvocationName());
-}
-
-TEST(ProgramInvocationShortNameTest, BaseTest) {
-  EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName());
-}
-
-TEST(ProgramUsageTest, BaseTest) {  // Depends on arg to SetUsageMessage()
-  EXPECT_STREQ("/test/argv/for/gflags_unittest: "
-               "<useless flag> [...]\nDoes something useless.\n",
-               ProgramUsage());
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndIsDefault) {
-  string value("will be changed");
-  bool r = GetCommandLineOption("test_bool", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("false", value);
-
-  r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("-1", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("400", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasSet) {
-  SetCommandLineOption("test_int32", "700");
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("700", value);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasNotSet) {
-  // This doesn't set the flag's value, but rather its default value.
-  // is_default is still true, but the 'default' value returned has changed!
-  SetCommandLineOptionWithMode("test_int32", "800", SET_FLAGS_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("800", value);
-  EXPECT_TRUE(GetCommandLineFlagInfoOrDie("test_int32").is_default);
-}
-
-TEST(GetCommandLineOptionTest, NameExistsAndWasConditionallySet) {
-  SetCommandLineOptionWithMode("test_int32", "900", SET_FLAG_IF_DEFAULT);
-  string value("will be changed");
-  const bool r = GetCommandLineOption("test_int32", &value);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("900", value);
-}
-
-TEST(GetCommandLineOptionTest, NameDoesNotExist) {
-  string value("will not be changed");
-  const bool r = GetCommandLineOption("test_int3210", &value);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("will not be changed", value);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagExists) {
-  CommandLineFlagInfo info;
-  bool r = GetCommandLineFlagInfo("test_int32", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = true;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-
-  FLAGS_test_bool = false;
-  r = GetCommandLineFlagInfo("test_bool", &info);
-  EXPECT_TRUE(r);
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);  // value is same, but flag *was* modified
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoTest, FlagDoesNotExist) {
-  CommandLineFlagInfo info;
-  // Set to some random values that GetCommandLineFlagInfo should not change
-  info.name = "name";
-  info.type = "type";
-  info.current_value = "curr";
-  info.default_value = "def";
-  info.filename = "/";
-  info.is_default = false;
-  info.has_validator_fn = true;
-  bool r = GetCommandLineFlagInfo("test_int3210", &info);
-  EXPECT_FALSE(r);
-  EXPECT_EQ("name", info.name);
-  EXPECT_EQ("type", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("curr", info.current_value);
-  EXPECT_EQ("def", info.default_value);
-  EXPECT_EQ("/", info.filename);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_TRUE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndIsDefault) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("-1", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("false", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_TRUE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieTest, FlagExistsAndWasAssigned) {
-  FLAGS_test_int32 = 400;
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_int32");
-  EXPECT_EQ("test_int32", info.name);
-  EXPECT_EQ("int32", info.type);
-  EXPECT_EQ("", info.description);
-  EXPECT_EQ("400", info.current_value);
-  EXPECT_EQ("-1", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  FLAGS_test_bool = true;
-  info = GetCommandLineFlagInfoOrDie("test_bool");
-  EXPECT_EQ("test_bool", info.name);
-  EXPECT_EQ("bool", info.type);
-  EXPECT_EQ("tests bool-ness", info.description);
-  EXPECT_EQ("true", info.current_value);
-  EXPECT_EQ("false", info.default_value);
-  EXPECT_FALSE(info.is_default);
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(GetCommandLineFlagInfoOrDieDeathTest, FlagDoesNotExist) {
-  EXPECT_DEATH(GetCommandLineFlagInfoOrDie("test_int3210"),
-               ".*: flag test_int3210 does not exist");
-}
-
-
-// These are lightly tested because they're deprecated.  Basically,
-// the tests are meant to cover how existing users use these functions,
-// but not necessarily how new users could use them.
-TEST(DeprecatedFunctionsTest, CommandlineFlagsIntoString) {
-  string s = CommandlineFlagsIntoString();
-  EXPECT_NE(string::npos, s.find("--test_bool="));
-}
-
-TEST(DeprecatedFunctionsTest, AppendFlagsIntoFile) {
-  FLAGS_test_int32 = 10;     // just to make the test more interesting
-  string filename(TmpFile("flagfile"));
-  unlink(filename.c_str());  // just to be safe
-  const bool r = AppendFlagsIntoFile(filename, "not the real argv0");
-  EXPECT_TRUE(r);
-
-  FILE* fp = fopen(filename.c_str(), "r");
-  EXPECT_TRUE(fp != NULL);
-  char line[8192];
-  EXPECT_TRUE(fgets(line, sizeof(line)-1, fp) != NULL);  // get the first line
-  // First line should be progname.
-  EXPECT_STREQ("not the real argv0\n", line);
-
-  bool found_bool = false, found_int32 = false;
-  while (fgets(line, sizeof(line)-1, fp)) {
-    line[sizeof(line)-1] = '\0';    // just to be safe
-    if (strcmp(line, "--test_bool=false\n") == 0)
-      found_bool = true;
-    if (strcmp(line, "--test_int32=10\n") == 0)
-      found_int32 = true;
-  }
-  EXPECT_TRUE(found_int32);
-  EXPECT_TRUE(found_bool);
-  fclose(fp);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFile) {
-  FLAGS_test_int32 = -10;    // just to make the test more interesting
-  string filename(TmpFile("flagfile2"));
-  unlink(filename.c_str());  // just to be safe
-  bool r = AppendFlagsIntoFile(filename, GetArgv0());
-  EXPECT_TRUE(r);
-
-  FLAGS_test_int32 = -11;
-  r = ReadFromFlagsFile(filename, GetArgv0(), true);
-  EXPECT_TRUE(r);
-  EXPECT_EQ(-10, FLAGS_test_int32);
-}
-
-TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) {
-  FLAGS_test_int32 = -20;
-  string filename(TmpFile("flagfile3"));
-  FILE* fp = fopen(filename.c_str(), "w");
-  EXPECT_TRUE(fp != NULL);
-  // Note the error in the bool assignment below...
-  fprintf(fp, "%s\n--test_int32=-21\n--test_bool=not_a_bool!\n", GetArgv0());
-  fclose(fp);
-
-  FLAGS_test_int32 = -22;
-  const bool r = ReadFromFlagsFile(filename, GetArgv0(), false);
-  EXPECT_FALSE(r);
-  EXPECT_EQ(-22, FLAGS_test_int32);   // the -21 from the flagsfile didn't take
-}
-
-TEST(FlagsSetBeforeInitTest, TryFromEnv) {
-  EXPECT_EQ("pre-set", FLAGS_test_tryfromenv);
-}
-
-// The following test case verifies that ParseCommandLineFlags() and
-// ParseCommandLineNonHelpFlags() uses the last definition of a flag
-// in case it's defined more than once.
-
-DEFINE_int32(test_flag, -1, "used for testing commandlineflags.cc");
-
-// Parses and returns the --test_flag flag.
-// If with_help is true, calls ParseCommandLineFlags; otherwise calls
-// ParseCommandLineNonHelpFlags.
-int32 ParseTestFlag(bool with_help, int argc, const char** const_argv) {
-  FlagSaver fs;  // Restores the flags before returning.
-
-  // Makes a copy of the input array s.t. it can be reused
-  // (ParseCommandLineFlags() will alter the array).
-  char** const argv_save = new char*[argc + 1];
-  char** argv = argv_save;
-  memcpy(argv, const_argv, sizeof(*argv)*(argc + 1));
-
-  if (with_help) {
-    ParseCommandLineFlags(&argc, &argv, true);
-  } else {
-    ParseCommandLineNonHelpFlags(&argc, &argv, true);
-  }
-
-  delete[] argv_save;
-  return FLAGS_test_flag;
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceOnCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=1",
-    "--test_flag=2",
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedTwiceInFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndThenFlagFile) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    NULL,
-  };
-
-  EXPECT_EQ(2, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(2, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUsesLastDefinitionTest,
-     WhenFlagIsDefinedInCommandLineAndFlagFileAndThenCommandLine) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=0",
-    GetFlagFileFlag(),
-    "--test_flag=3",
-    NULL,
-  };
-
-  EXPECT_EQ(3, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(3, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgFirst) {
-  const char* argv[] = {
-    "my_test",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(-1, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(-1, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, TwoDashArgMiddle) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=7",
-    "--",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(7, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(7, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsAndDashArgs, OneDashArg) {
-  const char* argv[] = {
-    "my_test",
-    "-",
-    "--test_flag=0",
-    NULL,
-  };
-
-  EXPECT_EQ(0, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  EXPECT_EQ(0, ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv));
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--this_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     BoolFlagIsCompletelyUnknown) {
-  const char* argv[] = {
-    "my_test",
-    "--nothis_flag_does_not_exist",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "unknown command line flag.*");
-}
-
-TEST(ParseCommandLineFlagsUnknownFlagDeathTest,
-     FlagIsNotABool) {
-  const char* argv[] = {
-    "my_test",
-    "--notest_string",
-    NULL,
-  };
-
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-  EXPECT_DEATH(ParseTestFlag(false, GET_ARRAY_SIZE(argv) - 1, argv),
-               "boolean value .* specified for .* command line flag");
-}
-
-TEST(ParseCommandLineFlagsWrongFields,
-     DescriptionIsInvalid) {
-  // These must not be automatic variables, since command line flags
-  // aren't unregistered and gUnit uses FlagSaver to save and restore
-  // command line flags' values.  If these are on the stack, then when
-  // later tests attempt to save and restore their values, the stack
-  // addresses of these variables will be overwritten...  Stack smash!
-  static bool current_storage;
-  static bool defvalue_storage;
-  FlagRegisterer fr("flag_name", "bool", 0, "filename",
-                    &current_storage, &defvalue_storage);
-  CommandLineFlagInfo fi;
-  EXPECT_TRUE(GetCommandLineFlagInfo("flag_name", &fi));
-  EXPECT_EQ("", fi.description);
-}
-
-static bool ValidateTestFlagIs5(const char* flagname, int32 flagval) {
-  if (flagval == 5)
-    return true;
-  printf("%s isn't 5!\n", flagname);
-  return false;
-}
-
-static bool ValidateTestFlagIs10(const char* flagname, int32 flagval) {
-  return flagval == 10;
-}
-
-
-TEST(FlagsValidator, ValidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=5",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_EQ(5, ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv));
-  // Undo the flag validator setting
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, ValidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_VALUE));
-  EXPECT_NE("", SetCommandLineOptionWithMode("test_flag", "5",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_NE("", SetCommandLineOption("test_flag", "5"));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagViaArgv) {
-  const char* argv[] = {
-    "my_test",
-    "--test_flag=50",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: failed validation of new value '50' for flag 'test_flag'");
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetDefault) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAG_IF_DEFAULT));
-  EXPECT_EQ(-1, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, InvalidFlagViaSetValue) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  FLAGS_test_flag = 100;   // doesn't trigger the validator
-  // SetCommandLineOptionWithMode returns the empty string on error.
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_VALUE));
-  EXPECT_EQ("", SetCommandLineOptionWithMode("test_flag", "50",
-                                             SET_FLAGS_DEFAULT));
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));
-  EXPECT_EQ(100, FLAGS_test_flag);   // the setting-to-50 should have failed
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidatorDeathTest, InvalidFlagNeverSet) {
-  // If a flag keeps its default value, and that default value is
-  // invalid, we should die at argv-parse time.
-  const char* argv[] = {
-    "my_test",
-    NULL,
-  };
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_DEATH(ParseTestFlag(true, GET_ARRAY_SIZE(argv) - 1, argv),
-               "ERROR: --test_flag must be set on the commandline");
-}
-
-TEST(FlagsValidator, InvalidFlagPtr) {
-  int32 dummy;
-  EXPECT_FALSE(RegisterFlagValidator(NULL, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&dummy, &ValidateTestFlagIs5));
-}
-
-TEST(FlagsValidator, RegisterValidatorTwice) {
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_FALSE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs10));
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-}
-
-TEST(FlagsValidator, CommandLineFlagInfo) {
-  CommandLineFlagInfo info;
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_TRUE(info.has_validator_fn);
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-  info = GetCommandLineFlagInfoOrDie("test_flag");
-  EXPECT_FALSE(info.has_validator_fn);
-}
-
-TEST(FlagsValidator, FlagSaver) {
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-    EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // fails validation
-  }
-  EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // validator is gone
-
-  EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, &ValidateTestFlagIs5));
-  {
-    FlagSaver fs;
-    EXPECT_TRUE(RegisterFlagValidator(&FLAGS_test_flag, NULL));
-    EXPECT_NE("", SetCommandLineOption("test_flag", "50"));  // no validator
-  }
-  EXPECT_EQ("", SetCommandLineOption("test_flag", "50"));  // validator is back
-}
-
-
-static int Main(int argc, char **argv) {
-  // We need to call SetArgv before SetUsage, so our "test" argv will
-  // win out over this executable's real argv.  That makes running this
-  // test with a real --help flag kinda annoying, unfortunately.
-  const char* test_argv[] = { "/test/argv/for/gflags_unittest",
-                              "argv 2", "3rd argv", "argv #4" };
-  SetArgv(GET_ARRAY_SIZE(test_argv), test_argv);
-
-  // The first arg is the usage message, also important for testing.
-  string usage_message = (string(GetArgv0()) +
-                          ": <useless flag> [...]\nDoes something useless.\n");
-
-  // We test setting tryfromenv manually, and making sure
-  // ParseCommandLineFlags still evaluates it.
-  FLAGS_tryfromenv = "test_tryfromenv";
-  setenv("FLAGS_test_tryfromenv", "pre-set", 1);
-
-  // Modify flag values from declared default value in two ways.
-  // The recommended way:
-  SetCommandLineOptionWithMode("changed_bool1", "true", SET_FLAGS_DEFAULT);
-  // The non-recommended way:
-  FLAGS_changed_bool2 = true;
-
-  SetUsageMessage(usage_message.c_str());
-  ParseCommandLineFlags(&argc, &argv, true);
-
-#if defined(__MINGW32__)
-  // I had trouble creating a directory in /tmp from mingw
-  FLAGS_test_tmpdir = "./gflags_unittest_testdir";
-  mkdir(FLAGS_test_tmpdir.c_str());   // mingw has a weird one-arg mkdir
-#elif defined(_MSC_VER)
-  char tmppath_buffer[1024];
-  int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
-  assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer));
-  assert(tmppath_buffer[tmppath_len - 1] == '\\');   // API guarantees it
-  FLAGS_test_tmpdir = string(tmppath_buffer) + "gflags_unittest_testdir";
-  _mkdir(FLAGS_test_tmpdir.c_str());
-#else
-  mkdir(FLAGS_test_tmpdir.c_str(), 0755);
-#endif
-
-  return RUN_ALL_TESTS();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-int main(int argc, char** argv) {
-  const int exit_status = GOOGLE_NAMESPACE::Main(argc, argv);
-  GOOGLE_NAMESPACE::ShutDownCommandLineFlags();
-  return exit_status;
-}

+ 0 - 34
Src/ThirdParty/gflags/src/google/gflags.h

@@ -1,34 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Header files have moved from the google directory to the gflags
-// directory.  This forwarding file is provided only for backwards
-// compatibility.  Use gflags/gflags.h in all new code.
-
-#include <gflags/gflags.h>

+ 0 - 34
Src/ThirdParty/gflags/src/google/gflags_completions.h

@@ -1,34 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Header files have moved from the google directory to the gflags
-// directory.  This forwarding file is provided only for backwards
-// compatibility.  Use gflags/gflags_completions.h in all new code.
-
-#include <gflags/gflags_completions.h>

+ 0 - 349
Src/ThirdParty/gflags/src/mutex.h

@@ -1,349 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-// ---
-// Author: Craig Silverstein.
-//
-// A simple mutex wrapper, supporting locks and read-write locks.
-// You should assume the locks are *not* re-entrant.
-//
-// To use: you should define the following macros in your configure.ac:
-//   ACX_PTHREAD
-//   AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
-// This class is meant to be internal-only and should be wrapped by an
-// internal namespace.  Before you use this module, please give the
-// name of your internal namespace for this module.  Or, if you want
-// to expose it, you'll want to move it to the Google namespace.  We
-// cannot put this class in global namespace because there can be some
-// problems when we have multiple versions of Mutex in each shared object.
-//
-// NOTE: by default, we have #ifdef'ed out the TryLock() method.
-//       This is for two reasons:
-// 1) TryLock() under Windows is a bit annoying (it requires a
-//    #define to be defined very early).
-// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
-//    mode.
-// If you need TryLock(), and either these two caveats are not a
-// problem for you, or you're willing to work around them, then
-// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
-// in the code below.
-//
-// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
-//    http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
-// Because of that, we might as well use windows locks for
-// cygwin.  They seem to be more reliable than the cygwin pthreads layer.
-//
-// TRICKY IMPLEMENTATION NOTE:
-// This class is designed to be safe to use during
-// dynamic-initialization -- that is, by global constructors that are
-// run before main() starts.  The issue in this case is that
-// dynamic-initialization happens in an unpredictable order, and it
-// could be that someone else's dynamic initializer could call a
-// function that tries to acquire this mutex -- but that all happens
-// before this mutex's constructor has run.  (This can happen even if
-// the mutex and the function that uses the mutex are in the same .cc
-// file.)  Basically, because Mutex does non-trivial work in its
-// constructor, it's not, in the naive implementation, safe to use
-// before dynamic initialization has run on it.
-//
-// The solution used here is to pair the actual mutex primitive with a
-// bool that is set to true when the mutex is dynamically initialized.
-// (Before that it's false.)  Then we modify all mutex routines to
-// look at the bool, and not try to lock/unlock until the bool makes
-// it to true (which happens after the Mutex constructor has run.)
-//
-// This works because before main() starts -- particularly, during
-// dynamic initialization -- there are no threads, so a) it's ok that
-// the mutex operations are a no-op, since we don't need locking then
-// anyway; and b) we can be quite confident our bool won't change
-// state between a call to Lock() and a call to Unlock() (that would
-// require a global constructor in one translation unit to call Lock()
-// and another global constructor in another translation unit to call
-// Unlock() later, which is pretty perverse).
-//
-// That said, it's tricky, and can conceivably fail; it's safest to
-// avoid trying to acquire a mutex in a global constructor, if you
-// can.  One way it can fail is that a really smart compiler might
-// initialize the bool to true at static-initialization time (too
-// early) rather than at dynamic-initialization time.  To discourage
-// that, we set is_safe_ to true in code (not the constructor
-// colon-initializer) and set it to true via a function that always
-// evaluates to true, but that the compiler can't know always
-// evaluates to true.  This should be good enough.
-//
-// A related issue is code that could try to access the mutex
-// after it's been destroyed in the global destructors (because
-// the Mutex global destructor runs before some other global
-// destructor, that tries to acquire the mutex).  The way we
-// deal with this is by taking a constructor arg that global
-// mutexes should pass in, that causes the destructor to do no
-// work.  We still depend on the compiler not doing anything
-// weird to a Mutex's memory after it is destroyed, but for a
-// static global variable, that's pretty safe.
-
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
-
-#include "config.h"           // to figure out pthreads support
-
-#if defined(NO_THREADS)
-  typedef int MutexType;      // to keep a lock-count
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# define WIN32_LEAN_AND_MEAN  // We only need minimal includes
-# ifdef GMUTEX_TRYLOCK
-  // We need Windows NT or later for TryEnterCriticalSection().  If you
-  // don't need that functionality, you can remove these _WIN32_WINNT
-  // lines, and change TryLock() to assert(0) or something.
-#   ifndef _WIN32_WINNT
-#     define _WIN32_WINNT 0x0400
-#   endif
-# endif
-# include <windows.h>
-  typedef CRITICAL_SECTION MutexType;
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-  // Needed for pthread_rwlock_*.  If it causes problems, you could take it
-  // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
-  // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
-  // for locking there.)
-# ifdef __linux__
-#   define _XOPEN_SOURCE 500  // may be needed to get the rwlock calls
-# endif
-# include <pthread.h>
-  typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
-# include <pthread.h>
-  typedef pthread_mutex_t MutexType;
-#else
-# error Need to implement mutex.h for your architecture, or #define NO_THREADS
-#endif
-
-#include <assert.h>
-#include <stdlib.h>      // for abort()
-
-#define MUTEX_NAMESPACE gflags_mutex_namespace
-
-namespace MUTEX_NAMESPACE {
-
-class Mutex {
- public:
-  // This is used for the single-arg constructor
-  enum LinkerInitialized { LINKER_INITIALIZED };
-
-  // Create a Mutex that is not held by anybody.  This constructor is
-  // typically used for Mutexes allocated on the heap or the stack.
-  inline Mutex();
-  // This constructor should be used for global, static Mutex objects.
-  // It inhibits work being done by the destructor, which makes it
-  // safer for code that tries to acqiure this mutex in their global
-  // destructor.
-  inline Mutex(LinkerInitialized);
-
-  // Destructor
-  inline ~Mutex();
-
-  inline void Lock();    // Block if needed until free then acquire exclusively
-  inline void Unlock();  // Release a lock acquired via Lock()
-#ifdef GMUTEX_TRYLOCK
-  inline bool TryLock(); // If free, Lock() and return true, else return false
-#endif
-  // Note that on systems that don't support read-write locks, these may
-  // be implemented as synonyms to Lock() and Unlock().  So you can use
-  // these for efficiency, but don't use them anyplace where being able
-  // to do shared reads is necessary to avoid deadlock.
-  inline void ReaderLock();   // Block until free or shared then acquire a share
-  inline void ReaderUnlock(); // Release a read share of this Mutex
-  inline void WriterLock() { Lock(); }     // Acquire an exclusive lock
-  inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
-
- private:
-  MutexType mutex_;
-  // We want to make sure that the compiler sets is_safe_ to true only
-  // when we tell it to, and never makes assumptions is_safe_ is
-  // always true.  volatile is the most reliable way to do that.
-  volatile bool is_safe_;
-  // This indicates which constructor was called.
-  bool destroy_;
-
-  inline void SetIsSafe() { is_safe_ = true; }
-
-  // Catch the error of writing Mutex when intending MutexLock.
-  Mutex(Mutex* /*ignored*/) {}
-  // Disallow "evil" constructors
-  Mutex(const Mutex&);
-  void operator=(const Mutex&);
-};
-
-// Now the implementation of Mutex for various systems
-#if defined(NO_THREADS)
-
-// When we don't have threads, we can be either reading or writing,
-// but not both.  We can have lots of readers at once (in no-threads
-// mode, that's most likely to happen in recursive function calls),
-// but only one writer.  We represent this by having mutex_ be -1 when
-// writing and a number > 0 when reading (and 0 when no lock is held).
-//
-// In debug mode, we assert these invariants, while in non-debug mode
-// we do nothing, for efficiency.  That's why everything is in an
-// assert.
-
-Mutex::Mutex() : mutex_(0) { }
-Mutex::Mutex(Mutex::LinkerInitialized) : mutex_(0) { }
-Mutex::~Mutex()            { assert(mutex_ == 0); }
-void Mutex::Lock()         { assert(--mutex_ == -1); }
-void Mutex::Unlock()       { assert(mutex_++ == -1); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { if (mutex_) return false; Lock(); return true; }
-#endif
-void Mutex::ReaderLock()   { assert(++mutex_ > 0); }
-void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-
-Mutex::Mutex() : destroy_(true) {
-  InitializeCriticalSection(&mutex_);
-  SetIsSafe();
-}
-Mutex::Mutex(LinkerInitialized) : destroy_(false) {
-  InitializeCriticalSection(&mutex_);
-  SetIsSafe();
-}
-Mutex::~Mutex()            { if (destroy_) DeleteCriticalSection(&mutex_); }
-void Mutex::Lock()         { if (is_safe_) EnterCriticalSection(&mutex_); }
-void Mutex::Unlock()       { if (is_safe_) LeaveCriticalSection(&mutex_); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 TryEnterCriticalSection(&mutex_) != 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }      // we don't have read-write locks
-void Mutex::ReaderUnlock() { Unlock(); }
-
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex() : destroy_(true) {
-  SetIsSafe();
-  if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) {
-  SetIsSafe();
-  if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()       { if (destroy_) SAFE_PTHREAD(pthread_rwlock_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_rwlock_wrlock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                               pthread_rwlock_trywrlock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock()   { SAFE_PTHREAD(pthread_rwlock_rdlock); }
-void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#undef SAFE_PTHREAD
-
-#elif defined(HAVE_PTHREAD)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex() : destroy_(true) {
-  SetIsSafe();
-  if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) {
-  SetIsSafe();
-  if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()       { if (destroy_) SAFE_PTHREAD(pthread_mutex_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_mutex_lock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_mutex_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 pthread_mutex_trylock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }
-void Mutex::ReaderUnlock() { Unlock(); }
-#undef SAFE_PTHREAD
-
-#endif
-
-// --------------------------------------------------------------------------
-// Some helper classes
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class MutexLock {
- public:
-  explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
-  ~MutexLock() { mu_->Unlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  MutexLock(const MutexLock&);
-  void operator=(const MutexLock&);
-};
-
-// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
-class ReaderMutexLock {
- public:
-  explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
-  ~ReaderMutexLock() { mu_->ReaderUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  ReaderMutexLock(const ReaderMutexLock&);
-  void operator=(const ReaderMutexLock&);
-};
-
-class WriterMutexLock {
- public:
-  explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
-  ~WriterMutexLock() { mu_->WriterUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  WriterMutexLock(const WriterMutexLock&);
-  void operator=(const WriterMutexLock&);
-};
-
-// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
-#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
-#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
-#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
-
-}  // namespace MUTEX_NAMESPACE
-
-using namespace MUTEX_NAMESPACE;
-
-#undef MUTEX_NAMESPACE
-
-#endif  /* #define GOOGLE_MUTEX_H__ */

+ 0 - 139
Src/ThirdParty/gflags/src/windows/config.h

@@ -1,139 +0,0 @@
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Sometimes we accidentally #include this config.h instead of the one
-   in .. -- this is particularly true for msys/mingw, which uses the
-   unix config.h but also runs code in the windows directory.
-   */
-#ifdef __MINGW32__
-#include "../config.h"
-#define GOOGLE_GFLAGS_WINDOWS_CONFIG_H_
-#endif
-
-#ifndef GOOGLE_GFLAGS_WINDOWS_CONFIG_H_
-#define GOOGLE_GFLAGS_WINDOWS_CONFIG_H_
-
-/* Always the empty-string on non-windows systems. On windows, should be
-   "__declspec(dllexport)". This way, when we compile the dll, we export our
-   functions/classes. It's safe to define this here because config.h is only
-   used internally, to compile the DLL, and every DLL source file #includes
-   "config.h" before anything else. */
-#ifndef GFLAGS_DLL_DECL
-# define GFLAGS_IS_A_DLL  1   /* not set if you're statically linking */
-# define GFLAGS_DLL_DECL  __declspec(dllexport)
-# define GFLAGS_DLL_DECL_FOR_UNITTESTS  __declspec(dllimport)
-#endif
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE  ::google
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <fnmatch.h> header file. */
-#undef HAVE_FNMATCH_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* define if the compiler implements namespaces */
-#define HAVE_NAMESPACES  1
-
-/* Define if you have POSIX threads libraries and header files. */
-#undef HAVE_PTHREAD
-
-/* Define to 1 if you have the `putenv' function. */
-#define HAVE_PUTENV  1
-
-/* Define to 1 if you have the `setenv' function. */
-#undef HAVE_SETENV
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strtoll' function. */
-#define HAVE_STRTOLL  1
-
-/* Define to 1 if you have the `strtoq' function. */
-#define HAVE_STRTOQ  1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* define if your compiler has __attribute__ */
-#undef HAVE___ATTRIBUTE__
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS  1
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE  std
-
-/* Version number of package */
-#undef VERSION
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_  }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_  namespace google {
-
-// ---------------------------------------------------------------------
-// Extra stuff not found in config.h.in
-
-// This must be defined before the windows.h is included.  It's needed
-// for mutex.h, to give access to the TryLock method.
-#ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0400
-#endif
-
-// TODO(csilvers): include windows/port.h in every relevant source file instead?
-#include "windows/port.h"
-
-#endif  /* GOOGLE_GFLAGS_WINDOWS_CONFIG_H_ */

+ 0 - 601
Src/ThirdParty/gflags/src/windows/gflags/gflags.h

@@ -1,601 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Ray Sidney
-// Revamped and reorganized by Craig Silverstein
-//
-// This is the file that should be included by any file which declares
-// or defines a command line flag or wants to parse command line flags
-// or print a program usage message (which will include information about
-// flags).  Executive summary, in the form of an example foo.cc file:
-//
-//    #include "foo.h"         // foo.h has a line "DECLARE_int32(start);"
-//    #include "validators.h"  // hypothetical file defining ValidateIsFile()
-//
-//    DEFINE_int32(end, 1000, "The last record to read");
-//
-//    DEFINE_string(filename, "my_file.txt", "The file to read");
-//    // Crash if the specified file does not exist.
-//    static bool dummy = RegisterFlagValidator(&FLAGS_filename,
-//                                              &ValidateIsFile);
-//
-//    DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
-//
-//    void MyFunc() {
-//      if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
-//    }
-//
-// Then, at the command-line:
-//    ./foo --noverbose --start=5 --end=100
-//
-// For more details, see
-//    doc/gflags.html
-//
-// --- A note about thread-safety:
-//
-// We describe many functions in this routine as being thread-hostile,
-// thread-compatible, or thread-safe.  Here are the meanings we use:
-//
-// thread-safe: it is safe for multiple threads to call this routine
-//   (or, when referring to a class, methods of this class)
-//   concurrently.
-// thread-hostile: it is not safe for multiple threads to call this
-//   routine (or methods of this class) concurrently.  In gflags,
-//   most thread-hostile routines are intended to be called early in,
-//   or even before, main() -- that is, before threads are spawned.
-// thread-compatible: it is safe for multiple threads to read from
-//   this variable (when applied to variables), or to call const
-//   methods of this class (when applied to classes), as long as no
-//   other thread is writing to the variable or calling non-const
-//   methods of this class.
-
-#ifndef GOOGLE_GFLAGS_H_
-#define GOOGLE_GFLAGS_H_
-
-#include <string>
-#include <vector>
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at gflags.h.in to see how they're calculated (based on your config).
-#if 0
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 0
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#if defined(_WIN32)
-# ifndef GFLAGS_DLL_DECL
-#   define GFLAGS_DLL_DECL  __declspec(dllimport)
-# endif
-# ifndef GFLAGS_DLL_DECLARE_FLAG
-#   define GFLAGS_DLL_DECLARE_FLAG  __declspec(dllimport)
-# endif
-# ifndef GFLAGS_DLL_DEFINE_FLAG
-#   define GFLAGS_DLL_DEFINE_FLAG   __declspec(dllexport)
-# endif
-#else
-# ifndef GFLAGS_DLL_DECL
-#   define GFLAGS_DLL_DECL
-# endif
-# ifndef GFLAGS_DLL_DECLARE_FLAG
-#   define GFLAGS_DLL_DECLARE_FLAG
-# endif
-# ifndef GFLAGS_DLL_DEFINE_FLAG
-#   define GFLAGS_DLL_DEFINE_FLAG
-# endif
-#endif
-
-namespace google {
-
-#if 0      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 0   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 1     // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-// --------------------------------------------------------------------
-// To actually define a flag in a file, use DEFINE_bool,
-// DEFINE_string, etc. at the bottom of this file.  You may also find
-// it useful to register a validator with the flag.  This ensures that
-// when the flag is parsed from the commandline, or is later set via
-// SetCommandLineOption, we call the validation function. It is _not_
-// called when you assign the value to the flag directly using the = operator.
-//
-// The validation function should return true if the flag value is valid, and
-// false otherwise. If the function returns false for the new setting of the
-// flag, the flag will retain its current value. If it returns false for the
-// default value, ParseCommandLineFlags() will die.
-//
-// This function is safe to call at global construct time (as in the
-// example below).
-//
-// Example use:
-//    static bool ValidatePort(const char* flagname, int32 value) {
-//       if (value > 0 && value < 32768)   // value is ok
-//         return true;
-//       printf("Invalid value for --%s: %d\n", flagname, (int)value);
-//       return false;
-//    }
-//    DEFINE_int32(port, 0, "What port to listen on");
-//    static bool dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
-
-// Returns true if successfully registered, false if not (because the
-// first argument doesn't point to a command-line flag, or because a
-// validator is already registered for this flag).
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag,
-                           bool (*validate_fn)(const char*, bool));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag,
-                           bool (*validate_fn)(const char*, int32));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag,
-                           bool (*validate_fn)(const char*, int64));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag,
-                           bool (*validate_fn)(const char*, uint64));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag,
-                           bool (*validate_fn)(const char*, double));
-GFLAGS_DLL_DECL bool RegisterFlagValidator(const std::string* flag,
-                           bool (*validate_fn)(const char*, const std::string&));
-
-
-// --------------------------------------------------------------------
-// These methods are the best way to get access to info about the
-// list of commandline flags.  Note that these routines are pretty slow.
-//   GetAllFlags: mostly-complete info about the list, sorted by file.
-//   ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
-//   ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
-//
-// In addition to accessing flags, you can also access argv[0] (the program
-// name) and argv (the entire commandline), which we sock away a copy of.
-// These variables are static, so you should only set them once.
-
-struct GFLAGS_DLL_DECL CommandLineFlagInfo {
-  std::string name;           // the name of the flag
-  std::string type;           // the type of the flag: int32, etc
-  std::string description;    // the "help text" associated with the flag
-  std::string current_value;  // the current value, as a string
-  std::string default_value;  // the default value, as a string
-  std::string filename;       // 'cleaned' version of filename holding the flag
-  bool has_validator_fn;      // true if RegisterFlagValidator called on flag
-  bool is_default;            // true if the flag has the default value and
-                              // has not been set explicitly from the cmdline
-                              // or via SetCommandLineOption
-};
-
-// Using this inside of a validator is a recipe for a deadlock.
-// TODO(wojtekm) Fix locking when validators are running, to make it safe to
-// call validators during ParseAllFlags.
-// Also make sure then to uncomment the corresponding unit test in
-// commandlineflags_unittest.sh
-extern GFLAGS_DLL_DECL void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
-// These two are actually defined in commandlineflags_reporting.cc.
-extern GFLAGS_DLL_DECL void ShowUsageWithFlags(const char *argv0);  // what --help does
-extern GFLAGS_DLL_DECL void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
-
-// Create a descriptive string for a flag.
-// Goes to some trouble to make pretty line breaks.
-extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
-
-// Thread-hostile; meant to be called before any threads are spawned.
-extern GFLAGS_DLL_DECL void SetArgv(int argc, const char** argv);
-// The following functions are thread-safe as long as SetArgv() is
-// only called before any threads start.
-extern GFLAGS_DLL_DECL const std::vector<std::string>& GetArgvs();  // all of argv as a vector
-extern GFLAGS_DLL_DECL const char* GetArgv();               // all of argv as a string
-extern GFLAGS_DLL_DECL const char* GetArgv0();              // only argv0
-extern GFLAGS_DLL_DECL uint32 GetArgvSum();                 // simple checksum of argv
-extern GFLAGS_DLL_DECL const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
-extern GFLAGS_DLL_DECL const char* ProgramInvocationShortName();   // basename(argv0)
-// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
-// called before any threads start.
-extern GFLAGS_DLL_DECL const char* ProgramUsage();          // string set by SetUsageMessage()
-
-
-// --------------------------------------------------------------------
-// Normally you access commandline flags by just saying "if (FLAGS_foo)"
-// or whatever, and set them by calling "FLAGS_foo = bar" (or, more
-// commonly, via the DEFINE_foo macro).  But if you need a bit more
-// control, we have programmatic ways to get/set the flags as well.
-// These programmatic ways to access flags are thread-safe, but direct
-// access is only thread-compatible.
-
-// Return true iff the flagname was found.
-// OUTPUT is set to the flag's value, or unchanged if we return false.
-extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string* OUTPUT);
-
-// Return true iff the flagname was found. OUTPUT is set to the flag's
-// CommandLineFlagInfo or unchanged if we return false.
-extern GFLAGS_DLL_DECL bool GetCommandLineFlagInfo(const char* name,
-                                   CommandLineFlagInfo* OUTPUT);
-
-// Return the CommandLineFlagInfo of the flagname.  exit() if name not found.
-// Example usage, to check if a flag's value is currently the default value:
-//   if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
-extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
-
-enum GFLAGS_DLL_DECL FlagSettingMode {
-  // update the flag's value (can call this multiple times).
-  SET_FLAGS_VALUE,
-  // update the flag's value, but *only if* it has not yet been updated
-  // with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef".
-  SET_FLAG_IF_DEFAULT,
-  // set the flag's default value to this.  If the flag has not yet updated
-  // yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef")
-  // change the flag's current value to the new default value as well.
-  SET_FLAGS_DEFAULT
-};
-
-// Set a particular flag ("command line option").  Returns a string
-// describing the new value that the option has been set to.  The
-// return value API is not well-specified, so basically just depend on
-// it to be empty if the setting failed for some reason -- the name is
-// not a valid flag name, or the value is not a valid value -- and
-// non-empty else.
-
-// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
-extern GFLAGS_DLL_DECL std::string SetCommandLineOption(const char* name, const char* value);
-extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name, const char* value,
-                                                FlagSettingMode set_mode);
-
-
-// --------------------------------------------------------------------
-// Saves the states (value, default value, whether the user has set
-// the flag, registered validators, etc) of all flags, and restores
-// them when the FlagSaver is destroyed.  This is very useful in
-// tests, say, when you want to let your tests change the flags, but
-// make sure that they get reverted to the original states when your
-// test is complete.
-//
-// Example usage:
-//   void TestFoo() {
-//     FlagSaver s1;
-//     FLAG_foo = false;
-//     FLAG_bar = "some value";
-//
-//     // test happens here.  You can return at any time
-//     // without worrying about restoring the FLAG values.
-//   }
-//
-// Note: This class is marked with __attribute__((unused)) because all the
-// work is done in the constructor and destructor, so in the standard
-// usage example above, the compiler would complain that it's an
-// unused variable.
-//
-// This class is thread-safe.
-
-class GFLAGS_DLL_DECL FlagSaver {
- public:
-  FlagSaver();
-  ~FlagSaver();
-
- private:
-  class FlagSaverImpl* impl_;   // we use pimpl here to keep API steady
-
-  FlagSaver(const FlagSaver&);  // no copying!
-  void operator=(const FlagSaver&);
-} ;
-
-// --------------------------------------------------------------------
-// Some deprecated or hopefully-soon-to-be-deprecated functions.
-
-// This is often used for logging.  TODO(csilvers): figure out a better way
-extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
-// Usually where this is used, a FlagSaver should be used instead.
-extern GFLAGS_DLL_DECL bool ReadFlagsFromString(const std::string& flagfilecontents,
-                                const char* prog_name,
-                                bool errors_are_fatal); // uses SET_FLAGS_VALUE
-
-// These let you manually implement --flagfile functionality.
-// DEPRECATED.
-extern GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
-extern GFLAGS_DLL_DECL bool SaveCommandFlags();  // actually defined in google.cc !
-extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
-                              bool errors_are_fatal);   // uses SET_FLAGS_VALUE
-
-
-// --------------------------------------------------------------------
-// Useful routines for initializing flags from the environment.
-// In each case, if 'varname' does not exist in the environment
-// return defval.  If 'varname' does exist but is not valid
-// (e.g., not a number for an int32 flag), abort with an error.
-// Otherwise, return the value.  NOTE: for booleans, for true use
-// 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
-
-extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
-extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
-extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
-extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
-extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
-extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char *defval);
-
-
-// --------------------------------------------------------------------
-// The next two functions parse commandlineflags from main():
-
-// Set the "usage" message for this program.  For example:
-//   string usage("This program does nothing.  Sample usage:\n");
-//   usage += argv[0] + " <uselessarg1> <uselessarg2>";
-//   SetUsageMessage(usage);
-// Do not include commandline flags in the usage: we do that for you!
-// Thread-hostile; meant to be called before any threads are spawned.
-extern GFLAGS_DLL_DECL void SetUsageMessage(const std::string& usage);
-
-// Looks for flags in argv and parses them.  Rearranges argv to put
-// flags first, or removes them entirely if remove_flags is true.
-// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.
-// See top-of-file for more details on this function.
-#ifndef SWIG   // In swig, use ParseCommandLineFlagsScript() instead.
-extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv,
-                                    bool remove_flags);
-#endif
-
-
-// Calls to ParseCommandLineNonHelpFlags and then to
-// HandleCommandLineHelpFlags can be used instead of a call to
-// ParseCommandLineFlags during initialization, in order to allow for
-// changing default values for some FLAGS (via
-// e.g. SetCommandLineOptionWithMode calls) between the time of
-// command line parsing and the time of dumping help information for
-// the flags as a result of command line parsing.
-// If a flag is defined more than once in the command line or flag
-// file, the last definition is used.
-extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
-                                           bool remove_flags);
-// This is actually defined in commandlineflags_reporting.cc.
-// This function is misnamed (it also handles --version, etc.), but
-// it's too late to change that now. :-(
-extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags();   // in commandlineflags_reporting.cc
-
-// Allow command line reparsing.  Disables the error normally
-// generated when an unknown flag is found, since it may be found in a
-// later parse.  Thread-hostile; meant to be called before any threads
-// are spawned.
-extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
-
-// Reparse the flags that have not yet been recognized.
-// Only flags registered since the last parse will be recognized.
-// Any flag value must be provided as part of the argument using "=",
-// not as a separate command line argument that follows the flag argument.
-// Intended for handling flags from dynamically loaded libraries,
-// since their flags are not registered until they are loaded.
-extern GFLAGS_DLL_DECL uint32 ReparseCommandLineNonHelpFlags();
-
-// Clean up memory allocated by flags.  This is only needed to reduce
-// the quantity of "potentially leaked" reports emitted by memory
-// debugging tools such as valgrind.  It is not required for normal
-// operation, or for the perftools heap-checker.  It must only be called
-// when the process is about to exit, and all threads that might
-// access flags are quiescent.  Referencing flags after this is called
-// will have unexpected consequences.  This is not safe to run when
-// multiple threads might be running: the function is thread-hostile.
-extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
-
-
-// --------------------------------------------------------------------
-// Now come the command line flag declaration/definition macros that
-// will actually be used.  They're kind of hairy.  A major reason
-// for this is initialization: we want people to be able to access
-// variables in global constructors and have that not crash, even if
-// their global constructor runs before the global constructor here.
-// (Obviously, we can't guarantee the flags will have the correct
-// default value in that case, but at least accessing them is safe.)
-// The only way to do that is have flags point to a static buffer.
-// So we make one, using a union to ensure proper alignment, and
-// then use placement-new to actually set up the flag with the
-// correct default value.  In the same vein, we have to worry about
-// flag access in global destructors, so FlagRegisterer has to be
-// careful never to destroy the flag-values it constructs.
-//
-// Note that when we define a flag variable FLAGS_<name>, we also
-// preemptively define a junk variable, FLAGS_no<name>.  This is to
-// cause a link-time error if someone tries to define 2 flags with
-// names like "logging" and "nologging".  We do this because a bool
-// flag FLAG can be set from the command line to true with a "-FLAG"
-// argument, and to false with a "-noFLAG" argument, and so this can
-// potentially avert confusion.
-//
-// We also put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the current
-// namespace.  The net result is to force people to use DECLARE to get
-// access to a flag, rather than saying "extern bool FLAGS_whatever;"
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want, and
-// make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-
-class GFLAGS_DLL_DECL FlagRegisterer {
- public:
-  FlagRegisterer(const char* name, const char* type,
-                 const char* help, const char* filename,
-                 void* current_storage, void* defvalue_storage);
-};
-
-extern bool FlagsTypeWarn(const char *name);
-
-// If your application #defines STRIP_FLAG_HELP to a non-zero value
-// before #including this file, we remove the help message from the
-// binary file. This can reduce the size of the resulting binary
-// somewhat, and may also be useful for security reasons.
-
-extern const char kStrippedFlagHelp[];
-
-}
-
-#ifndef SWIG  // In swig, ignore the main flag declarations
-
-#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
-// Need this construct to avoid the 'defined but not used' warning.
-#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : kStrippedFlagHelp)
-#else
-#define MAYBE_STRIPPED_HELP(txt) txt
-#endif
-
-// Each command-line flag has two variables associated with it: one
-// with the current value, and one with the default value.  However,
-// we have a third variable, which is where value is assigned; it's a
-// constant.  This guarantees that FLAG_##value is initialized at
-// static initialization time (e.g. before program-start) rather than
-// than global construction time (which is after program-start but
-// before main), at least when 'value' is a compile-time constant.  We
-// use a small trick for the "default value" variable, and call it
-// FLAGS_no<name>.  This serves the second purpose of assuring a
-// compile error if someone tries to define a flag named no<name>
-// which is illegal (--foo and --nofoo both affect the "foo" flag).
-#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
-  namespace fL##shorttype {                                     \
-    static const type FLAGS_nono##name = value;                 \
-    /* We always want to export defined variables, dll or no */ \
-    GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
-    type FLAGS_no##name = FLAGS_nono##name;                     \
-    static ::google::FlagRegisterer o_##name(                   \
-      #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__,        \
-      &FLAGS_##name, &FLAGS_no##name);                          \
-  }                                                             \
-  using fL##shorttype::FLAGS_##name
-
-#define DECLARE_VARIABLE(type, shorttype, name) \
-  namespace fL##shorttype {                     \
-    /* We always want to import declared variables, dll or no */ \
-    extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; \
-  }                                             \
-  using fL##shorttype::FLAGS_##name
-
-// For DEFINE_bool, we want to do the extra check that the passed-in
-// value is actually a bool, and not a string or something that can be
-// coerced to a bool.  These declarations (no definition needed!) will
-// help us do that, and never evaluate From, which is important.
-// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
-// that the compiler have different sizes for bool & double. Since
-// this is not guaranteed by the standard, we check it with a
-// compile-time assert (msg[-1] will give a compile-time error).
-namespace fLB {
-struct CompileAssert {};
-typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
-                      (sizeof(double) != sizeof(bool)) ? 1 : -1];
-template<typename From> GFLAGS_DLL_DECL double IsBoolFlag(const From& from);
-GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
-}  // namespace fLB
-
-#define DECLARE_bool(name)          DECLARE_VARIABLE(bool, B, name)
-#define DEFINE_bool(name, val, txt)                                       \
-  namespace fLB {                                                         \
-    typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[       \
-            (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
-  }                                                                       \
-  DEFINE_VARIABLE(bool, B, name, val, txt)
-
-#define DECLARE_int32(name)         DECLARE_VARIABLE(::google::int32, I, name)
-#define DEFINE_int32(name,val,txt)  DEFINE_VARIABLE(::google::int32, I, name, val, txt)
-
-#define DECLARE_int64(name)         DECLARE_VARIABLE(::google::int64, I64, name)
-#define DEFINE_int64(name,val,txt)  DEFINE_VARIABLE(::google::int64, I64, name, val, txt)
-
-#define DECLARE_uint64(name)        DECLARE_VARIABLE(::google::uint64, U64, name)
-#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt)
-
-#define DECLARE_double(name)          DECLARE_VARIABLE(double, D, name)
-#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
-
-// Strings are trickier, because they're not a POD, so we can't
-// construct them at static-initialization time (instead they get
-// constructed at global-constructor time, which is much later).  To
-// try to avoid crashes in that case, we use a char buffer to store
-// the string, which we can static-initialize, and then placement-new
-// into it later.  It's not perfect, but the best we can do.
-
-namespace fLS {
-// The meaning of "string" might be different between now and when the
-// macros below get invoked (e.g., if someone is experimenting with
-// other string implementations that get defined after this file is
-// included).  Save the current meaning now and use it in the macros.
-typedef std::string clstring;
-
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const char *value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           const clstring &value) {
-  return new(stringspot) clstring(value);
-}
-inline clstring* dont_pass0toDEFINE_string(char *stringspot,
-                                           int value);
-}  // namespace fLS
-
-#define DECLARE_string(name)  namespace fLS { extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; } \
-                              using fLS::FLAGS_##name
-
-// We need to define a var named FLAGS_no##name so people don't define
-// --string and --nostring.  And we need a temporary place to put val
-// so we don't have to evaluate it twice.  Two great needs that go
-// great together!
-#define DEFINE_string(name, val, txt)                                       \
-  namespace fLS {                                                           \
-    using ::fLS::clstring;                                                  \
-    static union { void* align; char s[sizeof(clstring)]; } s_##name[2];    \
-    clstring* const FLAGS_no##name = ::fLS::                                \
-                                   dont_pass0toDEFINE_string(s_##name[0].s, \
-                                                             val);          \
-    static ::google::FlagRegisterer o_##name(                  \
-        #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__,                \
-        s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name));      \
-    GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name = *FLAGS_no##name;        \
-  }                                                                         \
-  using fLS::FLAGS_##name
-
-#endif  // SWIG
-
-#endif  // GOOGLE_GFLAGS_H_

+ 0 - 130
Src/ThirdParty/gflags/src/windows/gflags/gflags_completions.h

@@ -1,130 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// ---
-// Author: Dave Nicponski
-//
-// Implement helpful bash-style command line flag completions
-//
-// ** Functional API:
-// HandleCommandLineCompletions() should be called early during
-// program startup, but after command line flag code has been
-// initialized, such as the beginning of HandleCommandLineHelpFlags().
-// It checks the value of the flag --tab_completion_word.  If this
-// flag is empty, nothing happens here.  If it contains a string,
-// however, then HandleCommandLineCompletions() will hijack the
-// process, attempting to identify the intention behind this
-// completion.  Regardless of the outcome of this deduction, the
-// process will be terminated, similar to --helpshort flag
-// handling.
-//
-// ** Overview of Bash completions:
-// Bash can be told to programatically determine completions for the
-// current 'cursor word'.  It does this by (in this case) invoking a
-// command with some additional arguments identifying the command
-// being executed, the word being completed, and the previous word
-// (if any).  Bash then expects a sequence of output lines to be
-// printed to stdout.  If these lines all contain a common prefix
-// longer than the cursor word, bash will replace the cursor word
-// with that common prefix, and display nothing.  If there isn't such
-// a common prefix, bash will display the lines in pages using 'more'.
-//
-// ** Strategy taken for command line completions:
-// If we can deduce either the exact flag intended, or a common flag
-// prefix, we'll output exactly that.  Otherwise, if information
-// must be displayed to the user, we'll take the opportunity to add
-// some helpful information beyond just the flag name (specifically,
-// we'll include the default flag value and as much of the flag's
-// description as can fit on a single terminal line width, as specified
-// by the flag --tab_completion_columns).  Furthermore, we'll try to
-// make bash order the output such that the most useful or relevent
-// flags are the most likely to be shown at the top.
-//
-// ** Additional features:
-// To assist in finding that one really useful flag, substring matching
-// was implemented.  Before pressing a <TAB> to get completion for the
-// current word, you can append one or more '?' to the flag to do
-// substring matching.  Here's the semantics:
-//   --foo<TAB>     Show me all flags with names prefixed by 'foo'
-//   --foo?<TAB>    Show me all flags with 'foo' somewhere in the name
-//   --foo??<TAB>   Same as prior case, but also search in module
-//                  definition path for 'foo'
-//   --foo???<TAB>  Same as prior case, but also search in flag
-//                  descriptions for 'foo'
-// Finally, we'll trim the output to a relatively small number of
-// flags to keep bash quiet about the verbosity of output.  If one
-// really wanted to see all possible matches, appending a '+' to the
-// search word will force the exhaustive list of matches to be printed.
-//
-// ** How to have bash accept completions from a binary:
-// Bash requires that it be informed about each command that programmatic
-// completion should be enabled for.  Example addition to a .bashrc
-// file would be (your path to gflags_completions.sh file may differ):
-
-/*
-$ complete -o bashdefault -o default -o nospace -C                        \
- '/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \
-  time  env  binary_name  another_binary  [...]
-*/
-
-// This would allow the following to work:
-//   $ /path/to/binary_name --vmodule<TAB>
-// Or:
-//   $ ./bin/path/another_binary --gfs_u<TAB>
-// (etc)
-//
-// Sadly, it appears that bash gives no easy way to force this behavior for
-// all commands.  That's where the "time" in the above example comes in.
-// If you haven't specifically added a command to the list of completion
-// supported commands, you can still get completions by prefixing the
-// entire command with "env".
-//   $ env /some/brand/new/binary --vmod<TAB>
-// Assuming that "binary" is a newly compiled binary, this should still
-// produce the expected completion output.
-
-
-#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_
-#define GOOGLE_GFLAGS_COMPLETIONS_H_
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GFLAGS_DLL_DECL
-# ifdef _WIN32
-#   define GFLAGS_DLL_DECL  __declspec(dllimport)
-# else
-#   define GFLAGS_DLL_DECL
-# endif
-#endif
-
-namespace google {
-
-GFLAGS_DLL_DECL void HandleCommandLineCompletions(void);
-
-}
-
-#endif  // GOOGLE_GFLAGS_COMPLETIONS_H_

+ 0 - 56
Src/ThirdParty/gflags/src/windows/port.cc

@@ -1,56 +0,0 @@
-/* Copyright (c) 2009, Google Inc.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- */
-
-#ifndef _WIN32
-# error You should only be including windows/port.cc in a windows environment!
-#endif
-
-#include <config.h>
-#include <string.h>    // for strlen(), memset(), memcmp()
-#include <assert.h>
-#include <stdarg.h>    // for va_list, va_start, va_end
-#include <windows.h>
-#include "port.h"
-
-#ifndef HAVE_SNPRINTF
-int snprintf(char *str, size_t size, const char *format, ...) {
-  if (size == 0)        // not even room for a \0?
-    return -1;          // not what C99 says to do, but what windows does
-  va_list ap;
-  va_start(ap, format);
-  const int r = _vsnprintf(str, size-1, format, ap);
-  va_end(ap);
-  str[size-1] = '\0';
-  return r;
-}
-#endif

+ 0 - 88
Src/ThirdParty/gflags/src/windows/port.h

@@ -1,88 +0,0 @@
-/* Copyright (c) 2009, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- *
- * These are some portability typedefs and defines to make it a bit
- * easier to compile this code under VC++.
- *
- * Several of these are taken from glib:
- *    http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html
- */
-
-#ifndef GOOGLE_GFLAGS_WINDOWS_PORT_H_
-#define GOOGLE_GFLAGS_WINDOWS_PORT_H_
-
-// You should never include this file directly, but always include it
-// from either config.h (MSVC) or mingw.h (MinGW/msys).
-#if !defined(GOOGLE_GFLAGS_WINDOWS_CONFIG_H_)
-# error "port.h should only be included from config.h"
-#endif
-
-#ifdef _WIN32
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN  /* We always want minimal includes */
-#endif
-#include <windows.h>
-#include <direct.h>          /* for mkdir */
-#include <stdio.h>           /* need this to override stdio's snprintf */
-
-#define putenv  _putenv
-
-// ----------------------------------- STRING ROUTINES
-
-// We can't just use _snprintf as a drop-in-replacement, because it
-// doesn't always NUL-terminate. :-(
-extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size,
-                                    const char *format, ...);
-
-#define strcasecmp   _stricmp
-
-#define PRId32  "d"
-#define PRIu32  "u"
-#define PRId64  "I64d"
-#define PRIu64  "I64u"
-
-#ifndef __MINGW32__
-#define strtoq   _strtoi64
-#define strtouq  _strtoui64
-#define strtoll  _strtoi64
-#define strtoull _strtoui64
-#define atoll    _atoi64
-#endif
-
-#ifndef PATH_MAX
-#define PATH_MAX 1024
-#endif
-
-#endif  /* _WIN32 */
-
-#endif  /* GOOGLE_GFLAGS_WINDOWS_PORT_H_ */

+ 0 - 13
Src/ThirdParty/glog/CMakeLists.txt

@@ -1,13 +0,0 @@
-SET(Glog
-	src/demangle.cc
-	src/logging.cc
-	src/raw_logging.cc
-	src/signalhandler.cc
-	src/symbolize.cc
-	src/utilities.cc
-	src/vlog_is_on.cc
-)
-
-INCLUDE_DIRECTORIES(./src)
-
-ADD_LIBRARY(Glog ${Glog})

+ 0 - 84
Src/ThirdParty/glog/log_severity.h

@@ -1,84 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef BASE_LOG_SEVERITY_H__
-#define BASE_LOG_SEVERITY_H__
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// Variables of type LogSeverity are widely taken to lie in the range
-// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
-// you ever need to change their values or add a new severity.
-typedef int LogSeverity;
-
-const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
-
-// DFATAL is FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
-#define DFATAL_LEVEL ERROR
-#else
-#define DFATAL_LEVEL FATAL
-#endif
-
-extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
-
-// NDEBUG usage helpers related to (RAW_)DCHECK:
-//
-// DEBUG_MODE is for small !NDEBUG uses like
-//   if (DEBUG_MODE) foo.CheckThatFoo();
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     foo.CheckThatFoo();
-//   #endif
-//
-// IF_DEBUG_MODE is for small !NDEBUG uses like
-//   IF_DEBUG_MODE( string error; )
-//   DCHECK(Foo(&error)) << error;
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     string error;
-//     DCHECK(Foo(&error)) << error;
-//   #endif
-//
-#ifdef NDEBUG
-enum { DEBUG_MODE = 0 };
-#define IF_DEBUG_MODE(x)
-#else
-enum { DEBUG_MODE = 1 };
-#define IF_DEBUG_MODE(x) x
-#endif
-
-#endif  // BASE_LOG_SEVERITY_H__

+ 0 - 1506
Src/ThirdParty/glog/logging.h

@@ -1,1506 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-//
-// This file contains #include information about logging-related stuff.
-// Pretty much everybody needs to #include this file so that they can
-// log various happenings.
-//
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <string>
-#if 1
-# include <unistd.h>
-#endif
-#ifdef __DEPRECATED
-// Make GCC quiet.
-# undef __DEPRECATED
-# include <strstream>
-# define __DEPRECATED
-#else
-# include <strstream>
-#endif
-#include <vector>
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at logging.h.in to see how they're calculated (based on your config).
-#if 1
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 1
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-#if 1
-#include <gflags/gflags.h>
-#endif
-
-namespace google {
-
-#if 1      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 1   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0    // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-}
-
-// The global value of GOOGLE_STRIP_LOG. All the messages logged to
-// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed.
-// If it can be determined at compile time that the message will not be
-// printed, the statement will be compiled out.
-//
-// Example: to strip out all INFO and WARNING messages, use the value
-// of 2 below. To make an exception for WARNING messages from a single
-// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including
-// base/logging.h
-#ifndef GOOGLE_STRIP_LOG
-#define GOOGLE_STRIP_LOG 0
-#endif
-
-// GCC can be told that a certain branch is not likely to be taken (for
-// instance, a CHECK failure), and use that information in static analysis.
-// Giving it this information can help it optimize for the common case in
-// the absence of better information (ie. -fprofile-arcs).
-//
-#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
-#if 1
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#else
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
-#endif
-#endif
-
-// Make a bunch of macros for logging.  The way to log things is to stream
-// things to LOG(<a particular severity level>).  E.g.,
-//
-//   LOG(INFO) << "Found " << num_cookies << " cookies";
-//
-// You can capture log messages in a string, rather than reporting them
-// immediately:
-//
-//   vector<string> errors;
-//   LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
-//
-// This pushes back the new error onto 'errors'; if given a NULL pointer,
-// it reports the error via LOG(ERROR).
-//
-// You can also do conditional logging:
-//
-//   LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-// You can also do occasional logging (log every n'th occurrence of an
-// event):
-//
-//   LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed.  Note that the special COUNTER value is used to
-// identify which repetition is happening.
-//
-// You can also do occasional conditional logging (log every n'th
-// occurrence of an event, when condition is satisfied):
-//
-//   LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
-//                                           << "th big cookie";
-//
-// You can log messages the first N times your code executes a line. E.g.
-//
-//   LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie";
-//
-// Outputs log messages for the first 20 times it is executed.
-//
-// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available.
-// These log to syslog as well as to the normal logs.  If you use these at
-// all, you need to be aware that syslog can drastically reduce performance,
-// especially if it is configured for remote logging!  Don't use these
-// unless you fully understand this and have a concrete need to use them.
-// Even then, try to minimize your use of them.
-//
-// There are also "debug mode" logging macros like the ones above:
-//
-//   DLOG(INFO) << "Found cookies";
-//
-//   DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-//   DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// All "debug mode" logging is compiled away to nothing for non-debug mode
-// compiles.
-//
-// We also have
-//
-//   LOG_ASSERT(assertion);
-//   DLOG_ASSERT(assertion);
-//
-// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
-//
-// There are "verbose level" logging macros.  They look like
-//
-//   VLOG(1) << "I'm printed when you run the program with --v=1 or more";
-//   VLOG(2) << "I'm printed when you run the program with --v=2 or more";
-//
-// These always log at the INFO log level (when they log at all).
-// The verbose logging can also be turned on module-by-module.  For instance,
-//    --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-// will cause:
-//   a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc}
-//   b. VLOG(1) and lower messages to be printed from file.{h,cc}
-//   c. VLOG(3) and lower messages to be printed from files prefixed with "gfs"
-//   d. VLOG(0) and lower messages to be printed from elsewhere
-//
-// The wildcarding functionality shown by (c) supports both '*' (match
-// 0 or more characters) and '?' (match any single character) wildcards.
-//
-// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
-//
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished with just VLOG(2) << ...;
-//   }
-//
-// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level"
-// condition macros for sample cases, when some extra computation and
-// preparation for logs is not needed.
-//   VLOG_IF(1, (size > 1024))
-//      << "I'm printed when size is more than 1024 and when you run the "
-//         "program with --v=1 or more";
-//   VLOG_EVERY_N(1, 10)
-//      << "I'm printed every 10th occurrence, and when you run the program "
-//         "with --v=1 or more. Present occurence is " << COUNTER;
-//   VLOG_IF_EVERY_N(1, (size > 1024), 10)
-//      << "I'm printed on every 10th occurence of case when size is more "
-//         " than 1024, when you run the program with --v=1 or more. ";
-//         "Present occurence is " << COUNTER;
-//
-// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
-// Note that messages of a given severity are logged not only in the
-// logfile for that severity, but also in all logfiles of lower severity.
-// E.g., a message of severity FATAL will be logged to the logfiles of
-// severity FATAL, ERROR, WARNING, and INFO.
-//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
-// Very important: logging a message at the FATAL severity level causes
-// the program to terminate (after the message is logged).
-//
-// Unless otherwise specified, logs will be written to the filename
-// "<program name>.<hostname>.<user name>.log.<severity level>.", followed
-// by the date, time, and pid (you can't prevent the date, time, and pid
-// from being in the filename).
-//
-// The logging code takes two flags:
-//     --v=#           set the verbose level
-//     --logtostderr   log all the messages to stderr instead of to logfiles
-
-// LOG LINE PREFIX FORMAT
-//
-// Log lines have this form:
-//
-//     Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
-//
-// where the fields are defined as follows:
-//
-//   L                A single character, representing the log level
-//                    (eg 'I' for INFO)
-//   mm               The month (zero padded; ie May is '05')
-//   dd               The day (zero padded)
-//   hh:mm:ss.uuuuuu  Time in hours, minutes and fractional seconds
-//   threadid         The space-padded thread ID as returned by GetTID()
-//                    (this matches the PID on Linux)
-//   file             The file name
-//   line             The line number
-//   msg              The user-supplied message
-//
-// Example:
-//
-//   I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
-//   I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
-//
-// NOTE: although the microseconds are useful for comparing events on
-// a single machine, clocks on different machines may not be well
-// synchronized.  Hence, use caution when comparing the low bits of
-// timestamps from different machines.
-
-#ifndef DECLARE_VARIABLE
-#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#define DECLARE_VARIABLE(type, name, tn)                                      \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                              \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, name, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(google::int32, name, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                          \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name;                       \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
-#endif
-
-// Set whether log messages go to stderr instead of logfiles
-DECLARE_bool(logtostderr);
-
-// Set whether log messages go to stderr in addition to logfiles.
-DECLARE_bool(alsologtostderr);
-
-// Log messages at a level >= this flag are automatically sent to
-// stderr in addition to log files.
-DECLARE_int32(stderrthreshold);
-
-// Set whether the log prefix should be prepended to each line of output.
-DECLARE_bool(log_prefix);
-
-// Log messages at a level <= this flag are buffered.
-// Log messages at a higher level are flushed immediately.
-DECLARE_int32(logbuflevel);
-
-// Sets the maximum number of seconds which logs may be buffered for.
-DECLARE_int32(logbufsecs);
-
-// Log suppression level: messages logged at a lower level than this
-// are suppressed.
-DECLARE_int32(minloglevel);
-
-// If specified, logfiles are written into this directory instead of the
-// default logging directory.
-DECLARE_string(log_dir);
-
-// Sets the path of the directory into which to put additional links
-// to the log files.
-DECLARE_string(log_link);
-
-DECLARE_int32(v);  // in vlog_is_on.cc
-
-// Sets the maximum log file size (in MB).
-DECLARE_int32(max_log_size);
-
-// Sets whether to avoid logging to the disk if the disk is full.
-DECLARE_bool(stop_logging_if_full_disk);
-
-#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef DECLARE_VARIABLE
-#undef DECLARE_bool
-#undef DECLARE_int32
-#undef DECLARE_string
-#endif
-
-// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
-// security reasons. See LOG(severtiy) below.
-
-// A few definitions of macros that don't generate much code.  Since
-// LOG(INFO) and its ilk are used all over our code, it's
-// better to have compact code for these operations.
-
-#if GOOGLE_STRIP_LOG == 0
-#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_INFO(message) google::LogMessage( \
-      __FILE__, __LINE__, google::INFO, message)
-#else
-#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
-#define LOG_TO_STRING_INFO(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 1
-#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING)
-#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING, message)
-#else
-#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
-#define LOG_TO_STRING_WARNING(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 2
-#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR)
-#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR, message)
-#else
-#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
-#define LOG_TO_STRING_ERROR(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL, message)
-#else
-#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
-#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
-#endif
-
-// For DFATAL, we want to use LogMessage (as opposed to
-// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
-#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
-#elif GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL)
-#else
-#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
-#endif
-
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
-#define SYSLOG_INFO(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
-// A very useful logging macro to log windows errors:
-#define LOG_SYSRESULT(result) \
-  if (FAILED(result)) { \
-    LPTSTR message = NULL; \
-    LPTSTR msg = reinterpret_cast<LPTSTR>(&message); \
-    DWORD message_length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
-                         FORMAT_MESSAGE_FROM_SYSTEM, \
-                         0, result, 0, msg, 100, NULL); \
-    if (message_length > 0) { \
-      google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
-          &google::LogMessage::SendToLog).stream() << message; \
-      LocalFree(message); \
-    } \
-  }
-#endif
-
-// We use the preprocessor's merging operator, "##", so that, e.g.,
-// LOG(INFO) becomes the token GOOGLE_LOG_INFO.  There's some funny
-// subtle difference between ostream member streaming functions (e.g.,
-// ostream::operator<<(int) and ostream non-member streaming functions
-// (e.g., ::operator<<(ostream&, string&): it turns out that it's
-// impossible to stream something like a string directly to an unnamed
-// ostream. We employ a neat hack by calling the stream() member
-// function of LogMessage which seems to avoid the problem.
-#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
-#define SYSLOG(severity) SYSLOG_ ## severity(0).stream()
-
-namespace google {
-
-// They need the definitions of integer types.
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Initialize google's logging library. You will see the program name
-// specified by argv0 in log outputs.
-GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
-
-// Shutdown google's logging library.
-GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
-
-// Install a function which will be called after LOG(FATAL).
-GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
-
-class LogSink;  // defined below
-
-// If a non-NULL sink pointer is given, we push this message to that sink.
-// For LOG_TO_SINK we then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and passing/storing them
-// somewhere more specific than the global log of the process.
-// Argument types:
-//   LogSink* sink;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-#define LOG_TO_SINK(sink, severity) \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), true).stream()
-#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)                  \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), false).stream()
-
-// If a non-NULL string pointer is given, we write this message to that string.
-// We then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and storing them somewhere more
-// specific than the global log of the process.
-// Argument types:
-//   string* message;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-// NOTE: LOG(severity) expands to LogMessage().stream() for the specified
-// severity.
-#define LOG_TO_STRING(severity, message) \
-  LOG_TO_STRING_##severity(static_cast<string*>(message)).stream()
-
-// If a non-NULL pointer is given, we push the message onto the end
-// of a vector of strings; otherwise, we report it with LOG(severity).
-// This is handy for capturing messages and perhaps passing them back
-// to the caller, rather than reporting them immediately.
-// Argument types:
-//   LogSeverity severity;
-//   vector<string> *outvec;
-// The cast is to disambiguate NULL arguments.
-#define LOG_STRING(severity, outvec) \
-  LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
-
-#define LOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-#define SYSLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & SYSLOG(severity)
-
-#define LOG_ASSERT(condition)  \
-  LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-#define SYSLOG_ASSERT(condition) \
-  SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-
-// CHECK dies with a fatal error if condition is not true.  It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode.  Therefore, it is safe to do things like:
-//    CHECK(fp->Write(x) == 4)
-#define CHECK(condition)  \
-      LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-             << "Check failed: " #condition " "
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
-  CheckOpString(std::string* str) : str_(str) { }
-  // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
-  // so there's no point in cleaning up str_.
-  operator bool() const {
-    return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
-  }
-  std::string* str_;
-};
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// CHECK* macros. It's not encouraged though.
-template <class T>
-inline const T&       GetReferenceableValue(const T&           t) { return t; }
-inline char           GetReferenceableValue(char               t) { return t; }
-inline unsigned char  GetReferenceableValue(unsigned char      t) { return t; }
-inline signed char    GetReferenceableValue(signed char        t) { return t; }
-inline short          GetReferenceableValue(short              t) { return t; }
-inline unsigned short GetReferenceableValue(unsigned short     t) { return t; }
-inline int            GetReferenceableValue(int                t) { return t; }
-inline unsigned int   GetReferenceableValue(unsigned int       t) { return t; }
-inline long           GetReferenceableValue(long               t) { return t; }
-inline unsigned long  GetReferenceableValue(unsigned long      t) { return t; }
-inline long long      GetReferenceableValue(long long          t) { return t; }
-inline unsigned long long GetReferenceableValue(unsigned long long t) {
-  return t;
-}
-
-// This is a dummy class to define the following operator.
-struct DummyClassToDefineOperator {};
-
-}
-
-// Define global operator<< to declare using ::operator<<.
-// This declaration will allow use to use CHECK macros for user
-// defined classes which have operator<< (e.g., stl_logging.h).
-inline std::ostream& operator<<(
-    std::ostream& out, const google::DummyClassToDefineOperator&) {
-  return out;
-}
-
-namespace google {
-
-// Build the error message string.
-template<class t1, class t2>
-std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
-  // It means that we cannot use stl_logging if compiler doesn't
-  // support using expression for operator.
-  // TODO(hamaji): Figure out a way to fix.
-#if 1
-  using ::operator<<;
-#endif
-  std::strstream ss;
-  ss << names << " (" << v1 << " vs. " << v2 << ")";
-  return new std::string(ss.str(), ss.pcount());
-}
-
-// Helper functions for CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
-  template <class t1, class t2> \
-  inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
-                                        const char* names) { \
-    if (v1 op v2) return NULL; \
-    else return MakeCheckOpString(v1, v2, names); \
-  } \
-  inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
-    return Check##name##Impl<int, int>(v1, v2, names); \
-  }
-
-// Use _EQ, _NE, _LE, etc. in case the file including base/logging.h
-// provides its own #defines for the simpler names EQ, NE, LE, etc.
-// This happens if, for example, those are used as token names in a
-// yacc grammar.
-DEFINE_CHECK_OP_IMPL(_EQ, ==)
-DEFINE_CHECK_OP_IMPL(_NE, !=)
-DEFINE_CHECK_OP_IMPL(_LE, <=)
-DEFINE_CHECK_OP_IMPL(_LT, < )
-DEFINE_CHECK_OP_IMPL(_GE, >=)
-DEFINE_CHECK_OP_IMPL(_GT, > )
-#undef DEFINE_CHECK_OP_IMPL
-
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-
-#if defined(STATIC_ANALYSIS)
-// Only for static analysis tool to know that it is equivalent to assert
-#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
-// In debug mode, avoid constructing CheckOpStrings if possible,
-// to reduce the overhead of CHECK statments by 2x.
-// Real DCHECK-heavy tests have seen 1.5x speedups.
-
-// The meaning of "string" might be different between now and 
-// when this macro gets invoked (e.g., if someone is experimenting
-// with other string implementations that get defined after this
-// file is included).  Save the current meaning now and use it 
-// in the macro.
-typedef std::string _Check_string;
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::_Check_string* _result =                \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__,                                             \
-        google::CheckOpString(_result)).stream()
-#else
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::CheckOpString _result =                 \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__, _result).stream()
-#endif  // STATIC_ANALYSIS, !NDEBUG
-
-#if GOOGLE_STRIP_LOG <= 3
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
-#else
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::NullStreamFatal)
-#endif // STRIP_LOG <= 3
-
-// Equality/Inequality checks - compare two values, and log a FATAL message
-// including the two values when the result is not as expected.  The values
-// must have operator<<(ostream, ...) defined.
-//
-// You may append to the error message like so:
-//   CHECK_NE(1, 2) << ": The world must be ending!";
-//
-// We are very careful to ensure that each argument is evaluated exactly
-// once, and that anything which is legal to pass as a function argument is
-// legal here.  In particular, the arguments may be temporary expressions
-// which will end up being destroyed at the end of the apparent statement,
-// for example:
-//   CHECK_EQ(string("abc")[1], 'b');
-//
-// WARNING: These don't compile correctly if one of the arguments is a pointer
-// and the other is NULL. To work around this, simply static_cast NULL to the
-// type of the desired pointer.
-
-#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
-
-// Check that the input is non NULL.  This very useful in constructor
-// initializer lists.
-
-#define CHECK_NOTNULL(val) \
-  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
-  GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
-      const char* s1, const char* s2, const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
-  while (google::CheckOpString _result = \
-         google::Check##func##expected##Impl((s1), (s2), \
-                                     #s1 " " #op " " #s2)) \
-    LOG(FATAL) << *_result.str_
-
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_DOUBLE_EQ(val1, val2)              \
-  do {                                           \
-    CHECK_LE((val1), (val2)+0.000000000000001L); \
-    CHECK_GE((val1), (val2)-0.000000000000001L); \
-  } while (0)
-
-#define CHECK_NEAR(val1, val2, margin)           \
-  do {                                           \
-    CHECK_LE((val1), (val2)+(margin));           \
-    CHECK_GE((val1), (val2)-(margin));           \
-  } while (0)
-
-// perror()..googly style!
-//
-// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and
-// CHECK equivalents with the addition that they postpend a description
-// of the current state of errno to their output lines.
-
-#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream()
-
-#define GOOGLE_PLOG(severity, counter)  \
-  google::ErrnoLogMessage( \
-      __FILE__, __LINE__, google::severity, counter, \
-      &google::LogMessage::SendToLog)
-
-#define PLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & PLOG(severity)
-
-// A CHECK() macro that postpends errno if the condition is false. E.g.
-//
-// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... }
-#define PCHECK(condition)  \
-      PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-              << "Check failed: " #condition " "
-
-// A CHECK() macro that lets you assert the success of a function that
-// returns -1 and sets errno in case of an error. E.g.
-//
-// CHECK_ERR(mkdir(path, 0700));
-//
-// or
-//
-// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename;
-#define CHECK_ERR(invocation)                                          \
-PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1))    \
-        << #invocation
-
-// Use macro expansion to create, for each use of LOG_EVERY_N(), static
-// variables with the __LINE__ expansion as part of the variable name.
-#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line)
-#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line
-
-#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__)
-#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__)
-
-#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (condition && \
-      ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-                 &what_to_do).stream()
-
-#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::ErrnoLogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0; \
-  if (LOG_OCCURRENCES <= n) \
-    ++LOG_OCCURRENCES; \
-  if (LOG_OCCURRENCES <= n) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-namespace glog_internal_namespace_ {
-template <bool>
-struct CompileAssert {
-};
-struct CrashReason;
-}  // namespace glog_internal_namespace_
-
-#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
-  typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
-#define LOG_EVERY_N(severity, n)                                        \
-  GOOGLE_GLOG_COMPILE_ASSERT(google::severity <          \
-                             google::NUM_SEVERITIES,     \
-                             INVALID_REQUESTED_LOG_SEVERITY);           \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define SYSLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToSyslogAndLog)
-
-#define PLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_PLOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_FIRST_N(severity, n) \
-  SOME_KIND_OF_LOG_FIRST_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_IF_EVERY_N(severity, condition, n) \
-  SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), google::LogMessage::SendToLog)
-
-// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
-enum PRIVATE_Counter {COUNTER};
-
-
-// Plus some debug-logging macros that get compiled to nothing for production
-
-#ifndef NDEBUG
-
-#define DLOG(severity) LOG(severity)
-#define DVLOG(verboselevel) VLOG(verboselevel)
-#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
-#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  LOG_IF_EVERY_N(severity, condition, n)
-#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-
-// debug-only checking.  not executed in NDEBUG mode.
-#define DCHECK(condition) CHECK(condition)
-#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
-#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
-#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
-#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
-#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
-#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
-#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
-#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
-#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
-#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
-#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-
-#else  // NDEBUG
-
-#define DLOG(severity) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DVLOG(verboselevel) \
-  (true || !VLOG_IS_ON(verboselevel)) ?\
-    (void) 0 : google::LogMessageVoidify() & LOG(INFO)
-
-#define DLOG_IF(severity, condition) \
-  (true || !(condition)) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_EVERY_N(severity, n) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  (true || !(condition))? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_ASSERT(condition) \
-  true ? (void) 0 : LOG_ASSERT(condition)
-
-#define DCHECK(condition) \
-  while (false) \
-    CHECK(condition)
-
-#define DCHECK_EQ(val1, val2) \
-  while (false) \
-    CHECK_EQ(val1, val2)
-
-#define DCHECK_NE(val1, val2) \
-  while (false) \
-    CHECK_NE(val1, val2)
-
-#define DCHECK_LE(val1, val2) \
-  while (false) \
-    CHECK_LE(val1, val2)
-
-#define DCHECK_LT(val1, val2) \
-  while (false) \
-    CHECK_LT(val1, val2)
-
-#define DCHECK_GE(val1, val2) \
-  while (false) \
-    CHECK_GE(val1, val2)
-
-#define DCHECK_GT(val1, val2) \
-  while (false) \
-    CHECK_GT(val1, val2)
-
-#define DCHECK_NOTNULL(val) (val)
-
-#define DCHECK_STREQ(str1, str2) \
-  while (false) \
-    CHECK_STREQ(str1, str2)
-
-#define DCHECK_STRCASEEQ(str1, str2) \
-  while (false) \
-    CHECK_STRCASEEQ(str1, str2)
-
-#define DCHECK_STRNE(str1, str2) \
-  while (false) \
-    CHECK_STRNE(str1, str2)
-
-#define DCHECK_STRCASENE(str1, str2) \
-  while (false) \
-    CHECK_STRCASENE(str1, str2)
-
-
-#endif  // NDEBUG
-
-// Log only in verbose mode.
-
-#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
-
-#define VLOG_IF(verboselevel, condition) \
-  LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel))
-
-#define VLOG_EVERY_N(verboselevel, n) \
-  LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
-
-#define VLOG_IF_EVERY_N(verboselevel, condition, n) \
-  LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n)
-
-//
-// This class more or less represents a particular log message.  You
-// create an instance of LogMessage and then stream stuff to it.
-// When you finish streaming to it, ~LogMessage is called and the
-// full message gets streamed to the appropriate destination.
-//
-// You shouldn't actually use LogMessage's constructor to log things,
-// though.  You should use the LOG() macro (and variants thereof)
-// above.
-class GOOGLE_GLOG_DLL_DECL LogMessage {
-public:
-  enum {
-    // Passing kNoLogPrefix for the line number disables the
-    // log-message prefix. Useful for using the LogMessage
-    // infrastructure as a printing utility. See also the --log_prefix
-    // flag for controlling the log-message prefix on an
-    // application-wide basis.
-    kNoLogPrefix = -1
-  };
-
-  // LogStream inherit from non-DLL-exported class (std::ostrstream)
-  // and VC++ produces a warning for this situation.
-  // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
-  // 2005 if you are deriving from a type in the Standard C++ Library"
-  // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-  // Let's just ignore the warning.
-#ifdef _MSC_VER
-# pragma warning(disable: 4275)
-#endif
-  class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostrstream {
-#ifdef _MSC_VER
-# pragma warning(default: 4275)
-#endif
-  public:
-    LogStream(char *buf, int len, int ctr)
-      : ostrstream(buf, len),
-        ctr_(ctr) {
-      self_ = this;
-    }
-
-    int ctr() const { return ctr_; }
-    void set_ctr(int ctr) { ctr_ = ctr; }
-    LogStream* self() const { return self_; }
-
-  private:
-    int ctr_;  // Counter hack (for the LOG_EVERY_X() macro)
-    LogStream *self_;  // Consistency check hack
-  };
-
-public:
-  // icc 8 requires this typedef to avoid an internal compiler error.
-  typedef void (LogMessage::*SendMethod)();
-
-  LogMessage(const char* file, int line, LogSeverity severity, int ctr,
-             SendMethod send_method);
-
-  // Two special constructors that generate reduced amounts of code at
-  // LOG call sites for common cases.
-
-  // Used for LOG(INFO): Implied are:
-  // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog.
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 19 bytes per call site.
-  LogMessage(const char* file, int line);
-
-  // Used for LOG(severity) where severity != INFO.  Implied
-  // are: ctr = 0, send_method = &LogMessage::SendToLog
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 17 bytes per call site.
-  LogMessage(const char* file, int line, LogSeverity severity);
-
-  // Constructor to log this message to a specified sink (if not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
-  // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
-  LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
-             bool also_send_to_log);
-
-  // Constructor where we also give a vector<string> pointer
-  // for storing the messages (if the pointer is not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::vector<std::string>* outvec);
-
-  // Constructor where we also give a string pointer for storing the
-  // message (if the pointer is not NULL).  Implied are: ctr = 0,
-  // send_method = &LogMessage::WriteToStringAndLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::string* message);
-
-  // A special constructor used for check failures
-  LogMessage(const char* file, int line, const CheckOpString& result);
-
-  ~LogMessage();
-
-  // Flush a buffered message to the sink set in the constructor.  Always
-  // called by the destructor, it may also be called from elsewhere if
-  // needed.  Only the first call is actioned; any later ones are ignored.
-  void Flush();
-
-  // An arbitrary limit on the length of a single log message.  This
-  // is so that streaming can be done more efficiently.
-  static const size_t kMaxLogMessageLen;
-
-  // Theses should not be called directly outside of logging.*,
-  // only passed as SendMethod arguments to other LogMessage methods:
-  void SendToLog();  // Actually dispatch to the logs
-  void SendToSyslogAndLog();  // Actually dispatch to syslog and the logs
-
-  // Call abort() or similar to perform LOG(FATAL) crash.
-  static void Fail() __attribute__ ((noreturn));
-
-  std::ostream& stream() { return *(data_->stream_); }
-
-  int preserved_errno() const { return data_->preserved_errno_; }
-
-  // Must be called without the log_mutex held.  (L < log_mutex)
-  static int64 num_messages(int severity);
-
-private:
-  // Fully internal SendMethod cases:
-  void SendToSinkAndLog();  // Send to sink if provided and dispatch to the logs
-  void SendToSink();  // Send to sink if provided, do nothing otherwise.
-
-  // Write to string if provided and dispatch to the logs.
-  void WriteToStringAndLog();
-
-  void SaveOrSendToLog();  // Save to stringvec if provided, else to logs
-
-  void Init(const char* file, int line, LogSeverity severity,
-            void (LogMessage::*send_method)());
-
-  // Used to fill in crash information during LOG(FATAL) failures.
-  void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
-
-  // Counts of messages sent at each priority:
-  static int64 num_messages_[NUM_SEVERITIES];  // under log_mutex
-
-  // We keep the data in a separate struct so that each instance of
-  // LogMessage uses less stack space.
-  struct GOOGLE_GLOG_DLL_DECL LogMessageData {
-    LogMessageData() {};
-
-    int preserved_errno_;      // preserved errno
-    char* buf_;
-    char* message_text_;  // Complete message text (points to selected buffer)
-    LogStream* stream_alloc_;
-    LogStream* stream_;
-    char severity_;      // What level is this LogMessage logged at?
-    int line_;                 // line number where logging call is.
-    void (LogMessage::*send_method_)();  // Call this in destructor to send
-    union {  // At most one of these is used: union to keep the size low.
-      LogSink* sink_;             // NULL or sink to send message to
-      std::vector<std::string>* outvec_; // NULL or vector to push message onto
-      std::string* message_;             // NULL or string to write message into
-    };
-    time_t timestamp_;            // Time of creation of LogMessage
-    struct ::tm tm_time_;         // Time of creation of LogMessage
-    size_t num_prefix_chars_;     // # of chars of prefix in this message
-    size_t num_chars_to_log_;     // # of chars of msg to send to log
-    size_t num_chars_to_syslog_;  // # of chars of msg to send to syslog
-    const char* basename_;        // basename of file that called LOG
-    const char* fullname_;        // fullname of file that called LOG
-    bool has_been_flushed_;       // false => data has not been flushed
-    bool first_fatal_;            // true => this was first fatal msg
-
-    ~LogMessageData();
-   private:
-    LogMessageData(const LogMessageData&);
-    void operator=(const LogMessageData&);
-  };
-
-  static LogMessageData fatal_msg_data_exclusive_;
-  static LogMessageData fatal_msg_data_shared_;
-
-  LogMessageData* allocated_;
-  LogMessageData* data_;
-
-  friend class LogDestination;
-
-  LogMessage(const LogMessage&);
-  void operator=(const LogMessage&);
-};
-
-// This class happens to be thread-hostile because all instances share
-// a single data buffer, but since it can only be created just before
-// the process dies, we don't worry so much.
-class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
- public:
-  LogMessageFatal(const char* file, int line);
-  LogMessageFatal(const char* file, int line, const CheckOpString& result);
-  ~LogMessageFatal() __attribute__ ((noreturn));
-};
-
-// A non-macro interface to the log facility; (useful
-// when the logging level is not a compile-time constant).
-inline void LogAtLevel(int const severity, std::string const &msg) {
-  LogMessage(__FILE__, __LINE__, severity).stream() << msg;
-}
-
-// A macro alternative of LogAtLevel. New code may want to use this
-// version since there are two advantages: 1. this version outputs the
-// file name and the line number where this macro is put like other
-// LOG macros, 2. this macro can be used as C++ stream.
-#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
-
-// A small helper for CHECK_NOTNULL().
-template <typename T>
-T* CheckNotNull(const char *file, int line, const char *names, T* t) {
-  if (t == NULL) {
-    LogMessageFatal(file, line, new std::string(names));
-  }
-  return t;
-}
-
-// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
-// only works if ostream is a LogStream. If the ostream is not a
-// LogStream you'll get an assert saying as much at runtime.
-GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
-                                              const PRIVATE_Counter&);
-
-
-// Derived class for PLOG*() above.
-class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
- public:
-
-  ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
-                  void (LogMessage::*send_method)());
-
-  // Postpends ": strerror(errno) [errno]".
-  ~ErrnoLogMessage();
-
- private:
-  ErrnoLogMessage(const ErrnoLogMessage&);
-  void operator=(const ErrnoLogMessage&);
-};
-
-
-// This class is used to explicitly ignore values in the conditional
-// logging macros.  This avoids compiler warnings like "value computed
-// is not used" and "statement has no effect".
-
-class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
- public:
-  LogMessageVoidify() { }
-  // This has to be an operator with a precedence lower than << but
-  // higher than ?:
-  void operator&(std::ostream&) { }
-};
-
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level. Thread-hostile because it ignores
-// locking -- used for catastrophic failures.
-GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
-
-//
-// Set the destination to which a particular severity level of log
-// messages is sent.  If base_filename is "", it means "don't log this
-// severity".  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
-                                            const char* base_filename);
-
-//
-// Set the basename of the symlink to the latest log file at a given
-// severity.  If symlink_basename is empty, do not make a symlink.  If
-// you don't call this function, the symlink basename is the
-// invocation name of the program.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
-                                        const char* symlink_basename);
-
-//
-// Used to send logs to some other kind of destination
-// Users should subclass LogSink and override send to do whatever they want.
-// Implementations must be thread-safe because a shared instance will
-// be called from whichever thread ran the LOG(XXX) line.
-class GOOGLE_GLOG_DLL_DECL LogSink {
- public:
-  virtual ~LogSink();
-
-  // Sink's logging logic (message_len is such as to exclude '\n' at the end).
-  // This method can't use LOG() or CHECK() as logging system mutex(s) are held
-  // during this call.
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct ::tm* tm_time,
-                    const char* message, size_t message_len) = 0;
-
-  // Redefine this to implement waiting for
-  // the sink's logging logic to complete.
-  // It will be called after each send() returns,
-  // but before that LogMessage exits or crashes.
-  // By default this function does nothing.
-  // Using this function one can implement complex logic for send()
-  // that itself involves logging; and do all this w/o causing deadlocks and
-  // inconsistent rearrangement of log messages.
-  // E.g. if a LogSink has thread-specific actions, the send() method
-  // can simply add the message to a queue and wake up another thread that
-  // handles real logging while itself making some LOG() calls;
-  // WaitTillSent() can be implemented to wait for that logic to complete.
-  // See our unittest for an example.
-  virtual void WaitTillSent();
-
-  // Returns the normal text output of the log message.
-  // Can be useful to implement send().
-  static std::string ToString(LogSeverity severity, const char* file, int line,
-                              const struct ::tm* tm_time,
-                              const char* message, size_t message_len);
-};
-
-// Add or remove a LogSink as a consumer of logging data.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
-GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
-
-//
-// Specify an "extension" added to the filename specified via
-// SetLogDestination.  This applies to all severity levels.  It's
-// often used to append the port we're listening on to the logfile
-// name.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
-    const char* filename_extension);
-
-//
-// Make it so that all log messages of at least a particular severity
-// are logged to stderr (in addition to logging to the usual log
-// file(s)).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
-
-//
-// Make it so that all log messages go only to stderr.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
-//
-// Make it so that all log messages of at least a particular severity are
-// logged via email to a list of addresses (in addition to logging to the
-// usual log file(s)).  The list of addresses is just a string containing
-// the email addresses to send to (separated by spaces, say).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
-                                          const char* addresses);
-
-// A simple function that sends email. dest is a commma-separated
-// list of addressess.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
-                                    const char *subject, const char *body);
-
-GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
-
-// For tests only:  Clear the internal [cached] list of logging directories to
-// force a refresh the next time GetLoggingDirectories is called.
-// Thread-hostile.
-void TestOnly_ClearLoggingDirectoriesList();
-
-// Returns a set of existing temporary directories, which will be a
-// subset of the directories returned by GetLogginDirectories().
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
-    std::vector<std::string>* list);
-
-// Print any fatal message again -- useful to call from signal handler
-// so that the last thing in the output is the fatal message.
-// Thread-hostile, but a race is unlikely.
-GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
-
-// Truncate a log file that may be the append-only output of multiple
-// processes and hence can't simply be renamed/reopened (typically a
-// stdout/stderr).  If the file "path" is > "limit" bytes, copy the
-// last "keep" bytes to offset 0 and truncate the rest. Since we could
-// be racing with other writers, this approach has the potential to
-// lose very small amounts of data. For security, only follow symlinks
-// if the path is /proc/self/fd/*
-GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
-                                          int64 limit, int64 keep);
-
-// Truncate stdout and stderr if they are over the value specified by
-// --max_log_size; keep the final 1MB.  This function has the same
-// race condition as TruncateLogFile.
-GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
-
-// Return the string representation of the provided LogSeverity level.
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
-
-// ---------------------------------------------------------------------
-// Implementation details that are not useful to most clients
-// ---------------------------------------------------------------------
-
-// A Logger is the interface used by logging modules to emit entries
-// to a log.  A typical implementation will dump formatted data to a
-// sequence of files.  We also provide interfaces that will forward
-// the data to another thread so that the invoker never blocks.
-// Implementations should be thread-safe since the logging system
-// will write to them from multiple threads.
-
-namespace base {
-
-class GOOGLE_GLOG_DLL_DECL Logger {
- public:
-  virtual ~Logger();
-
-  // Writes "message[0,message_len-1]" corresponding to an event that
-  // occurred at "timestamp".  If "force_flush" is true, the log file
-  // is flushed immediately.
-  //
-  // The input message has already been formatted as deemed
-  // appropriate by the higher level logging facility.  For example,
-  // textual log messages already contain timestamps, and the
-  // file:linenumber header.
-  virtual void Write(bool force_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int message_len) = 0;
-
-  // Flush any buffered messages
-  virtual void Flush() = 0;
-
-  // Get the current LOG file size.
-  // The returned value is approximate since some
-  // logged data may not have been flushed to disk yet.
-  virtual uint32 LogSize() = 0;
-};
-
-// Get the logger for the specified severity level.  The logger
-// remains the property of the logging module and should not be
-// deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
-
-// Set the logger for the specified severity level.  The logger
-// becomes the property of the logging module and should not
-// be deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
-
-}
-
-// glibc has traditionally implemented two incompatible versions of
-// strerror_r(). There is a poorly defined convention for picking the
-// version that we want, but it is not clear whether it even works with
-// all versions of glibc.
-// So, instead, we provide this wrapper that automatically detects the
-// version that is in use, and then implements POSIX semantics.
-// N.B. In addition to what POSIX says, we also guarantee that "buf" will
-// be set to an empty string, if this function failed. This means, in most
-// cases, you do not need to check the error code and you can directly
-// use the value of "buf". It will never have an undefined value.
-GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
-
-
-// A class for which we define operator<<, which does nothing.
-class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
- public:
-  // Initialize the LogStream so the messages can be written somewhere
-  // (they'll never be actually displayed). This will be needed if a
-  // NullStream& is implicitly converted to LogStream&, in which case
-  // the overloaded NullStream::operator<< will not be invoked.
-  NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream(const char* /*file*/, int /*line*/,
-             const CheckOpString& /*result*/) :
-      LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream &stream() { return *this; }
- private:
-  // A very short buffer for messages (which we discard anyway). This
-  // will be needed if NullStream& converted to LogStream& (e.g. as a
-  // result of a conditional expression).
-  char message_buffer_[2];
-};
-
-// Do nothing. This operator is inline, allowing the message to be
-// compiled away. The message will not be compiled away if we do
-// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when
-// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly
-// converted to LogStream and the message will be computed and then
-// quietly discarded.
-template<class T>
-inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
-
-// Similar to NullStream, but aborts the program (without stack
-// trace), like LogMessageFatal.
-class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
- public:
-  NullStreamFatal() { }
-  NullStreamFatal(const char* file, int line, const CheckOpString& result) :
-      NullStream(file, line, result) { }
-  __attribute__ ((noreturn)) ~NullStreamFatal() { _exit(1); }
-};
-
-// Install a signal handler that will dump signal information and a stack
-// trace when the program crashes on certain signals.  We'll install the
-// signal handler for the following signals.
-//
-// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
-//
-// By default, the signal handler will write the failure dump to the
-// standard error.  You can customize the destination by installing your
-// own writer function by InstallFailureWriter() below.
-//
-// Note on threading:
-//
-// The function should be called before threads are created, if you want
-// to use the failure signal handler for all threads.  The stack trace
-// will be shown only for the thread that receives the signal.  In other
-// words, stack traces of other threads won't be shown.
-GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
-
-// Installs a function that is used for writing the failure dump.  "data"
-// is the pointer to the beginning of a message to be written, and "size"
-// is the size of the message.  You should not expect the data is
-// terminated with '\0'.
-GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
-    void (*writer)(const char* data, int size));
-
-}
-
-#endif // _LOGGING_H_

+ 0 - 185
Src/ThirdParty/glog/raw_logging.h

@@ -1,185 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// Thread-safe logging routines that do not allocate any memory or
-// acquire any locks, and can therefore be used by low-level memory
-// allocation and synchronization code.
-
-#ifndef BASE_RAW_LOGGING_H_
-#define BASE_RAW_LOGGING_H_
-
-#include <time.h>
-
-namespace google {
-
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// This is similar to LOG(severity) << format... and VLOG(level) << format..,
-// but
-// * it is to be used ONLY by low-level modules that can't use normal LOG()
-// * it is desiged to be a low-level logger that does not allocate any
-//   memory and does not need any locks, hence:
-// * it logs straight and ONLY to STDERR w/o buffering
-// * it uses an explicit format and arguments list
-// * it will silently chop off really long message strings
-// Usage example:
-//   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
-//   RAW_VLOG(3, "status is %i", status);
-// These will print an almost standard log lines like this to stderr only:
-//   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
-//   I0821 211317 file.cc:142] RAW: status is 20
-#define RAW_LOG(severity, ...) \
-  do { \
-    switch (google::severity) {  \
-      case 0: \
-        RAW_LOG_INFO(__VA_ARGS__); \
-        break; \
-      case 1: \
-        RAW_LOG_WARNING(__VA_ARGS__); \
-        break; \
-      case 2: \
-        RAW_LOG_ERROR(__VA_ARGS__); \
-        break; \
-      case 3: \
-        RAW_LOG_FATAL(__VA_ARGS__); \
-        break; \
-      default: \
-        break; \
-    } \
-  } while (0)
-
-// The following STRIP_LOG testing is performed in the header file so that it's
-// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0
-#define RAW_VLOG(verboselevel, ...) \
-  do { \
-    if (VLOG_IS_ON(verboselevel)) { \
-      RAW_LOG_INFO(__VA_ARGS__); \
-    } \
-  } while (0)
-#else
-#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
-                                   __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING,   \
-                                      __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 1
-
-#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 2
-
-#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_FATAL(...) \
-  do { \
-    google::RawLogStub__(0, __VA_ARGS__);        \
-    exit(1); \
-  } while (0)
-#endif // STRIP_LOG <= 3
-
-// Similar to CHECK(condition) << message,
-// but for low-level modules: we use only RAW_LOG that does not allocate memory.
-// We do not want to provide args list here to encourage this usage:
-//   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
-// so that the args are not computed when not needed.
-#define RAW_CHECK(condition, message)                                   \
-  do {                                                                  \
-    if (!(condition)) {                                                 \
-      RAW_LOG(FATAL, "Check %s failed: %s", #condition, message);       \
-    }                                                                   \
-  } while (0)
-
-// Debug versions of RAW_LOG and RAW_CHECK
-#ifndef NDEBUG
-
-#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
-
-#else  // NDEBUG
-
-#define RAW_DLOG(severity, ...)                                 \
-  while (false)                                                 \
-    RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) \
-  while (false) \
-    RAW_CHECK(condition, message)
-
-#endif  // NDEBUG
-
-// Stub log function used to work around for unused variable warnings when
-// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int ignored, ...) {
-}
-
-// Helper function to implement RAW_LOG and RAW_VLOG
-// Logs format... at "severity" level, reporting it
-// as called from file:line.
-// This does not allocate memory or acquire locks.
-GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
-                                   const char* file,
-                                   int line,
-                                   const char* format, ...)
-   __attribute__((__format__ (__printf__, 4, 5)));
-
-// Hack to propagate time information into this module so that
-// this module does not have to directly call localtime_r(),
-// which could allocate memory.
-GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
-
-}
-
-#endif  // BASE_RAW_LOGGING_H_

+ 0 - 132
Src/ThirdParty/glog/src/base/commandlineflags.h

@@ -1,132 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// This file is a compatibility layer that defines Google's version of
-// command line flags that are used for configuration.
-//
-// We put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the
-// current namespace.  The net result is to force people to use
-// DECLARE to get access to a flag, rather than saying
-//   extern bool FLAGS_logtostderr;
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want,
-// and make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-#ifndef BASE_COMMANDLINEFLAGS_H__
-#define BASE_COMMANDLINEFLAGS_H__
-
-#include "config.h"
-#include <string>
-#include <string.h>               // for memchr
-#include <stdlib.h>               // for getenv
-
-#ifdef HAVE_LIB_GFLAGS
-
-#include <gflags/gflags.h>
-
-#else
-
-#include "glog/logging.h"
-
-#define DECLARE_VARIABLE(type, name, tn)                                      \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                              \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
-#define DEFINE_VARIABLE(type, name, value, meaning, tn) \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead {  \
-  GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value);                              \
-  char FLAGS_no##name;                                                        \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, name, bool)
-#define DEFINE_bool(name, value, meaning) \
-  DEFINE_VARIABLE(bool, name, value, meaning, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, name, int32)
-#define DEFINE_int32(name, value, meaning) \
-  DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, name, value, meaning, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                          \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name;                       \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
-#define DEFINE_string(name, value, meaning)                                   \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead {  \
-  GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name(value);                       \
-  char FLAGS_no##name;                                                        \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
-
-#endif  // HAVE_LIB_GFLAGS
-
-// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
-// have GLOG_* environ variables even if we have gflags installed.
-//
-// If both an environment variable and a flag are specified, the value
-// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the
-// verbosity will be 1, not 0.
-
-#define GLOG_DEFINE_bool(name, value, meaning) \
-  DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_int32(name, value, meaning) \
-  DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_string(name, value, meaning) \
-  DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
-
-// These macros (could be functions, but I don't want to bother with a .cc
-// file), make it easier to initialize flags from the environment.
-
-#define EnvToString(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : getenv(envname))
-
-#define EnvToBool(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
-
-#define EnvToInt(envname, dflt)  \
-  (!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
-
-#endif  // BASE_COMMANDLINEFLAGS_H__

+ 0 - 51
Src/ThirdParty/glog/src/base/googleinit.h

@@ -1,51 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Jacob Hoffman-Andrews
-
-#ifndef _GOOGLEINIT_H
-#define _GOOGLEINIT_H
-
-class GoogleInitializer {
- public:
-  typedef void (*void_function)(void);
-  GoogleInitializer(const char* name, void_function f) {
-    f();
-  }
-};
-
-#define REGISTER_MODULE_INITIALIZER(name, body)                 \
-  namespace {                                                   \
-    static void google_init_module_##name () { body; }          \
-    GoogleInitializer google_initializer_module_##name(#name,   \
-            google_init_module_##name);                         \
-  }
-
-#endif /* _GOOGLEINIT_H */

+ 0 - 325
Src/ThirdParty/glog/src/base/mutex.h

@@ -1,325 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-// ---
-// Author: Craig Silverstein.
-//
-// A simple mutex wrapper, supporting locks and read-write locks.
-// You should assume the locks are *not* re-entrant.
-//
-// To use: you should define the following macros in your configure.ac:
-//   ACX_PTHREAD
-//   AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
-// This class is meant to be internal-only and should be wrapped by an
-// internal namespace.  Before you use this module, please give the
-// name of your internal namespace for this module.  Or, if you want
-// to expose it, you'll want to move it to the Google namespace.  We
-// cannot put this class in global namespace because there can be some
-// problems when we have multiple versions of Mutex in each shared object.
-//
-// NOTE: by default, we have #ifdef'ed out the TryLock() method.
-//       This is for two reasons:
-// 1) TryLock() under Windows is a bit annoying (it requires a
-//    #define to be defined very early).
-// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
-//    mode.
-// If you need TryLock(), and either these two caveats are not a
-// problem for you, or you're willing to work around them, then
-// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
-// in the code below.
-//
-// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
-//    http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
-// Because of that, we might as well use windows locks for
-// cygwin.  They seem to be more reliable than the cygwin pthreads layer.
-//
-// TRICKY IMPLEMENTATION NOTE:
-// This class is designed to be safe to use during
-// dynamic-initialization -- that is, by global constructors that are
-// run before main() starts.  The issue in this case is that
-// dynamic-initialization happens in an unpredictable order, and it
-// could be that someone else's dynamic initializer could call a
-// function that tries to acquire this mutex -- but that all happens
-// before this mutex's constructor has run.  (This can happen even if
-// the mutex and the function that uses the mutex are in the same .cc
-// file.)  Basically, because Mutex does non-trivial work in its
-// constructor, it's not, in the naive implementation, safe to use
-// before dynamic initialization has run on it.
-//
-// The solution used here is to pair the actual mutex primitive with a
-// bool that is set to true when the mutex is dynamically initialized.
-// (Before that it's false.)  Then we modify all mutex routines to
-// look at the bool, and not try to lock/unlock until the bool makes
-// it to true (which happens after the Mutex constructor has run.)
-//
-// This works because before main() starts -- particularly, during
-// dynamic initialization -- there are no threads, so a) it's ok that
-// the mutex operations are a no-op, since we don't need locking then
-// anyway; and b) we can be quite confident our bool won't change
-// state between a call to Lock() and a call to Unlock() (that would
-// require a global constructor in one translation unit to call Lock()
-// and another global constructor in another translation unit to call
-// Unlock() later, which is pretty perverse).
-//
-// That said, it's tricky, and can conceivably fail; it's safest to
-// avoid trying to acquire a mutex in a global constructor, if you
-// can.  One way it can fail is that a really smart compiler might
-// initialize the bool to true at static-initialization time (too
-// early) rather than at dynamic-initialization time.  To discourage
-// that, we set is_safe_ to true in code (not the constructor
-// colon-initializer) and set it to true via a function that always
-// evaluates to true, but that the compiler can't know always
-// evaluates to true.  This should be good enough.
-
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
-
-#include "config.h"           // to figure out pthreads support
-
-#if defined(NO_THREADS)
-  typedef int MutexType;      // to keep a lock-count
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# define WIN32_LEAN_AND_MEAN  // We only need minimal includes
-# ifdef GMUTEX_TRYLOCK
-  // We need Windows NT or later for TryEnterCriticalSection().  If you
-  // don't need that functionality, you can remove these _WIN32_WINNT
-  // lines, and change TryLock() to assert(0) or something.
-#   ifndef _WIN32_WINNT
-#     define _WIN32_WINNT 0x0400
-#   endif
-# endif
-// To avoid macro definition of ERROR.
-# define NOGDI
-// To avoid macro definition of min/max.
-# define NOMINMAX
-# include <windows.h>
-  typedef CRITICAL_SECTION MutexType;
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-  // Needed for pthread_rwlock_*.  If it causes problems, you could take it
-  // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
-  // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
-  // for locking there.)
-# ifdef __linux__
-#   define _XOPEN_SOURCE 500  // may be needed to get the rwlock calls
-# endif
-# include <pthread.h>
-  typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
-# include <pthread.h>
-  typedef pthread_mutex_t MutexType;
-#else
-# error Need to implement mutex.h for your architecture, or #define NO_THREADS
-#endif
-
-// We need to include these header files after defining _XOPEN_SOURCE
-// as they may define the _XOPEN_SOURCE macro.
-#include <assert.h>
-#include <stdlib.h>      // for abort()
-
-#define MUTEX_NAMESPACE glog_internal_namespace_
-
-namespace MUTEX_NAMESPACE {
-
-class Mutex {
- public:
-  // Create a Mutex that is not held by anybody.  This constructor is
-  // typically used for Mutexes allocated on the heap or the stack.
-  // See below for a recommendation for constructing global Mutex
-  // objects.
-  inline Mutex();
-
-  // Destructor
-  inline ~Mutex();
-
-  inline void Lock();    // Block if needed until free then acquire exclusively
-  inline void Unlock();  // Release a lock acquired via Lock()
-#ifdef GMUTEX_TRYLOCK
-  inline bool TryLock(); // If free, Lock() and return true, else return false
-#endif
-  // Note that on systems that don't support read-write locks, these may
-  // be implemented as synonyms to Lock() and Unlock().  So you can use
-  // these for efficiency, but don't use them anyplace where being able
-  // to do shared reads is necessary to avoid deadlock.
-  inline void ReaderLock();   // Block until free or shared then acquire a share
-  inline void ReaderUnlock(); // Release a read share of this Mutex
-  inline void WriterLock() { Lock(); }     // Acquire an exclusive lock
-  inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
-
-  // TODO(hamaji): Do nothing, implement correctly.
-  inline void AssertHeld() {}
-
- private:
-  MutexType mutex_;
-  // We want to make sure that the compiler sets is_safe_ to true only
-  // when we tell it to, and never makes assumptions is_safe_ is
-  // always true.  volatile is the most reliable way to do that.
-  volatile bool is_safe_;
-
-  inline void SetIsSafe() { is_safe_ = true; }
-
-  // Catch the error of writing Mutex when intending MutexLock.
-  Mutex(Mutex* /*ignored*/) {}
-  // Disallow "evil" constructors
-  Mutex(const Mutex&);
-  void operator=(const Mutex&);
-};
-
-// Now the implementation of Mutex for various systems
-#if defined(NO_THREADS)
-
-// When we don't have threads, we can be either reading or writing,
-// but not both.  We can have lots of readers at once (in no-threads
-// mode, that's most likely to happen in recursive function calls),
-// but only one writer.  We represent this by having mutex_ be -1 when
-// writing and a number > 0 when reading (and 0 when no lock is held).
-//
-// In debug mode, we assert these invariants, while in non-debug mode
-// we do nothing, for efficiency.  That's why everything is in an
-// assert.
-
-Mutex::Mutex() : mutex_(0) { }
-Mutex::~Mutex()            { assert(mutex_ == 0); }
-void Mutex::Lock()         { assert(--mutex_ == -1); }
-void Mutex::Unlock()       { assert(mutex_++ == -1); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { if (mutex_) return false; Lock(); return true; }
-#endif
-void Mutex::ReaderLock()   { assert(++mutex_ > 0); }
-void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-
-Mutex::Mutex()             { InitializeCriticalSection(&mutex_); SetIsSafe(); }
-Mutex::~Mutex()            { DeleteCriticalSection(&mutex_); }
-void Mutex::Lock()         { if (is_safe_) EnterCriticalSection(&mutex_); }
-void Mutex::Unlock()       { if (is_safe_) LeaveCriticalSection(&mutex_); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 TryEnterCriticalSection(&mutex_) != 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }      // we don't have read-write locks
-void Mutex::ReaderUnlock() { Unlock(); }
-
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex() {
-  SetIsSafe();
-  if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_rwlock_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_rwlock_wrlock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                    pthread_rwlock_trywrlock(&mutex_) == 0 :
-                                    true; }
-#endif
-void Mutex::ReaderLock()   { SAFE_PTHREAD(pthread_rwlock_rdlock); }
-void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#undef SAFE_PTHREAD
-
-#elif defined(HAVE_PTHREAD)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex()             {
-  SetIsSafe();
-  if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_mutex_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_mutex_lock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_mutex_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 pthread_mutex_trylock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }
-void Mutex::ReaderUnlock() { Unlock(); }
-#undef SAFE_PTHREAD
-
-#endif
-
-// --------------------------------------------------------------------------
-// Some helper classes
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class MutexLock {
- public:
-  explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
-  ~MutexLock() { mu_->Unlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  MutexLock(const MutexLock&);
-  void operator=(const MutexLock&);
-};
-
-// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
-class ReaderMutexLock {
- public:
-  explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
-  ~ReaderMutexLock() { mu_->ReaderUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  ReaderMutexLock(const ReaderMutexLock&);
-  void operator=(const ReaderMutexLock&);
-};
-
-class WriterMutexLock {
- public:
-  explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
-  ~WriterMutexLock() { mu_->WriterUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  WriterMutexLock(const WriterMutexLock&);
-  void operator=(const WriterMutexLock&);
-};
-
-// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
-#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
-#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
-#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
-
-}  // namespace MUTEX_NAMESPACE
-
-using namespace MUTEX_NAMESPACE;
-
-#undef MUTEX_NAMESPACE
-
-#endif  /* #define GOOGLE_MUTEX_H__ */

+ 0 - 167
Src/ThirdParty/glog/src/config.h

@@ -1,167 +0,0 @@
-/* src/config.h.  Generated from config.h.in by configure.  */
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE google
-
-/* Define if you have the `dladdr' function */
-/* #undef HAVE_DLADDR */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#define HAVE_EXECINFO_H 1
-
-/* Define if you have the `fcntl' function */
-#define HAVE_FCNTL 1
-
-/* Define to 1 if you have the <glob.h> header file. */
-#define HAVE_GLOB_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#define HAVE_LIBPTHREAD 1
-
-/* Define to 1 if you have the <libunwind.h> header file. */
-/* #undef HAVE_LIBUNWIND_H */
-
-/* define if you have google gflags library */
-#define HAVE_LIB_GFLAGS 1
-
-/* define if you have google gmock library */
-#define HAVE_LIB_GMOCK 1
-
-/* define if you have google gtest library */
-#define HAVE_LIB_GTEST 1
-
-/* define if you have libunwind */
-/* #undef HAVE_LIB_UNWIND */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* define if the compiler implements namespaces */
-#define HAVE_NAMESPACES 1
-
-/* Define if you have POSIX threads libraries and header files. */
-#define HAVE_PTHREAD 1
-
-/* Define to 1 if you have the <pwd.h> header file. */
-#define HAVE_PWD_H 1
-
-/* define if the compiler implements pthread_rwlock_* */
-#define HAVE_RWLOCK 1
-
-/* Define if you have the `sigaltstack' function */
-#define HAVE_SIGALTSTACK 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <syscall.h> header file. */
-#define HAVE_SYSCALL_H 1
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#define HAVE_SYS_SYSCALL_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/ucontext.h> header file. */
-#define HAVE_SYS_UCONTEXT_H 1
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
-#define HAVE_SYS_UTSNAME_H 1
-
-/* Define to 1 if you have the <ucontext.h> header file. */
-#define HAVE_UCONTEXT_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* define if the compiler supports using expression for operator */
-#define HAVE_USING_OPERATOR 1
-
-/* define if your compiler has __attribute__ */
-#define HAVE___ATTRIBUTE__ 1
-
-/* define if your compiler has __builtin_expect */
-#define HAVE___BUILTIN_EXPECT 1
-
-/* define if your compiler has __sync_val_compare_and_swap */
-/* #undef HAVE___SYNC_VAL_COMPARE_AND_SWAP */
-
-/* Name of package */
-#define PACKAGE "glog"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "opensource@google.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "glog"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "glog 0.3.1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "glog"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.3.1"
-
-/* How to access the PC from a struct ucontext */
-#ifdef __x86_64__
-#  define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP]
-#else
-#  define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_EIP]
-#endif
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* The size of `void *', as computed by sizeof. */
-#ifdef __x86_64__
-#  define SIZEOF_VOID_P 8
-#else
-#  define SIZEOF_VOID_P 4
-#endif
-
-/* Define to 1 if you have the ANSI C header files. */
-/* #undef STDC_HEADERS */
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE std
-
-/* location of source code */
-#define TEST_SRC_DIR "."
-
-/* Version number of package */
-#define VERSION "0.3.1"
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {

+ 0 - 66
Src/ThirdParty/glog/src/config_for_unittests.h

@@ -1,66 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// All Rights Reserved.
-//
-// Author: Craig Silverstein
-// Copied from google-perftools and modified by Shinichiro Hamaji
-//
-// This file is needed for windows -- unittests are not part of the
-// glog dll, but still want to include config.h just like the
-// dll does, so they can use internal tools and APIs for testing.
-//
-// The problem is that config.h declares GOOGLE_GLOG_DLL_DECL to be
-// for exporting symbols, but the unittest needs to *import* symbols
-// (since it's not the dll).
-//
-// The solution is to have this file, which is just like config.h but
-// sets GOOGLE_GLOG_DLL_DECL to do a dllimport instead of a dllexport.
-//
-// The reason we need this extra GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-// variable is in case people want to set GOOGLE_GLOG_DLL_DECL explicitly
-// to something other than __declspec(dllexport).  In that case, they
-// may want to use something other than __declspec(dllimport) for the
-// unittest case.  For that, we allow folks to define both
-// GOOGLE_GLOG_DLL_DECL and GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS explicitly.
-//
-// NOTE: This file is equivalent to config.h on non-windows systems,
-// which never defined GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS and always
-// define GOOGLE_GLOG_DLL_DECL to the empty string.
-
-#include "config.h"
-
-#undef GOOGLE_GLOG_DLL_DECL
-#ifdef GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-# define GOOGLE_GLOG_DLL_DECL  GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-#else
-// if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
-# define GOOGLE_GLOG_DLL_DECL
-#endif

+ 0 - 1231
Src/ThirdParty/glog/src/demangle.cc

@@ -1,1231 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-
-#include <stdio.h>  // for NULL
-#include "demangle.h"
-
-_START_GOOGLE_NAMESPACE_
-
-typedef struct {
-  const char *abbrev;
-  const char *real_name;
-} AbbrevPair;
-
-// List of operators from Itanium C++ ABI.
-static const AbbrevPair kOperatorList[] = {
-  { "nw", "new" },
-  { "na", "new[]" },
-  { "dl", "delete" },
-  { "da", "delete[]" },
-  { "ps", "+" },
-  { "ng", "-" },
-  { "ad", "&" },
-  { "de", "*" },
-  { "co", "~" },
-  { "pl", "+" },
-  { "mi", "-" },
-  { "ml", "*" },
-  { "dv", "/" },
-  { "rm", "%" },
-  { "an", "&" },
-  { "or", "|" },
-  { "eo", "^" },
-  { "aS", "=" },
-  { "pL", "+=" },
-  { "mI", "-=" },
-  { "mL", "*=" },
-  { "dV", "/=" },
-  { "rM", "%=" },
-  { "aN", "&=" },
-  { "oR", "|=" },
-  { "eO", "^=" },
-  { "ls", "<<" },
-  { "rs", ">>" },
-  { "lS", "<<=" },
-  { "rS", ">>=" },
-  { "eq", "==" },
-  { "ne", "!=" },
-  { "lt", "<" },
-  { "gt", ">" },
-  { "le", "<=" },
-  { "ge", ">=" },
-  { "nt", "!" },
-  { "aa", "&&" },
-  { "oo", "||" },
-  { "pp", "++" },
-  { "mm", "--" },
-  { "cm", "," },
-  { "pm", "->*" },
-  { "pt", "->" },
-  { "cl", "()" },
-  { "ix", "[]" },
-  { "qu", "?" },
-  { "st", "sizeof" },
-  { "sz", "sizeof" },
-  { NULL, NULL },
-};
-
-// List of builtin types from Itanium C++ ABI.
-static const AbbrevPair kBuiltinTypeList[] = {
-  { "v", "void" },
-  { "w", "wchar_t" },
-  { "b", "bool" },
-  { "c", "char" },
-  { "a", "signed char" },
-  { "h", "unsigned char" },
-  { "s", "short" },
-  { "t", "unsigned short" },
-  { "i", "int" },
-  { "j", "unsigned int" },
-  { "l", "long" },
-  { "m", "unsigned long" },
-  { "x", "long long" },
-  { "y", "unsigned long long" },
-  { "n", "__int128" },
-  { "o", "unsigned __int128" },
-  { "f", "float" },
-  { "d", "double" },
-  { "e", "long double" },
-  { "g", "__float128" },
-  { "z", "ellipsis" },
-  { NULL, NULL }
-};
-
-// List of substitutions Itanium C++ ABI.
-static const AbbrevPair kSubstitutionList[] = {
-  { "St", "" },
-  { "Sa", "allocator" },
-  { "Sb", "basic_string" },
-  // std::basic_string<char, std::char_traits<char>,std::allocator<char> >
-  { "Ss", "string"},
-  // std::basic_istream<char, std::char_traits<char> >
-  { "Si", "istream" },
-  // std::basic_ostream<char, std::char_traits<char> >
-  { "So", "ostream" },
-  // std::basic_iostream<char, std::char_traits<char> >
-  { "Sd", "iostream" },
-  { NULL, NULL }
-};
-
-// State needed for demangling.
-typedef struct {
-  const char *mangled_cur;  // Cursor of mangled name.
-  const char *mangled_end;  // End of mangled name.
-  char *out_cur;            // Cursor of output string.
-  const char *out_begin;    // Beginning of output string.
-  const char *out_end;      // End of output string.
-  const char *prev_name;    // For constructors/destructors.
-  int prev_name_length;     // For constructors/destructors.
-  int nest_level;           // For nested names.
-  int number;               // Remember the previous number.
-  bool append;              // Append flag.
-  bool overflowed;          // True if output gets overflowed.
-} State;
-
-// We don't use strlen() in libc since it's not guaranteed to be async
-// signal safe.
-static size_t StrLen(const char *str) {
-  size_t len = 0;
-  while (*str != '\0') {
-    ++str;
-    ++len;
-  }
-  return len;
-}
-
-// Returns true if "str" has "prefix" as a prefix.
-static bool StrPrefix(const char *str, const char *prefix) {
-  size_t i = 0;
-  while (str[i] != '\0' && prefix[i] != '\0' &&
-         str[i] == prefix[i]) {
-    ++i;
-  }
-  return prefix[i] == '\0';  // Consumed everything in "prefix".
-}
-
-static void InitState(State *state, const char *mangled,
-                      char *out, int out_size) {
-  state->mangled_cur = mangled;
-  state->mangled_end = mangled + StrLen(mangled);
-  state->out_cur = out;
-  state->out_begin = out;
-  state->out_end = out + out_size;
-  state->prev_name  = NULL;
-  state->prev_name_length = -1;
-  state->nest_level = -1;
-  state->number = -1;
-  state->append = true;
-  state->overflowed = false;
-}
-
-// Calculates the remaining length of the mangled name.
-static int RemainingLength(State *state) {
-  return state->mangled_end - state->mangled_cur;
-}
-
-// Returns true and advances "mangled_cur" if we find "c" at
-// "mangled_cur" position.
-static bool ParseChar(State *state, const char c) {
-  if (RemainingLength(state) >= 1 && *state->mangled_cur == c) {
-    ++state->mangled_cur;
-    return true;
-  }
-  return false;
-}
-
-// Returns true and advances "mangled_cur" if we find "two_chars" at
-// "mangled_cur" position.
-static bool ParseTwoChar(State *state, const char *two_chars) {
-  if (RemainingLength(state) >= 2 &&
-      state->mangled_cur[0] == two_chars[0] &&
-      state->mangled_cur[1] == two_chars[1]) {
-    state->mangled_cur += 2;
-    return true;
-  }
-  return false;
-}
-
-// Returns true and advances "mangled_cur" if we find any character in
-// "char_class" at "mangled_cur" position.
-static bool ParseCharClass(State *state, const char *char_class) {
-  if (state->mangled_cur == state->mangled_end) {
-    return false;
-  }
-  const char *p = char_class;
-  for (; *p != '\0'; ++p) {
-    if (*state->mangled_cur == *p) {
-      state->mangled_cur += 1;
-      return true;
-    }
-  }
-  return false;
-}
-
-// This function is used for handling an optional non-terminal.
-static bool Optional(bool status) {
-  return true;
-}
-
-// This function is used for handling <non-terminal>+ syntax.
-typedef bool (*ParseFunc)(State *);
-static bool OneOrMore(ParseFunc parse_func, State *state) {
-  if (parse_func(state)) {
-    while (parse_func(state)) {
-    }
-    return true;
-  }
-  return false;
-}
-
-// Append "str" at "out_cur".  If there is an overflow, "overflowed"
-// is set to true for later use.  The output string is ensured to
-// always terminate with '\0' as long as there is no overflow.
-static void Append(State *state, const char * const str, const int length) {
-  int i;
-  for (i = 0; i < length; ++i) {
-    if (state->out_cur + 1 < state->out_end) {  // +1 for '\0'
-      *state->out_cur = str[i];
-      ++state->out_cur;
-    } else {
-      state->overflowed = true;
-      break;
-    }
-  }
-  if (!state->overflowed) {
-    *state->out_cur = '\0';  // Terminate it with '\0'
-  }
-}
-
-// We don't use equivalents in libc to avoid locale issues.
-static bool IsLower(char c) {
-  return c >= 'a' && c <= 'z';
-}
-
-static bool IsAlpha(char c) {
-  return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
-}
-
-// Append "str" with some tweaks, iff "append" state is true.
-// Returns true so that it can be placed in "if" conditions.
-static void MaybeAppendWithLength(State *state, const char * const str,
-                                  const int length) {
-  if (state->append && length > 0) {
-    // Append a space if the output buffer ends with '<' and "str"
-    // starts with '<' to avoid <<<.
-    if (str[0] == '<' && state->out_begin < state->out_cur  &&
-        state->out_cur[-1] == '<') {
-      Append(state, " ", 1);
-    }
-    // Remember the last identifier name for ctors/dtors.
-    if (IsAlpha(str[0]) || str[0] == '_') {
-      state->prev_name = state->out_cur;
-      state->prev_name_length = length;
-    }
-    Append(state, str, length);
-  }
-}
-
-// A convenient wrapper arount MaybeAppendWithLength().
-static bool MaybeAppend(State *state, const char * const str) {
-  if (state->append) {
-    int length = StrLen(str);
-    MaybeAppendWithLength(state, str, length);
-  }
-  return true;
-}
-
-// This function is used for handling nested names.
-static bool EnterNestedName(State *state) {
-  state->nest_level = 0;
-  return true;
-}
-
-// This function is used for handling nested names.
-static bool LeaveNestedName(State *state, int prev_value) {
-  state->nest_level = prev_value;
-  return true;
-}
-
-// Disable the append mode not to print function parameters, etc.
-static bool DisableAppend(State *state) {
-  state->append = false;
-  return true;
-}
-
-// Restore the append mode to the previous state.
-static bool RestoreAppend(State *state, bool prev_value) {
-  state->append = prev_value;
-  return true;
-}
-
-// Increase the nest level for nested names.
-static void MaybeIncreaseNestLevel(State *state) {
-  if (state->nest_level > -1) {
-    ++state->nest_level;
-  }
-}
-
-// Appends :: for nested names if necessary.
-static void MaybeAppendSeparator(State *state) {
-  if (state->nest_level >= 1) {
-    MaybeAppend(state, "::");
-  }
-}
-
-// Cancel the last separator if necessary.
-static void MaybeCancelLastSeparator(State *state) {
-  if (state->nest_level >= 1 && state->append &&
-      state->out_begin <= state->out_cur - 2) {
-    state->out_cur -= 2;
-    *state->out_cur = '\0';
-  }
-}
-
-// Returns true if identifier pointed by "mangled_cur" is anonymous
-// namespace.
-static bool IdentifierIsAnonymousNamespace(State *state) {
-  const char anon_prefix[] = "_GLOBAL__N_";
-  return (state->number > sizeof(anon_prefix) - 1 &&  // Should be longer.
-          StrPrefix(state->mangled_cur, anon_prefix));
-}
-
-// Forward declarations of our parsing functions.
-static bool ParseMangledName(State *state);
-static bool ParseEncoding(State *state);
-static bool ParseName(State *state);
-static bool ParseUnscopedName(State *state);
-static bool ParseUnscopedTemplateName(State *state);
-static bool ParseNestedName(State *state);
-static bool ParsePrefix(State *state);
-static bool ParseUnqualifiedName(State *state);
-static bool ParseSourceName(State *state);
-static bool ParseLocalSourceName(State *state);
-static bool ParseNumber(State *state);
-static bool ParseFloatNumber(State *state);
-static bool ParseSeqId(State *state);
-static bool ParseIdentifier(State *state);
-static bool ParseOperatorName(State *state);
-static bool ParseSpecialName(State *state);
-static bool ParseCallOffset(State *state);
-static bool ParseNVOffset(State *state);
-static bool ParseVOffset(State *state);
-static bool ParseCtorDtorName(State *state);
-static bool ParseType(State *state);
-static bool ParseCVQualifiers(State *state);
-static bool ParseBuiltinType(State *state);
-static bool ParseFunctionType(State *state);
-static bool ParseBareFunctionType(State *state);
-static bool ParseClassEnumType(State *state);
-static bool ParseArrayType(State *state);
-static bool ParsePointerToMemberType(State *state);
-static bool ParseTemplateParam(State *state);
-static bool ParseTemplateTemplateParam(State *state);
-static bool ParseTemplateArgs(State *state);
-static bool ParseTemplateArg(State *state);
-static bool ParseExpression(State *state);
-static bool ParseExprPrimary(State *state);
-static bool ParseLocalName(State *state);
-static bool ParseDiscriminator(State *state);
-static bool ParseSubstitution(State *state);
-
-// Implementation note: the following code is a straightforward
-// translation of the Itanium C++ ABI defined in BNF with a couple of
-// exceptions.
-//
-// - Support GNU extensions not defined in the Itanium C++ ABI
-// - <prefix> and <template-prefix> are combined to avoid infinite loop
-// - Reorder patterns to shorten the code
-// - Reorder patterns to give greedier functions precedence
-//   We'll mark "Less greedy than" for these cases in the code
-//
-// Each parsing function changes the state and returns true on
-// success.  Otherwise, don't change the state and returns false.  To
-// ensure that the state isn't changed in the latter case, we save the
-// original state before we call more than one parsing functions
-// consecutively with &&, and restore the state if unsuccessful.  See
-// ParseEncoding() as an example of this convention.  We follow the
-// convention throughout the code.
-//
-// Originally we tried to do demangling without following the full ABI
-// syntax but it turned out we needed to follow the full syntax to
-// parse complicated cases like nested template arguments.  Note that
-// implementing a full-fledged demangler isn't trivial (libiberty's
-// cp-demangle.c has +4300 lines).
-//
-// Note that (foo) in <(foo) ...> is a modifier to be ignored.
-//
-// Reference:
-// - Itanium C++ ABI
-//   <http://www.codesourcery.com/cxx-abi/abi.html#mangling>
-
-// <mangled-name> ::= _Z <encoding>
-static bool ParseMangledName(State *state) {
-  if (ParseTwoChar(state, "_Z") && ParseEncoding(state)) {
-    // Append trailing version suffix if any.
-    // ex. _Z3foo@@GLIBCXX_3.4
-    if (state->mangled_cur < state->mangled_end &&
-        state->mangled_cur[0] == '@') {
-      MaybeAppend(state, state->mangled_cur);
-      state->mangled_cur = state->mangled_end;
-    }
-    return true;
-  }
-  return false;
-}
-
-// <encoding> ::= <(function) name> <bare-function-type>
-//            ::= <(data) name>
-//            ::= <special-name>
-static bool ParseEncoding(State *state) {
-  State copy = *state;
-  if (ParseName(state) && ParseBareFunctionType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseName(state) || ParseSpecialName(state)) {
-    return true;
-  }
-  return false;
-}
-
-// <name> ::= <nested-name>
-//        ::= <unscoped-template-name> <template-args>
-//        ::= <unscoped-name>
-//        ::= <local-name>
-static bool ParseName(State *state) {
-  if (ParseNestedName(state) || ParseLocalName(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseUnscopedTemplateName(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Less greedy than <unscoped-template-name> <template-args>.
-  if (ParseUnscopedName(state)) {
-    return true;
-  }
-  return false;
-}
-
-// <unscoped-name> ::= <unqualified-name>
-//                 ::= St <unqualified-name>
-static bool ParseUnscopedName(State *state) {
-  if (ParseUnqualifiedName(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseTwoChar(state, "St") &&
-      MaybeAppend(state, "std::") &&
-      ParseUnqualifiedName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <unscoped-template-name> ::= <unscoped-name>
-//                          ::= <substitution>
-static bool ParseUnscopedTemplateName(State *state) {
-  return ParseUnscopedName(state) || ParseSubstitution(state);
-}
-
-// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
-//               ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
-static bool ParseNestedName(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'N') &&
-      EnterNestedName(state) &&
-      Optional(ParseCVQualifiers(state)) &&
-      ParsePrefix(state) &&
-      LeaveNestedName(state, copy.nest_level) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// This part is tricky.  If we literally translate them to code, we'll
-// end up infinite loop.  Hence we merge them to avoid the case.
-//
-// <prefix> ::= <prefix> <unqualified-name>
-//          ::= <template-prefix> <template-args>
-//          ::= <template-param>
-//          ::= <substitution>
-//          ::= # empty
-// <template-prefix> ::= <prefix> <(template) unqualified-name>
-//                   ::= <template-param>
-//                   ::= <substitution>
-static bool ParsePrefix(State *state) {
-  bool has_something = false;
-  while (true) {
-    MaybeAppendSeparator(state);
-    if (ParseTemplateParam(state) ||
-        ParseSubstitution(state) ||
-        ParseUnscopedName(state)) {
-      has_something = true;
-      MaybeIncreaseNestLevel(state);
-      continue;
-    }
-    MaybeCancelLastSeparator(state);
-    if (has_something && ParseTemplateArgs(state)) {
-      return ParsePrefix(state);
-    } else {
-      break;
-    }
-  }
-  return true;
-}
-
-// <unqualified-name> ::= <operator-name>
-//                    ::= <ctor-dtor-name>
-//                    ::= <source-name>
-//                    ::= <local-source-name>
-static bool ParseUnqualifiedName(State *state) {
-  return (ParseOperatorName(state) ||
-          ParseCtorDtorName(state) ||
-          ParseSourceName(state) ||
-          ParseLocalSourceName(state));
-}
-
-// <source-name> ::= <positive length number> <identifier>
-static bool ParseSourceName(State *state) {
-  State copy = *state;
-  if (ParseNumber(state) && ParseIdentifier(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <local-source-name> ::= L <source-name> [<discriminator>]
-//
-// References:
-//   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
-//   http://gcc.gnu.org/viewcvs?view=rev&revision=124467
-static bool ParseLocalSourceName(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'L') && ParseSourceName(state) &&
-      Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <number> ::= [n] <non-negative decimal integer>
-static bool ParseNumber(State *state) {
-  int sign = 1;
-  if (ParseChar(state, 'n')) {
-    sign = -1;
-  }
-  const char *p = state->mangled_cur;
-  int number = 0;
-  for (;p < state->mangled_end; ++p) {
-    if ((*p >= '0' && *p <= '9')) {
-      number = number * 10 + (*p - '0');
-    } else {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    state->number = number * sign;
-    return true;
-  }
-  return false;
-}
-
-// Floating-point literals are encoded using a fixed-length lowercase
-// hexadecimal string.
-static bool ParseFloatNumber(State *state) {
-  const char *p = state->mangled_cur;
-  int number = 0;
-  for (;p < state->mangled_end; ++p) {
-    if ((*p >= '0' && *p <= '9')) {
-      number = number * 16 + (*p - '0');
-    } else if (*p >= 'a' && *p <= 'f') {
-      number = number * 16 + (*p - 'a' + 10);
-    } else {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    state->number = number;
-    return true;
-  }
-  return false;
-}
-
-// The <seq-id> is a sequence number in base 36,
-// using digits and upper case letters
-static bool ParseSeqId(State *state) {
-  const char *p = state->mangled_cur;
-  int number = 0;
-  for (;p < state->mangled_end; ++p) {
-    if ((*p >= '0' && *p <= '9')) {
-      number = number * 36 + (*p - '0');
-    } else if (*p >= 'A' && *p <= 'Z') {
-      number = number * 36 + (*p - 'A' + 10);
-    } else {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    state->number = number;
-    return true;
-  }
-  return false;
-}
-
-// <identifier> ::= <unqualified source code identifier>
-static bool ParseIdentifier(State *state) {
-  if (state->number == -1 ||
-      RemainingLength(state) < state->number) {
-    return false;
-  }
-  if (IdentifierIsAnonymousNamespace(state)) {
-    MaybeAppend(state, "(anonymous namespace)");
-  } else {
-    MaybeAppendWithLength(state, state->mangled_cur, state->number);
-  }
-  state->mangled_cur += state->number;
-  state->number = -1;  // Reset the number.
-  return true;
-}
-
-// <operator-name> ::= nw, and other two letters cases
-//                 ::= cv <type>  # (cast)
-//                 ::= v  <digit> <source-name> # vendor extended operator
-static bool ParseOperatorName(State *state) {
-  if (RemainingLength(state) < 2) {
-    return false;
-  }
-  // First check with "cv" (cast) case.
-  State copy = *state;
-  if (ParseTwoChar(state, "cv") &&
-      MaybeAppend(state, "operator ") &&
-      EnterNestedName(state) &&
-      ParseType(state) &&
-      LeaveNestedName(state, copy.nest_level)) {
-    return true;
-  }
-  *state = copy;
-
-  // Then vendor extended operators.
-  if (ParseChar(state, 'v') && ParseCharClass(state, "0123456789") &&
-      ParseSourceName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Other operator names should start with a lower alphabet followed
-  // by a lower/upper alphabet.
-  if (!(IsLower(state->mangled_cur[0]) &&
-        IsAlpha(state->mangled_cur[1]))) {
-    return false;
-  }
-  // We may want to perform a binary search if we really need speed.
-  const AbbrevPair *p;
-  for (p = kOperatorList; p->abbrev != NULL; ++p) {
-    if (state->mangled_cur[0] == p->abbrev[0] &&
-        state->mangled_cur[1] == p->abbrev[1]) {
-      MaybeAppend(state, "operator");
-      if (IsLower(*p->real_name)) {  // new, delete, etc.
-        MaybeAppend(state, " ");
-      }
-      MaybeAppend(state, p->real_name);
-      state->mangled_cur += 2;
-      return true;
-    }
-  }
-  return false;
-}
-
-// <special-name> ::= TV <type>
-//                ::= TT <type>
-//                ::= TI <type>
-//                ::= TS <type>
-//                ::= Tc <call-offset> <call-offset> <(base) encoding>
-//                ::= GV <(object) name>
-//                ::= T <call-offset> <(base) encoding>
-// G++ extensions:
-//                ::= TC <type> <(offset) number> _ <(base) type>
-//                ::= TF <type>
-//                ::= TJ <type>
-//                ::= GR <name>
-//                ::= GA <encoding>
-//                ::= Th <call-offset> <(base) encoding>
-//                ::= Tv <call-offset> <(base) encoding>
-//
-// Note: we don't care much about them since they don't appear in
-// stack traces.  The are special data.
-static bool ParseSpecialName(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'T') &&
-      ParseCharClass(state, "VTIS") &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "Tc") && ParseCallOffset(state) &&
-      ParseCallOffset(state) && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "GV") &&
-      ParseName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'T') && ParseCallOffset(state) &&
-      ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // G++ extensions
-  if (ParseTwoChar(state, "TC") && ParseType(state) &&
-      ParseNumber(state) && ParseChar(state, '_') &&
-      DisableAppend(state) &&
-      ParseType(state)) {
-    RestoreAppend(state, copy.append);
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'T') && ParseCharClass(state, "FJ") &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "GR") && ParseName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "GA") && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'T') && ParseCharClass(state, "hv") &&
-      ParseCallOffset(state) && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <call-offset> ::= h <nv-offset> _
-//               ::= v <v-offset> _
-static bool ParseCallOffset(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'h') &&
-      ParseNVOffset(state) && ParseChar(state, '_')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'v') &&
-      ParseVOffset(state) && ParseChar(state, '_')) {
-    return true;
-  }
-  *state = copy;
-
-  return false;
-}
-
-// <nv-offset> ::= <(offset) number>
-static bool ParseNVOffset(State *state) {
-  return ParseNumber(state);
-}
-
-// <v-offset>  ::= <(offset) number> _ <(virtual offset) number>
-static bool ParseVOffset(State *state) {
-  State copy = *state;
-  if (ParseNumber(state) && ParseChar(state, '_') &&
-      ParseNumber(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <ctor-dtor-name> ::= C1 | C2 | C3
-//                  ::= D0 | D1 | D2
-static bool ParseCtorDtorName(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'C') &&
-      ParseCharClass(state, "123")) {
-    const char * const prev_name = state->prev_name;
-    const int prev_name_length = state->prev_name_length;
-    MaybeAppendWithLength(state, prev_name, prev_name_length);
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'D') &&
-      ParseCharClass(state, "012")) {
-    const char * const prev_name = state->prev_name;
-    const int prev_name_length = state->prev_name_length;
-    MaybeAppend(state, "~");
-    MaybeAppendWithLength(state, prev_name, prev_name_length);
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <type> ::= <CV-qualifiers> <type>
-//        ::= P <type>
-//        ::= R <type>
-//        ::= C <type>
-//        ::= G <type>
-//        ::= U <source-name> <type>
-//        ::= <builtin-type>
-//        ::= <function-type>
-//        ::= <class-enum-type>
-//        ::= <array-type>
-//        ::= <pointer-to-member-type>
-//        ::= <template-template-param> <template-args>
-//        ::= <template-param>
-//        ::= <substitution>
-static bool ParseType(State *state) {
-  // We should check CV-qualifers, and PRGC things first.
-  State copy = *state;
-  if (ParseCVQualifiers(state) && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseCharClass(state, "PRCG") && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'U') && ParseSourceName(state) &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseBuiltinType(state) ||
-      ParseFunctionType(state) ||
-      ParseClassEnumType(state) ||
-      ParseArrayType(state) ||
-      ParsePointerToMemberType(state) ||
-      ParseSubstitution(state)) {
-    return true;
-  }
-
-  if (ParseTemplateTemplateParam(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Less greedy than <template-template-param> <template-args>.
-  if (ParseTemplateParam(state)) {
-    return true;
-  }
-
-  return false;
-}
-
-// <CV-qualifiers> ::= [r] [V] [K]
-// We don't allow empty <CV-qualifiers> to avoid infinite loop in
-// ParseType().
-static bool ParseCVQualifiers(State *state) {
-  int num_cv_qualifiers = 0;
-  num_cv_qualifiers += ParseChar(state, 'r');
-  num_cv_qualifiers += ParseChar(state, 'V');
-  num_cv_qualifiers += ParseChar(state, 'K');
-  return num_cv_qualifiers > 0;
-}
-
-// <builtin-type> ::= v, etc.
-//                ::= u <source-name>
-static bool ParseBuiltinType(State *state) {
-  const AbbrevPair *p;
-  for (p = kBuiltinTypeList; p->abbrev != NULL; ++p) {
-    if (state->mangled_cur[0] == p->abbrev[0]) {
-      MaybeAppend(state, p->real_name);
-      ++state->mangled_cur;
-      return true;
-    }
-  }
-
-  State copy = *state;
-  if (ParseChar(state, 'u') && ParseSourceName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <function-type> ::= F [Y] <bare-function-type> E
-static bool ParseFunctionType(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'F') && Optional(ParseChar(state, 'Y')) &&
-      ParseBareFunctionType(state) && ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <bare-function-type> ::= <(signature) type>+
-static bool ParseBareFunctionType(State *state) {
-  State copy = *state;
-  DisableAppend(state);
-  if (OneOrMore(ParseType, state)) {
-    RestoreAppend(state, copy.append);
-    MaybeAppend(state, "()");
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <class-enum-type> ::= <name>
-static bool ParseClassEnumType(State *state) {
-  return ParseName(state);
-}
-
-// <array-type> ::= A <(positive dimension) number> _ <(element) type>
-//              ::= A [<(dimension) expression>] _ <(element) type>
-static bool ParseArrayType(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'A') && ParseNumber(state) &&
-      ParseChar(state, '_') && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'A') && Optional(ParseExpression(state)) &&
-      ParseChar(state, '_') && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <pointer-to-member-type> ::= M <(class) type> <(member) type>
-static bool ParsePointerToMemberType(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'M') && ParseType(state) &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <template-param> ::= T_
-//                  ::= T <parameter-2 non-negative number> _
-static bool ParseTemplateParam(State *state) {
-  if (ParseTwoChar(state, "T_")) {
-    MaybeAppend(state, "?");  // We don't support template substitutions.
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseChar(state, 'T') && ParseNumber(state) &&
-      ParseChar(state, '_')) {
-    MaybeAppend(state, "?");  // We don't support template substitutions.
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-
-// <template-template-param> ::= <template-param>
-//                           ::= <substitution>
-static bool ParseTemplateTemplateParam(State *state) {
-  return (ParseTemplateParam(state) ||
-          ParseSubstitution(state));
-}
-
-// <template-args> ::= I <template-arg>+ E
-static bool ParseTemplateArgs(State *state) {
-  State copy = *state;
-  DisableAppend(state);
-  if (ParseChar(state, 'I') &&
-      OneOrMore(ParseTemplateArg, state) &&
-      ParseChar(state, 'E')) {
-    RestoreAppend(state, copy.append);
-    MaybeAppend(state, "<>");
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <template-arg>  ::= <type>
-//                 ::= <expr-primary>
-//                 ::= X <expression> E
-static bool ParseTemplateArg(State *state) {
-  if (ParseType(state) ||
-      ParseExprPrimary(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseChar(state, 'X') && ParseExpression(state) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <expression> ::= <template-param>
-//              ::= <expr-primary>
-//              ::= <unary operator-name> <expression>
-//              ::= <binary operator-name> <expression> <expression>
-//              ::= <trinary operator-name> <expression> <expression>
-//                  <expression>
-//              ::= st <type>
-//              ::= sr <type> <unqualified-name> <template-args>
-//              ::= sr <type> <unqualified-name>
-static bool ParseExpression(State *state) {
-  if (ParseTemplateParam(state) || ParseExprPrimary(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseOperatorName(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOperatorName(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOperatorName(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "st") && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "sr") && ParseType(state) &&
-      ParseUnqualifiedName(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "sr") && ParseType(state) &&
-      ParseUnqualifiedName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <expr-primary> ::= L <type> <(value) number> E
-//                ::= L <type> <(value) float> E
-//                ::= L <mangled-name> E
-//                // A bug in g++'s C++ ABI version 2 (-fabi-version=2).
-//                ::= LZ <encoding> E
-static bool ParseExprPrimary(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'L') && ParseType(state) &&
-      ParseNumber(state) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'L') && ParseType(state) &&
-      ParseFloatNumber(state) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'L') && ParseMangledName(state) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoChar(state, "LZ") && ParseEncoding(state) &&
-      ParseChar(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  return false;
-}
-
-// <local-name> := Z <(function) encoding> E <(entity) name>
-//                 [<discriminator>]
-//              := Z <(function) encoding> E s [<discriminator>]
-static bool ParseLocalName(State *state) {
-  State copy = *state;
-  if (ParseChar(state, 'Z') && ParseEncoding(state) &&
-      ParseChar(state, 'E') && MaybeAppend(state, "::") &&
-      ParseName(state) && Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseChar(state, 'Z') && ParseEncoding(state) &&
-      ParseTwoChar(state, "Es") && Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <discriminator> := _ <(non-negative) number>
-static bool ParseDiscriminator(State *state) {
-  State copy = *state;
-  if (ParseChar(state, '_') && ParseNumber(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <substitution> ::= S_
-//                ::= S <seq-id> _
-//                ::= St, etc.
-static bool ParseSubstitution(State *state) {
-  if (ParseTwoChar(state, "S_")) {
-    MaybeAppend(state, "?");  // We don't support substitutions.
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseChar(state, 'S') && ParseSeqId(state) &&
-      ParseChar(state, '_')) {
-    MaybeAppend(state, "?");  // We don't support substitutions.
-    return true;
-  }
-  *state = copy;
-
-  // Expand abbreviations like "St" => "std".
-  if (ParseChar(state, 'S')) {
-    const AbbrevPair *p;
-    for (p = kSubstitutionList; p->abbrev != NULL; ++p) {
-      if (state->mangled_cur[0] == p->abbrev[1]) {
-        MaybeAppend(state, "std");
-        if (p->real_name[0] != '\0') {
-          MaybeAppend(state, "::");
-          MaybeAppend(state, p->real_name);
-        }
-        state->mangled_cur += 1;
-        return true;
-      }
-    }
-  }
-  *state = copy;
-  return false;
-}
-
-// The demangler entry point.
-bool Demangle(const char *mangled, char *out, int out_size) {
-  State state;
-  InitState(&state, mangled, out, out_size);
-  return (ParseMangledName(&state) &&
-          state.overflowed == false &&
-          RemainingLength(&state) == 0);
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 84
Src/ThirdParty/glog/src/demangle.h

@@ -1,84 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// An async-signal-safe and thread-safe demangler for Itanium C++ ABI
-// (aka G++ V3 ABI).
-
-// The demangler is implemented to be used in async signal handlers to
-// symbolize stack traces.  We cannot use libstdc++'s
-// abi::__cxa_demangle() in such signal handlers since it's not async
-// signal safe (it uses malloc() internally).
-//
-// Note that this demangler doesn't support full demangling.  More
-// specifically, it doesn't print types of function parameters and
-// types of template arguments.  It just skips them.  However, it's
-// still very useful to extract basic information such as class,
-// function, constructor, destructor, and operator names.
-//
-// See the implementation note in demangle.cc if you are interested.
-//
-// Example:
-//
-// | Mangled Name  | The Demangler | abi::__cxa_demangle()
-// |---------------|---------------|-----------------------
-// | _Z1fv         | f()           | f()
-// | _Z1fi         | f()           | f(int)
-// | _Z3foo3bar    | foo()         | foo(bar)
-// | _Z1fIiEvi     | f<>()         | void f<int>(int)
-// | _ZN1N1fE      | N::f          | N::f
-// | _ZN3Foo3BarEv | Foo::Bar()    | Foo::Bar()
-// | _Zrm1XS_"     | operator%()   | operator%(X, X)
-// | _ZN3FooC1Ev   | Foo::Foo()    | Foo::Foo()
-// | _Z1fSs        | f()           | f(std::basic_string<char,
-// |               |               |   std::char_traits<char>,
-// |               |               |   std::allocator<char> >)
-//
-// See the unit test for more examples.
-//
-// Note: we might want to write demanglers for ABIs other than Itanium
-// C++ ABI in the future.
-//
-
-#ifndef BASE_DEMANGLE_H_
-#define BASE_DEMANGLE_H_
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Demangle "mangled".  On success, return true and write the
-// demangled symbol name to "out".  Otherwise, return false.
-// "out" is modified even if demangling is unsuccessful.
-bool Demangle(const char *mangled, char *out, int out_size);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_DEMANGLE_H_

+ 0 - 116
Src/ThirdParty/glog/src/demangle_unittest.cc

@@ -1,116 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Unit tests for functions in demangle.c.
-
-#include "utilities.h"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include "glog/logging.h"
-#include "demangle.h"
-#include "googletest.h"
-#include "config.h"
-
-GLOG_DEFINE_bool(demangle_filter, false,
-                 "Run demangle_unittest in filter mode");
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-// A wrapper function for Demangle() to make the unit test simple.
-static const char *DemangleIt(const char * const mangled) {
-  static char demangled[4096];
-  if (Demangle(mangled, demangled, sizeof(demangled))) {
-    return demangled;
-  } else {
-    return mangled;
-  }
-}
-
-// Test corner cases of bounary conditions.
-TEST(Demangle, CornerCases) {
-  char tmp[10];
-  EXPECT_TRUE(Demangle("_Z6foobarv", tmp, sizeof(tmp)));
-  // sizeof("foobar()") == 9
-  EXPECT_STREQ("foobar()", tmp);
-  EXPECT_TRUE(Demangle("_Z6foobarv", tmp, 9));
-  EXPECT_STREQ("foobar()", tmp);
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 8));  // Not enough.
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 1));
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 0));
-  EXPECT_FALSE(Demangle("_Z6foobarv", NULL, 0));  // Should not cause SEGV.
-}
-
-TEST(Demangle, FromFile) {
-  string test_file = FLAGS_test_srcdir + "/src/demangle_unittest.txt";
-  ifstream f(test_file.c_str());  // The file should exist.
-  EXPECT_FALSE(f.fail());
-
-  string line;
-  while (getline(f, line)) {
-    // Lines start with '#' are considered as comments.
-    if (line.empty() || line[0] == '#') {
-      continue;
-    }
-    // Each line should contain a mangled name and a demangled name
-    // separated by '\t'.  Example: "_Z3foo\tfoo"
-    string::size_type tab_pos = line.find('\t');
-    EXPECT_NE(string::npos, tab_pos);
-    string mangled = line.substr(0, tab_pos);
-    string demangled = line.substr(tab_pos + 1);
-    EXPECT_EQ(demangled, DemangleIt(mangled.c_str()));
-  }
-}
-
-int main(int argc, char **argv) {
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-  InitGoogleTest(&argc, argv);
-
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  if (FLAGS_demangle_filter) {
-    // Read from cin and write to cout.
-    string line;
-    while (getline(cin, line, '\n')) {
-      cout << DemangleIt(line.c_str()) << endl;
-    }
-    return 0;
-  } else if (argc > 1) {
-    cout << DemangleIt(argv[1]) << endl;
-    return 0;
-  } else {
-    return RUN_ALL_TESTS();
-  }
-}

+ 0 - 84
Src/ThirdParty/glog/src/glog/log_severity.h

@@ -1,84 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef BASE_LOG_SEVERITY_H__
-#define BASE_LOG_SEVERITY_H__
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// Variables of type LogSeverity are widely taken to lie in the range
-// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
-// you ever need to change their values or add a new severity.
-typedef int LogSeverity;
-
-const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
-
-// DFATAL is FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
-#define DFATAL_LEVEL ERROR
-#else
-#define DFATAL_LEVEL FATAL
-#endif
-
-extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
-
-// NDEBUG usage helpers related to (RAW_)DCHECK:
-//
-// DEBUG_MODE is for small !NDEBUG uses like
-//   if (DEBUG_MODE) foo.CheckThatFoo();
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     foo.CheckThatFoo();
-//   #endif
-//
-// IF_DEBUG_MODE is for small !NDEBUG uses like
-//   IF_DEBUG_MODE( string error; )
-//   DCHECK(Foo(&error)) << error;
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     string error;
-//     DCHECK(Foo(&error)) << error;
-//   #endif
-//
-#ifdef NDEBUG
-enum { DEBUG_MODE = 0 };
-#define IF_DEBUG_MODE(x)
-#else
-enum { DEBUG_MODE = 1 };
-#define IF_DEBUG_MODE(x) x
-#endif
-
-#endif  // BASE_LOG_SEVERITY_H__

+ 0 - 1506
Src/ThirdParty/glog/src/glog/logging.h

@@ -1,1506 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-//
-// This file contains #include information about logging-related stuff.
-// Pretty much everybody needs to #include this file so that they can
-// log various happenings.
-//
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <string>
-#if 1
-# include <unistd.h>
-#endif
-#ifdef __DEPRECATED
-// Make GCC quiet.
-# undef __DEPRECATED
-# include <strstream>
-# define __DEPRECATED
-#else
-# include <strstream>
-#endif
-#include <vector>
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at logging.h.in to see how they're calculated (based on your config).
-#if 1
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 1
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-#if 1
-#include <gflags/gflags.h>
-#endif
-
-namespace google {
-
-#if 1      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 1   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0    // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-}
-
-// The global value of GOOGLE_STRIP_LOG. All the messages logged to
-// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed.
-// If it can be determined at compile time that the message will not be
-// printed, the statement will be compiled out.
-//
-// Example: to strip out all INFO and WARNING messages, use the value
-// of 2 below. To make an exception for WARNING messages from a single
-// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including
-// base/logging.h
-#ifndef GOOGLE_STRIP_LOG
-#define GOOGLE_STRIP_LOG 0
-#endif
-
-// GCC can be told that a certain branch is not likely to be taken (for
-// instance, a CHECK failure), and use that information in static analysis.
-// Giving it this information can help it optimize for the common case in
-// the absence of better information (ie. -fprofile-arcs).
-//
-#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
-#if 1
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#else
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
-#endif
-#endif
-
-// Make a bunch of macros for logging.  The way to log things is to stream
-// things to LOG(<a particular severity level>).  E.g.,
-//
-//   LOG(INFO) << "Found " << num_cookies << " cookies";
-//
-// You can capture log messages in a string, rather than reporting them
-// immediately:
-//
-//   vector<string> errors;
-//   LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
-//
-// This pushes back the new error onto 'errors'; if given a NULL pointer,
-// it reports the error via LOG(ERROR).
-//
-// You can also do conditional logging:
-//
-//   LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-// You can also do occasional logging (log every n'th occurrence of an
-// event):
-//
-//   LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed.  Note that the special COUNTER value is used to
-// identify which repetition is happening.
-//
-// You can also do occasional conditional logging (log every n'th
-// occurrence of an event, when condition is satisfied):
-//
-//   LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
-//                                           << "th big cookie";
-//
-// You can log messages the first N times your code executes a line. E.g.
-//
-//   LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie";
-//
-// Outputs log messages for the first 20 times it is executed.
-//
-// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available.
-// These log to syslog as well as to the normal logs.  If you use these at
-// all, you need to be aware that syslog can drastically reduce performance,
-// especially if it is configured for remote logging!  Don't use these
-// unless you fully understand this and have a concrete need to use them.
-// Even then, try to minimize your use of them.
-//
-// There are also "debug mode" logging macros like the ones above:
-//
-//   DLOG(INFO) << "Found cookies";
-//
-//   DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-//   DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// All "debug mode" logging is compiled away to nothing for non-debug mode
-// compiles.
-//
-// We also have
-//
-//   LOG_ASSERT(assertion);
-//   DLOG_ASSERT(assertion);
-//
-// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
-//
-// There are "verbose level" logging macros.  They look like
-//
-//   VLOG(1) << "I'm printed when you run the program with --v=1 or more";
-//   VLOG(2) << "I'm printed when you run the program with --v=2 or more";
-//
-// These always log at the INFO log level (when they log at all).
-// The verbose logging can also be turned on module-by-module.  For instance,
-//    --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-// will cause:
-//   a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc}
-//   b. VLOG(1) and lower messages to be printed from file.{h,cc}
-//   c. VLOG(3) and lower messages to be printed from files prefixed with "gfs"
-//   d. VLOG(0) and lower messages to be printed from elsewhere
-//
-// The wildcarding functionality shown by (c) supports both '*' (match
-// 0 or more characters) and '?' (match any single character) wildcards.
-//
-// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
-//
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished with just VLOG(2) << ...;
-//   }
-//
-// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level"
-// condition macros for sample cases, when some extra computation and
-// preparation for logs is not needed.
-//   VLOG_IF(1, (size > 1024))
-//      << "I'm printed when size is more than 1024 and when you run the "
-//         "program with --v=1 or more";
-//   VLOG_EVERY_N(1, 10)
-//      << "I'm printed every 10th occurrence, and when you run the program "
-//         "with --v=1 or more. Present occurence is " << COUNTER;
-//   VLOG_IF_EVERY_N(1, (size > 1024), 10)
-//      << "I'm printed on every 10th occurence of case when size is more "
-//         " than 1024, when you run the program with --v=1 or more. ";
-//         "Present occurence is " << COUNTER;
-//
-// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
-// Note that messages of a given severity are logged not only in the
-// logfile for that severity, but also in all logfiles of lower severity.
-// E.g., a message of severity FATAL will be logged to the logfiles of
-// severity FATAL, ERROR, WARNING, and INFO.
-//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
-// Very important: logging a message at the FATAL severity level causes
-// the program to terminate (after the message is logged).
-//
-// Unless otherwise specified, logs will be written to the filename
-// "<program name>.<hostname>.<user name>.log.<severity level>.", followed
-// by the date, time, and pid (you can't prevent the date, time, and pid
-// from being in the filename).
-//
-// The logging code takes two flags:
-//     --v=#           set the verbose level
-//     --logtostderr   log all the messages to stderr instead of to logfiles
-
-// LOG LINE PREFIX FORMAT
-//
-// Log lines have this form:
-//
-//     Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
-//
-// where the fields are defined as follows:
-//
-//   L                A single character, representing the log level
-//                    (eg 'I' for INFO)
-//   mm               The month (zero padded; ie May is '05')
-//   dd               The day (zero padded)
-//   hh:mm:ss.uuuuuu  Time in hours, minutes and fractional seconds
-//   threadid         The space-padded thread ID as returned by GetTID()
-//                    (this matches the PID on Linux)
-//   file             The file name
-//   line             The line number
-//   msg              The user-supplied message
-//
-// Example:
-//
-//   I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
-//   I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
-//
-// NOTE: although the microseconds are useful for comparing events on
-// a single machine, clocks on different machines may not be well
-// synchronized.  Hence, use caution when comparing the low bits of
-// timestamps from different machines.
-
-#ifndef DECLARE_VARIABLE
-#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#define DECLARE_VARIABLE(type, name, tn)                                      \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                              \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, name, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(google::int32, name, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                          \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name;                       \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
-#endif
-
-// Set whether log messages go to stderr instead of logfiles
-DECLARE_bool(logtostderr);
-
-// Set whether log messages go to stderr in addition to logfiles.
-DECLARE_bool(alsologtostderr);
-
-// Log messages at a level >= this flag are automatically sent to
-// stderr in addition to log files.
-DECLARE_int32(stderrthreshold);
-
-// Set whether the log prefix should be prepended to each line of output.
-DECLARE_bool(log_prefix);
-
-// Log messages at a level <= this flag are buffered.
-// Log messages at a higher level are flushed immediately.
-DECLARE_int32(logbuflevel);
-
-// Sets the maximum number of seconds which logs may be buffered for.
-DECLARE_int32(logbufsecs);
-
-// Log suppression level: messages logged at a lower level than this
-// are suppressed.
-DECLARE_int32(minloglevel);
-
-// If specified, logfiles are written into this directory instead of the
-// default logging directory.
-DECLARE_string(log_dir);
-
-// Sets the path of the directory into which to put additional links
-// to the log files.
-DECLARE_string(log_link);
-
-DECLARE_int32(v);  // in vlog_is_on.cc
-
-// Sets the maximum log file size (in MB).
-DECLARE_int32(max_log_size);
-
-// Sets whether to avoid logging to the disk if the disk is full.
-DECLARE_bool(stop_logging_if_full_disk);
-
-#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef DECLARE_VARIABLE
-#undef DECLARE_bool
-#undef DECLARE_int32
-#undef DECLARE_string
-#endif
-
-// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
-// security reasons. See LOG(severtiy) below.
-
-// A few definitions of macros that don't generate much code.  Since
-// LOG(INFO) and its ilk are used all over our code, it's
-// better to have compact code for these operations.
-
-#if GOOGLE_STRIP_LOG == 0
-#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_INFO(message) google::LogMessage( \
-      __FILE__, __LINE__, google::INFO, message)
-#else
-#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
-#define LOG_TO_STRING_INFO(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 1
-#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING)
-#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING, message)
-#else
-#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
-#define LOG_TO_STRING_WARNING(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 2
-#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR)
-#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR, message)
-#else
-#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
-#define LOG_TO_STRING_ERROR(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL, message)
-#else
-#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
-#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
-#endif
-
-// For DFATAL, we want to use LogMessage (as opposed to
-// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
-#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
-#elif GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL)
-#else
-#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
-#endif
-
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
-#define SYSLOG_INFO(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
-// A very useful logging macro to log windows errors:
-#define LOG_SYSRESULT(result) \
-  if (FAILED(result)) { \
-    LPTSTR message = NULL; \
-    LPTSTR msg = reinterpret_cast<LPTSTR>(&message); \
-    DWORD message_length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
-                         FORMAT_MESSAGE_FROM_SYSTEM, \
-                         0, result, 0, msg, 100, NULL); \
-    if (message_length > 0) { \
-      google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
-          &google::LogMessage::SendToLog).stream() << message; \
-      LocalFree(message); \
-    } \
-  }
-#endif
-
-// We use the preprocessor's merging operator, "##", so that, e.g.,
-// LOG(INFO) becomes the token GOOGLE_LOG_INFO.  There's some funny
-// subtle difference between ostream member streaming functions (e.g.,
-// ostream::operator<<(int) and ostream non-member streaming functions
-// (e.g., ::operator<<(ostream&, string&): it turns out that it's
-// impossible to stream something like a string directly to an unnamed
-// ostream. We employ a neat hack by calling the stream() member
-// function of LogMessage which seems to avoid the problem.
-#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
-#define SYSLOG(severity) SYSLOG_ ## severity(0).stream()
-
-namespace google {
-
-// They need the definitions of integer types.
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Initialize google's logging library. You will see the program name
-// specified by argv0 in log outputs.
-GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
-
-// Shutdown google's logging library.
-GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
-
-// Install a function which will be called after LOG(FATAL).
-GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
-
-class LogSink;  // defined below
-
-// If a non-NULL sink pointer is given, we push this message to that sink.
-// For LOG_TO_SINK we then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and passing/storing them
-// somewhere more specific than the global log of the process.
-// Argument types:
-//   LogSink* sink;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-#define LOG_TO_SINK(sink, severity) \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), true).stream()
-#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)                  \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), false).stream()
-
-// If a non-NULL string pointer is given, we write this message to that string.
-// We then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and storing them somewhere more
-// specific than the global log of the process.
-// Argument types:
-//   string* message;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-// NOTE: LOG(severity) expands to LogMessage().stream() for the specified
-// severity.
-#define LOG_TO_STRING(severity, message) \
-  LOG_TO_STRING_##severity(static_cast<string*>(message)).stream()
-
-// If a non-NULL pointer is given, we push the message onto the end
-// of a vector of strings; otherwise, we report it with LOG(severity).
-// This is handy for capturing messages and perhaps passing them back
-// to the caller, rather than reporting them immediately.
-// Argument types:
-//   LogSeverity severity;
-//   vector<string> *outvec;
-// The cast is to disambiguate NULL arguments.
-#define LOG_STRING(severity, outvec) \
-  LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
-
-#define LOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-#define SYSLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & SYSLOG(severity)
-
-#define LOG_ASSERT(condition)  \
-  LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-#define SYSLOG_ASSERT(condition) \
-  SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-
-// CHECK dies with a fatal error if condition is not true.  It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode.  Therefore, it is safe to do things like:
-//    CHECK(fp->Write(x) == 4)
-#define CHECK(condition)  \
-      LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-             << "Check failed: " #condition " "
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
-  CheckOpString(std::string* str) : str_(str) { }
-  // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
-  // so there's no point in cleaning up str_.
-  operator bool() const {
-    return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
-  }
-  std::string* str_;
-};
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// CHECK* macros. It's not encouraged though.
-template <class T>
-inline const T&       GetReferenceableValue(const T&           t) { return t; }
-inline char           GetReferenceableValue(char               t) { return t; }
-inline unsigned char  GetReferenceableValue(unsigned char      t) { return t; }
-inline signed char    GetReferenceableValue(signed char        t) { return t; }
-inline short          GetReferenceableValue(short              t) { return t; }
-inline unsigned short GetReferenceableValue(unsigned short     t) { return t; }
-inline int            GetReferenceableValue(int                t) { return t; }
-inline unsigned int   GetReferenceableValue(unsigned int       t) { return t; }
-inline long           GetReferenceableValue(long               t) { return t; }
-inline unsigned long  GetReferenceableValue(unsigned long      t) { return t; }
-inline long long      GetReferenceableValue(long long          t) { return t; }
-inline unsigned long long GetReferenceableValue(unsigned long long t) {
-  return t;
-}
-
-// This is a dummy class to define the following operator.
-struct DummyClassToDefineOperator {};
-
-}
-
-// Define global operator<< to declare using ::operator<<.
-// This declaration will allow use to use CHECK macros for user
-// defined classes which have operator<< (e.g., stl_logging.h).
-inline std::ostream& operator<<(
-    std::ostream& out, const google::DummyClassToDefineOperator&) {
-  return out;
-}
-
-namespace google {
-
-// Build the error message string.
-template<class t1, class t2>
-std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
-  // It means that we cannot use stl_logging if compiler doesn't
-  // support using expression for operator.
-  // TODO(hamaji): Figure out a way to fix.
-#if 1
-  using ::operator<<;
-#endif
-  std::strstream ss;
-  ss << names << " (" << v1 << " vs. " << v2 << ")";
-  return new std::string(ss.str(), ss.pcount());
-}
-
-// Helper functions for CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
-  template <class t1, class t2> \
-  inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
-                                        const char* names) { \
-    if (v1 op v2) return NULL; \
-    else return MakeCheckOpString(v1, v2, names); \
-  } \
-  inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
-    return Check##name##Impl<int, int>(v1, v2, names); \
-  }
-
-// Use _EQ, _NE, _LE, etc. in case the file including base/logging.h
-// provides its own #defines for the simpler names EQ, NE, LE, etc.
-// This happens if, for example, those are used as token names in a
-// yacc grammar.
-DEFINE_CHECK_OP_IMPL(_EQ, ==)
-DEFINE_CHECK_OP_IMPL(_NE, !=)
-DEFINE_CHECK_OP_IMPL(_LE, <=)
-DEFINE_CHECK_OP_IMPL(_LT, < )
-DEFINE_CHECK_OP_IMPL(_GE, >=)
-DEFINE_CHECK_OP_IMPL(_GT, > )
-#undef DEFINE_CHECK_OP_IMPL
-
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-
-#if defined(STATIC_ANALYSIS)
-// Only for static analysis tool to know that it is equivalent to assert
-#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
-// In debug mode, avoid constructing CheckOpStrings if possible,
-// to reduce the overhead of CHECK statments by 2x.
-// Real DCHECK-heavy tests have seen 1.5x speedups.
-
-// The meaning of "string" might be different between now and 
-// when this macro gets invoked (e.g., if someone is experimenting
-// with other string implementations that get defined after this
-// file is included).  Save the current meaning now and use it 
-// in the macro.
-typedef std::string _Check_string;
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::_Check_string* _result =                \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__,                                             \
-        google::CheckOpString(_result)).stream()
-#else
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::CheckOpString _result =                 \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__, _result).stream()
-#endif  // STATIC_ANALYSIS, !NDEBUG
-
-#if GOOGLE_STRIP_LOG <= 3
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
-#else
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::NullStreamFatal)
-#endif // STRIP_LOG <= 3
-
-// Equality/Inequality checks - compare two values, and log a FATAL message
-// including the two values when the result is not as expected.  The values
-// must have operator<<(ostream, ...) defined.
-//
-// You may append to the error message like so:
-//   CHECK_NE(1, 2) << ": The world must be ending!";
-//
-// We are very careful to ensure that each argument is evaluated exactly
-// once, and that anything which is legal to pass as a function argument is
-// legal here.  In particular, the arguments may be temporary expressions
-// which will end up being destroyed at the end of the apparent statement,
-// for example:
-//   CHECK_EQ(string("abc")[1], 'b');
-//
-// WARNING: These don't compile correctly if one of the arguments is a pointer
-// and the other is NULL. To work around this, simply static_cast NULL to the
-// type of the desired pointer.
-
-#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
-
-// Check that the input is non NULL.  This very useful in constructor
-// initializer lists.
-
-#define CHECK_NOTNULL(val) \
-  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
-  GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
-      const char* s1, const char* s2, const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
-  while (google::CheckOpString _result = \
-         google::Check##func##expected##Impl((s1), (s2), \
-                                     #s1 " " #op " " #s2)) \
-    LOG(FATAL) << *_result.str_
-
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_DOUBLE_EQ(val1, val2)              \
-  do {                                           \
-    CHECK_LE((val1), (val2)+0.000000000000001L); \
-    CHECK_GE((val1), (val2)-0.000000000000001L); \
-  } while (0)
-
-#define CHECK_NEAR(val1, val2, margin)           \
-  do {                                           \
-    CHECK_LE((val1), (val2)+(margin));           \
-    CHECK_GE((val1), (val2)-(margin));           \
-  } while (0)
-
-// perror()..googly style!
-//
-// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and
-// CHECK equivalents with the addition that they postpend a description
-// of the current state of errno to their output lines.
-
-#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream()
-
-#define GOOGLE_PLOG(severity, counter)  \
-  google::ErrnoLogMessage( \
-      __FILE__, __LINE__, google::severity, counter, \
-      &google::LogMessage::SendToLog)
-
-#define PLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & PLOG(severity)
-
-// A CHECK() macro that postpends errno if the condition is false. E.g.
-//
-// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... }
-#define PCHECK(condition)  \
-      PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-              << "Check failed: " #condition " "
-
-// A CHECK() macro that lets you assert the success of a function that
-// returns -1 and sets errno in case of an error. E.g.
-//
-// CHECK_ERR(mkdir(path, 0700));
-//
-// or
-//
-// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename;
-#define CHECK_ERR(invocation)                                          \
-PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1))    \
-        << #invocation
-
-// Use macro expansion to create, for each use of LOG_EVERY_N(), static
-// variables with the __LINE__ expansion as part of the variable name.
-#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line)
-#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line
-
-#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__)
-#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__)
-
-#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (condition && \
-      ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-                 &what_to_do).stream()
-
-#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::ErrnoLogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0; \
-  if (LOG_OCCURRENCES <= n) \
-    ++LOG_OCCURRENCES; \
-  if (LOG_OCCURRENCES <= n) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-namespace glog_internal_namespace_ {
-template <bool>
-struct CompileAssert {
-};
-struct CrashReason;
-}  // namespace glog_internal_namespace_
-
-#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
-  typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
-#define LOG_EVERY_N(severity, n)                                        \
-  GOOGLE_GLOG_COMPILE_ASSERT(google::severity <          \
-                             google::NUM_SEVERITIES,     \
-                             INVALID_REQUESTED_LOG_SEVERITY);           \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define SYSLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToSyslogAndLog)
-
-#define PLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_PLOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_FIRST_N(severity, n) \
-  SOME_KIND_OF_LOG_FIRST_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_IF_EVERY_N(severity, condition, n) \
-  SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), google::LogMessage::SendToLog)
-
-// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
-enum PRIVATE_Counter {COUNTER};
-
-
-// Plus some debug-logging macros that get compiled to nothing for production
-
-#ifndef NDEBUG
-
-#define DLOG(severity) LOG(severity)
-#define DVLOG(verboselevel) VLOG(verboselevel)
-#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
-#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  LOG_IF_EVERY_N(severity, condition, n)
-#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-
-// debug-only checking.  not executed in NDEBUG mode.
-#define DCHECK(condition) CHECK(condition)
-#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
-#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
-#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
-#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
-#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
-#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
-#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
-#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
-#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
-#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
-#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-
-#else  // NDEBUG
-
-#define DLOG(severity) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DVLOG(verboselevel) \
-  (true || !VLOG_IS_ON(verboselevel)) ?\
-    (void) 0 : google::LogMessageVoidify() & LOG(INFO)
-
-#define DLOG_IF(severity, condition) \
-  (true || !(condition)) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_EVERY_N(severity, n) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  (true || !(condition))? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_ASSERT(condition) \
-  true ? (void) 0 : LOG_ASSERT(condition)
-
-#define DCHECK(condition) \
-  while (false) \
-    CHECK(condition)
-
-#define DCHECK_EQ(val1, val2) \
-  while (false) \
-    CHECK_EQ(val1, val2)
-
-#define DCHECK_NE(val1, val2) \
-  while (false) \
-    CHECK_NE(val1, val2)
-
-#define DCHECK_LE(val1, val2) \
-  while (false) \
-    CHECK_LE(val1, val2)
-
-#define DCHECK_LT(val1, val2) \
-  while (false) \
-    CHECK_LT(val1, val2)
-
-#define DCHECK_GE(val1, val2) \
-  while (false) \
-    CHECK_GE(val1, val2)
-
-#define DCHECK_GT(val1, val2) \
-  while (false) \
-    CHECK_GT(val1, val2)
-
-#define DCHECK_NOTNULL(val) (val)
-
-#define DCHECK_STREQ(str1, str2) \
-  while (false) \
-    CHECK_STREQ(str1, str2)
-
-#define DCHECK_STRCASEEQ(str1, str2) \
-  while (false) \
-    CHECK_STRCASEEQ(str1, str2)
-
-#define DCHECK_STRNE(str1, str2) \
-  while (false) \
-    CHECK_STRNE(str1, str2)
-
-#define DCHECK_STRCASENE(str1, str2) \
-  while (false) \
-    CHECK_STRCASENE(str1, str2)
-
-
-#endif  // NDEBUG
-
-// Log only in verbose mode.
-
-#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
-
-#define VLOG_IF(verboselevel, condition) \
-  LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel))
-
-#define VLOG_EVERY_N(verboselevel, n) \
-  LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
-
-#define VLOG_IF_EVERY_N(verboselevel, condition, n) \
-  LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n)
-
-//
-// This class more or less represents a particular log message.  You
-// create an instance of LogMessage and then stream stuff to it.
-// When you finish streaming to it, ~LogMessage is called and the
-// full message gets streamed to the appropriate destination.
-//
-// You shouldn't actually use LogMessage's constructor to log things,
-// though.  You should use the LOG() macro (and variants thereof)
-// above.
-class GOOGLE_GLOG_DLL_DECL LogMessage {
-public:
-  enum {
-    // Passing kNoLogPrefix for the line number disables the
-    // log-message prefix. Useful for using the LogMessage
-    // infrastructure as a printing utility. See also the --log_prefix
-    // flag for controlling the log-message prefix on an
-    // application-wide basis.
-    kNoLogPrefix = -1
-  };
-
-  // LogStream inherit from non-DLL-exported class (std::ostrstream)
-  // and VC++ produces a warning for this situation.
-  // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
-  // 2005 if you are deriving from a type in the Standard C++ Library"
-  // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-  // Let's just ignore the warning.
-#ifdef _MSC_VER
-# pragma warning(disable: 4275)
-#endif
-  class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostrstream {
-#ifdef _MSC_VER
-# pragma warning(default: 4275)
-#endif
-  public:
-    LogStream(char *buf, int len, int ctr)
-      : ostrstream(buf, len),
-        ctr_(ctr) {
-      self_ = this;
-    }
-
-    int ctr() const { return ctr_; }
-    void set_ctr(int ctr) { ctr_ = ctr; }
-    LogStream* self() const { return self_; }
-
-  private:
-    int ctr_;  // Counter hack (for the LOG_EVERY_X() macro)
-    LogStream *self_;  // Consistency check hack
-  };
-
-public:
-  // icc 8 requires this typedef to avoid an internal compiler error.
-  typedef void (LogMessage::*SendMethod)();
-
-  LogMessage(const char* file, int line, LogSeverity severity, int ctr,
-             SendMethod send_method);
-
-  // Two special constructors that generate reduced amounts of code at
-  // LOG call sites for common cases.
-
-  // Used for LOG(INFO): Implied are:
-  // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog.
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 19 bytes per call site.
-  LogMessage(const char* file, int line);
-
-  // Used for LOG(severity) where severity != INFO.  Implied
-  // are: ctr = 0, send_method = &LogMessage::SendToLog
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 17 bytes per call site.
-  LogMessage(const char* file, int line, LogSeverity severity);
-
-  // Constructor to log this message to a specified sink (if not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
-  // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
-  LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
-             bool also_send_to_log);
-
-  // Constructor where we also give a vector<string> pointer
-  // for storing the messages (if the pointer is not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::vector<std::string>* outvec);
-
-  // Constructor where we also give a string pointer for storing the
-  // message (if the pointer is not NULL).  Implied are: ctr = 0,
-  // send_method = &LogMessage::WriteToStringAndLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::string* message);
-
-  // A special constructor used for check failures
-  LogMessage(const char* file, int line, const CheckOpString& result);
-
-  ~LogMessage();
-
-  // Flush a buffered message to the sink set in the constructor.  Always
-  // called by the destructor, it may also be called from elsewhere if
-  // needed.  Only the first call is actioned; any later ones are ignored.
-  void Flush();
-
-  // An arbitrary limit on the length of a single log message.  This
-  // is so that streaming can be done more efficiently.
-  static const size_t kMaxLogMessageLen;
-
-  // Theses should not be called directly outside of logging.*,
-  // only passed as SendMethod arguments to other LogMessage methods:
-  void SendToLog();  // Actually dispatch to the logs
-  void SendToSyslogAndLog();  // Actually dispatch to syslog and the logs
-
-  // Call abort() or similar to perform LOG(FATAL) crash.
-  static void Fail() __attribute__ ((noreturn));
-
-  std::ostream& stream() { return *(data_->stream_); }
-
-  int preserved_errno() const { return data_->preserved_errno_; }
-
-  // Must be called without the log_mutex held.  (L < log_mutex)
-  static int64 num_messages(int severity);
-
-private:
-  // Fully internal SendMethod cases:
-  void SendToSinkAndLog();  // Send to sink if provided and dispatch to the logs
-  void SendToSink();  // Send to sink if provided, do nothing otherwise.
-
-  // Write to string if provided and dispatch to the logs.
-  void WriteToStringAndLog();
-
-  void SaveOrSendToLog();  // Save to stringvec if provided, else to logs
-
-  void Init(const char* file, int line, LogSeverity severity,
-            void (LogMessage::*send_method)());
-
-  // Used to fill in crash information during LOG(FATAL) failures.
-  void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
-
-  // Counts of messages sent at each priority:
-  static int64 num_messages_[NUM_SEVERITIES];  // under log_mutex
-
-  // We keep the data in a separate struct so that each instance of
-  // LogMessage uses less stack space.
-  struct GOOGLE_GLOG_DLL_DECL LogMessageData {
-    LogMessageData() {};
-
-    int preserved_errno_;      // preserved errno
-    char* buf_;
-    char* message_text_;  // Complete message text (points to selected buffer)
-    LogStream* stream_alloc_;
-    LogStream* stream_;
-    char severity_;      // What level is this LogMessage logged at?
-    int line_;                 // line number where logging call is.
-    void (LogMessage::*send_method_)();  // Call this in destructor to send
-    union {  // At most one of these is used: union to keep the size low.
-      LogSink* sink_;             // NULL or sink to send message to
-      std::vector<std::string>* outvec_; // NULL or vector to push message onto
-      std::string* message_;             // NULL or string to write message into
-    };
-    time_t timestamp_;            // Time of creation of LogMessage
-    struct ::tm tm_time_;         // Time of creation of LogMessage
-    size_t num_prefix_chars_;     // # of chars of prefix in this message
-    size_t num_chars_to_log_;     // # of chars of msg to send to log
-    size_t num_chars_to_syslog_;  // # of chars of msg to send to syslog
-    const char* basename_;        // basename of file that called LOG
-    const char* fullname_;        // fullname of file that called LOG
-    bool has_been_flushed_;       // false => data has not been flushed
-    bool first_fatal_;            // true => this was first fatal msg
-
-    ~LogMessageData();
-   private:
-    LogMessageData(const LogMessageData&);
-    void operator=(const LogMessageData&);
-  };
-
-  static LogMessageData fatal_msg_data_exclusive_;
-  static LogMessageData fatal_msg_data_shared_;
-
-  LogMessageData* allocated_;
-  LogMessageData* data_;
-
-  friend class LogDestination;
-
-  LogMessage(const LogMessage&);
-  void operator=(const LogMessage&);
-};
-
-// This class happens to be thread-hostile because all instances share
-// a single data buffer, but since it can only be created just before
-// the process dies, we don't worry so much.
-class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
- public:
-  LogMessageFatal(const char* file, int line);
-  LogMessageFatal(const char* file, int line, const CheckOpString& result);
-  ~LogMessageFatal() __attribute__ ((noreturn));
-};
-
-// A non-macro interface to the log facility; (useful
-// when the logging level is not a compile-time constant).
-inline void LogAtLevel(int const severity, std::string const &msg) {
-  LogMessage(__FILE__, __LINE__, severity).stream() << msg;
-}
-
-// A macro alternative of LogAtLevel. New code may want to use this
-// version since there are two advantages: 1. this version outputs the
-// file name and the line number where this macro is put like other
-// LOG macros, 2. this macro can be used as C++ stream.
-#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
-
-// A small helper for CHECK_NOTNULL().
-template <typename T>
-T* CheckNotNull(const char *file, int line, const char *names, T* t) {
-  if (t == NULL) {
-    LogMessageFatal(file, line, new std::string(names));
-  }
-  return t;
-}
-
-// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
-// only works if ostream is a LogStream. If the ostream is not a
-// LogStream you'll get an assert saying as much at runtime.
-GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
-                                              const PRIVATE_Counter&);
-
-
-// Derived class for PLOG*() above.
-class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
- public:
-
-  ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
-                  void (LogMessage::*send_method)());
-
-  // Postpends ": strerror(errno) [errno]".
-  ~ErrnoLogMessage();
-
- private:
-  ErrnoLogMessage(const ErrnoLogMessage&);
-  void operator=(const ErrnoLogMessage&);
-};
-
-
-// This class is used to explicitly ignore values in the conditional
-// logging macros.  This avoids compiler warnings like "value computed
-// is not used" and "statement has no effect".
-
-class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
- public:
-  LogMessageVoidify() { }
-  // This has to be an operator with a precedence lower than << but
-  // higher than ?:
-  void operator&(std::ostream&) { }
-};
-
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level. Thread-hostile because it ignores
-// locking -- used for catastrophic failures.
-GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
-
-//
-// Set the destination to which a particular severity level of log
-// messages is sent.  If base_filename is "", it means "don't log this
-// severity".  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
-                                            const char* base_filename);
-
-//
-// Set the basename of the symlink to the latest log file at a given
-// severity.  If symlink_basename is empty, do not make a symlink.  If
-// you don't call this function, the symlink basename is the
-// invocation name of the program.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
-                                        const char* symlink_basename);
-
-//
-// Used to send logs to some other kind of destination
-// Users should subclass LogSink and override send to do whatever they want.
-// Implementations must be thread-safe because a shared instance will
-// be called from whichever thread ran the LOG(XXX) line.
-class GOOGLE_GLOG_DLL_DECL LogSink {
- public:
-  virtual ~LogSink();
-
-  // Sink's logging logic (message_len is such as to exclude '\n' at the end).
-  // This method can't use LOG() or CHECK() as logging system mutex(s) are held
-  // during this call.
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct ::tm* tm_time,
-                    const char* message, size_t message_len) = 0;
-
-  // Redefine this to implement waiting for
-  // the sink's logging logic to complete.
-  // It will be called after each send() returns,
-  // but before that LogMessage exits or crashes.
-  // By default this function does nothing.
-  // Using this function one can implement complex logic for send()
-  // that itself involves logging; and do all this w/o causing deadlocks and
-  // inconsistent rearrangement of log messages.
-  // E.g. if a LogSink has thread-specific actions, the send() method
-  // can simply add the message to a queue and wake up another thread that
-  // handles real logging while itself making some LOG() calls;
-  // WaitTillSent() can be implemented to wait for that logic to complete.
-  // See our unittest for an example.
-  virtual void WaitTillSent();
-
-  // Returns the normal text output of the log message.
-  // Can be useful to implement send().
-  static std::string ToString(LogSeverity severity, const char* file, int line,
-                              const struct ::tm* tm_time,
-                              const char* message, size_t message_len);
-};
-
-// Add or remove a LogSink as a consumer of logging data.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
-GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
-
-//
-// Specify an "extension" added to the filename specified via
-// SetLogDestination.  This applies to all severity levels.  It's
-// often used to append the port we're listening on to the logfile
-// name.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
-    const char* filename_extension);
-
-//
-// Make it so that all log messages of at least a particular severity
-// are logged to stderr (in addition to logging to the usual log
-// file(s)).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
-
-//
-// Make it so that all log messages go only to stderr.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
-//
-// Make it so that all log messages of at least a particular severity are
-// logged via email to a list of addresses (in addition to logging to the
-// usual log file(s)).  The list of addresses is just a string containing
-// the email addresses to send to (separated by spaces, say).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
-                                          const char* addresses);
-
-// A simple function that sends email. dest is a commma-separated
-// list of addressess.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
-                                    const char *subject, const char *body);
-
-GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
-
-// For tests only:  Clear the internal [cached] list of logging directories to
-// force a refresh the next time GetLoggingDirectories is called.
-// Thread-hostile.
-void TestOnly_ClearLoggingDirectoriesList();
-
-// Returns a set of existing temporary directories, which will be a
-// subset of the directories returned by GetLogginDirectories().
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
-    std::vector<std::string>* list);
-
-// Print any fatal message again -- useful to call from signal handler
-// so that the last thing in the output is the fatal message.
-// Thread-hostile, but a race is unlikely.
-GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
-
-// Truncate a log file that may be the append-only output of multiple
-// processes and hence can't simply be renamed/reopened (typically a
-// stdout/stderr).  If the file "path" is > "limit" bytes, copy the
-// last "keep" bytes to offset 0 and truncate the rest. Since we could
-// be racing with other writers, this approach has the potential to
-// lose very small amounts of data. For security, only follow symlinks
-// if the path is /proc/self/fd/*
-GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
-                                          int64 limit, int64 keep);
-
-// Truncate stdout and stderr if they are over the value specified by
-// --max_log_size; keep the final 1MB.  This function has the same
-// race condition as TruncateLogFile.
-GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
-
-// Return the string representation of the provided LogSeverity level.
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
-
-// ---------------------------------------------------------------------
-// Implementation details that are not useful to most clients
-// ---------------------------------------------------------------------
-
-// A Logger is the interface used by logging modules to emit entries
-// to a log.  A typical implementation will dump formatted data to a
-// sequence of files.  We also provide interfaces that will forward
-// the data to another thread so that the invoker never blocks.
-// Implementations should be thread-safe since the logging system
-// will write to them from multiple threads.
-
-namespace base {
-
-class GOOGLE_GLOG_DLL_DECL Logger {
- public:
-  virtual ~Logger();
-
-  // Writes "message[0,message_len-1]" corresponding to an event that
-  // occurred at "timestamp".  If "force_flush" is true, the log file
-  // is flushed immediately.
-  //
-  // The input message has already been formatted as deemed
-  // appropriate by the higher level logging facility.  For example,
-  // textual log messages already contain timestamps, and the
-  // file:linenumber header.
-  virtual void Write(bool force_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int message_len) = 0;
-
-  // Flush any buffered messages
-  virtual void Flush() = 0;
-
-  // Get the current LOG file size.
-  // The returned value is approximate since some
-  // logged data may not have been flushed to disk yet.
-  virtual uint32 LogSize() = 0;
-};
-
-// Get the logger for the specified severity level.  The logger
-// remains the property of the logging module and should not be
-// deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
-
-// Set the logger for the specified severity level.  The logger
-// becomes the property of the logging module and should not
-// be deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
-
-}
-
-// glibc has traditionally implemented two incompatible versions of
-// strerror_r(). There is a poorly defined convention for picking the
-// version that we want, but it is not clear whether it even works with
-// all versions of glibc.
-// So, instead, we provide this wrapper that automatically detects the
-// version that is in use, and then implements POSIX semantics.
-// N.B. In addition to what POSIX says, we also guarantee that "buf" will
-// be set to an empty string, if this function failed. This means, in most
-// cases, you do not need to check the error code and you can directly
-// use the value of "buf". It will never have an undefined value.
-GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
-
-
-// A class for which we define operator<<, which does nothing.
-class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
- public:
-  // Initialize the LogStream so the messages can be written somewhere
-  // (they'll never be actually displayed). This will be needed if a
-  // NullStream& is implicitly converted to LogStream&, in which case
-  // the overloaded NullStream::operator<< will not be invoked.
-  NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream(const char* /*file*/, int /*line*/,
-             const CheckOpString& /*result*/) :
-      LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream &stream() { return *this; }
- private:
-  // A very short buffer for messages (which we discard anyway). This
-  // will be needed if NullStream& converted to LogStream& (e.g. as a
-  // result of a conditional expression).
-  char message_buffer_[2];
-};
-
-// Do nothing. This operator is inline, allowing the message to be
-// compiled away. The message will not be compiled away if we do
-// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when
-// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly
-// converted to LogStream and the message will be computed and then
-// quietly discarded.
-template<class T>
-inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
-
-// Similar to NullStream, but aborts the program (without stack
-// trace), like LogMessageFatal.
-class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
- public:
-  NullStreamFatal() { }
-  NullStreamFatal(const char* file, int line, const CheckOpString& result) :
-      NullStream(file, line, result) { }
-  __attribute__ ((noreturn)) ~NullStreamFatal() { _exit(1); }
-};
-
-// Install a signal handler that will dump signal information and a stack
-// trace when the program crashes on certain signals.  We'll install the
-// signal handler for the following signals.
-//
-// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
-//
-// By default, the signal handler will write the failure dump to the
-// standard error.  You can customize the destination by installing your
-// own writer function by InstallFailureWriter() below.
-//
-// Note on threading:
-//
-// The function should be called before threads are created, if you want
-// to use the failure signal handler for all threads.  The stack trace
-// will be shown only for the thread that receives the signal.  In other
-// words, stack traces of other threads won't be shown.
-GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
-
-// Installs a function that is used for writing the failure dump.  "data"
-// is the pointer to the beginning of a message to be written, and "size"
-// is the size of the message.  You should not expect the data is
-// terminated with '\0'.
-GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
-    void (*writer)(const char* data, int size));
-
-}
-
-#endif // _LOGGING_H_

+ 0 - 185
Src/ThirdParty/glog/src/glog/raw_logging.h

@@ -1,185 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// Thread-safe logging routines that do not allocate any memory or
-// acquire any locks, and can therefore be used by low-level memory
-// allocation and synchronization code.
-
-#ifndef BASE_RAW_LOGGING_H_
-#define BASE_RAW_LOGGING_H_
-
-#include <time.h>
-
-namespace google {
-
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// This is similar to LOG(severity) << format... and VLOG(level) << format..,
-// but
-// * it is to be used ONLY by low-level modules that can't use normal LOG()
-// * it is desiged to be a low-level logger that does not allocate any
-//   memory and does not need any locks, hence:
-// * it logs straight and ONLY to STDERR w/o buffering
-// * it uses an explicit format and arguments list
-// * it will silently chop off really long message strings
-// Usage example:
-//   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
-//   RAW_VLOG(3, "status is %i", status);
-// These will print an almost standard log lines like this to stderr only:
-//   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
-//   I0821 211317 file.cc:142] RAW: status is 20
-#define RAW_LOG(severity, ...) \
-  do { \
-    switch (google::severity) {  \
-      case 0: \
-        RAW_LOG_INFO(__VA_ARGS__); \
-        break; \
-      case 1: \
-        RAW_LOG_WARNING(__VA_ARGS__); \
-        break; \
-      case 2: \
-        RAW_LOG_ERROR(__VA_ARGS__); \
-        break; \
-      case 3: \
-        RAW_LOG_FATAL(__VA_ARGS__); \
-        break; \
-      default: \
-        break; \
-    } \
-  } while (0)
-
-// The following STRIP_LOG testing is performed in the header file so that it's
-// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0
-#define RAW_VLOG(verboselevel, ...) \
-  do { \
-    if (VLOG_IS_ON(verboselevel)) { \
-      RAW_LOG_INFO(__VA_ARGS__); \
-    } \
-  } while (0)
-#else
-#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
-                                   __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING,   \
-                                      __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 1
-
-#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 2
-
-#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_FATAL(...) \
-  do { \
-    google::RawLogStub__(0, __VA_ARGS__);        \
-    exit(1); \
-  } while (0)
-#endif // STRIP_LOG <= 3
-
-// Similar to CHECK(condition) << message,
-// but for low-level modules: we use only RAW_LOG that does not allocate memory.
-// We do not want to provide args list here to encourage this usage:
-//   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
-// so that the args are not computed when not needed.
-#define RAW_CHECK(condition, message)                                   \
-  do {                                                                  \
-    if (!(condition)) {                                                 \
-      RAW_LOG(FATAL, "Check %s failed: %s", #condition, message);       \
-    }                                                                   \
-  } while (0)
-
-// Debug versions of RAW_LOG and RAW_CHECK
-#ifndef NDEBUG
-
-#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
-
-#else  // NDEBUG
-
-#define RAW_DLOG(severity, ...)                                 \
-  while (false)                                                 \
-    RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) \
-  while (false) \
-    RAW_CHECK(condition, message)
-
-#endif  // NDEBUG
-
-// Stub log function used to work around for unused variable warnings when
-// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int ignored, ...) {
-}
-
-// Helper function to implement RAW_LOG and RAW_VLOG
-// Logs format... at "severity" level, reporting it
-// as called from file:line.
-// This does not allocate memory or acquire locks.
-GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
-                                   const char* file,
-                                   int line,
-                                   const char* format, ...)
-   __attribute__((__format__ (__printf__, 4, 5)));
-
-// Hack to propagate time information into this module so that
-// this module does not have to directly call localtime_r(),
-// which could allocate memory.
-GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
-
-}
-
-#endif  // BASE_RAW_LOGGING_H_

+ 0 - 154
Src/ThirdParty/glog/src/glog/stl_logging.h

@@ -1,154 +0,0 @@
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Stream output operators for STL containers; to be used for logging *only*.
-// Inclusion of this file lets you do:
-//
-// list<string> x;
-// LOG(INFO) << "data: " << x;
-// vector<int> v1, v2;
-// CHECK_EQ(v1, v2);
-//
-// Note that if you want to use these operators from the non-global namespace,
-// you may get an error since they are not in namespace std (and they are not
-// in namespace std since that would result in undefined behavior). You may
-// need to write
-//
-//   using ::operator<<;
-//
-// to fix these errors.
-
-#ifndef UTIL_GTL_STL_LOGGING_INL_H_
-#define UTIL_GTL_STL_LOGGING_INL_H_
-
-#if !1
-# error We do not support stl_logging for this compiler
-#endif
-
-#include <deque>
-#include <list>
-#include <map>
-#include <ostream>
-#include <set>
-#include <utility>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_set>
-# include <ext/hash_map>
-# include <ext/slist>
-#endif
-
-template<class First, class Second>
-inline std::ostream& operator<<(std::ostream& out,
-                                const std::pair<First, Second>& p) {
-  out << '(' << p.first << ", " << p.second << ')';
-  return out;
-}
-
-namespace google {
-
-template<class Iter>
-inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
-  using ::operator<<;
-  // Output at most 100 elements -- appropriate if used for logging.
-  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
-    if (i > 0) out << ' ';
-    out << *begin;
-  }
-  if (begin != end) {
-    out << " ...";
-  }
-}
-
-}
-
-#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
-template<class T1, class T2> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_TWO_ARG_CONTAINER(std::vector)
-OUTPUT_TWO_ARG_CONTAINER(std::deque)
-OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
-OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
-#endif
-
-#undef OUTPUT_TWO_ARG_CONTAINER
-
-#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_THREE_ARG_CONTAINER(std::set)
-OUTPUT_THREE_ARG_CONTAINER(std::multiset)
-
-#undef OUTPUT_THREE_ARG_CONTAINER
-
-#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_FOUR_ARG_CONTAINER(std::map)
-OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
-#ifdef __GNUC__
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
-#endif
-
-#undef OUTPUT_FOUR_ARG_CONTAINER
-
-#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4, class T5> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-#ifdef __GNUC__
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
-#endif
-
-#undef OUTPUT_FIVE_ARG_CONTAINER
-
-#endif  // UTIL_GTL_STL_LOGGING_INL_H_

+ 0 - 129
Src/ThirdParty/glog/src/glog/vlog_is_on.h

@@ -1,129 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Defines the VLOG_IS_ON macro that controls the variable-verbosity
-// conditional logging.
-//
-// It's used by VLOG and VLOG_IF in logging.h
-// and by RAW_VLOG in raw_logging.h to trigger the logging.
-//
-// It can also be used directly e.g. like this:
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished e.g. via just VLOG(2) << ...;
-//   }
-//
-// The truth value that VLOG_IS_ON(level) returns is determined by 
-// the three verbosity level flags:
-//   --v=<n>  Gives the default maximal active V-logging level;
-//            0 is the default.
-//            Normally positive values are used for V-logging levels.
-//   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
-//                    the value given by --v.
-//                    E.g. "my_module=2,foo*=3" would change the logging level
-//                    for all code in source files "my_module.*" and "foo*.*"
-//                    ("-inl" suffixes are also disregarded for this matching).
-//
-// SetVLOGLevel helper function is provided to do limited dynamic control over
-// V-logging by overriding the per-module settings given via --vmodule flag.
-//
-// CAVEAT: --vmodule functionality is not available in non gcc compilers.
-//
-
-#ifndef BASE_VLOG_IS_ON_H_
-#define BASE_VLOG_IS_ON_H_
-
-#include "glog/log_severity.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-#if defined(__GNUC__)
-// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
-// (Normally) the first time every VLOG_IS_ON(n) site is hit,
-// we determine what variable will dynamically control logging at this site:
-// it's either FLAGS_v or an appropriate internal variable
-// matching the current source file that represents results of
-// parsing of --vmodule flag and/or SetVLOGLevel calls.
-#define VLOG_IS_ON(verboselevel)                                \
-  __extension__  \
-  ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
-     google::int32 verbose_level__ = (verboselevel);                    \
-     (*vlocal__ >= verbose_level__) &&                          \
-     ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
-      (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
-                   __FILE__, verbose_level__))); })
-#else
-// GNU extensions not available, so we do not support --vmodule.
-// Dynamic value of FLAGS_v always controls the logging level.
-#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
-#endif
-
-// Set VLOG(_IS_ON) level for module_pattern to log_level.
-// This lets us dynamically control what is normally set by the --vmodule flag.
-// Returns the level that previously applied to module_pattern.
-// NOTE: To change the log level for VLOG(_IS_ON) sites
-//	 that have already executed after/during InitGoogleLogging,
-//	 one needs to supply the exact --vmodule pattern that applied to them.
-//       (If no --vmodule pattern applied to them
-//       the value of FLAGS_v will continue to control them.)
-extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
-                                             int log_level);
-
-// Various declarations needed for VLOG_IS_ON above: =========================
-
-// Special value used to indicate that a VLOG_IS_ON site has not been
-// initialized.  We make this a large value, so the common-case check
-// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
-// passes in such cases and InitVLOG3__ is then triggered.
-extern google::int32 kLogSiteUninitialized;
-
-// Helper routine which determines the logging info for a particalur VLOG site.
-//   site_flag     is the address of the site-local pointer to the controlling
-//                 verbosity level
-//   site_default  is the default to use for *site_flag
-//   fname         is the current source file name
-//   verbose_level is the argument to VLOG_IS_ON
-// We will return the return value for VLOG_IS_ON
-// and if possible set *site_flag appropriately.
-extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
-    google::int32** site_flag,
-    google::int32* site_default,
-    const char* fname,
-    google::int32 verbose_level);
-
-#endif  // BASE_VLOG_IS_ON_H_

+ 0 - 604
Src/ThirdParty/glog/src/googletest.h

@@ -1,604 +0,0 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-//   (based on googletest: http://code.google.com/p/googletest/)
-
-#ifdef GOOGLETEST_H__
-#error You must not include this file twice.
-#endif
-#define GOOGLETEST_H__
-
-#include "utilities.h"
-
-#include <ctype.h>
-#include <setjmp.h>
-#include <time.h>
-
-#include <map>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include "base/commandlineflags.h"
-
-using std::map;
-using std::string;
-using std::vector;
-
-_START_GOOGLE_NAMESPACE_
-
-extern GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)();
-
-_END_GOOGLE_NAMESPACE_
-
-#undef GOOGLE_GLOG_DLL_DECL
-#define GOOGLE_GLOG_DLL_DECL
-
-static inline string GetTempDir() {
-#ifndef OS_WINDOWS
-  return "/tmp";
-#else
-  char tmp[MAX_PATH];
-  GetTempPathA(MAX_PATH, tmp);
-  return tmp;
-#endif
-}
-
-#ifdef OS_WINDOWS
-// The test will run in glog/vsproject/<project name>
-// (e.g., glog/vsproject/logging_unittest).
-static const char TEST_SRC_DIR[] = "../..";
-#elif !defined(TEST_SRC_DIR)
-# warning TEST_SRC_DIR should be defined in config.h
-static const char TEST_SRC_DIR[] = ".";
-#endif
-
-DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files");
-DEFINE_string(test_srcdir, TEST_SRC_DIR,
-              "Source-dir root, needed to find glog_unittest_flagfile");
-DEFINE_bool(run_benchmark, false, "If true, run benchmarks");
-#ifdef NDEBUG
-DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark");
-#else
-DEFINE_int32(benchmark_iters, 100000, "Number of iterations per benchmark");
-#endif
-
-#ifdef HAVE_LIB_GTEST
-# include <gtest/gtest.h>
-// Use our ASSERT_DEATH implementation.
-# undef ASSERT_DEATH
-# undef ASSERT_DEBUG_DEATH
-using testing::InitGoogleTest;
-#else
-
-_START_GOOGLE_NAMESPACE_
-
-void InitGoogleTest(int* argc, char** argv) {}
-
-// The following is some bare-bones testing infrastructure
-
-#define EXPECT_TRUE(cond)                               \
-  do {                                                  \
-    if (!(cond)) {                                      \
-      fprintf(stderr, "Check failed: %s\n", #cond);     \
-      exit(1);                                          \
-    }                                                   \
-  } while (0)
-
-#define EXPECT_FALSE(cond)  EXPECT_TRUE(!(cond))
-
-#define EXPECT_OP(op, val1, val2)                                       \
-  do {                                                                  \
-    if (!((val1) op (val2))) {                                          \
-      fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_EQ(val1, val2)  EXPECT_OP(==, val1, val2)
-#define EXPECT_NE(val1, val2)  EXPECT_OP(!=, val1, val2)
-#define EXPECT_GT(val1, val2)  EXPECT_OP(>, val1, val2)
-#define EXPECT_LT(val1, val2)  EXPECT_OP(<, val1, val2)
-
-#define EXPECT_NAN(arg)                                         \
-  do {                                                          \
-    if (!isnan(arg)) {                                          \
-      fprintf(stderr, "Check failed: isnan(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-
-#define EXPECT_INF(arg)                                         \
-  do {                                                          \
-    if (!isinf(arg)) {                                          \
-      fprintf(stderr, "Check failed: isinf(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-
-#define EXPECT_DOUBLE_EQ(val1, val2)                                    \
-  do {                                                                  \
-    if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) {         \
-      fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2);        \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_STREQ(val1, val2)                                        \
-  do {                                                                  \
-    if (strcmp((val1), (val2)) != 0) {                                  \
-      fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-vector<void (*)()> g_testlist;  // the tests to run
-
-#define TEST(a, b)                                      \
-  struct Test_##a##_##b {                               \
-    Test_##a##_##b() { g_testlist.push_back(&Run); }    \
-    static void Run() { FlagSaver fs; RunTest(); }      \
-    static void RunTest();                              \
-  };                                                    \
-  static Test_##a##_##b g_test_##a##_##b;               \
-  void Test_##a##_##b::RunTest()
-
-
-static inline int RUN_ALL_TESTS() {
-  vector<void (*)()>::const_iterator it;
-  for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
-    (*it)();
-  }
-  fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
-  return 0;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // ! HAVE_LIB_GTEST
-
-_START_GOOGLE_NAMESPACE_
-
-static bool g_called_abort;
-static jmp_buf g_jmp_buf;
-static inline void CalledAbort() {
-  g_called_abort = true;
-  longjmp(g_jmp_buf, 1);
-}
-
-#ifdef OS_WINDOWS
-// TODO(hamaji): Death test somehow doesn't work in Windows.
-#define ASSERT_DEATH(fn, msg)
-#else
-#define ASSERT_DEATH(fn, msg)                                           \
-  do {                                                                  \
-    g_called_abort = false;                                             \
-    /* in logging.cc */                                                 \
-    void (*original_logging_fail_func)() = g_logging_fail_func;         \
-    g_logging_fail_func = &CalledAbort;                                 \
-    if (!setjmp(g_jmp_buf)) fn;                                         \
-    /* set back to their default */                                     \
-    g_logging_fail_func = original_logging_fail_func;                   \
-    if (!g_called_abort) {                                              \
-      fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn);      \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-#endif
-
-#ifdef NDEBUG
-#define ASSERT_DEBUG_DEATH(fn, msg)
-#else
-#define ASSERT_DEBUG_DEATH(fn, msg) ASSERT_DEATH(fn, msg)
-#endif  // NDEBUG
-
-// Benchmark tools.
-
-#define BENCHMARK(n) static BenchmarkRegisterer __benchmark_ ## n (#n, &n);
-
-map<string, void (*)(int)> g_benchlist;  // the benchmarks to run
-
-class BenchmarkRegisterer {
- public:
-  BenchmarkRegisterer(const char* name, void (*function)(int iters)) {
-    EXPECT_TRUE(g_benchlist.insert(std::make_pair(name, function)).second);
-  }
-};
-
-static inline void RunSpecifiedBenchmarks() {
-  if (!FLAGS_run_benchmark) {
-    return;
-  }
-
-  int iter_cnt = FLAGS_benchmark_iters;
-  puts("Benchmark\tTime(ns)\tIterations");
-  for (map<string, void (*)(int)>::const_iterator iter = g_benchlist.begin();
-       iter != g_benchlist.end();
-       ++iter) {
-    clock_t start = clock();
-    iter->second(iter_cnt);
-    double elapsed_ns =
-        ((double)clock() - start) / CLOCKS_PER_SEC * 1000*1000*1000;
-    printf("%s\t%8.2lf\t%10d\n",
-           iter->first.c_str(), elapsed_ns / iter_cnt, iter_cnt);
-  }
-  puts("");
-}
-
-// ----------------------------------------------------------------------
-// Golden file functions
-// ----------------------------------------------------------------------
-
-class CapturedStream {
- public:
-  CapturedStream(int fd, const string & filename) :
-    fd_(fd),
-    uncaptured_fd_(-1),
-    filename_(filename) {
-    Capture();
-  }
-
-  ~CapturedStream() {
-    if (uncaptured_fd_ != -1) {
-      CHECK(close(uncaptured_fd_) != -1);
-    }
-  }
-
-  // Start redirecting output to a file
-  void Capture() {
-    // Keep original stream for later
-    CHECK(uncaptured_fd_ == -1) << ", Stream " << fd_ << " already captured!";
-    uncaptured_fd_ = dup(fd_);
-    CHECK(uncaptured_fd_ != -1);
-
-    // Open file to save stream to
-    int cap_fd = open(filename_.c_str(),
-                      O_CREAT | O_TRUNC | O_WRONLY,
-                      S_IRUSR | S_IWUSR);
-    CHECK(cap_fd != -1);
-
-    // Send stdout/stderr to this file
-    fflush(NULL);
-    CHECK(dup2(cap_fd, fd_) != -1);
-    CHECK(close(cap_fd) != -1);
-  }
-
-  // Remove output redirection
-  void StopCapture() {
-    // Restore original stream
-    if (uncaptured_fd_ != -1) {
-      fflush(NULL);
-      CHECK(dup2(uncaptured_fd_, fd_) != -1);
-    }
-  }
-
-  const string & filename() const { return filename_; }
-
- private:
-  int fd_;             // file descriptor being captured
-  int uncaptured_fd_;  // where the stream was originally being sent to
-  string filename_;    // file where stream is being saved
-};
-static CapturedStream * s_captured_streams[STDERR_FILENO+1];
-// Redirect a file descriptor to a file.
-//   fd       - Should be STDOUT_FILENO or STDERR_FILENO
-//   filename - File where output should be stored
-static inline void CaptureTestOutput(int fd, const string & filename) {
-  CHECK((fd == STDOUT_FILENO) || (fd == STDERR_FILENO));
-  CHECK(s_captured_streams[fd] == NULL);
-  s_captured_streams[fd] = new CapturedStream(fd, filename);
-}
-static inline void CaptureTestStderr() {
-  CaptureTestOutput(STDERR_FILENO, FLAGS_test_tmpdir + "/captured.err");
-}
-// Return the size (in bytes) of a file
-static inline size_t GetFileSize(FILE * file) {
-  fseek(file, 0, SEEK_END);
-  return static_cast<size_t>(ftell(file));
-}
-// Read the entire content of a file as a string
-static inline string ReadEntireFile(FILE * file) {
-  const size_t file_size = GetFileSize(file);
-  char * const buffer = new char[file_size];
-
-  size_t bytes_last_read = 0;  // # of bytes read in the last fread()
-  size_t bytes_read = 0;       // # of bytes read so far
-
-  fseek(file, 0, SEEK_SET);
-
-  // Keep reading the file until we cannot read further or the
-  // pre-determined file size is reached.
-  do {
-    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
-    bytes_read += bytes_last_read;
-  } while (bytes_last_read > 0 && bytes_read < file_size);
-
-  const string content = string(buffer, buffer+bytes_read);
-  delete[] buffer;
-
-  return content;
-}
-// Get the captured stdout (when fd is STDOUT_FILENO) or stderr (when
-// fd is STDERR_FILENO) as a string
-static inline string GetCapturedTestOutput(int fd) {
-  CHECK(fd == STDOUT_FILENO || fd == STDERR_FILENO);
-  CapturedStream * const cap = s_captured_streams[fd];
-  CHECK(cap)
-    << ": did you forget CaptureTestStdout() or CaptureTestStderr()?";
-
-  // Make sure everything is flushed.
-  cap->StopCapture();
-
-  // Read the captured file.
-  FILE * const file = fopen(cap->filename().c_str(), "r");
-  const string content = ReadEntireFile(file);
-  fclose(file);
-
-  delete cap;
-  s_captured_streams[fd] = NULL;
-
-  return content;
-}
-// Get the captured stderr of a test as a string.
-static inline string GetCapturedTestStderr() {
-  return GetCapturedTestOutput(STDERR_FILENO);
-}
-
-// Check if the string is [IWEF](\d{4}|DATE)
-static inline bool IsLoggingPrefix(const string& s) {
-  if (s.size() != 5) return false;
-  if (!strchr("IWEF", s[0])) return false;
-  for (int i = 1; i <= 4; ++i) {
-    if (!isdigit(s[i]) && s[i] != "DATE"[i-1]) return false;
-  }
-  return true;
-}
-
-// Convert log output into normalized form.
-//
-// Example:
-//     I0102 030405 logging_unittest.cc:345] RAW: vlog -1
-//  => IDATE TIME__ logging_unittest.cc:LINE] RAW: vlog -1
-static inline string MungeLine(const string& line) {
-  std::istringstream iss(line);
-  string before, logcode_date, time, thread_lineinfo;
-  iss >> logcode_date;
-  while (!IsLoggingPrefix(logcode_date)) {
-    before += " " + logcode_date;
-    if (!(iss >> logcode_date)) {
-      // We cannot find the header of log output.
-      return before;
-    }
-  }
-  if (!before.empty()) before += " ";
-  iss >> time;
-  iss >> thread_lineinfo;
-  CHECK(!thread_lineinfo.empty());
-  if (thread_lineinfo[thread_lineinfo.size() - 1] != ']') {
-    // We found thread ID.
-    string tmp;
-    iss >> tmp;
-    CHECK(!tmp.empty());
-    CHECK_EQ(']', tmp[tmp.size() - 1]);
-    thread_lineinfo = "THREADID " + tmp;
-  }
-  size_t index = thread_lineinfo.find(':');
-  CHECK_NE(string::npos, index);
-  thread_lineinfo = thread_lineinfo.substr(0, index+1) + "LINE]";
-  string rest;
-  std::getline(iss, rest);
-  return (before + logcode_date[0] + "DATE TIME__ " + thread_lineinfo +
-          MungeLine(rest));
-}
-
-static inline void StringReplace(string* str,
-                          const string& oldsub,
-                          const string& newsub) {
-  size_t pos = str->find(oldsub);
-  if (pos != string::npos) {
-    str->replace(pos, oldsub.size(), newsub.c_str());
-  }
-}
-
-static inline string Munge(const string& filename) {
-  FILE* fp = fopen(filename.c_str(), "rb");
-  CHECK(fp != NULL) << filename << ": couldn't open";
-  char buf[4096];
-  string result;
-  while (fgets(buf, 4095, fp)) {
-    string line = MungeLine(buf);
-    char null_str[256];
-    sprintf(null_str, "%p", static_cast<void*>(NULL));
-    StringReplace(&line, "__NULLP__", null_str);
-    // Remove 0x prefix produced by %p. VC++ doesn't put the prefix.
-    StringReplace(&line, " 0x", " ");
-
-    char errmsg_buf[100];
-    posix_strerror_r(0, errmsg_buf, sizeof(errmsg_buf));
-    if (*errmsg_buf == '\0') {
-      // MacOSX 10.4 and FreeBSD return empty string for errno=0.
-      // In such case, the we need to remove an extra space.
-      StringReplace(&line, "__SUCCESS__ ", "");
-    } else {
-      StringReplace(&line, "__SUCCESS__", errmsg_buf);
-    }
-    StringReplace(&line, "__ENOENT__", strerror(ENOENT));
-    StringReplace(&line, "__EINTR__", strerror(EINTR));
-    StringReplace(&line, "__ENXIO__", strerror(ENXIO));
-    StringReplace(&line, "__ENOEXEC__", strerror(ENOEXEC));
-    result += line + "\n";
-  }
-  fclose(fp);
-  return result;
-}
-
-static inline void WriteToFile(const string& body, const string& file) {
-  FILE* fp = fopen(file.c_str(), "wb");
-  fwrite(body.data(), 1, body.size(), fp);
-  fclose(fp);
-}
-
-static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
-  CapturedStream* cap = s_captured_streams[STDERR_FILENO];
-  CHECK(cap) << ": did you forget CaptureTestStderr()?";
-
-  cap->StopCapture();
-
-  // Run munge
-  const string captured = Munge(cap->filename());
-  const string golden = Munge(golden_filename);
-  if (captured != golden) {
-    fprintf(stderr,
-            "Test with golden file failed. We'll try to show the diff:\n");
-    string munged_golden = golden_filename + ".munged";
-    WriteToFile(golden, munged_golden);
-    string munged_captured = cap->filename() + ".munged";
-    WriteToFile(captured, munged_captured);
-    string diffcmd("diff -u " + munged_golden + " " + munged_captured);
-    if (system(diffcmd.c_str()) != 0) {
-      fprintf(stderr, "diff command was failed.\n");
-    }
-    unlink(munged_golden.c_str());
-    unlink(munged_captured.c_str());
-    return false;
-  }
-  LOG(INFO) << "Diff was successful";
-  return true;
-}
-
-// Save flags used from logging_unittest.cc.
-#ifndef HAVE_LIB_GFLAGS
-struct FlagSaver {
-  FlagSaver()
-      : v_(FLAGS_v),
-        stderrthreshold_(FLAGS_stderrthreshold),
-        logtostderr_(FLAGS_logtostderr),
-        alsologtostderr_(FLAGS_alsologtostderr) {}
-  ~FlagSaver() {
-    FLAGS_v = v_;
-    FLAGS_stderrthreshold = stderrthreshold_;
-    FLAGS_logtostderr = logtostderr_;
-    FLAGS_alsologtostderr = alsologtostderr_;
-  }
-  int v_;
-  int stderrthreshold_;
-  bool logtostderr_;
-  bool alsologtostderr_;
-};
-#endif
-
-class Thread {
- public:
-  virtual ~Thread() {}
-
-  void SetJoinable(bool joinable) {}
-#if defined(OS_WINDOWS) || defined(OS_CYGWIN)
-  void Start() {
-    handle_ = CreateThread(NULL,
-                           0,
-                           (LPTHREAD_START_ROUTINE)&Thread::InvokeThread,
-                           (LPVOID)this,
-                           0,
-                           &th_);
-    CHECK(handle_) << "CreateThread";
-  }
-  void Join() {
-    WaitForSingleObject(handle_, INFINITE);
-  }
-#elif defined(HAVE_PTHREAD)
-  void Start() {
-    pthread_create(&th_, NULL, &Thread::InvokeThread, this);
-  }
-  void Join() {
-    pthread_join(th_, NULL);
-  }
-#else
-# error No thread implementation.
-#endif
-
- protected:
-  virtual void Run() = 0;
-
- private:
-  static void* InvokeThread(void* self) {
-    ((Thread*)self)->Run();
-    return NULL;
-  }
-
-#if defined(OS_WINDOWS) || defined(OS_CYGWIN)
-  HANDLE handle_;
-  DWORD th_;
-#else
-  pthread_t th_;
-#endif
-};
-
-static inline void SleepForMilliseconds(int t) {
-#ifndef OS_WINDOWS
-  usleep(t * 1000);
-#else
-  Sleep(t);
-#endif
-}
-
-// Add hook for operator new to ensure there are no memory allocation.
-
-void (*g_new_hook)() = NULL;
-
-_END_GOOGLE_NAMESPACE_
-
-void* operator new(size_t size) {
-  if (GOOGLE_NAMESPACE::g_new_hook) {
-    GOOGLE_NAMESPACE::g_new_hook();
-  }
-  return malloc(size);
-}
-
-void* operator new[](size_t size) {
-  return ::operator new(size);
-}
-
-void operator delete(void* p) {
-  free(p);
-}
-
-void operator delete[](void* p) {
-  ::operator delete(p);
-}

+ 0 - 1781
Src/ThirdParty/glog/src/logging.cc

@@ -1,1781 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite()
-
-#include "utilities.h"
-
-#include <assert.h>
-#include <iomanip>
-#include <string>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>  // For _exit.
-#endif
-#include <climits>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>  // For uname.
-#endif
-#include <fcntl.h>
-#include <cstdio>
-#include <iostream>
-#include <stdarg.h>
-#include <stdlib.h>
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#include <vector>
-#include <errno.h>                   // for errno
-#include <sstream>
-#include "base/commandlineflags.h"        // to get the program name
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-using std::string;
-using std::vector;
-using std::ostrstream;
-using std::setw;
-using std::setfill;
-using std::hex;
-using std::dec;
-using std::min;
-using std::ostream;
-using std::ostringstream;
-using std::strstream;
-
-// There is no thread annotation support.
-#define EXCLUSIVE_LOCKS_REQUIRED(mu)
-
-static bool BoolFromEnv(const char *varname, bool defval) {
-  const char* const valstr = getenv(varname);
-  if (!valstr) {
-    return defval;
-  }
-  return memchr("tTyY1\0", valstr[0], 6) != NULL;
-}
-
-GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false),
-                 "log messages go to stderr instead of logfiles");
-GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
-                 "log messages go to stderr in addition to logfiles");
-#ifdef OS_LINUX
-GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. "
-                 "Logs can grow very quickly and they are rarely read before they "
-                 "need to be evicted from memory. Instead, drop them from memory "
-                 "as soon as they are flushed to disk.");
-_START_GOOGLE_NAMESPACE_
-namespace logging {
-static const int64 kPageSize = getpagesize();
-}
-_END_GOOGLE_NAMESPACE_
-#endif
-
-// By default, errors (including fatal errors) get logged to stderr as
-// well as the file.
-//
-// The default is ERROR instead of FATAL so that users can see problems
-// when they run a program without having to look in another file.
-DEFINE_int32(stderrthreshold,
-             GOOGLE_NAMESPACE::ERROR,
-             "log messages at or above this level are copied to stderr in "
-             "addition to logfiles.  This flag obsoletes --alsologtostderr.");
-
-GLOG_DEFINE_string(alsologtoemail, "",
-                   "log messages go to these email addresses "
-                   "in addition to logfiles");
-GLOG_DEFINE_bool(log_prefix, true,
-                 "Prepend the log prefix to the start of each log line");
-GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't "
-                  "actually get logged anywhere");
-GLOG_DEFINE_int32(logbuflevel, 0,
-                  "Buffer log messages logged at this level or lower"
-                  " (-1 means don't buffer; 0 means buffer INFO only;"
-                  " ...)");
-GLOG_DEFINE_int32(logbufsecs, 30,
-                  "Buffer log messages for at most this many seconds");
-GLOG_DEFINE_int32(logemaillevel, 999,
-                  "Email log messages logged at this level or higher"
-                  " (0 means email all; 3 means email FATAL only;"
-                  " ...)");
-GLOG_DEFINE_string(logmailer, "/bin/mail",
-                   "Mailer used to send logging email");
-
-// Compute the default value for --log_dir
-static const char* DefaultLogDir() {
-  const char* env;
-  env = getenv("GOOGLE_LOG_DIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  env = getenv("TEST_TMPDIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  return "";
-}
-
-GLOG_DEFINE_string(log_dir, DefaultLogDir(),
-                   "If specified, logfiles are written into this directory instead "
-                   "of the default logging directory.");
-GLOG_DEFINE_string(log_link, "", "Put additional links to the log "
-                   "files in this directory");
-
-GLOG_DEFINE_int32(max_log_size, 1800,
-                  "approx. maximum log file size (in MB). A value of 0 will "
-                  "be silently overridden to 1.");
-
-GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
-                 "Stop attempting to log to disk if the disk is full.");
-
-GLOG_DEFINE_string(log_backtrace_at, "",
-                   "Emit a backtrace when logging at file:linenum.");
-
-// TODO(hamaji): consider windows
-#define PATH_SEPARATOR '/'
-
-static void GetHostName(string* hostname) {
-#if defined(HAVE_SYS_UTSNAME_H)
-  struct utsname buf;
-  if (0 != uname(&buf)) {
-    // ensure null termination on failure
-    *buf.nodename = '\0';
-  }
-  *hostname = buf.nodename;
-#elif defined(OS_WINDOWS)
-  char buf[MAX_COMPUTERNAME_LENGTH + 1];
-  DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
-  if (GetComputerNameA(buf, &len)) {
-    *hostname = buf;
-  } else {
-    hostname->clear();
-  }
-#else
-# warning There is no way to retrieve the host name.
-  *hostname = "(unknown)";
-#endif
-}
-
-_START_GOOGLE_NAMESPACE_
-
-// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
-static int32 MaxLogSize() {
-  return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
-}
-
-// A mutex that allows only one thread to log at a time, to keep things from
-// getting jumbled.  Some other very uncommon logging operations (like
-// changing the destination file for log messages of a given severity) also
-// lock this mutex.  Please be sure that anybody who might possibly need to
-// lock it does so.
-static Mutex log_mutex;
-
-// Number of messages sent at each severity.  Under log_mutex.
-int64 LogMessage::num_messages_[NUM_SEVERITIES] = {0, 0, 0, 0};
-
-// Globally disable log writing (if disk is full)
-static bool stop_writing = false;
-
-const char*const LogSeverityNames[NUM_SEVERITIES] = {
-  "INFO", "WARNING", "ERROR", "FATAL"
-};
-
-// Has the user called SetExitOnDFatal(true)?
-static bool exit_on_dfatal = true;
-
-const char* GetLogSeverityName(LogSeverity severity) {
-  return LogSeverityNames[severity];
-}
-
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging);
-
-base::Logger::~Logger() {
-}
-
-namespace {
-
-// Encapsulates all file-system related state
-class LogFileObject : public base::Logger {
- public:
-  LogFileObject(LogSeverity severity, const char* base_filename);
-  ~LogFileObject();
-
-  virtual void Write(bool force_flush, // Should we force a flush here?
-                     time_t timestamp,  // Timestamp for this entry
-                     const char* message,
-                     int message_len);
-
-  // Configuration options
-  void SetBasename(const char* basename);
-  void SetExtension(const char* ext);
-  void SetSymlinkBasename(const char* symlink_basename);
-
-  // Normal flushing routine
-  virtual void Flush();
-
-  // It is the actual file length for the system loggers,
-  // i.e., INFO, ERROR, etc.
-  virtual uint32 LogSize() {
-    MutexLock l(&lock_);
-    return file_length_;
-  }
-
-  // Internal flush routine.  Exposed so that FlushLogFilesUnsafe()
-  // can avoid grabbing a lock.  Usually Flush() calls it after
-  // acquiring lock_.
-  void FlushUnlocked();
-
- private:
-  static const uint32 kRolloverAttemptFrequency = 0x20;
-
-  Mutex lock_;
-  bool base_filename_selected_;
-  string base_filename_;
-  string symlink_basename_;
-  string filename_extension_;     // option users can specify (eg to add port#)
-  FILE* file_;
-  LogSeverity severity_;
-  uint32 bytes_since_flush_;
-  uint32 file_length_;
-  unsigned int rollover_attempt_;
-  int64 next_flush_time_;         // cycle count at which to flush log
-
-  // Actually create a logfile using the value of base_filename_ and the
-  // supplied argument time_pid_string
-  // REQUIRES: lock_ is held
-  bool CreateLogfile(const char* time_pid_string);
-};
-
-}  // namespace
-
-class LogDestination {
- public:
-  friend class LogMessage;
-  friend void ReprintFatalMessage();
-  friend base::Logger* base::GetLogger(LogSeverity);
-  friend void base::SetLogger(LogSeverity, base::Logger*);
-
-  // These methods are just forwarded to by their global versions.
-  static void SetLogDestination(LogSeverity severity,
-				const char* base_filename);
-  static void SetLogSymlink(LogSeverity severity,
-                            const char* symlink_basename);
-  static void AddLogSink(LogSink *destination);
-  static void RemoveLogSink(LogSink *destination);
-  static void SetLogFilenameExtension(const char* filename_extension);
-  static void SetStderrLogging(LogSeverity min_severity);
-  static void SetEmailLogging(LogSeverity min_severity, const char* addresses);
-  static void LogToStderr();
-  // Flush all log files that are at least at the given severity level
-  static void FlushLogFiles(int min_severity);
-  static void FlushLogFilesUnsafe(int min_severity);
-
-  // we set the maximum size of our packet to be 1400, the logic being
-  // to prevent fragmentation.
-  // Really this number is arbitrary.
-  static const int kNetworkBytes = 1400;
-
-  static const string& hostname();
- private:
-
-  LogDestination(LogSeverity severity, const char* base_filename);
-  ~LogDestination() { }
-
-  // Take a log message of a particular severity and log it to stderr
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToStderr(LogSeverity severity, const char* message,
-			       size_t len);
-
-  // Take a log message of a particular severity and log it to email
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToEmail(LogSeverity severity, const char* message,
-			      size_t len);
-  // Take a log message of a particular severity and log it to a file
-  // iff the base filename is not "" (which means "don't log to me")
-  static void MaybeLogToLogfile(LogSeverity severity,
-                                time_t timestamp,
-				const char* message, size_t len);
-  // Take a log message of a particular severity and log it to the file
-  // for that severity and also for all files with severity less than
-  // this severity.
-  static void LogToAllLogfiles(LogSeverity severity,
-                               time_t timestamp,
-                               const char* message, size_t len);
-
-  // Send logging info to all registered sinks.
-  static void LogToSinks(LogSeverity severity,
-                         const char *full_filename,
-                         const char *base_filename,
-                         int line,
-                         const struct ::tm* tm_time,
-                         const char* message,
-                         size_t message_len);
-
-  // Wait for all registered sinks via WaitTillSent
-  // including the optional one in "data".
-  static void WaitForSinks(LogMessage::LogMessageData* data);
-
-  static LogDestination* log_destination(LogSeverity severity);
-
-  LogFileObject fileobject_;
-  base::Logger* logger_;      // Either &fileobject_, or wrapper around it
-
-  static LogDestination* log_destinations_[NUM_SEVERITIES];
-  static LogSeverity email_logging_severity_;
-  static string addresses_;
-  static string hostname_;
-
-  // arbitrary global logging destinations.
-  static vector<LogSink*>* sinks_;
-
-  // Protects the vector sinks_,
-  // but not the LogSink objects its elements reference.
-  static Mutex sink_mutex_;
-
-  // Disallow
-  LogDestination(const LogDestination&);
-  LogDestination& operator=(const LogDestination&);
-};
-
-// Errors do not get logged to email by default.
-LogSeverity LogDestination::email_logging_severity_ = 99999;
-
-string LogDestination::addresses_;
-string LogDestination::hostname_;
-
-vector<LogSink*>* LogDestination::sinks_ = NULL;
-Mutex LogDestination::sink_mutex_;
-
-/* static */
-const string& LogDestination::hostname() {
-  if (hostname_.empty()) {
-    GetHostName(&hostname_);
-    if (hostname_.empty()) {
-      hostname_ = "(unknown)";
-    }
-  }
-  return hostname_;
-}
-
-LogDestination::LogDestination(LogSeverity severity,
-                               const char* base_filename)
-  : fileobject_(severity, base_filename),
-    logger_(&fileobject_) {
-}
-
-inline void LogDestination::FlushLogFilesUnsafe(int min_severity) {
-  // assume we have the log_mutex or we simply don't care
-  // about it
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      // Flush the base fileobject_ logger directly instead of going
-      // through any wrappers to reduce chance of deadlock.
-      log->fileobject_.FlushUnlocked();
-    }
-  }
-}
-
-inline void LogDestination::FlushLogFiles(int min_severity) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      log->logger_->Flush();
-    }
-  }
-}
-
-inline void LogDestination::SetLogDestination(LogSeverity severity,
-					      const char* base_filename) {
-  assert(severity >= 0 && severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetBasename(base_filename);
-}
-
-inline void LogDestination::SetLogSymlink(LogSeverity severity,
-                                          const char* symlink_basename) {
-  CHECK_GE(severity, 0);
-  CHECK_LT(severity, NUM_SEVERITIES);
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename);
-}
-
-inline void LogDestination::AddLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  if (!sinks_)  sinks_ = new vector<LogSink*>;
-  sinks_->push_back(destination);
-}
-
-inline void LogDestination::RemoveLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  // This doesn't keep the sinks in order, but who cares?
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      if ((*sinks_)[i] == destination) {
-        (*sinks_)[i] = (*sinks_)[sinks_->size() - 1];
-        sinks_->pop_back();
-        break;
-      }
-    }
-  }
-}
-
-inline void LogDestination::SetLogFilenameExtension(const char* ext) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) {
-    log_destination(severity)->fileobject_.SetExtension(ext);
-  }
-}
-
-inline void LogDestination::SetStderrLogging(LogSeverity min_severity) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  FLAGS_stderrthreshold = min_severity;
-}
-
-inline void LogDestination::LogToStderr() {
-  // *Don't* put this stuff in a mutex lock, since SetStderrLogging &
-  // SetLogDestination already do the locking!
-  SetStderrLogging(0);            // thus everything is "also" logged to stderr
-  for ( int i = 0; i < NUM_SEVERITIES; ++i ) {
-    SetLogDestination(i, "");     // "" turns off logging to a logfile
-  }
-}
-
-inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
-					    const char* addresses) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  LogDestination::email_logging_severity_ = min_severity;
-  LogDestination::addresses_ = addresses;
-}
-
-static void WriteToStderr(const char* message, size_t len) {
-  // Avoid using cerr from this module since we may get called during
-  // exit code, and cerr may be partially or fully destroyed by then.
-  write(STDERR_FILENO, message, len);
-}
-
-inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
-					     const char* message, size_t len) {
-  if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
-    WriteToStderr(message, len);
-#ifdef OS_WINDOWS
-    // On Windows, also output to the debugger
-    ::OutputDebugStringA(string(message,len).c_str());
-#endif
-  }
-}
-
-
-inline void LogDestination::MaybeLogToEmail(LogSeverity severity,
-					    const char* message, size_t len) {
-  if (severity >= email_logging_severity_ ||
-      severity >= FLAGS_logemaillevel) {
-    string to(FLAGS_alsologtoemail);
-    if (!addresses_.empty()) {
-      if (!to.empty()) {
-        to += ",";
-      }
-      to += addresses_;
-    }
-    const string subject(string("[LOG] ") + LogSeverityNames[severity] + ": " +
-                         glog_internal_namespace_::ProgramInvocationShortName());
-    string body(hostname());
-    body += "\n\n";
-    body.append(message, len);
-
-    // should NOT use SendEmail().  The caller of this function holds the
-    // log_mutex and SendEmail() calls LOG/VLOG which will block trying to
-    // acquire the log_mutex object.  Use SendEmailInternal() and set
-    // use_logging to false.
-    SendEmailInternal(to.c_str(), subject.c_str(), body.c_str(), false);
-  }
-}
-
-
-inline void LogDestination::MaybeLogToLogfile(LogSeverity severity,
-                                              time_t timestamp,
-					      const char* message,
-					      size_t len) {
-  const bool should_flush = severity > FLAGS_logbuflevel;
-  LogDestination* destination = log_destination(severity);
-  destination->logger_->Write(should_flush, timestamp, message, len);
-}
-
-inline void LogDestination::LogToAllLogfiles(LogSeverity severity,
-                                             time_t timestamp,
-                                             const char* message,
-                                             size_t len) {
-
-  if ( FLAGS_logtostderr )            // global flag: never log to file
-    WriteToStderr(message, len);
-  else
-    for (int i = severity; i >= 0; --i)
-      LogDestination::MaybeLogToLogfile(i, timestamp, message, len);
-
-}
-
-inline void LogDestination::LogToSinks(LogSeverity severity,
-                                       const char *full_filename,
-                                       const char *base_filename,
-                                       int line,
-                                       const struct ::tm* tm_time,
-                                       const char* message,
-                                       size_t message_len) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->send(severity, full_filename, base_filename,
-                         line, tm_time, message, message_len);
-    }
-  }
-}
-
-inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->WaitTillSent();
-    }
-  }
-  const bool send_to_sink =
-      (data->send_method_ == &LogMessage::SendToSink) ||
-      (data->send_method_ == &LogMessage::SendToSinkAndLog);
-  if (send_to_sink && data->sink_ != NULL) {
-    data->sink_->WaitTillSent();
-  }
-}
-
-LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES];
-
-inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
-  assert(severity >=0 && severity < NUM_SEVERITIES);
-  if (!log_destinations_[severity]) {
-    log_destinations_[severity] = new LogDestination(severity, NULL);
-  }
-  return log_destinations_[severity];
-}
-
-namespace {
-
-LogFileObject::LogFileObject(LogSeverity severity,
-                             const char* base_filename)
-  : base_filename_selected_(base_filename != NULL),
-    base_filename_((base_filename != NULL) ? base_filename : ""),
-    symlink_basename_(glog_internal_namespace_::ProgramInvocationShortName()),
-    filename_extension_(),
-    file_(NULL),
-    severity_(severity),
-    bytes_since_flush_(0),
-    file_length_(0),
-    rollover_attempt_(kRolloverAttemptFrequency-1),
-    next_flush_time_(0) {
-  assert(severity >= 0);
-  assert(severity < NUM_SEVERITIES);
-}
-
-LogFileObject::~LogFileObject() {
-  MutexLock l(&lock_);
-  if (file_ != NULL) {
-    fclose(file_);
-    file_ = NULL;
-  }
-}
-
-void LogFileObject::SetBasename(const char* basename) {
-  MutexLock l(&lock_);
-  base_filename_selected_ = true;
-  if (base_filename_ != basename) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    base_filename_ = basename;
-  }
-}
-
-void LogFileObject::SetExtension(const char* ext) {
-  MutexLock l(&lock_);
-  if (filename_extension_ != ext) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    filename_extension_ = ext;
-  }
-}
-
-void LogFileObject::SetSymlinkBasename(const char* symlink_basename) {
-  MutexLock l(&lock_);
-  symlink_basename_ = symlink_basename;
-}
-
-void LogFileObject::Flush() {
-  MutexLock l(&lock_);
-  FlushUnlocked();
-}
-
-void LogFileObject::FlushUnlocked(){
-  if (file_ != NULL) {
-    fflush(file_);
-    bytes_since_flush_ = 0;
-  }
-  // Figure out when we are due for another flush.
-  const int64 next = (FLAGS_logbufsecs
-                      * static_cast<int64>(1000000));  // in usec
-  next_flush_time_ = CycleClock_Now() + UsecToCycles(next);
-}
-
-bool LogFileObject::CreateLogfile(const char* time_pid_string) {
-  string string_filename = base_filename_+filename_extension_+
-                           time_pid_string;
-  const char* filename = string_filename.c_str();
-  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
-  if (fd == -1) return false;
-#ifdef HAVE_FCNTL
-  // Mark the file close-on-exec. We don't really care if this fails
-  fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
-
-  file_ = fdopen(fd, "a");  // Make a FILE*.
-  if (file_ == NULL) {  // Man, we're screwed!
-    close(fd);
-    unlink(filename);  // Erase the half-baked evidence: an unusable log file
-    return false;
-  }
-
-  // We try to create a symlink called <program_name>.<severity>,
-  // which is easier to use.  (Every time we create a new logfile,
-  // we destroy the old symlink and create a new one, so it always
-  // points to the latest logfile.)  If it fails, we're sad but it's
-  // no error.
-  if (!symlink_basename_.empty()) {
-    // take directory from filename
-    const char* slash = strrchr(filename, PATH_SEPARATOR);
-    const string linkname =
-      symlink_basename_ + '.' + LogSeverityNames[severity_];
-    string linkpath;
-    if ( slash ) linkpath = string(filename, slash-filename+1);  // get dirname
-    linkpath += linkname;
-    unlink(linkpath.c_str());                    // delete old one if it exists
-
-    // We must have unistd.h.
-#ifdef HAVE_UNISTD_H
-    // Make the symlink be relative (in the same dir) so that if the
-    // entire log directory gets relocated the link is still valid.
-    const char *linkdest = slash ? (slash + 1) : filename;
-    symlink(linkdest, linkpath.c_str());         // silently ignore failures
-
-    // Make an additional link to the log file in a place specified by
-    // FLAGS_log_link, if indicated
-    if (!FLAGS_log_link.empty()) {
-      linkpath = FLAGS_log_link + "/" + linkname;
-      unlink(linkpath.c_str());                  // delete old one if it exists
-      symlink(filename, linkpath.c_str());       // silently ignore failures
-    }
-#endif
-  }
-
-  return true;  // Everything worked
-}
-
-void LogFileObject::Write(bool force_flush,
-                          time_t timestamp,
-                          const char* message,
-                          int message_len) {
-  MutexLock l(&lock_);
-
-  // We don't log if the base_name_ is "" (which means "don't write")
-  if (base_filename_selected_ && base_filename_.empty()) {
-    return;
-  }
-
-  if (static_cast<int>(file_length_ >> 20) >= MaxLogSize()) {
-    if (file_ != NULL) fclose(file_);
-    file_ = NULL;
-    file_length_ = bytes_since_flush_ = 0;
-    rollover_attempt_ = kRolloverAttemptFrequency-1;
-  }
-
-  // If there's no destination file, make one before outputting
-  if (file_ == NULL) {
-    // Try to rollover the log file every 32 log messages.  The only time
-    // this could matter would be when we have trouble creating the log
-    // file.  If that happens, we'll lose lots of log messages, of course!
-    if (++rollover_attempt_ != kRolloverAttemptFrequency) return;
-    rollover_attempt_ = 0;
-
-    struct ::tm tm_time;
-    localtime_r(&timestamp, &tm_time);
-
-    // The logfile's filename will have the date/time & pid in it
-    char time_pid_string[256];  // More than enough chars for time, pid, \0
-    ostrstream time_pid_stream(time_pid_string, sizeof(time_pid_string));
-    time_pid_stream.fill('0');
-    time_pid_stream << 1900+tm_time.tm_year
-		    << setw(2) << 1+tm_time.tm_mon
-		    << setw(2) << tm_time.tm_mday
-		    << '-'
-		    << setw(2) << tm_time.tm_hour
-		    << setw(2) << tm_time.tm_min
-		    << setw(2) << tm_time.tm_sec
-		    << '.'
-		    << GetMainThreadPid()
-		    << '\0';
-
-    if (base_filename_selected_) {
-      if (!CreateLogfile(time_pid_string)) {
-        perror("Could not create log file");
-        fprintf(stderr, "COULD NOT CREATE LOGFILE '%s'!\n", time_pid_string);
-        return;
-      }
-    } else {
-      // If no base filename for logs of this severity has been set, use a
-      // default base filename of
-      // "<program name>.<hostname>.<user name>.log.<severity level>.".  So
-      // logfiles will have names like
-      // webserver.examplehost.root.log.INFO.19990817-150000.4354, where
-      // 19990817 is a date (1999 August 17), 150000 is a time (15:00:00),
-      // and 4354 is the pid of the logging process.  The date & time reflect
-      // when the file was created for output.
-      //
-      // Where does the file get put?  Successively try the directories
-      // "/tmp", and "."
-      string stripped_filename(
-          glog_internal_namespace_::ProgramInvocationShortName());
-      string hostname;
-      GetHostName(&hostname);
-
-      string uidname = MyUserName();
-      // We should not call CHECK() here because this function can be
-      // called after holding on to log_mutex. We don't want to
-      // attempt to hold on to the same mutex, and get into a
-      // deadlock. Simply use a name like invalid-user.
-      if (uidname.empty()) uidname = "invalid-user";
-
-      stripped_filename = stripped_filename+'.'+hostname+'.'
-                          +uidname+".log."
-                          +LogSeverityNames[severity_]+'.';
-      // We're going to (potentially) try to put logs in several different dirs
-      const vector<string> & log_dirs = GetLoggingDirectories();
-
-      // Go through the list of dirs, and try to create the log file in each
-      // until we succeed or run out of options
-      bool success = false;
-      for (vector<string>::const_iterator dir = log_dirs.begin();
-           dir != log_dirs.end();
-           ++dir) {
-        base_filename_ = *dir + "/" + stripped_filename;
-        if ( CreateLogfile(time_pid_string) ) {
-          success = true;
-          break;
-        }
-      }
-      // If we never succeeded, we have to give up
-      if ( success == false ) {
-        perror("Could not create logging file");
-        fprintf(stderr, "COULD NOT CREATE A LOGGINGFILE %s!", time_pid_string);
-        return;
-      }
-    }
-
-    // Write a header message into the log file
-    char file_header_string[512];  // Enough chars for time and binary info
-    ostrstream file_header_stream(file_header_string,
-                                  sizeof(file_header_string));
-    file_header_stream.fill('0');
-    file_header_stream << "Log file created at: "
-                       << 1900+tm_time.tm_year << '/'
-                       << setw(2) << 1+tm_time.tm_mon << '/'
-                       << setw(2) << tm_time.tm_mday
-                       << ' '
-                       << setw(2) << tm_time.tm_hour << ':'
-                       << setw(2) << tm_time.tm_min << ':'
-                       << setw(2) << tm_time.tm_sec << '\n'
-                       << "Running on machine: "
-                       << LogDestination::hostname() << '\n'
-                       << "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu "
-                       << "threadid file:line] msg" << '\n'
-                       << '\0';
-    int header_len = strlen(file_header_string);
-    fwrite(file_header_string, 1, header_len, file_);
-    file_length_ += header_len;
-    bytes_since_flush_ += header_len;
-  }
-
-  // Write to LOG file
-  if ( !stop_writing ) {
-    // fwrite() doesn't return an error when the disk is full, for
-    // messages that are less than 4096 bytes. When the disk is full,
-    // it returns the message length for messages that are less than
-    // 4096 bytes. fwrite() returns 4096 for message lengths that are
-    // greater than 4096, thereby indicating an error.
-    errno = 0;
-    fwrite(message, 1, message_len, file_);
-    if ( FLAGS_stop_logging_if_full_disk &&
-         errno == ENOSPC ) {  // disk full, stop writing to disk
-      stop_writing = true;  // until the disk is
-      return;
-    } else {
-      file_length_ += message_len;
-      bytes_since_flush_ += message_len;
-    }
-  } else {
-    if ( CycleClock_Now() >= next_flush_time_ )
-      stop_writing = false;  // check to see if disk has free space.
-    return;  // no need to flush
-  }
-
-  // See important msgs *now*.  Also, flush logs at least every 10^6 chars,
-  // or every "FLAGS_logbufsecs" seconds.
-  if ( force_flush ||
-       (bytes_since_flush_ >= 1000000) ||
-       (CycleClock_Now() >= next_flush_time_) ) {
-    FlushUnlocked();
-#ifdef OS_LINUX
-    if (FLAGS_drop_log_memory) {
-      if (file_length_ >= logging::kPageSize) {
-        // don't evict the most recent page
-        uint32 len = file_length_ & ~(logging::kPageSize - 1);
-        posix_fadvise(fileno(file_), 0, len, POSIX_FADV_DONTNEED);
-      }
-    }
-#endif
-  }
-}
-
-}  // namespace
-
-// An arbitrary limit on the length of a single log message.  This
-// is so that streaming can be done more efficiently.
-const size_t LogMessage::kMaxLogMessageLen = 30000;
-
-// Static log data space to avoid alloc failures in a LOG(FATAL)
-//
-// Since multiple threads may call LOG(FATAL), and we want to preserve
-// the data from the first call, we allocate two sets of space.  One
-// for exclusive use by the first thread, and one for shared use by
-// all other threads.
-static Mutex fatal_msg_lock;
-static CrashReason crash_reason;
-static bool fatal_msg_exclusive = true;
-static char fatal_msg_buf_exclusive[LogMessage::kMaxLogMessageLen+1];
-static char fatal_msg_buf_shared[LogMessage::kMaxLogMessageLen+1];
-static LogMessage::LogStream fatal_msg_stream_exclusive(
-    fatal_msg_buf_exclusive, LogMessage::kMaxLogMessageLen, 0);
-static LogMessage::LogStream fatal_msg_stream_shared(
-    fatal_msg_buf_shared, LogMessage::kMaxLogMessageLen, 0);
-LogMessage::LogMessageData LogMessage::fatal_msg_data_exclusive_;
-LogMessage::LogMessageData LogMessage::fatal_msg_data_shared_;
-
-LogMessage::LogMessageData::~LogMessageData() {
-  delete[] buf_;
-  delete stream_alloc_;
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-		       int ctr, void (LogMessage::*send_method)()) {
-  Init(file, line, severity, send_method);
-  data_->stream_->set_ctr(ctr);
-}
-
-LogMessage::LogMessage(const char* file, int line,
-                       const CheckOpString& result) {
-  Init(file, line, FATAL, &LogMessage::SendToLog);
-  stream() << "Check failed: " << (*result.str_) << " ";
-}
-
-LogMessage::LogMessage(const char* file, int line) {
-  Init(file, line, INFO, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity) {
-  Init(file, line, severity, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       LogSink* sink, bool also_send_to_log) {
-  Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog :
-                                                &LogMessage::SendToSink);
-  data_->sink_ = sink;  // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       vector<string> *outvec) {
-  Init(file, line, severity, &LogMessage::SaveOrSendToLog);
-  data_->outvec_ = outvec; // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       string *message) {
-  Init(file, line, severity, &LogMessage::WriteToStringAndLog);
-  data_->message_ = message;  // override Init()'s setting to NULL
-}
-
-void LogMessage::Init(const char* file,
-                      int line,
-                      LogSeverity severity,
-                      void (LogMessage::*send_method)()) {
-  allocated_ = NULL;
-  if (severity != FATAL || !exit_on_dfatal) {
-    allocated_ = new LogMessageData();
-    data_ = allocated_;
-    data_->buf_ = new char[kMaxLogMessageLen+1];
-    data_->message_text_ = data_->buf_;
-    data_->stream_alloc_ =
-        new LogStream(data_->message_text_, kMaxLogMessageLen, 0);
-    data_->stream_ = data_->stream_alloc_;
-    data_->first_fatal_ = false;
-  } else {
-    MutexLock l(&fatal_msg_lock);
-    if (fatal_msg_exclusive) {
-      fatal_msg_exclusive = false;
-      data_ = &fatal_msg_data_exclusive_;
-      data_->message_text_ = fatal_msg_buf_exclusive;
-      data_->stream_ = &fatal_msg_stream_exclusive;
-      data_->first_fatal_ = true;
-    } else {
-      data_ = &fatal_msg_data_shared_;
-      data_->message_text_ = fatal_msg_buf_shared;
-      data_->stream_ = &fatal_msg_stream_shared;
-      data_->first_fatal_ = false;
-    }
-    data_->stream_alloc_ = NULL;
-  }
-
-  stream().fill('0');
-  data_->preserved_errno_ = errno;
-  data_->severity_ = severity;
-  data_->line_ = line;
-  data_->send_method_ = send_method;
-  data_->sink_ = NULL;
-  data_->outvec_ = NULL;
-  WallTime now = WallTime_Now();
-  data_->timestamp_ = static_cast<time_t>(now);
-  localtime_r(&data_->timestamp_, &data_->tm_time_);
-  int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
-  RawLog__SetLastTime(data_->tm_time_, usecs);
-
-  data_->num_chars_to_log_ = 0;
-  data_->num_chars_to_syslog_ = 0;
-  data_->basename_ = const_basename(file);
-  data_->fullname_ = file;
-  data_->has_been_flushed_ = false;
-
-  // If specified, prepend a prefix to each line.  For example:
-  //    I1018 160715 f5d4fbb0 logging.cc:1153]
-  //    (log level, GMT month, date, time, thread_id, file basename, line)
-  // We exclude the thread_id for the default thread.
-  if (FLAGS_log_prefix && (line != kNoLogPrefix)) {
-    stream() << LogSeverityNames[severity][0]
-             << setw(2) << 1+data_->tm_time_.tm_mon
-             << setw(2) << data_->tm_time_.tm_mday
-             << ' '
-             << setw(2) << data_->tm_time_.tm_hour  << ':'
-             << setw(2) << data_->tm_time_.tm_min   << ':'
-             << setw(2) << data_->tm_time_.tm_sec   << "."
-             << setw(6) << usecs
-             << ' '
-             << setfill(' ') << setw(5)
-             << static_cast<unsigned int>(GetTID()) << setfill('0')
-             << ' '
-             << data_->basename_ << ':' << data_->line_ << "] ";
-  }
-  data_->num_prefix_chars_ = data_->stream_->pcount();
-
-  if (!FLAGS_log_backtrace_at.empty()) {
-    char fileline[128];
-    snprintf(fileline, sizeof(fileline), "%s:%d", data_->basename_, line);
-#ifdef HAVE_STACKTRACE
-    if (!strcmp(FLAGS_log_backtrace_at.c_str(), fileline)) {
-      string stacktrace;
-      DumpStackTraceToString(&stacktrace);
-      stream() << " (stacktrace:\n" << stacktrace << ") ";
-    }
-#endif
-  }
-}
-
-LogMessage::~LogMessage() {
-  Flush();
-  delete allocated_;
-}
-
-// Flush buffered message, called by the destructor, or any other function
-// that needs to synchronize the log.
-void LogMessage::Flush() {
-  if (data_->has_been_flushed_ || data_->severity_ < FLAGS_minloglevel)
-    return;
-
-  data_->num_chars_to_log_ = data_->stream_->pcount();
-  data_->num_chars_to_syslog_ =
-    data_->num_chars_to_log_ - data_->num_prefix_chars_;
-
-  // Do we need to add a \n to the end of this message?
-  bool append_newline =
-      (data_->message_text_[data_->num_chars_to_log_-1] != '\n');
-  char original_final_char = '\0';
-
-  // If we do need to add a \n, we'll do it by violating the memory of the
-  // ostrstream buffer.  This is quick, and we'll make sure to undo our
-  // modification before anything else is done with the ostrstream.  It
-  // would be preferable not to do things this way, but it seems to be
-  // the best way to deal with this.
-  if (append_newline) {
-    original_final_char = data_->message_text_[data_->num_chars_to_log_];
-    data_->message_text_[data_->num_chars_to_log_++] = '\n';
-  }
-
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // the actual logging action per se.
-  {
-    MutexLock l(&log_mutex);
-    (this->*(data_->send_method_))();
-    ++num_messages_[static_cast<int>(data_->severity_)];
-  }
-  LogDestination::WaitForSinks(data_);
-
-  if (append_newline) {
-    // Fix the ostrstream back how it was before we screwed with it.
-    // It's 99.44% certain that we don't need to worry about doing this.
-    data_->message_text_[data_->num_chars_to_log_-1] = original_final_char;
-  }
-
-  // If errno was already set before we enter the logging call, we'll
-  // set it back to that value when we return from the logging call.
-  // It happens often that we log an error message after a syscall
-  // failure, which can potentially set the errno to some other
-  // values.  We would like to preserve the original errno.
-  if (data_->preserved_errno_ != 0) {
-    errno = data_->preserved_errno_;
-  }
-
-  // Note that this message is now safely logged.  If we're asked to flush
-  // again, as a result of destruction, say, we'll do nothing on future calls.
-  data_->has_been_flushed_ = true;
-}
-
-// Copy of first FATAL log message so that we can print it out again
-// after all the stack traces.  To preserve legacy behavior, we don't
-// use fatal_msg_buf_exclusive.
-static time_t fatal_time;
-static char fatal_message[256];
-
-void ReprintFatalMessage() {
-  if (fatal_message[0]) {
-    const int n = strlen(fatal_message);
-    if (!FLAGS_logtostderr) {
-      // Also write to stderr
-      WriteToStderr(fatal_message, n);
-    }
-    LogDestination::LogToAllLogfiles(ERROR, fatal_time, fatal_message, n);
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  static bool already_warned_before_initgoogle = false;
-
-  log_mutex.AssertHeld();
-
-  RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-             data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-
-  // Messages of a given severity get logged to lower severity logs, too
-
-  if (!already_warned_before_initgoogle && !IsGoogleLoggingInitialized()) {
-    const char w[] = "WARNING: Logging before InitGoogleLogging() is "
-                     "written to STDERR\n";
-    WriteToStderr(w, strlen(w));
-    already_warned_before_initgoogle = true;
-  }
-
-  // global flag: never log to file if set.  Also -- don't log to a
-  // file if we haven't parsed the command line flags to get the
-  // program name.
-  if (FLAGS_logtostderr || !IsGoogleLoggingInitialized()) {
-    WriteToStderr(data_->message_text_, data_->num_chars_to_log_);
-
-    // this could be protected by a flag if necessary.
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_ -
-                                data_->num_prefix_chars_ - 1));
-  } else {
-
-    // log this message to all log files of severity <= severity_
-    LogDestination::LogToAllLogfiles(data_->severity_, data_->timestamp_,
-                                     data_->message_text_,
-                                     data_->num_chars_to_log_);
-
-    LogDestination::MaybeLogToStderr(data_->severity_, data_->message_text_,
-                                     data_->num_chars_to_log_);
-    LogDestination::MaybeLogToEmail(data_->severity_, data_->message_text_,
-                                    data_->num_chars_to_log_);
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_
-                                - data_->num_prefix_chars_ - 1));
-    // NOTE: -1 removes trailing \n
-  }
-
-  // If we log a FATAL message, flush all the log destinations, then toss
-  // a signal for others to catch. We leave the logs in a state that
-  // someone else can use them (as long as they flush afterwards)
-  if (data_->severity_ == FATAL && exit_on_dfatal) {
-    if (data_->first_fatal_) {
-      // Store crash information so that it is accessible from within signal
-      // handlers that may be invoked later.
-      RecordCrashReason(&crash_reason);
-      SetCrashReason(&crash_reason);
-
-      // Store shortened fatal message for other logs and GWQ status
-      const int copy = min<int>(data_->num_chars_to_log_,
-                                sizeof(fatal_message)-1);
-      memcpy(fatal_message, data_->message_text_, copy);
-      fatal_message[copy] = '\0';
-      fatal_time = data_->timestamp_;
-    }
-
-    if (!FLAGS_logtostderr) {
-      for (int i = 0; i < NUM_SEVERITIES; ++i) {
-        if ( LogDestination::log_destinations_[i] )
-          LogDestination::log_destinations_[i]->logger_->Write(true, 0, "", 0);
-      }
-    }
-
-    // release the lock that our caller (directly or indirectly)
-    // LogMessage::~LogMessage() grabbed so that signal handlers
-    // can use the logging facility. Alternately, we could add
-    // an entire unsafe logging interface to bypass locking
-    // for signal handlers but this seems simpler.
-    log_mutex.Unlock();
-    LogDestination::WaitForSinks(data_);
-
-    const char* message = "*** Check failure stack trace: ***\n";
-    write(STDERR_FILENO, message, strlen(message));
-    Fail();
-  }
-}
-
-void LogMessage::RecordCrashReason(
-    glog_internal_namespace_::CrashReason* reason) {
-  reason->filename = fatal_msg_data_exclusive_.fullname_;
-  reason->line_number = fatal_msg_data_exclusive_.line_;
-  reason->message = fatal_msg_buf_exclusive +
-                    fatal_msg_data_exclusive_.num_prefix_chars_;
-#ifdef HAVE_STACKTRACE
-  // Retrieve the stack trace, omitting the logging frames that got us here.
-  reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4);
-#else
-  reason->depth = 0;
-#endif
-}
-
-static void logging_fail() {
-#if defined(_DEBUG) && defined(_MSC_VER)
-  // When debugging on windows, avoid the obnoxious dialog and make
-  // it possible to continue past a LOG(FATAL) in the debugger
-  _asm int 3
-#else
-  abort();
-#endif
-}
-
-#ifdef HAVE___ATTRIBUTE__
-GOOGLE_GLOG_DLL_DECL
-void (*g_logging_fail_func)() __attribute__((noreturn)) = &logging_fail;
-#else
-GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() = &logging_fail;
-#endif
-
-void InstallFailureFunction(void (*fail_func)()) {
-  g_logging_fail_func = fail_func;
-}
-
-void LogMessage::Fail() {
-  g_logging_fail_func();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->sink_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_,
-                       data_->line_, &data_->tm_time_,
-                       data_->message_text_ + data_->num_prefix_chars_,
-                       (data_->num_chars_to_log_ -
-                        data_->num_prefix_chars_ - 1));
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  SendToSink();
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->outvec_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when recording in outvec_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->outvec_->push_back(string(start, len));
-  } else {
-    SendToLog();
-  }
-}
-
-void LogMessage::WriteToStringAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->message_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when writing to message_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->message_->assign(start, len);
-  }
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSyslogAndLog() {
-#ifdef HAVE_SYSLOG_H
-  // Before any calls to syslog(), make a single call to openlog()
-  static bool openlog_already_called = false;
-  if (!openlog_already_called) {
-    openlog(glog_internal_namespace_::ProgramInvocationShortName(),
-            LOG_CONS | LOG_NDELAY | LOG_PID,
-            LOG_USER);
-    openlog_already_called = true;
-  }
-
-  // This array maps Google severity levels to syslog levels
-  const int SEVERITY_TO_LEVEL[] = { LOG_INFO, LOG_WARNING, LOG_ERR, LOG_EMERG };
-  syslog(LOG_USER | SEVERITY_TO_LEVEL[static_cast<int>(data_->severity_)], "%.*s",
-         int(data_->num_chars_to_syslog_),
-         data_->message_text_ + data_->num_prefix_chars_);
-  SendToLog();
-#else
-  LOG(ERROR) << "No syslog support: message=" << data_->message_text_;
-#endif
-}
-
-base::Logger* base::GetLogger(LogSeverity severity) {
-  MutexLock l(&log_mutex);
-  return LogDestination::log_destination(severity)->logger_;
-}
-
-void base::SetLogger(LogSeverity severity, base::Logger* logger) {
-  MutexLock l(&log_mutex);
-  LogDestination::log_destination(severity)->logger_ = logger;
-}
-
-// L < log_mutex.  Acquires and releases mutex_.
-int64 LogMessage::num_messages(int severity) {
-  MutexLock l(&log_mutex);
-  return num_messages_[severity];
-}
-
-// Output the COUNTER value. This is only valid if ostream is a
-// LogStream.
-ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
-  LogMessage::LogStream *log = dynamic_cast<LogMessage::LogStream*>(&os);
-  CHECK(log == log->self());
-  os << log->ctr();
-  return os;
-}
-
-ErrnoLogMessage::ErrnoLogMessage(const char* file, int line,
-                                 LogSeverity severity, int ctr,
-                                 void (LogMessage::*send_method)())
-    : LogMessage(file, line, severity, ctr, send_method) {
-}
-
-ErrnoLogMessage::~ErrnoLogMessage() {
-  // Don't access errno directly because it may have been altered
-  // while streaming the message.
-  char buf[100];
-  posix_strerror_r(preserved_errno(), buf, sizeof(buf));
-  stream() << ": " << buf << " [" << preserved_errno() << "]";
-}
-
-void FlushLogFiles(LogSeverity min_severity) {
-  LogDestination::FlushLogFiles(min_severity);
-}
-
-void FlushLogFilesUnsafe(LogSeverity min_severity) {
-  LogDestination::FlushLogFilesUnsafe(min_severity);
-}
-
-void SetLogDestination(LogSeverity severity, const char* base_filename) {
-  LogDestination::SetLogDestination(severity, base_filename);
-}
-
-void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
-  LogDestination::SetLogSymlink(severity, symlink_basename);
-}
-
-LogSink::~LogSink() {
-}
-
-void LogSink::WaitTillSent() {
-  // noop default
-}
-
-string LogSink::ToString(LogSeverity severity, const char* file, int line,
-                         const struct ::tm* tm_time,
-                         const char* message, size_t message_len) {
-  ostringstream stream(string(message, message_len));
-  stream.fill('0');
-
-  // FIXME(jrvb): Updating this to use the correct value for usecs
-  // requires changing the signature for both this method and
-  // LogSink::send().  This change needs to be done in a separate CL
-  // so subclasses of LogSink can be updated at the same time.
-  int usecs = 0;
-
-  stream << LogSeverityNames[severity][0]
-         << setw(2) << 1+tm_time->tm_mon
-         << setw(2) << tm_time->tm_mday
-         << ' '
-         << setw(2) << tm_time->tm_hour << ':'
-         << setw(2) << tm_time->tm_min << ':'
-         << setw(2) << tm_time->tm_sec << '.'
-         << setw(6) << usecs
-         << ' '
-         << setfill(' ') << setw(5) << GetTID() << setfill('0')
-         << ' '
-         << file << ':' << line << "] ";
-
-  stream << string(message, message_len);
-  return stream.str();
-}
-
-void AddLogSink(LogSink *destination) {
-  LogDestination::AddLogSink(destination);
-}
-
-void RemoveLogSink(LogSink *destination) {
-  LogDestination::RemoveLogSink(destination);
-}
-
-void SetLogFilenameExtension(const char* ext) {
-  LogDestination::SetLogFilenameExtension(ext);
-}
-
-void SetStderrLogging(LogSeverity min_severity) {
-  LogDestination::SetStderrLogging(min_severity);
-}
-
-void SetEmailLogging(LogSeverity min_severity, const char* addresses) {
-  LogDestination::SetEmailLogging(min_severity, addresses);
-}
-
-void LogToStderr() {
-  LogDestination::LogToStderr();
-}
-
-namespace base {
-namespace internal {
-
-bool GetExitOnDFatal() {
-  MutexLock l(&log_mutex);
-  return exit_on_dfatal;
-}
-
-// Determines whether we exit the program for a LOG(DFATAL) message in
-// debug mode.  It does this by skipping the call to Fail/FailQuietly.
-// This is intended for testing only.
-//
-// This can have some effects on LOG(FATAL) as well.  Failure messages
-// are always allocated (rather than sharing a buffer), the crash
-// reason is not recorded, the "gwq" status message is not updated,
-// and the stack trace is not recorded.  The LOG(FATAL) *will* still
-// exit the program.  Since this function is used only in testing,
-// these differences are acceptable.
-void SetExitOnDFatal(bool value) {
-  MutexLock l(&log_mutex);
-  exit_on_dfatal = value;
-}
-
-}  // namespace internal
-}  // namespace base
-
-// use_logging controls whether the logging functions LOG/VLOG are used
-// to log errors.  It should be set to false when the caller holds the
-// log_mutex.
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging) {
-  if (dest && *dest) {
-    if ( use_logging ) {
-      VLOG(1) << "Trying to send TITLE:" << subject
-              << " BODY:" << body << " to " << dest;
-    } else {
-      fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n",
-              subject, body, dest);
-    }
-
-    string cmd =
-        FLAGS_logmailer + " -s\"" + subject + "\" " + dest;
-    FILE* pipe = popen(cmd.c_str(), "w");
-    if (pipe != NULL) {
-      // Add the body if we have one
-      if (body)
-        fwrite(body, sizeof(char), strlen(body), pipe);
-      bool ok = pclose(pipe) != -1;
-      if ( !ok ) {
-        if ( use_logging ) {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          LOG(ERROR) << "Problems sending mail to " << dest << ": " << buf;
-        } else {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          fprintf(stderr, "Problems sending mail to %s: %s\n", dest, buf);
-        }
-      }
-      return ok;
-    } else {
-      if ( use_logging ) {
-        LOG(ERROR) << "Unable to send mail to " << dest;
-      } else {
-        fprintf(stderr, "Unable to send mail to %s\n", dest);
-      }
-    }
-  }
-  return false;
-}
-
-bool SendEmail(const char*dest, const char *subject, const char*body){
-  return SendEmailInternal(dest, subject, body, true);
-}
-
-static void GetTempDirectories(vector<string>* list) {
-  list->clear();
-#ifdef OS_WINDOWS
-  // On windows we'll try to find a directory in this order:
-  //   C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
-  //   C:/TMP/
-  //   C:/TEMP/
-  //   C:/WINDOWS/ or C:/WINNT/
-  //   .
-  char tmp[MAX_PATH];
-  if (GetTempPathA(MAX_PATH, tmp))
-    list->push_back(tmp);
-  list->push_back("C:\\tmp\\");
-  list->push_back("C:\\temp\\");
-#else
-  // Directories, in order of preference. If we find a dir that
-  // exists, we stop adding other less-preferred dirs
-  const char * candidates[] = {
-    // Non-null only during unittest/regtest
-    getenv("TEST_TMPDIR"),
-
-    // Explicitly-supplied temp dirs
-    getenv("TMPDIR"), getenv("TMP"),
-
-    // If all else fails
-    "/tmp",
-  };
-
-  for (int i = 0; i < ARRAYSIZE(candidates); i++) {
-    const char *d = candidates[i];
-    if (!d) continue;  // Empty env var
-
-    // Make sure we don't surprise anyone who's expecting a '/'
-    string dstr = d;
-    if (dstr[dstr.size() - 1] != '/') {
-      dstr += "/";
-    }
-    list->push_back(dstr);
-
-    struct stat statbuf;
-    if (!stat(d, &statbuf) && S_ISDIR(statbuf.st_mode)) {
-      // We found a dir that exists - we're done.
-      return;
-    }
-  }
-
-#endif
-}
-
-static vector<string>* logging_directories_list;
-
-const vector<string>& GetLoggingDirectories() {
-  // Not strictly thread-safe but we're called early in InitGoogle().
-  if (logging_directories_list == NULL) {
-    logging_directories_list = new vector<string>;
-
-    if ( !FLAGS_log_dir.empty() ) {
-      // A dir was specified, we should use it
-      logging_directories_list->push_back(FLAGS_log_dir.c_str());
-    } else {
-      GetTempDirectories(logging_directories_list);
-#ifdef OS_WINDOWS
-      char tmp[MAX_PATH];
-      if (GetWindowsDirectoryA(tmp, MAX_PATH))
-        logging_directories_list->push_back(tmp);
-      logging_directories_list->push_back(".\\");
-#else
-      logging_directories_list->push_back("./");
-#endif
-    }
-  }
-  return *logging_directories_list;
-}
-
-void TestOnly_ClearLoggingDirectoriesList() {
-  fprintf(stderr, "TestOnly_ClearLoggingDirectoriesList should only be "
-          "called from test code.\n");
-  delete logging_directories_list;
-  logging_directories_list = NULL;
-}
-
-void GetExistingTempDirectories(vector<string>* list) {
-  GetTempDirectories(list);
-  vector<string>::iterator i_dir = list->begin();
-  while( i_dir != list->end() ) {
-    // zero arg to access means test for existence; no constant
-    // defined on windows
-    if ( access(i_dir->c_str(), 0) ) {
-      i_dir = list->erase(i_dir);
-    } else {
-      ++i_dir;
-    }
-  }
-}
-
-void TruncateLogFile(const char *path, int64 limit, int64 keep) {
-#ifdef HAVE_UNISTD_H
-  struct stat statbuf;
-  const int kCopyBlockSize = 8 << 10;
-  char copybuf[kCopyBlockSize];
-  int64 read_offset, write_offset;
-  // Don't follow symlinks unless they're our own fd symlinks in /proc
-  int flags = O_RDWR;
-  const char *procfd_prefix = "/proc/self/fd/";
-  if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
-
-  int fd = open(path, flags);
-  if (fd == -1) {
-    if (errno == EFBIG) {
-      // The log file in question has got too big for us to open. The
-      // real fix for this would be to compile logging.cc (or probably
-      // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's
-      // rather scary.
-      // Instead just truncate the file to something we can manage
-      if (truncate(path, 0) == -1) {
-	PLOG(ERROR) << "Unable to truncate " << path;
-      } else {
-	LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
-      }
-    } else {
-      PLOG(ERROR) << "Unable to open " << path;
-    }
-    return;
-  }
-
-  if (fstat(fd, &statbuf) == -1) {
-    PLOG(ERROR) << "Unable to fstat()";
-    goto out_close_fd;
-  }
-
-  // See if the path refers to a regular file bigger than the
-  // specified limit
-  if (!S_ISREG(statbuf.st_mode)) goto out_close_fd;
-  if (statbuf.st_size <= limit)  goto out_close_fd;
-  if (statbuf.st_size <= keep) goto out_close_fd;
-
-  // This log file is too large - we need to truncate it
-  LOG(INFO) << "Truncating " << path << " to " << keep << " bytes";
-
-  // Copy the last "keep" bytes of the file to the beginning of the file
-  read_offset = statbuf.st_size - keep;
-  write_offset = 0;
-  int bytesin, bytesout;
-  while ((bytesin = pread(fd, copybuf, sizeof(copybuf), read_offset)) > 0) {
-    bytesout = pwrite(fd, copybuf, bytesin, write_offset);
-    if (bytesout == -1) {
-      PLOG(ERROR) << "Unable to write to " << path;
-      break;
-    } else if (bytesout != bytesin) {
-      LOG(ERROR) << "Expected to write " << bytesin << ", wrote " << bytesout;
-    }
-    read_offset += bytesin;
-    write_offset += bytesout;
-  }
-  if (bytesin == -1) PLOG(ERROR) << "Unable to read from " << path;
-
-  // Truncate the remainder of the file. If someone else writes to the
-  // end of the file after our last read() above, we lose their latest
-  // data. Too bad ...
-  if (ftruncate(fd, write_offset) == -1) {
-    PLOG(ERROR) << "Unable to truncate " << path;
-  }
-
- out_close_fd:
-  close(fd);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-void TruncateStdoutStderr() {
-#ifdef HAVE_UNISTD_H
-  int64 limit = MaxLogSize() << 20;
-  int64 keep = 1 << 20;
-  TruncateLogFile("/proc/self/fd/1", limit, keep);
-  TruncateLogFile("/proc/self/fd/2", limit, keep);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-
-// Helper functions for string comparisons.
-#define DEFINE_CHECK_STROP_IMPL(name, func, expected)                   \
-  string* Check##func##expected##Impl(const char* s1, const char* s2,   \
-                                      const char* names) {              \
-    bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2));               \
-    if (equal == expected) return NULL;                                 \
-    else {                                                              \
-      strstream ss;                                                     \
-      if (!s1) s1 = "";                                                 \
-      if (!s2) s2 = "";                                                 \
-      ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \
-      return new string(ss.str(), ss.pcount());                         \
-    }                                                                   \
-  }
-DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false)
-#undef DEFINE_CHECK_STROP_IMPL
-
-int posix_strerror_r(int err, char *buf, size_t len) {
-  // Sanity check input parameters
-  if (buf == NULL || len <= 0) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  // Reset buf and errno, and try calling whatever version of strerror_r()
-  // is implemented by glibc
-  buf[0] = '\000';
-  int old_errno = errno;
-  errno = 0;
-  char *rc = reinterpret_cast<char *>(strerror_r(err, buf, len));
-
-  // Both versions set errno on failure
-  if (errno) {
-    // Should already be there, but better safe than sorry
-    buf[0]     = '\000';
-    return -1;
-  }
-  errno = old_errno;
-
-  // POSIX is vague about whether the string will be terminated, although
-  // is indirectly implies that typically ERANGE will be returned, instead
-  // of truncating the string. This is different from the GNU implementation.
-  // We play it safe by always terminating the string explicitly.
-  buf[len-1] = '\000';
-
-  // If the function succeeded, we can use its exit code to determine the
-  // semantics implemented by glibc
-  if (!rc) {
-    return 0;
-  } else {
-    // GNU semantics detected
-    if (rc == buf) {
-      return 0;
-    } else {
-      buf[0] = '\000';
-#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
-      if (reinterpret_cast<intptr_t>(rc) < sys_nerr) {
-        // This means an error on MacOSX or FreeBSD.
-        return -1;
-      }
-#endif
-      strncat(buf, rc, len-1);
-      return 0;
-    }
-  }
-}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line) :
-    LogMessage(file, line, FATAL) {}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line,
-                                 const CheckOpString& result) :
-    LogMessage(file, line, result) {}
-
-LogMessageFatal::~LogMessageFatal() {
-    Flush();
-    LogMessage::Fail();
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 35
Src/ThirdParty/glog/src/logging_striptest10.cc

@@ -1,35 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-#define GOOGLE_STRIP_LOG 10
-
-// Include the actual test.
-#include "logging_striptest_main.cc"

+ 0 - 35
Src/ThirdParty/glog/src/logging_striptest2.cc

@@ -1,35 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-#define GOOGLE_STRIP_LOG 2
-
-// Include the actual test.
-#include "logging_striptest_main.cc"

+ 0 - 68
Src/ThirdParty/glog/src/logging_striptest_main.cc

@@ -1,68 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-// The common part of the striplog tests.
-
-#include <stdio.h>
-#include <string>
-#include <iosfwd>
-#include "glog/logging.h"
-#include "base/commandlineflags.h"
-#include "config.h"
-
-DECLARE_bool(logtostderr);
-
-using std::string;
-using namespace GOOGLE_NAMESPACE;
-
-int CheckNoReturn(bool b) {
-  string s;
-  if (b) {
-    LOG(FATAL) << "Fatal";
-  } else {
-    return 0;
-  }
-}
-
-struct A { };
-std::ostream &operator<<(std::ostream &str, const A&) {return str;}
-
-int main(int argc, char* argv[]) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  LOG(INFO) << "TESTMESSAGE INFO";
-  LOG(WARNING) << 2 << "something" << "TESTMESSAGE WARNING"
-               << 1 << 'c' << A() << std::endl;
-  LOG(ERROR) << "TESTMESSAGE ERROR";
-  bool flag = true;
-  (flag ? LOG(INFO) : LOG(ERROR)) << "TESTMESSAGE COND";
-  LOG(FATAL) << "TESTMESSAGE FATAL";
-}

+ 0 - 1210
Src/ThirdParty/glog/src/logging_unittest.cc

@@ -1,1210 +0,0 @@
-// Copyright (c) 2002, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-
-#include "config_for_unittests.h"
-#include "utilities.h"
-
-#include <fcntl.h>
-#ifdef HAVE_GLOB_H
-# include <glob.h>
-#endif
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include <iomanip>
-#include <iostream>
-#include <memory>
-#include <queue>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "googletest.h"
-
-DECLARE_string(log_backtrace_at);  // logging.cc
-
-#ifdef HAVE_LIB_GFLAGS
-#include <gflags/gflags.h>
-#endif
-
-#ifdef HAVE_LIB_GMOCK
-#include <gmock/gmock.h>
-#include "mock-log.h"
-// Introduce several symbols from gmock.
-using testing::_;
-using testing::AnyNumber;
-using testing::HasSubstr;
-using testing::AllOf;
-using testing::StrNe;
-using testing::StrictMock;
-using testing::InitGoogleMock;
-using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
-#endif
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-// Some non-advertised functions that we want to test or use.
-_START_GOOGLE_NAMESPACE_
-namespace base {
-namespace internal {
-bool GetExitOnDFatal();
-void SetExitOnDFatal(bool value);
-}  // namespace internal
-}  // namespace base
-_END_GOOGLE_NAMESPACE_
-
-static void TestLogging(bool check_counts);
-static void TestRawLogging();
-static void LogWithLevels(int v, int severity, bool err, bool alsoerr);
-static void TestLoggingLevels();
-static void TestLogString();
-static void TestLogSink();
-static void TestLogToString();
-static void TestLogSinkWaitTillSent();
-static void TestCHECK();
-static void TestDCHECK();
-static void TestSTREQ();
-static void TestBasename();
-static void TestSymlink();
-static void TestExtension();
-static void TestWrapper();
-static void TestErrno();
-static void TestTruncate();
-
-static int x = -1;
-static void BM_Check1(int n) {
-  while (n-- > 0) {
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-  }
-}
-BENCHMARK(BM_Check1);
-
-static void CheckFailure(int a, int b, const char* file, int line, const char* msg);
-static void BM_Check3(int n) {
-  while (n-- > 0) {
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-  }
-}
-BENCHMARK(BM_Check3);
-
-static void BM_Check2(int n) {
-  if (n == 17) {
-    x = 5;
-  }
-  while (n-- > 0) {
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-  }
-}
-BENCHMARK(BM_Check2);
-
-static void CheckFailure(int a, int b, const char* file, int line, const char* msg) {
-}
-
-static void BM_logspeed(int n) {
-  while (n-- > 0) {
-    LOG(INFO) << "test message";
-  }
-}
-BENCHMARK(BM_logspeed);
-
-static void BM_vlog(int n) {
-  while (n-- > 0) {
-    VLOG(1) << "test message";
-  }
-}
-BENCHMARK(BM_vlog);
-
-int main(int argc, char **argv) {
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-
-  // Test some basics before InitGoogleLogging:
-  CaptureTestStderr();
-  LogWithLevels(FLAGS_v, FLAGS_stderrthreshold,
-                FLAGS_logtostderr, FLAGS_alsologtostderr);
-  LogWithLevels(0, 0, 0, 0);  // simulate "before global c-tors"
-  const string early_stderr = GetCapturedTestStderr();
-
-  InitGoogleLogging(argv[0]);
-
-  RunSpecifiedBenchmarks();
-
-  FLAGS_logtostderr = true;
-
-  InitGoogleTest(&argc, argv);
-#ifdef HAVE_LIB_GMOCK
-  InitGoogleMock(&argc, argv);
-#endif
-
-  // so that death tests run before we use threads
-  CHECK_EQ(RUN_ALL_TESTS(), 0);
-
-  CaptureTestStderr();
-
-  // re-emit early_stderr
-  LogMessage("dummy", LogMessage::kNoLogPrefix, INFO).stream() << early_stderr;
-
-  TestLogging(true);
-  TestRawLogging();
-  TestLoggingLevels();
-  TestLogString();
-  TestLogSink();
-  TestLogToString();
-  TestLogSinkWaitTillSent();
-  TestCHECK();
-  TestDCHECK();
-  TestSTREQ();
-
-  // TODO: The golden test portion of this test is very flakey.
-  EXPECT_TRUE(
-      MungeAndDiffTestStderr(FLAGS_test_srcdir + "/src/logging_unittest.err"));
-
-  FLAGS_logtostderr = false;
-
-  TestBasename();
-  TestSymlink();
-  TestExtension();
-  TestWrapper();
-  TestErrno();
-  TestTruncate();
-
-  ShutdownGoogleLogging();
-
-  fprintf(stdout, "PASS\n");
-  return 0;
-}
-
-void TestLogging(bool check_counts) {
-  int64 base_num_infos   = LogMessage::num_messages(INFO);
-  int64 base_num_warning = LogMessage::num_messages(WARNING);
-  int64 base_num_errors  = LogMessage::num_messages(ERROR);
-
-  LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4;
-  for ( int i = 0; i < 10; ++i ) {
-    int old_errno = errno;
-    errno = i;
-    PLOG_EVERY_N(ERROR, 2) << "Plog every 2, iteration " << COUNTER;
-    errno = old_errno;
-
-    LOG_EVERY_N(ERROR, 3) << "Log every 3, iteration " << COUNTER << endl;
-    LOG_EVERY_N(ERROR, 4) << "Log every 4, iteration " << COUNTER << endl;
-
-    LOG_IF_EVERY_N(WARNING, true, 5) << "Log if every 5, iteration " << COUNTER;
-    LOG_IF_EVERY_N(WARNING, false, 3)
-        << "Log if every 3, iteration " << COUNTER;
-    LOG_IF_EVERY_N(INFO, true, 1) << "Log if every 1, iteration " << COUNTER;
-    LOG_IF_EVERY_N(ERROR, (i < 3), 2)
-        << "Log if less than 3 every 2, iteration " << COUNTER;
-  }
-  LOG_IF(WARNING, true) << "log_if this";
-  LOG_IF(WARNING, false) << "don't log_if this";
-
-  char s[] = "array";
-  LOG(INFO) << s;
-  const char const_s[] = "const array";
-  LOG(INFO) << const_s;
-  int j = 1000;
-  LOG(ERROR) << string("foo") << ' '<< j << ' ' << setw(10) << j << " "
-             << setw(1) << hex << j;
-
-  LogMessage("foo", LogMessage::kNoLogPrefix, INFO).stream() << "no prefix";
-
-  if (check_counts) {
-    CHECK_EQ(base_num_infos   + 14, LogMessage::num_messages(INFO));
-    CHECK_EQ(base_num_warning + 3,  LogMessage::num_messages(WARNING));
-    CHECK_EQ(base_num_errors  + 15, LogMessage::num_messages(ERROR));
-  }
-}
-
-static void NoAllocNewHook() {
-  CHECK(false) << "unexpected new";
-}
-
-struct NewHook {
-  NewHook() {
-    g_new_hook = &NoAllocNewHook;
-  }
-  ~NewHook() {
-    g_new_hook = NULL;
-  }
-};
-
-TEST(DeathNoAllocNewHook, logging) {
-  // tests that NewHook used below works
-  NewHook new_hook;
-  ASSERT_DEATH({
-    new int;
-  }, "unexpected new");
-}
-
-void TestRawLogging() {
-  string* foo = new string("foo ");
-  string huge_str(50000, 'a');
-
-  FlagSaver saver;
-
-  // Check that RAW loggging does not use mallocs.
-  NewHook new_hook;
-
-  RAW_LOG(INFO, "%s%s%d%c%f", foo->c_str(), "bar ", 10, ' ', 3.4);
-  char s[] = "array";
-  RAW_LOG(WARNING, "%s", s);
-  const char const_s[] = "const array";
-  RAW_LOG(INFO, "%s", const_s);
-  void* p = reinterpret_cast<void*>(0x12345678);
-  RAW_LOG(INFO, "ptr %p", p);
-  p = NULL;
-  RAW_LOG(INFO, "ptr %p", p);
-  int j = 1000;
-  RAW_LOG(ERROR, "%s%d%c%010d%s%1x", foo->c_str(), j, ' ', j, " ", j);
-  RAW_VLOG(0, "foo %d", j);
-
-#ifdef NDEBUG
-  RAW_LOG(INFO, "foo %d", j);  // so that have same stderr to compare
-#else
-  RAW_DLOG(INFO, "foo %d", j);  // test RAW_DLOG in debug mode
-#endif
-
-  // test how long messages are chopped:
-  RAW_LOG(WARNING, "Huge string: %s", huge_str.c_str());
-  RAW_VLOG(0, "Huge string: %s", huge_str.c_str());
-
-  FLAGS_v = 0;
-  RAW_LOG(INFO, "log");
-  RAW_VLOG(0, "vlog 0 on");
-  RAW_VLOG(1, "vlog 1 off");
-  RAW_VLOG(2, "vlog 2 off");
-  RAW_VLOG(3, "vlog 3 off");
-  FLAGS_v = 2;
-  RAW_LOG(INFO, "log");
-  RAW_VLOG(1, "vlog 1 on");
-  RAW_VLOG(2, "vlog 2 on");
-  RAW_VLOG(3, "vlog 3 off");
-
-#ifdef NDEBUG
-  RAW_DCHECK(1 == 2, " RAW_DCHECK's shouldn't be compiled in normal mode");
-#endif
-
-  RAW_CHECK(1 == 1, "should be ok");
-  RAW_DCHECK(true, "should be ok");
-
-  delete foo;
-}
-
-void LogWithLevels(int v, int severity, bool err, bool alsoerr) {
-  RAW_LOG(INFO,
-          "Test: v=%d stderrthreshold=%d logtostderr=%d alsologtostderr=%d",
-          v, severity, err, alsoerr);
-
-  FlagSaver saver;
-
-  FLAGS_v = v;
-  FLAGS_stderrthreshold = severity;
-  FLAGS_logtostderr = err;
-  FLAGS_alsologtostderr = alsoerr;
-
-  RAW_VLOG(-1, "vlog -1");
-  RAW_VLOG(0, "vlog 0");
-  RAW_VLOG(1, "vlog 1");
-  RAW_LOG(INFO, "log info");
-  RAW_LOG(WARNING, "log warning");
-  RAW_LOG(ERROR, "log error");
-
-  VLOG(-1) << "vlog -1";
-  VLOG(0) << "vlog 0";
-  VLOG(1) << "vlog 1";
-  LOG(INFO) << "log info";
-  LOG(WARNING) << "log warning";
-  LOG(ERROR) << "log error";
-
-  VLOG_IF(-1, true) << "vlog_if -1";
-  VLOG_IF(-1, false) << "don't vlog_if -1";
-  VLOG_IF(0, true) << "vlog_if 0";
-  VLOG_IF(0, false) << "don't vlog_if 0";
-  VLOG_IF(1, true) << "vlog_if 1";
-  VLOG_IF(1, false) << "don't vlog_if 1";
-  LOG_IF(INFO, true) << "log_if info";
-  LOG_IF(INFO, false) << "don't log_if info";
-  LOG_IF(WARNING, true) << "log_if warning";
-  LOG_IF(WARNING, false) << "don't log_if warning";
-  LOG_IF(ERROR, true) << "log_if error";
-  LOG_IF(ERROR, false) << "don't log_if error";
-
-  int c;
-  c = 1; VLOG_IF(100, c -= 2) << "vlog_if 100 expr"; EXPECT_EQ(c, -1);
-  c = 1; VLOG_IF(0, c -= 2) << "vlog_if 0 expr"; EXPECT_EQ(c, -1);
-  c = 1; LOG_IF(INFO, c -= 2) << "log_if info expr"; EXPECT_EQ(c, -1);
-  c = 1; LOG_IF(ERROR, c -= 2) << "log_if error expr"; EXPECT_EQ(c, -1);
-  c = 2; VLOG_IF(0, c -= 2) << "don't vlog_if 0 expr"; EXPECT_EQ(c, 0);
-  c = 2; LOG_IF(ERROR, c -= 2) << "don't log_if error expr"; EXPECT_EQ(c, 0);
-
-  c = 3; LOG_IF_EVERY_N(INFO, c -= 4, 1) << "log_if info every 1 expr";
-  EXPECT_EQ(c, -1);
-  c = 3; LOG_IF_EVERY_N(ERROR, c -= 4, 1) << "log_if error every 1 expr";
-  EXPECT_EQ(c, -1);
-  c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if info every 3 expr";
-  EXPECT_EQ(c, 0);
-  c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if error every 3 expr";
-  EXPECT_EQ(c, 0);
-  c = 5; VLOG_IF_EVERY_N(0, c -= 4, 1) << "vlog_if 0 every 1 expr";
-  EXPECT_EQ(c, 1);
-  c = 5; VLOG_IF_EVERY_N(100, c -= 4, 3) << "vlog_if 100 every 3 expr";
-  EXPECT_EQ(c, 1);
-  c = 6; VLOG_IF_EVERY_N(0, c -= 6, 1) << "don't vlog_if 0 every 1 expr";
-  EXPECT_EQ(c, 0);
-  c = 6; VLOG_IF_EVERY_N(100, c -= 6, 3) << "don't vlog_if 100 every 1 expr";
-  EXPECT_EQ(c, 0);
-}
-
-void TestLoggingLevels() {
-  LogWithLevels(0, INFO, false, false);
-  LogWithLevels(1, INFO, false, false);
-  LogWithLevels(-1, INFO, false, false);
-  LogWithLevels(0, WARNING, false, false);
-  LogWithLevels(0, ERROR, false, false);
-  LogWithLevels(0, FATAL, false, false);
-  LogWithLevels(0, FATAL, true, false);
-  LogWithLevels(0, FATAL, false, true);
-  LogWithLevels(1, WARNING, false, false);
-  LogWithLevels(1, FATAL, false, true);
-}
-
-TEST(DeathRawCHECK, logging) {
-  ASSERT_DEATH(RAW_CHECK(false, "failure 1"),
-               "RAW: Check false failed: failure 1");
-  ASSERT_DEBUG_DEATH(RAW_DCHECK(1 == 2, "failure 2"),
-               "RAW: Check 1 == 2 failed: failure 2");
-}
-
-void TestLogString() {
-  vector<string> errors;
-  vector<string> *no_errors = NULL;
-
-  LOG_STRING(INFO, &errors) << "LOG_STRING: " << "collected info";
-  LOG_STRING(WARNING, &errors) << "LOG_STRING: " << "collected warning";
-  LOG_STRING(ERROR, &errors) << "LOG_STRING: " << "collected error";
-
-  LOG_STRING(INFO, no_errors) << "LOG_STRING: " << "reported info";
-  LOG_STRING(WARNING, no_errors) << "LOG_STRING: " << "reported warning";
-  LOG_STRING(ERROR, NULL) << "LOG_STRING: " << "reported error";
-
-  for (size_t i = 0; i < errors.size(); ++i) {
-    LOG(INFO) << "Captured by LOG_STRING:  " << errors[i];
-  }
-}
-
-void TestLogToString() {
-  string error;
-  string* no_error = NULL;
-
-  LOG_TO_STRING(INFO, &error) << "LOG_TO_STRING: " << "collected info";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-  LOG_TO_STRING(WARNING, &error) << "LOG_TO_STRING: " << "collected warning";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-  LOG_TO_STRING(ERROR, &error) << "LOG_TO_STRING: " << "collected error";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-
-  LOG_TO_STRING(INFO, no_error) << "LOG_TO_STRING: " << "reported info";
-  LOG_TO_STRING(WARNING, no_error) << "LOG_TO_STRING: " << "reported warning";
-  LOG_TO_STRING(ERROR, NULL) << "LOG_TO_STRING: " << "reported error";
-}
-
-class TestLogSinkImpl : public LogSink {
- public:
-  vector<string> errors;
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct tm* tm_time,
-                    const char* message, size_t message_len) {
-    errors.push_back(
-      ToString(severity, base_filename, line, tm_time, message, message_len));
-  }
-};
-
-void TestLogSink() {
-  TestLogSinkImpl sink;
-  LogSink *no_sink = NULL;
-
-  LOG_TO_SINK(&sink, INFO) << "LOG_TO_SINK: " << "collected info";
-  LOG_TO_SINK(&sink, WARNING) << "LOG_TO_SINK: " << "collected warning";
-  LOG_TO_SINK(&sink, ERROR) << "LOG_TO_SINK: " << "collected error";
-
-  LOG_TO_SINK(no_sink, INFO) << "LOG_TO_SINK: " << "reported info";
-  LOG_TO_SINK(no_sink, WARNING) << "LOG_TO_SINK: " << "reported warning";
-  LOG_TO_SINK(NULL, ERROR) << "LOG_TO_SINK: " << "reported error";
-
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, INFO)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected info";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, WARNING)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected warning";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, ERROR)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected error";
-
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, INFO)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed info";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, WARNING)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed warning";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(NULL, ERROR)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed error";
-
-  LOG(INFO) << "Captured by LOG_TO_SINK:";
-  for (size_t i = 0; i < sink.errors.size(); ++i) {
-    LogMessage("foo", LogMessage::kNoLogPrefix, INFO).stream()
-      << sink.errors[i];
-  }
-}
-
-// For testing using CHECK*() on anonymous enums.
-enum {
-  CASE_A,
-  CASE_B
-};
-
-void TestCHECK() {
-  // Tests using CHECK*() on int values.
-  CHECK(1 == 1);
-  CHECK_EQ(1, 1);
-  CHECK_NE(1, 2);
-  CHECK_GE(1, 1);
-  CHECK_GE(2, 1);
-  CHECK_LE(1, 1);
-  CHECK_LE(1, 2);
-  CHECK_GT(2, 1);
-  CHECK_LT(1, 2);
-
-  // Tests using CHECK*() on anonymous enums.
-  // Apple's GCC doesn't like this.
-#if !defined(OS_MACOSX)
-  CHECK_EQ(CASE_A, CASE_A);
-  CHECK_NE(CASE_A, CASE_B);
-  CHECK_GE(CASE_A, CASE_A);
-  CHECK_GE(CASE_B, CASE_A);
-  CHECK_LE(CASE_A, CASE_A);
-  CHECK_LE(CASE_A, CASE_B);
-  CHECK_GT(CASE_B, CASE_A);
-  CHECK_LT(CASE_A, CASE_B);
-#endif
-}
-
-void TestDCHECK() {
-#ifdef NDEBUG
-  DCHECK( 1 == 2 ) << " DCHECK's shouldn't be compiled in normal mode";
-#endif
-  DCHECK( 1 == 1 );
-  DCHECK_EQ(1, 1);
-  DCHECK_NE(1, 2);
-  DCHECK_GE(1, 1);
-  DCHECK_GE(2, 1);
-  DCHECK_LE(1, 1);
-  DCHECK_LE(1, 2);
-  DCHECK_GT(2, 1);
-  DCHECK_LT(1, 2);
-
-  auto_ptr<int64> sptr(new int64);
-  int64* ptr = DCHECK_NOTNULL(sptr.get());
-  CHECK_EQ(ptr, sptr.get());
-}
-
-void TestSTREQ() {
-  CHECK_STREQ("this", "this");
-  CHECK_STREQ(NULL, NULL);
-  CHECK_STRCASEEQ("this", "tHiS");
-  CHECK_STRCASEEQ(NULL, NULL);
-  CHECK_STRNE("this", "tHiS");
-  CHECK_STRNE("this", NULL);
-  CHECK_STRCASENE("this", "that");
-  CHECK_STRCASENE(NULL, "that");
-  CHECK_STREQ((string("a")+"b").c_str(), "ab");
-  CHECK_STREQ(string("test").c_str(),
-              (string("te") + string("st")).c_str());
-}
-
-TEST(DeathSTREQ, logging) {
-  ASSERT_DEATH(CHECK_STREQ(NULL, "this"), "");
-  ASSERT_DEATH(CHECK_STREQ("this", "siht"), "");
-  ASSERT_DEATH(CHECK_STRCASEEQ(NULL, "siht"), "");
-  ASSERT_DEATH(CHECK_STRCASEEQ("this", "siht"), "");
-  ASSERT_DEATH(CHECK_STRNE(NULL, NULL), "");
-  ASSERT_DEATH(CHECK_STRNE("this", "this"), "");
-  ASSERT_DEATH(CHECK_STREQ((string("a")+"b").c_str(), "abc"), "");
-}
-
-TEST(CheckNOTNULL, Simple) {
-  int64 t;
-  void *ptr = static_cast<void *>(&t);
-  void *ref = CHECK_NOTNULL(ptr);
-  EXPECT_EQ(ptr, ref);
-  CHECK_NOTNULL(reinterpret_cast<char *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<unsigned char *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<int *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<int64 *>(ptr));
-}
-
-TEST(DeathCheckNN, Simple) {
-  ASSERT_DEATH(CHECK_NOTNULL(static_cast<void *>(NULL)), "");
-}
-
-// Get list of file names that match pattern
-static void GetFiles(const string& pattern, vector<string>* files) {
-  files->clear();
-#if defined(HAVE_GLOB_H)
-  glob_t g;
-  const int r = glob(pattern.c_str(), 0, NULL, &g);
-  CHECK((r == 0) || (r == GLOB_NOMATCH)) << ": error matching " << pattern;
-  for (int i = 0; i < g.gl_pathc; i++) {
-    files->push_back(string(g.gl_pathv[i]));
-  }
-  globfree(&g);
-#elif defined(OS_WINDOWS)
-  WIN32_FIND_DATAA data;
-  HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
-  size_t index = pattern.rfind('\\');
-  if (index == string::npos) {
-    LOG(FATAL) << "No directory separator.";
-  }
-  const string dirname = pattern.substr(0, index + 1);
-  if (FAILED(handle)) {
-    // Finding no files is OK.
-    return;
-  }
-  do {
-    files->push_back(dirname + data.cFileName);
-  } while (FindNextFileA(handle, &data));
-  LOG_SYSRESULT(FindClose(handle));
-#else
-# error There is no way to do glob.
-#endif
-}
-
-// Delete files patching pattern
-static void DeleteFiles(const string& pattern) {
-  vector<string> files;
-  GetFiles(pattern, &files);
-  for (size_t i = 0; i < files.size(); i++) {
-    CHECK(unlink(files[i].c_str()) == 0) << ": " << strerror(errno);
-  }
-}
-
-static void CheckFile(const string& name, const string& expected_string) {
-  vector<string> files;
-  GetFiles(name + "*", &files);
-  CHECK_EQ(files.size(), 1);
-
-  FILE* file = fopen(files[0].c_str(), "r");
-  CHECK(file != NULL) << ": could not open " << files[0];
-  char buf[1000];
-  while (fgets(buf, sizeof(buf), file) != NULL) {
-    if (strstr(buf, expected_string.c_str()) != NULL) {
-      fclose(file);
-      return;
-    }
-  }
-  fclose(file);
-  LOG(FATAL) << "Did not find " << expected_string << " in " << files[0];
-}
-
-static void TestBasename() {
-  fprintf(stderr, "==== Test setting log file basename\n");
-  const string dest = FLAGS_test_tmpdir + "/logging_test_basename";
-  DeleteFiles(dest + "*");
-
-  SetLogDestination(INFO, dest.c_str());
-  LOG(INFO) << "message to new base";
-  FlushLogFiles(INFO);
-
-  CheckFile(dest, "message to new base");
-
-  // Release file handle for the destination file to unlock the file in Windows.
-  LogToStderr();
-  DeleteFiles(dest + "*");
-}
-
-static void TestSymlink() {
-#ifndef OS_WINDOWS
-  fprintf(stderr, "==== Test setting log file symlink\n");
-  string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
-  string sym = FLAGS_test_tmpdir + "/symlinkbase";
-  DeleteFiles(dest + "*");
-  DeleteFiles(sym + "*");
-
-  SetLogSymlink(INFO, "symlinkbase");
-  SetLogDestination(INFO, dest.c_str());
-  LOG(INFO) << "message to new symlink";
-  FlushLogFiles(INFO);
-  CheckFile(sym, "message to new symlink");
-
-  DeleteFiles(dest + "*");
-  DeleteFiles(sym + "*");
-#endif
-}
-
-static void TestExtension() {
-  fprintf(stderr, "==== Test setting log file extension\n");
-  string dest = FLAGS_test_tmpdir + "/logging_test_extension";
-  DeleteFiles(dest + "*");
-
-  SetLogDestination(INFO, dest.c_str());
-  SetLogFilenameExtension("specialextension");
-  LOG(INFO) << "message to new extension";
-  FlushLogFiles(INFO);
-  CheckFile(dest, "message to new extension");
-
-  // Check that file name ends with extension
-  vector<string> filenames;
-  GetFiles(dest + "*", &filenames);
-  CHECK_EQ(filenames.size(), 1);
-  CHECK(strstr(filenames[0].c_str(), "specialextension") != NULL);
-
-  // Release file handle for the destination file to unlock the file in Windows.
-  LogToStderr();
-  DeleteFiles(dest + "*");
-}
-
-struct MyLogger : public base::Logger {
-  string data;
-
-  virtual void Write(bool should_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int length) {
-    data.append(message, length);
-  }
-
-  virtual void Flush() { }
-
-  virtual uint32 LogSize() { return data.length(); }
-};
-
-static void TestWrapper() {
-  fprintf(stderr, "==== Test log wrapper\n");
-
-  MyLogger my_logger;
-  base::Logger* old_logger = base::GetLogger(INFO);
-  base::SetLogger(INFO, &my_logger);
-  LOG(INFO) << "Send to wrapped logger";
-  FlushLogFiles(INFO);
-  base::SetLogger(INFO, old_logger);
-
-  CHECK(strstr(my_logger.data.c_str(), "Send to wrapped logger") != NULL);
-}
-
-static void TestErrno() {
-  fprintf(stderr, "==== Test errno preservation\n");
-
-  errno = ENOENT;
-  TestLogging(false);
-  CHECK_EQ(errno, ENOENT);
-}
-
-static void TestOneTruncate(const char *path, int64 limit, int64 keep,
-                            int64 dsize, int64 ksize, int64 expect) {
-  int fd;
-  CHECK_ERR(fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600));
-
-  const char *discardstr = "DISCARDME!", *keepstr = "KEEPME!";
-
-  // Fill the file with the requested data; first discard data, then kept data
-  int64 written = 0;
-  while (written < dsize) {
-    int bytes = min<int64>(dsize - written, strlen(discardstr));
-    CHECK_ERR(write(fd, discardstr, bytes));
-    written += bytes;
-  }
-  written = 0;
-  while (written < ksize) {
-    int bytes = min<int64>(ksize - written, strlen(keepstr));
-    CHECK_ERR(write(fd, keepstr, bytes));
-    written += bytes;
-  }
-
-  TruncateLogFile(path, limit, keep);
-
-  // File should now be shorter
-  struct stat statbuf;
-  CHECK_ERR(fstat(fd, &statbuf));
-  CHECK_EQ(statbuf.st_size, expect);
-  CHECK_ERR(lseek(fd, 0, SEEK_SET));
-
-  // File should contain the suffix of the original file
-  int buf_size = statbuf.st_size + 1;
-  char* buf = new char[buf_size];
-  memset(buf, 0, sizeof(buf));
-  CHECK_ERR(read(fd, buf, buf_size));
-
-  const char *p = buf;
-  int64 checked = 0;
-  while (checked < expect) {
-    int bytes = min<int64>(expect - checked, strlen(keepstr));
-    CHECK(!memcmp(p, keepstr, bytes));
-    checked += bytes;
-  }
-  close(fd);
-  delete[] buf;
-}
-
-static void TestTruncate() {
-#ifdef HAVE_UNISTD_H
-  fprintf(stderr, "==== Test log truncation\n");
-  string path = FLAGS_test_tmpdir + "/truncatefile";
-
-  // Test on a small file
-  TestOneTruncate(path.c_str(), 10, 10, 10, 10, 10);
-
-  // And a big file (multiple blocks to copy)
-  TestOneTruncate(path.c_str(), 2<<20, 4<<10, 3<<20, 4<<10, 4<<10);
-
-  // Check edge-case limits
-  TestOneTruncate(path.c_str(), 10, 20, 0, 20, 20);
-  TestOneTruncate(path.c_str(), 10, 0, 0, 0, 0);
-  TestOneTruncate(path.c_str(), 10, 50, 0, 10, 10);
-  TestOneTruncate(path.c_str(), 50, 100, 0, 30, 30);
-
-  // MacOSX 10.4 doesn't fail in this case.
-  // Windows doesn't have symlink.
-  // Let's just ignore this test for these cases.
-#if !defined(OS_MACOSX) && !defined(OS_WINDOWS)
-  // Through a symlink should fail to truncate
-  string linkname = path + ".link";
-  unlink(linkname.c_str());
-  CHECK_ERR(symlink(path.c_str(), linkname.c_str()));
-  TestOneTruncate(linkname.c_str(), 10, 10, 0, 30, 30);
-#endif
-
-  // The /proc/self path makes sense only for linux.
-#if defined(OS_LINUX)
-  // Through an open fd symlink should work
-  int fd;
-  CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
-  char fdpath[64];
-  snprintf(fdpath, sizeof(fdpath), "/proc/self/fd/%d", fd);
-  TestOneTruncate(fdpath, 10, 10, 10, 10, 10);
-#endif
-
-#endif
-}
-
-_START_GOOGLE_NAMESPACE_
-namespace glog_internal_namespace_ {
-extern  // in logging.cc
-bool SafeFNMatch_(const char* pattern, size_t patt_len,
-                  const char* str, size_t str_len);
-} // namespace glog_internal_namespace_
-using glog_internal_namespace_::SafeFNMatch_;
-_END_GOOGLE_NAMESPACE_
-
-static bool WrapSafeFNMatch(string pattern, string str) {
-  pattern += "abc";
-  str += "defgh";
-  return SafeFNMatch_(pattern.data(), pattern.size() - 3,
-                      str.data(), str.size() - 5);
-}
-
-TEST(SafeFNMatch, logging) {
-  CHECK(WrapSafeFNMatch("foo", "foo"));
-  CHECK(!WrapSafeFNMatch("foo", "bar"));
-  CHECK(!WrapSafeFNMatch("foo", "fo"));
-  CHECK(!WrapSafeFNMatch("foo", "foo2"));
-  CHECK(WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext"));
-  CHECK(WrapSafeFNMatch("*ba*r/fo*o.ext*", "bar/foo.ext"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/baz.ext"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext.zip"));
-  CHECK(WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext"));
-  CHECK(WrapSafeFNMatch("ba?/*.ext", "baZ/FOO.ext"));
-  CHECK(!WrapSafeFNMatch("ba?/*.ext", "barr/foo.ext"));
-  CHECK(!WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext2"));
-  CHECK(WrapSafeFNMatch("ba?/*", "bar/foo.ext2"));
-  CHECK(WrapSafeFNMatch("ba?/*", "bar/"));
-  CHECK(!WrapSafeFNMatch("ba?/?", "bar/"));
-  CHECK(!WrapSafeFNMatch("ba?/*", "bar"));
-}
-
-// TestWaitingLogSink will save messages here
-// No lock: Accessed only by TestLogSinkWriter thread
-// and after its demise by its creator.
-static vector<string> global_messages;
-
-// helper for TestWaitingLogSink below.
-// Thread that does the logic of TestWaitingLogSink
-// It's free to use LOG() itself.
-class TestLogSinkWriter : public Thread {
- public:
-
-  TestLogSinkWriter() : should_exit_(false) {
-    SetJoinable(true);
-    Start();
-  }
-
-  // Just buffer it (can't use LOG() here).
-  void Buffer(const string& message) {
-    mutex_.Lock();
-    RAW_LOG(INFO, "Buffering");
-    messages_.push(message);
-    mutex_.Unlock();
-    RAW_LOG(INFO, "Buffered");
-  }
-
-  // Wait for the buffer to clear (can't use LOG() here).
-  void Wait() {
-    RAW_LOG(INFO, "Waiting");
-    mutex_.Lock();
-    while (!NoWork()) {
-      mutex_.Unlock();
-      SleepForMilliseconds(1);
-      mutex_.Lock();
-    }
-    RAW_LOG(INFO, "Waited");
-    mutex_.Unlock();
-  }
-
-  // Trigger thread exit.
-  void Stop() {
-    MutexLock l(&mutex_);
-    should_exit_ = true;
-  }
-
- private:
-
-  // helpers ---------------
-
-  // For creating a "Condition".
-  bool NoWork() { return messages_.empty(); }
-  bool HaveWork() { return !messages_.empty() || should_exit_; }
-
-  // Thread body; CAN use LOG() here!
-  virtual void Run() {
-    while (1) {
-      mutex_.Lock();
-      while (!HaveWork()) {
-        mutex_.Unlock();
-        SleepForMilliseconds(1);
-        mutex_.Lock();
-      }
-      if (should_exit_ && messages_.empty()) {
-        mutex_.Unlock();
-        break;
-      }
-      // Give the main thread time to log its message,
-      // so that we get a reliable log capture to compare to golden file.
-      // Same for the other sleep below.
-      SleepForMilliseconds(20);
-      RAW_LOG(INFO, "Sink got a messages");  // only RAW_LOG under mutex_ here
-      string message = messages_.front();
-      messages_.pop();
-      // Normally this would be some more real/involved logging logic
-      // where LOG() usage can't be eliminated,
-      // e.g. pushing the message over with an RPC:
-      int messages_left = messages_.size();
-      mutex_.Unlock();
-      SleepForMilliseconds(20);
-      // May not use LOG while holding mutex_, because Buffer()
-      // acquires mutex_, and Buffer is called from LOG(),
-      // which has its own internal mutex:
-      // LOG()->LogToSinks()->TestWaitingLogSink::send()->Buffer()
-      LOG(INFO) << "Sink is sending out a message: " << message;
-      LOG(INFO) << "Have " << messages_left << " left";
-      global_messages.push_back(message);
-    }
-  }
-
-  // data ---------------
-
-  Mutex mutex_;
-  bool should_exit_;
-  queue<string> messages_;  // messages to be logged
-};
-
-// A log sink that exercises WaitTillSent:
-// it pushes data to a buffer and wakes up another thread to do the logging
-// (that other thread can than use LOG() itself),
-class TestWaitingLogSink : public LogSink {
- public:
-
-  TestWaitingLogSink() {
-    tid_ = pthread_self();  // for thread-specific behavior
-    AddLogSink(this);
-  }
-  ~TestWaitingLogSink() {
-    RemoveLogSink(this);
-    writer_.Stop();
-    writer_.Join();
-  }
-
-  // (re)define LogSink interface
-
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct tm* tm_time,
-                    const char* message, size_t message_len) {
-    // Push it to Writer thread if we are the original logging thread.
-    // Note: Something like ThreadLocalLogSink is a better choice
-    //       to do thread-specific LogSink logic for real.
-    if (pthread_equal(tid_, pthread_self())) {
-      writer_.Buffer(ToString(severity, base_filename, line,
-                              tm_time, message, message_len));
-    }
-  }
-  virtual void WaitTillSent() {
-    // Wait for Writer thread if we are the original logging thread.
-    if (pthread_equal(tid_, pthread_self()))  writer_.Wait();
-  }
-
- private:
-
-  pthread_t tid_;
-  TestLogSinkWriter writer_;
-};
-
-// Check that LogSink::WaitTillSent can be used in the advertised way.
-// We also do golden-stderr comparison.
-static void TestLogSinkWaitTillSent() {
-  { TestWaitingLogSink sink;
-    // Sleeps give the sink threads time to do all their work,
-    // so that we get a reliable log capture to compare to the golden file.
-    LOG(INFO) << "Message 1";
-    SleepForMilliseconds(60);
-    LOG(ERROR) << "Message 2";
-    SleepForMilliseconds(60);
-    LOG(WARNING) << "Message 3";
-    SleepForMilliseconds(60);
-  }
-  for (size_t i = 0; i < global_messages.size(); ++i) {
-    LOG(INFO) << "Sink capture: " << global_messages[i];
-  }
-  CHECK_EQ(global_messages.size(), 3);
-}
-
-TEST(Strerror, logging) {
-  int errcode = EINTR;
-  char *msg = strdup(strerror(errcode));
-  int buf_size = strlen(msg) + 1;
-  char *buf = new char[buf_size];
-  CHECK_EQ(posix_strerror_r(errcode, NULL, 0), -1);
-  buf[0] = 'A';
-  CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
-  CHECK_EQ(buf[0], 'A');
-  CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
-#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
-  // MacOSX or FreeBSD considers this case is an error since there is
-  // no enough space.
-  CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
-#else
-  CHECK_EQ(posix_strerror_r(errcode, buf, 1), 0);
-#endif
-  CHECK_STREQ(buf, "");
-  CHECK_EQ(posix_strerror_r(errcode, buf, buf_size), 0);
-  CHECK_STREQ(buf, msg);
-  free(msg);
-  delete[] buf;
-}
-
-// Simple routines to look at the sizes of generated code for LOG(FATAL) and
-// CHECK(..) via objdump
-void MyFatal() {
-  LOG(FATAL) << "Failed";
-}
-void MyCheck(bool a, bool b) {
-  CHECK_EQ(a, b);
-}
-
-#ifdef HAVE_LIB_GMOCK
-
-TEST(DVLog, Basic) {
-  ScopedMockLog log;
-
-#if NDEBUG
-  // We are expecting that nothing is logged.
-  EXPECT_CALL(log, Log(_, _, _)).Times(0);
-#else
-  EXPECT_CALL(log, Log(INFO, __FILE__, "debug log"));
-#endif
-
-  FLAGS_v = 1;
-  DVLOG(1) << "debug log";
-}
-
-TEST(DVLog, V0) {
-  ScopedMockLog log;
-
-  // We are expecting that nothing is logged.
-  EXPECT_CALL(log, Log(_, _, _)).Times(0);
-
-  FLAGS_v = 0;
-  DVLOG(1) << "debug log";
-}
-
-TEST(LogAtLevel, Basic) {
-  ScopedMockLog log;
-
-  // The function version outputs "logging.h" as a file name.
-  EXPECT_CALL(log, Log(WARNING, StrNe(__FILE__), "function version"));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "macro version"));
-
-  int severity = WARNING;
-  LogAtLevel(severity, "function version");
-
-  severity = INFO;
-  // We can use the macro version as a C++ stream.
-  LOG_AT_LEVEL(severity) << "macro" << ' ' << "version";
-}
-
-TEST(TestExitOnDFatal, ToBeOrNotToBe) {
-  // Check the default setting...
-  EXPECT_TRUE(base::internal::GetExitOnDFatal());
-
-  // Turn off...
-  base::internal::SetExitOnDFatal(false);
-  EXPECT_FALSE(base::internal::GetExitOnDFatal());
-
-  // We don't die.
-  {
-    ScopedMockLog log;
-    //EXPECT_CALL(log, Log(_, _, _)).Times(AnyNumber());
-    // LOG(DFATAL) has severity FATAL if debugging, but is
-    // downgraded to ERROR if not debugging.
-    const LogSeverity severity =
-#ifdef NDEBUG
-        ERROR;
-#else
-        FATAL;
-#endif
-    EXPECT_CALL(log, Log(severity, __FILE__, "This should not be fatal"));
-    LOG(DFATAL) << "This should not be fatal";
-  }
-
-  // Turn back on...
-  base::internal::SetExitOnDFatal(true);
-  EXPECT_TRUE(base::internal::GetExitOnDFatal());
-
-#ifdef GTEST_HAS_DEATH_TEST
-  // Death comes on little cats' feet.
-  EXPECT_DEBUG_DEATH({
-      LOG(DFATAL) << "This should be fatal in debug mode";
-    }, "This should be fatal in debug mode");
-#endif
-}
-
-#ifdef HAVE_STACKTRACE
-
-static void BacktraceAtHelper() {
-  LOG(INFO) << "Not me";
-
-// The vertical spacing of the next 3 lines is significant.
-  LOG(INFO) << "Backtrace me";
-}
-static int kBacktraceAtLine = __LINE__ - 2;  // The line of the LOG(INFO) above
-
-TEST(LogBacktraceAt, DoesNotBacktraceWhenDisabled) {
-  StrictMock<ScopedMockLog> log;
-
-  FLAGS_log_backtrace_at = "";
-
-  EXPECT_CALL(log, Log(_, _, "Backtrace me"));
-  EXPECT_CALL(log, Log(_, _, "Not me"));
-
-  BacktraceAtHelper();
-}
-
-TEST(LogBacktraceAt, DoesBacktraceAtRightLineWhenEnabled) {
-  StrictMock<ScopedMockLog> log;
-
-  char where[100];
-  snprintf(where, 100, "%s:%d", const_basename(__FILE__), kBacktraceAtLine);
-  FLAGS_log_backtrace_at = where;
-
-  // The LOG at the specified line should include a stacktrace which includes
-  // the name of the containing function, followed by the log message.
-  // We use HasSubstr()s instead of ContainsRegex() for environments
-  // which don't have regexp.
-  EXPECT_CALL(log, Log(_, _, AllOf(HasSubstr("stacktrace:"),
-                                   HasSubstr("BacktraceAtHelper"),
-                                   HasSubstr("main"),
-                                   HasSubstr("Backtrace me"))));
-  // Other LOGs should not include a backtrace.
-  EXPECT_CALL(log, Log(_, _, "Not me"));
-
-  BacktraceAtHelper();
-}
-
-#endif // HAVE_STACKTRACE
-
-#endif // HAVE_LIB_GMOCK
-
-struct UserDefinedClass {
-  bool operator==(const UserDefinedClass& rhs) const { return true; }
-};
-
-inline ostream& operator<<(ostream& out, const UserDefinedClass& u) {
-  out << "OK";
-  return out;
-}
-
-TEST(UserDefinedClass, logging) {
-  UserDefinedClass u;
-  vector<string> buf;
-  LOG_STRING(INFO, &buf) << u;
-  CHECK_EQ(1, buf.size());
-  CHECK(buf[0].find("OK") != string::npos);
-
-  // We must be able to compile this.
-  CHECK_EQ(u, u);
-}

+ 0 - 155
Src/ThirdParty/glog/src/mock-log.h

@@ -1,155 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Zhanyong Wan
-//
-// Defines the ScopedMockLog class (using Google C++ Mocking
-// Framework), which is convenient for testing code that uses LOG().
-
-#ifndef GLOG_SRC_MOCK_LOG_H_
-#define GLOG_SRC_MOCK_LOG_H_
-
-// For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE.
-#include "utilities.h"
-
-#include <string>
-
-#include <gmock/gmock.h>
-
-#include "glog/logging.h"
-
-_START_GOOGLE_NAMESPACE_
-namespace glog_testing {
-
-// A ScopedMockLog object intercepts LOG() messages issued during its
-// lifespan.  Using this together with Google C++ Mocking Framework,
-// it's very easy to test how a piece of code calls LOG().  The
-// typical usage:
-//
-//   TEST(FooTest, LogsCorrectly) {
-//     ScopedMockLog log;
-//
-//     // We expect the WARNING "Something bad!" exactly twice.
-//     EXPECT_CALL(log, Log(WARNING, _, "Something bad!"))
-//         .Times(2);
-//
-//     // We allow foo.cc to call LOG(INFO) any number of times.
-//     EXPECT_CALL(log, Log(INFO, HasSubstr("/foo.cc"), _))
-//         .Times(AnyNumber());
-//
-//     Foo();  // Exercises the code under test.
-//   }
-class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
- public:
-  // When a ScopedMockLog object is constructed, it starts to
-  // intercept logs.
-  ScopedMockLog() { AddLogSink(this); }
-
-  // When the object is destructed, it stops intercepting logs.
-  virtual ~ScopedMockLog() { RemoveLogSink(this); }
-
-  // Implements the mock method:
-  //
-  //   void Log(LogSeverity severity, const string& file_path,
-  //            const string& message);
-  //
-  // The second argument to Send() is the full path of the source file
-  // in which the LOG() was issued.
-  //
-  // Note, that in a multi-threaded environment, all LOG() messages from a
-  // single thread will be handled in sequence, but that cannot be guaranteed
-  // for messages from different threads. In fact, if the same or multiple
-  // expectations are matched on two threads concurrently, their actions will
-  // be executed concurrently as well and may interleave.
-  MOCK_METHOD3(Log, void(GOOGLE_NAMESPACE::LogSeverity severity,
-                         const std::string& file_path,
-                         const std::string& message));
-
- private:
-  // Implements the send() virtual function in class LogSink.
-  // Whenever a LOG() statement is executed, this function will be
-  // invoked with information presented in the LOG().
-  //
-  // The method argument list is long and carries much information a
-  // test usually doesn't care about, so we trim the list before
-  // forwarding the call to Log(), which is much easier to use in
-  // tests.
-  //
-  // We still cannot call Log() directly, as it may invoke other LOG()
-  // messages, either due to Invoke, or due to an error logged in
-  // Google C++ Mocking Framework code, which would trigger a deadlock
-  // since a lock is held during send().
-  //
-  // Hence, we save the message for WaitTillSent() which will be called after
-  // the lock on send() is released, and we'll call Log() inside
-  // WaitTillSent(). Since while a single send() call may be running at a
-  // time, multiple WaitTillSent() calls (along with the one send() call) may
-  // be running simultaneously, we ensure thread-safety of the exchange between
-  // send() and WaitTillSent(), and that for each message, LOG(), send(),
-  // WaitTillSent() and Log() are executed in the same thread.
-  virtual void send(GOOGLE_NAMESPACE::LogSeverity severity,
-                    const char* full_filename,
-                    const char* base_filename, int line, const tm* tm_time,
-                    const char* message, size_t message_len) {
-    // We are only interested in the log severity, full file name, and
-    // log message.
-    message_info_.severity = severity;
-    message_info_.file_path = full_filename;
-    message_info_.message = std::string(message, message_len);
-  }
-
-  // Implements the WaitTillSent() virtual function in class LogSink.
-  // It will be executed after send() and after the global logging lock is
-  // released, so calls within it (or rather within the Log() method called
-  // within) may also issue LOG() statements.
-  //
-  // LOG(), send(), WaitTillSent() and Log() will occur in the same thread for
-  // a given log message.
-  virtual void WaitTillSent() {
-    // First, and very importantly, we save a copy of the message being
-    // processed before calling Log(), since Log() may indirectly call send()
-    // and WaitTillSent() in the same thread again.
-    MessageInfo message_info = message_info_;
-    Log(message_info.severity, message_info.file_path, message_info.message);
-  }
-
-  // All relevant information about a logged message that needs to be passed
-  // from send() to WaitTillSent().
-  struct MessageInfo {
-    GOOGLE_NAMESPACE::LogSeverity severity;
-    std::string file_path;
-    std::string message;
-  };
-  MessageInfo message_info_;
-};
-
-}  // namespace glog_testing
-_END_GOOGLE_NAMESPACE_
-
-#endif  // GLOG_SRC_MOCK_LOG_H_

+ 0 - 106
Src/ThirdParty/glog/src/mock-log_test.cc

@@ -1,106 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Zhanyong Wan
-
-// Tests the ScopedMockLog class.
-
-#include "mock-log.h"
-
-#include <string>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-namespace {
-
-using GOOGLE_NAMESPACE::INFO;
-using GOOGLE_NAMESPACE::WARNING;
-using GOOGLE_NAMESPACE::ERROR;
-using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
-using std::string;
-using testing::_;
-using testing::HasSubstr;
-using testing::InSequence;
-using testing::InvokeWithoutArgs;
-
-// Tests that ScopedMockLog intercepts LOG()s when it's alive.
-TEST(ScopedMockLogTest, InterceptsLog) {
-  ScopedMockLog log;
-
-  InSequence s;
-  EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_test.cc"), "Fishy."));
-  EXPECT_CALL(log, Log(INFO, _, "Working..."))
-      .Times(2);
-  EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));
-
-  LOG(WARNING) << "Fishy.";
-  LOG(INFO) << "Working...";
-  LOG(INFO) << "Working...";
-  LOG(ERROR) << "Bad!!";
-}
-
-void LogBranch() {
-  LOG(INFO) << "Logging a branch...";
-}
-
-void LogTree() {
-  LOG(INFO) << "Logging the whole tree...";
-}
-
-void LogForest() {
-  LOG(INFO) << "Logging the entire forest.";
-  LOG(INFO) << "Logging the entire forest..";
-  LOG(INFO) << "Logging the entire forest...";
-}
-
-// The purpose of the following test is to verify that intercepting logging
-// continues to work properly if a LOG statement is executed within the scope
-// of a mocked call.
-TEST(ScopedMockLogTest, LogDuringIntercept) {
-  ScopedMockLog log;
-  InSequence s;
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging a branch..."))
-      .WillOnce(InvokeWithoutArgs(LogTree));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the whole tree..."))
-      .WillOnce(InvokeWithoutArgs(LogForest));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest."));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest.."));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest..."));
-  LogBranch();
-}
-
-}  // namespace
-
-int main(int argc, char **argv) {
-  GOOGLE_NAMESPACE::InitGoogleLogging(argv[0]);
-  testing::InitGoogleMock(&argc, argv);
-
-  return RUN_ALL_TESTS();
-}

+ 0 - 172
Src/ThirdParty/glog/src/raw_logging.cc

@@ -1,172 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>               // for close() and write()
-#endif
-#include <fcntl.h>                 // for open()
-#include <time.h>
-#include "config.h"
-#include "glog/logging.h"          // To pick up flag settings etc.
-#include "glog/raw_logging.h"
-#include "base/commandlineflags.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)
-# define safe_write(fd, s, len)  syscall(SYS_write, fd, s, len)
-#else
-  // Not so safe, but what can you do?
-# define safe_write(fd, s, len)  write(fd, s, len)
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Data for RawLog__ below. We simply pick up the latest
-// time data created by a normal log message to avoid calling
-// localtime_r which can allocate memory.
-static struct ::tm last_tm_time_for_raw_log;
-static int last_usecs_for_raw_log;
-
-void RawLog__SetLastTime(const struct ::tm& t, int usecs) {
-  memcpy(&last_tm_time_for_raw_log, &t, sizeof(last_tm_time_for_raw_log));
-  last_usecs_for_raw_log = usecs;
-}
-
-// CAVEAT: vsnprintf called from *DoRawLog below has some (exotic) code paths
-// that invoke malloc() and getenv() that might acquire some locks.
-// If this becomes a problem we should reimplement a subset of vsnprintf
-// that does not need locks and malloc.
-
-// Helper for RawLog__ below.
-// *DoRawLog writes to *buf of *size and move them past the written portion.
-// It returns true iff there was no overflow or error.
-static bool DoRawLog(char** buf, int* size, const char* format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  int n = vsnprintf(*buf, *size, format, ap);
-  va_end(ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-// Helper for RawLog__ below.
-inline static bool VADoRawLog(char** buf, int* size,
-                              const char* format, va_list ap) {
-  int n = vsnprintf(*buf, *size, format, ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-static const int kLogBufSize = 3000;
-static bool crashed = false;
-static CrashReason crash_reason;
-static char crash_buf[kLogBufSize + 1] = { 0 };  // Will end in '\0'
-
-void RawLog__(LogSeverity severity, const char* file, int line,
-              const char* format, ...) {
-  if (!(FLAGS_logtostderr || severity >= FLAGS_stderrthreshold ||
-        FLAGS_alsologtostderr || !IsGoogleLoggingInitialized())) {
-    return;  // this stderr log message is suppressed
-  }
-  // can't call localtime_r here: it can allocate
-  struct ::tm& t = last_tm_time_for_raw_log;
-  char buffer[kLogBufSize];
-  char* buf = buffer;
-  int size = sizeof(buffer);
-
-  // NOTE: this format should match the specification in base/logging.h
-  DoRawLog(&buf, &size, "%c%02d%02d %02d:%02d:%02d.%06d %5u %s:%d] RAW: ",
-           LogSeverityNames[severity][0],
-           1 + t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
-           last_usecs_for_raw_log,
-           static_cast<unsigned int>(GetTID()),
-           const_basename(const_cast<char *>(file)), line);
-
-  // Record the position and size of the buffer after the prefix
-  const char* msg_start = buf;
-  const int msg_size = size;
-
-  va_list ap;
-  va_start(ap, format);
-  bool no_chop = VADoRawLog(&buf, &size, format, ap);
-  va_end(ap);
-  if (no_chop) {
-    DoRawLog(&buf, &size, "\n");
-  } else {
-    DoRawLog(&buf, &size, "RAW_LOG ERROR: The Message was too long!\n");
-  }
-  // We make a raw syscall to write directly to the stderr file descriptor,
-  // avoiding FILE buffering (to avoid invoking malloc()), and bypassing
-  // libc (to side-step any libc interception).
-  // We write just once to avoid races with other invocations of RawLog__.
-  safe_write(STDERR_FILENO, buffer, strlen(buffer));
-  if (severity == FATAL)  {
-    if (!sync_val_compare_and_swap(&crashed, false, true)) {
-      crash_reason.filename = file;
-      crash_reason.line_number = line;
-      memcpy(crash_buf, msg_start, msg_size);  // Don't include prefix
-      crash_reason.message = crash_buf;
-#ifdef HAVE_STACKTRACE
-      crash_reason.depth =
-          GetStackTrace(crash_reason.stack, ARRAYSIZE(crash_reason.stack), 1);
-#else
-      crash_reason.depth = 0;
-#endif
-      SetCrashReason(&crash_reason);
-    }
-    LogMessage::Fail();  // abort()
-  }
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 348
Src/ThirdParty/glog/src/signalhandler.cc

@@ -1,348 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Implementation of InstallFailureSignalHandler().
-
-#include "utilities.h"
-#include "stacktrace.h"
-#include "symbolize.h"
-#include "glog/logging.h"
-
-#include <signal.h>
-#include <time.h>
-#ifdef HAVE_UCONTEXT_H
-# include <ucontext.h>
-#endif
-#ifdef HAVE_SYS_UCONTEXT_H
-# include <sys/ucontext.h>
-#endif
-#include <algorithm>
-
-_START_GOOGLE_NAMESPACE_
-
-namespace {
-
-// We'll install the failure signal handler for these signals.  We could
-// use strsignal() to get signal names, but we don't use it to avoid
-// introducing yet another #ifdef complication.
-//
-// The list should be synced with the comment in signalhandler.h.
-const struct {
-  int number;
-  const char *name;
-} kFailureSignals[] = {
-  { SIGSEGV, "SIGSEGV" },
-  { SIGILL, "SIGILL" },
-  { SIGFPE, "SIGFPE" },
-  { SIGABRT, "SIGABRT" },
-  { SIGBUS, "SIGBUS" },
-  { SIGTERM, "SIGTERM" },
-};
-
-// Returns the program counter from signal context, NULL if unknown.
-void* GetPC(void* ucontext_in_void) {
-#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT)
-  if (ucontext_in_void != NULL) {
-    ucontext_t *context = reinterpret_cast<ucontext_t *>(ucontext_in_void);
-    return (void*)context->PC_FROM_UCONTEXT;
-  }
-#endif
-  return NULL;
-}
-
-// The class is used for formatting error messages.  We don't use printf()
-// as it's not async signal safe.
-class MinimalFormatter {
- public:
-  MinimalFormatter(char *buffer, int size)
-      : buffer_(buffer),
-        cursor_(buffer),
-        end_(buffer + size) {
-  }
-
-  // Returns the number of bytes written in the buffer.
-  int num_bytes_written() const { return cursor_ - buffer_; }
-
-  // Appends string from "str" and updates the internal cursor.
-  void AppendString(const char* str) {
-    int i = 0;
-    while (str[i] != '\0' && cursor_ + i < end_) {
-      cursor_[i] = str[i];
-      ++i;
-    }
-    cursor_ += i;
-  }
-
-  // Formats "number" in "radix" and updates the internal cursor.
-  // Lowercase letters are used for 'a' - 'z'.
-  void AppendUint64(uint64 number, int radix) {
-    int i = 0;
-    while (cursor_ + i < end_) {
-      const int tmp = number % radix;
-      number /= radix;
-      cursor_[i] = (tmp < 10 ? '0' + tmp : 'a' + tmp - 10);
-      ++i;
-      if (number == 0) {
-        break;
-      }
-    }
-    // Reverse the bytes written.
-    std::reverse(cursor_, cursor_ + i);
-    cursor_ += i;
-  }
-
-  // Formats "number" as hexadecimal number, and updates the internal
-  // cursor.  Padding will be added in front if needed.
-  void AppendHexWithPadding(uint64 number, int width) {
-    char* start = cursor_;
-    AppendString("0x");
-    AppendUint64(number, 16);
-    // Move to right and add padding in front if needed.
-    if (cursor_ < start + width) {
-      const int64 delta = start + width - cursor_;
-      std::copy(start, cursor_, start + delta);
-      std::fill(start, start + delta, ' ');
-      cursor_ = start + width;
-    }
-  }
-
- private:
-  char *buffer_;
-  char *cursor_;
-  const char * const end_;
-};
-
-// Writes the given data with the size to the standard error.
-void WriteToStderr(const char* data, int size) {
-  write(STDERR_FILENO, data, size);
-}
-
-// The writer function can be changed by InstallFailureWriter().
-void (*g_failure_writer)(const char* data, int size) = WriteToStderr;
-
-// Dumps time information.  We don't dump human-readable time information
-// as localtime() is not guaranteed to be async signal safe.
-void DumpTimeInfo() {
-  time_t time_in_sec = time(NULL);
-  char buf[256];  // Big enough for time info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-  formatter.AppendString("*** Aborted at ");
-  formatter.AppendUint64(time_in_sec, 10);
-  formatter.AppendString(" (unix time)");
-  formatter.AppendString(" try \"date -d @");
-  formatter.AppendUint64(time_in_sec, 10);
-  formatter.AppendString("\" if you are using GNU date ***\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Dumps information about the signal to STDERR.
-void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
-  // Get the signal name.
-  const char* signal_name = NULL;
-  for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
-    if (signal_number == kFailureSignals[i].number) {
-      signal_name = kFailureSignals[i].name;
-    }
-  }
-
-  char buf[256];  // Big enough for signal info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-
-  formatter.AppendString("*** ");
-  if (signal_name) {
-    formatter.AppendString(signal_name);
-  } else {
-    // Use the signal number if the name is unknown.  The signal name
-    // should be known, but just in case.
-    formatter.AppendString("Signal ");
-    formatter.AppendUint64(signal_number, 10);
-  }
-  formatter.AppendString(" (@0x");
-  formatter.AppendUint64(reinterpret_cast<uintptr_t>(siginfo->si_addr), 16);
-  formatter.AppendString(")");
-  formatter.AppendString(" received by PID ");
-  formatter.AppendUint64(getpid(), 10);
-  formatter.AppendString(" (TID 0x");
-  // We assume pthread_t is an integral number or a pointer, rather
-  // than a complex struct.  In some environments, pthread_self()
-  // returns an uint64 but in some other environments pthread_self()
-  // returns a pointer.  Hence we use C-style cast here, rather than
-  // reinterpret/static_cast, to support both types of environments.
-  formatter.AppendUint64((uintptr_t)pthread_self(), 16);
-  formatter.AppendString(") ");
-  // Only linux has the PID of the signal sender in si_pid.
-#ifdef OS_LINUX
-  formatter.AppendString("from PID ");
-  formatter.AppendUint64(siginfo->si_pid, 10);
-  formatter.AppendString("; ");
-#endif
-  formatter.AppendString("stack trace: ***\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Dumps information about the stack frame to STDERR.
-void DumpStackFrameInfo(const char* prefix, void* pc) {
-  // Get the symbol name.
-  const char *symbol = "(unknown)";
-  char symbolized[1024];  // Big enough for a sane symbol.
-  // Symbolizes the previous address of pc because pc may be in the
-  // next function.
-  if (Symbolize(reinterpret_cast<char *>(pc) - 1,
-                symbolized, sizeof(symbolized))) {
-    symbol = symbolized;
-  }
-
-  char buf[1024];  // Big enough for stack frame info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-
-  formatter.AppendString(prefix);
-  formatter.AppendString("@ ");
-  const int width = 2 * sizeof(void*) + 2;  // + 2  for "0x".
-  formatter.AppendHexWithPadding(reinterpret_cast<uintptr_t>(pc), width);
-  formatter.AppendString(" ");
-  formatter.AppendString(symbol);
-  formatter.AppendString("\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Invoke the default signal handler.
-void InvokeDefaultSignalHandler(int signal_number) {
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_handler = SIG_DFL;
-  sigaction(signal_number, &sig_action, NULL);
-  kill(getpid(), signal_number);
-}
-
-// This variable is used for protecting FailureSignalHandler() from
-// dumping stuff while another thread is doing it.  Our policy is to let
-// the first thread dump stuff and let other threads wait.
-// See also comments in FailureSignalHandler().
-static pthread_t* g_entered_thread_id_pointer = NULL;
-
-// Dumps signal and stack frame information, and invokes the default
-// signal handler once our job is done.
-void FailureSignalHandler(int signal_number,
-                          siginfo_t *signal_info,
-                          void *ucontext) {
-  // First check if we've already entered the function.  We use an atomic
-  // compare and swap operation for platforms that support it.  For other
-  // platforms, we use a naive method that could lead to a subtle race.
-
-  // We assume pthread_self() is async signal safe, though it's not
-  // officially guaranteed.
-  pthread_t my_thread_id = pthread_self();
-  // NOTE: We could simply use pthread_t rather than pthread_t* for this,
-  // if pthread_self() is guaranteed to return non-zero value for thread
-  // ids, but there is no such guarantee.  We need to distinguish if the
-  // old value (value returned from __sync_val_compare_and_swap) is
-  // different from the original value (in this case NULL).
-  pthread_t* old_thread_id_pointer =
-      glog_internal_namespace_::sync_val_compare_and_swap(
-          &g_entered_thread_id_pointer,
-          static_cast<pthread_t*>(NULL),
-          &my_thread_id);
-  if (old_thread_id_pointer != NULL) {
-    // We've already entered the signal handler.  What should we do?
-    if (pthread_equal(my_thread_id, *g_entered_thread_id_pointer)) {
-      // It looks the current thread is reentering the signal handler.
-      // Something must be going wrong (maybe we are reentering by another
-      // type of signal?).  Kill ourself by the default signal handler.
-      InvokeDefaultSignalHandler(signal_number);
-    }
-    // Another thread is dumping stuff.  Let's wait until that thread
-    // finishes the job and kills the process.
-    while (true) {
-      sleep(1);
-    }
-  }
-  // This is the first time we enter the signal handler.  We are going to
-  // do some interesting stuff from here.
-  // TODO(satorux): We might want to set timeout here using alarm(), but
-  // mixing alarm() and sleep() can be a bad idea.
-
-  // First dump time info.
-  DumpTimeInfo();
-
-  // Get the program counter from ucontext.
-  void *pc = GetPC(ucontext);
-  DumpStackFrameInfo("PC: ", pc);
-
-#ifdef HAVE_STACKTRACE
-  // Get the stack traces.
-  void *stack[32];
-  // +1 to exclude this function.
-  const int depth = GetStackTrace(stack, ARRAYSIZE(stack), 1);
-  DumpSignalInfo(signal_number, signal_info);
-  // Dump the stack traces.
-  for (int i = 0; i < depth; ++i) {
-    DumpStackFrameInfo("    ", stack[i]);
-  }
-#endif
-
-  // *** TRANSITION ***
-  //
-  // BEFORE this point, all code must be async-termination-safe!
-  // (See WARNING above.)
-  //
-  // AFTER this point, we do unsafe things, like using LOG()!
-  // The process could be terminated or hung at any time.  We try to
-  // do more useful things first and riskier things later.
-
-  // Flush the logs before we do anything in case 'anything'
-  // causes problems.
-  FlushLogFilesUnsafe(0);
-
-  // Kill ourself by the default signal handler.
-  InvokeDefaultSignalHandler(signal_number);
-}
-
-}  // namespace
-
-void InstallFailureSignalHandler() {
-  // Build the sigaction struct.
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_flags |= SA_SIGINFO;
-  sig_action.sa_sigaction = &FailureSignalHandler;
-
-  for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
-    CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
-  }
-}
-
-void InstallFailureWriter(void (*writer)(const char* data, int size)) {
-  g_failure_writer = writer;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 95
Src/ThirdParty/glog/src/signalhandler_unittest.cc

@@ -1,95 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// This is a helper binary for testing signalhandler.cc.  The actual test
-// is done in signalhandler_unittest.sh.
-
-#include "utilities.h"
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string>
-#include "glog/logging.h"
-
-using namespace GOOGLE_NAMESPACE;
-
-void* DieInThread(void*) {
-  // We assume pthread_t is an integral number or a pointer, rather
-  // than a complex struct.  In some environments, pthread_self()
-  // returns an uint64 but in some other environments pthread_self()
-  // returns a pointer.  Hence we use C-style cast here, rather than
-  // reinterpret/static_cast, to support both types of environments.
-  fprintf(stderr, "0x%lx is dying\n", (long)pthread_self());
-  // Use volatile to prevent from these to be optimized away.
-  volatile int a = 0;
-  volatile int b = 1 / a;
-  fprintf(stderr, "We should have died: b=%d\n", b);
-  return NULL;
-}
-
-void WriteToStdout(const char* data, int size) {
-  write(STDOUT_FILENO, data, size);
-}
-
-int main(int argc, char **argv) {
-#if defined(HAVE_STACKTRACE) && defined(HAVE_SYMBOLIZE)
-  InitGoogleLogging(argv[0]);
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-  InstallFailureSignalHandler();
-  const std::string command = argc > 1 ? argv[1] : "none";
-  if (command == "segv") {
-    // We'll check if this is outputted.
-    LOG(INFO) << "create the log file";
-    LOG(INFO) << "a message before segv";
-    // We assume 0xDEAD is not writable.
-    int *a = (int*)0xDEAD;
-    *a = 0;
-  } else if (command == "loop") {
-    fprintf(stderr, "looping\n");
-    while (true);
-  } else if (command == "die_in_thread") {
-    pthread_t thread;
-    pthread_create(&thread, NULL, &DieInThread, NULL);
-    pthread_join(thread, NULL);
-  } else if (command == "dump_to_stdout") {
-    InstallFailureWriter(WriteToStdout);
-    abort();
-  } else {
-    // Tell the shell script
-    puts("OK");
-  }
-#endif
-  return 0;
-}

+ 0 - 60
Src/ThirdParty/glog/src/stacktrace.h

@@ -1,60 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Routines to extract the current stack trace.  These functions are
-// thread-safe.
-
-#ifndef BASE_STACKTRACE_H_
-#define BASE_STACKTRACE_H_
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// This is similar to the GetStackFrames routine, except that it returns
-// the stack trace only, and not the stack frame sizes as well.
-// Example:
-//      main() { foo(); }
-//      foo() { bar(); }
-//      bar() {
-//        void* result[10];
-//        int depth = GetStackFrames(result, 10, 1);
-//      }
-//
-// This produces:
-//      result[0]       foo
-//      result[1]       main
-//           ....       ...
-//
-// "result" must not be NULL.
-extern int GetStackTrace(void** result, int max_depth, int skip_count);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_STACKTRACE_H_

+ 0 - 59
Src/ThirdParty/glog/src/stacktrace_generic-inl.h

@@ -1,59 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Portable implementation - just use glibc
-//
-// Note:  The glibc implementation may cause a call to malloc.
-// This can cause a deadlock in HeapProfiler.
-#include <execinfo.h>
-#include <string.h>
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  static const int kStackLength = 64;
-  void * stack[kStackLength];
-  int size;
-
-  size = backtrace(stack, kStackLength);
-  skip_count++;  // we want to skip the current frame as well
-  int result_count = size - skip_count;
-  if (result_count < 0)
-    result_count = 0;
-  if (result_count > max_depth)
-    result_count = max_depth;
-  for (int i = 0; i < result_count; i++)
-    result[i] = stack[i + skip_count];
-
-  return result_count;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 87
Src/ThirdParty/glog/src/stacktrace_libunwind-inl.h

@@ -1,87 +0,0 @@
-// Copyright (c) 2005 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Arun Sharma
-//
-// Produce stack trace using libunwind
-
-#include "utilities.h"
-
-extern "C" {
-#define UNW_LOCAL_ONLY
-#include <libunwind.h>
-}
-#include "glog/raw_logging.h"
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Sometimes, we can try to get a stack trace from within a stack
-// trace, because libunwind can call mmap (maybe indirectly via an
-// internal mmap based memory allocator), and that mmap gets trapped
-// and causes a stack-trace request.  If were to try to honor that
-// recursive request, we'd end up with infinite recursion or deadlock.
-// Luckily, it's safe to ignore those subsequent traces.  In such
-// cases, we return 0 to indicate the situation.
-static bool g_now_entering = false;
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void *ip;
-  int n = 0;
-  unw_cursor_t cursor;
-  unw_context_t uc;
-
-  if (sync_val_compare_and_swap(&g_now_entering, false, true)) {
-    return 0;
-  }
-
-  unw_getcontext(&uc);
-  RAW_CHECK(unw_init_local(&cursor, &uc) >= 0, "unw_init_local failed");
-  skip_count++;         // Do not include the "GetStackTrace" frame
-
-  while (n < max_depth) {
-    int ret = unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip);
-    if (ret < 0)
-      break;
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      result[n++] = ip;
-    }
-    ret = unw_step(&cursor);
-    if (ret <= 0)
-      break;
-  }
-
-  g_now_entering = false;
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 130
Src/ThirdParty/glog/src/stacktrace_powerpc-inl.h

@@ -1,130 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Craig Silverstein
-//
-// Produce stack trace.  I'm guessing (hoping!) the code is much like
-// for x86.  For apple machines, at least, it seems to be; see
-//    http://developer.apple.com/documentation/mac/runtimehtml/RTArch-59.html
-//    http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
-// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882
-
-#include <stdio.h>
-#include <stdint.h>   // for uintptr_t
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Given a pointer to a stack frame, locate and return the calling
-// stackframe, or return NULL if no stackframe can be found. Perform sanity
-// checks (the strictness of which is controlled by the boolean parameter
-// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned.
-template<bool STRICT_UNWINDING>
-static void **NextStackFrame(void **old_sp) {
-  void **new_sp = (void **) *old_sp;
-
-  // Check that the transition from frame pointer old_sp to frame
-  // pointer new_sp isn't clearly bogus
-  if (STRICT_UNWINDING) {
-    // With the stack growing downwards, older stack frame must be
-    // at a greater address that the current one.
-    if (new_sp <= old_sp) return NULL;
-    // Assume stack frames larger than 100,000 bytes are bogus.
-    if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000) return NULL;
-  } else {
-    // In the non-strict mode, allow discontiguous stack frames.
-    // (alternate-signal-stacks for example).
-    if (new_sp == old_sp) return NULL;
-    // And allow frames upto about 1MB.
-    if ((new_sp > old_sp)
-        && ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000)) return NULL;
-  }
-  if ((uintptr_t)new_sp & (sizeof(void *) - 1)) return NULL;
-  return new_sp;
-}
-
-// This ensures that GetStackTrace stes up the Link Register properly.
-void StacktracePowerPCDummyFunction() __attribute__((noinline));
-void StacktracePowerPCDummyFunction() { __asm__ volatile(""); }
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void **sp;
-  // Apple OS X uses an old version of gnu as -- both Darwin 7.9.0 (Panther)
-  // and Darwin 8.8.1 (Tiger) use as 1.38.  This means we have to use a
-  // different asm syntax.  I don't know quite the best way to discriminate
-  // systems using the old as from the new one; I've gone with __APPLE__.
-#ifdef __APPLE__
-  __asm__ volatile ("mr %0,r1" : "=r" (sp));
-#else
-  __asm__ volatile ("mr %0,1" : "=r" (sp));
-#endif
-
-  // On PowerPC, the "Link Register" or "Link Record" (LR), is a stack
-  // entry that holds the return address of the subroutine call (what
-  // instruction we run after our function finishes).  This is the
-  // same as the stack-pointer of our parent routine, which is what we
-  // want here.  While the compiler will always(?) set up LR for
-  // subroutine calls, it may not for leaf functions (such as this one).
-  // This routine forces the compiler (at least gcc) to push it anyway.
-  StacktracePowerPCDummyFunction();
-
-  // The LR save area is used by the callee, so the top entry is bogus.
-  skip_count++;
-
-  int n = 0;
-  while (sp && n < max_depth) {
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      // PowerPC has 3 main ABIs, which say where in the stack the
-      // Link Register is.  For DARWIN and AIX (used by apple and
-      // linux ppc64), it's in sp[2].  For SYSV (used by linux ppc),
-      // it's in sp[1].
-#if defined(_CALL_AIX) || defined(_CALL_DARWIN)
-      result[n++] = *(sp+2);
-#elif defined(_CALL_SYSV)
-      result[n++] = *(sp+1);
-#elif defined(__APPLE__) || (defined(__linux) && defined(__PPC64__))
-      // This check is in case the compiler doesn't define _CALL_AIX/etc.
-      result[n++] = *(sp+2);
-#elif defined(__linux)
-      // This check is in case the compiler doesn't define _CALL_SYSV.
-      result[n++] = *(sp+1);
-#else
-#error Need to specify the PPC ABI for your archiecture.
-#endif
-    }
-    // Use strict unwinding rules.
-    sp = NextStackFrame<true>(sp);
-  }
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 157
Src/ThirdParty/glog/src/stacktrace_unittest.cc

@@ -1,157 +0,0 @@
-// Copyright (c) 2004, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "utilities.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "config.h"
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "stacktrace.h"
-
-#ifdef HAVE_EXECINFO_H
-# include <execinfo.h>
-#endif
-
-using namespace GOOGLE_NAMESPACE;
-
-#ifdef HAVE_STACKTRACE
-
-// Obtain a backtrace, verify that the expected callers are present in the
-// backtrace, and maybe print the backtrace to stdout.
-
-//-----------------------------------------------------------------------//
-void CheckStackTraceLeaf();
-void CheckStackTrace4(int i);
-void CheckStackTrace3(int i);
-void CheckStackTrace2(int i);
-void CheckStackTrace1(int i);
-void CheckStackTrace(int i);
-//-----------------------------------------------------------------------//
-
-// The sequence of functions whose return addresses we expect to see in the
-// backtrace.
-const int BACKTRACE_STEPS = 6;
-void * expected_stack[BACKTRACE_STEPS] = {
-  (void *) &CheckStackTraceLeaf,
-  (void *) &CheckStackTrace4,
-  (void *) &CheckStackTrace3,
-  (void *) &CheckStackTrace2,
-  (void *) &CheckStackTrace1,
-  (void *) &CheckStackTrace,
-};
-
-// Depending on the architecture/compiler/libraries, (not sure which)
-// the current function may or may not appear in the backtrace.
-// For gcc-2:
-//
-// stack[0] is ret addr within CheckStackTrace4
-// stack[1] is ret addr within CheckStackTrace3
-// stack[2] is ret addr within CheckStackTrace2
-// stack[3] is ret addr within CheckStackTrace1
-// stack[4] is ret addr within CheckStackTrace
-//
-// For gcc3-k8:
-//
-// stack[0] is ret addr within CheckStackTraceLeaf
-// stack[1] is ret addr within CheckStackTrace4
-// ...
-// stack[5] is ret addr within CheckStackTrace
-
-//-----------------------------------------------------------------------//
-
-const int kMaxFnLen = 0x40; // assume relevant functions are only this long
-
-void CheckRetAddrIsInFunction( void * ret_addr, void * function_start_addr)
-{
-  CHECK_GE(ret_addr, function_start_addr);
-  CHECK_LE(ret_addr, (void *) ((char *) function_start_addr + kMaxFnLen));
-}
-
-//-----------------------------------------------------------------------//
-
-void CheckStackTraceLeaf(void) {
-  const int STACK_LEN = 10;
-  void *stack[STACK_LEN];
-  int size;
-
-  size = GetStackTrace(stack, STACK_LEN, 0);
-  printf("Obtained %d stack frames.\n", size);
-  CHECK_LE(size, STACK_LEN);
-
-  if (1) {
-#ifdef HAVE_EXECINFO_H
-    char **strings = backtrace_symbols(stack, size);
-    printf("Obtained %d stack frames.\n", size);
-    for (int i = 0; i < size; i++)
-      printf("%s %p\n", strings[i], stack[i]);
-    printf("CheckStackTrace() addr: %p\n", &CheckStackTrace);
-    free(strings);
-#endif
-  }
-  for (int i = 0; i < BACKTRACE_STEPS; i++) {
-    printf("Backtrace %d: expected: %p..%p  actual: %p ... ",
-           i, expected_stack[i],
-           reinterpret_cast<char*>(expected_stack[i]) + kMaxFnLen, stack[i]);
-    CheckRetAddrIsInFunction(stack[i], expected_stack[i]);
-    printf("OK\n");
-  }
-
-  // Check if the second stacktrace returns the same size.
-  CHECK_EQ(size, GetStackTrace(stack, STACK_LEN, 0));
-}
-
-//-----------------------------------------------------------------------//
-
-/* Dummy functions to make the backtrace more interesting. */
-void CheckStackTrace4(int i) { for (int j = i; j >= 0; j--) CheckStackTraceLeaf(); }
-void CheckStackTrace3(int i) { for (int j = i; j >= 0; j--) CheckStackTrace4(j); }
-void CheckStackTrace2(int i) { for (int j = i; j >= 0; j--) CheckStackTrace3(j); }
-void CheckStackTrace1(int i) { for (int j = i; j >= 0; j--) CheckStackTrace2(j); }
-void CheckStackTrace(int i)  { for (int j = i; j >= 0; j--) CheckStackTrace1(j); }
-
-//-----------------------------------------------------------------------//
-
-int main(int argc, char ** argv) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  
-  CheckStackTrace(0);
-  
-  printf("PASS\n");
-  return 0;
-}
-
-#else
-int main() {
-  printf("PASS (no stacktrace support)\n");
-  return 0;
-}
-#endif  // HAVE_STACKTRACE

+ 0 - 139
Src/ThirdParty/glog/src/stacktrace_x86-inl.h

@@ -1,139 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Produce stack trace
-
-#include <stdint.h>   // for uintptr_t
-
-#include "utilities.h"   // for OS_* macros
-
-#if !defined(OS_WINDOWS)
-#include <unistd.h>
-#include <sys/mman.h>
-#endif
-
-#include <stdio.h>  // for NULL
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Given a pointer to a stack frame, locate and return the calling
-// stackframe, or return NULL if no stackframe can be found. Perform sanity
-// checks (the strictness of which is controlled by the boolean parameter
-// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned.
-template<bool STRICT_UNWINDING>
-static void **NextStackFrame(void **old_sp) {
-  void **new_sp = (void **) *old_sp;
-
-  // Check that the transition from frame pointer old_sp to frame
-  // pointer new_sp isn't clearly bogus
-  if (STRICT_UNWINDING) {
-    // With the stack growing downwards, older stack frame must be
-    // at a greater address that the current one.
-    if (new_sp <= old_sp) return NULL;
-    // Assume stack frames larger than 100,000 bytes are bogus.
-    if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000) return NULL;
-  } else {
-    // In the non-strict mode, allow discontiguous stack frames.
-    // (alternate-signal-stacks for example).
-    if (new_sp == old_sp) return NULL;
-    // And allow frames upto about 1MB.
-    if ((new_sp > old_sp)
-        && ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000)) return NULL;
-  }
-  if ((uintptr_t)new_sp & (sizeof(void *) - 1)) return NULL;
-#ifdef __i386__
-  // On 64-bit machines, the stack pointer can be very close to
-  // 0xffffffff, so we explicitly check for a pointer into the
-  // last two pages in the address space
-  if ((uintptr_t)new_sp >= 0xffffe000) return NULL;
-#endif
-#if !defined(OS_WINDOWS)
-  if (!STRICT_UNWINDING) {
-    // Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test
-    // on AMD-based machines with VDSO-enabled kernels.
-    // Make an extra sanity check to insure new_sp is readable.
-    // Note: NextStackFrame<false>() is only called while the program
-    //       is already on its last leg, so it's ok to be slow here.
-    static int page_size = getpagesize();
-    void *new_sp_aligned = (void *)((uintptr_t)new_sp & ~(page_size - 1));
-    if (msync(new_sp_aligned, page_size, MS_ASYNC) == -1)
-      return NULL;
-  }
-#endif
-  return new_sp;
-}
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void **sp;
-#ifdef __i386__
-  // Stack frame format:
-  //    sp[0]   pointer to previous frame
-  //    sp[1]   caller address
-  //    sp[2]   first argument
-  //    ...
-  sp = (void **)&result - 2;
-#endif
-
-#ifdef __x86_64__
-  // __builtin_frame_address(0) can return the wrong address on gcc-4.1.0-k8
-  unsigned long rbp;
-  // Move the value of the register %rbp into the local variable rbp.
-  // We need 'volatile' to prevent this instruction from getting moved
-  // around during optimization to before function prologue is done.
-  // An alternative way to achieve this
-  // would be (before this __asm__ instruction) to call Noop() defined as
-  //   static void Noop() __attribute__ ((noinline));  // prevent inlining
-  //   static void Noop() { asm(""); }  // prevent optimizing-away
-  __asm__ volatile ("mov %%rbp, %0" : "=r" (rbp));
-  // Arguments are passed in registers on x86-64, so we can't just
-  // offset from &result
-  sp = (void **) rbp;
-#endif
-
-  int n = 0;
-  while (sp && n < max_depth) {
-    if (*(sp+1) == (void *)0) {
-      // In 64-bit code, we often see a frame that
-      // points to itself and has a return address of 0.
-      break;
-    }
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      result[n++] = *(sp+1);
-    }
-    // Use strict unwinding rules.
-    sp = NextStackFrame<true>(sp);
-  }
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 105
Src/ThirdParty/glog/src/stacktrace_x86_64-inl.h

@@ -1,105 +0,0 @@
-// Copyright (c) 2005 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Arun Sharma
-//
-// Produce stack trace using libgcc
-
-extern "C" {
-#include <stdlib.h> // for NULL
-#include <unwind.h> // ABI defined unwinder
-}
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-typedef struct {
-  void **result;
-  int max_depth;
-  int skip_count;
-  int count;
-} trace_arg_t;
-
-
-// Workaround for the malloc() in _Unwind_Backtrace() issue.
-static _Unwind_Reason_Code nop_backtrace(struct _Unwind_Context *uc, void *opq) {
-  return _URC_NO_REASON;
-}
-
-
-// This code is not considered ready to run until
-// static initializers run so that we are guaranteed
-// that any malloc-related initialization is done.
-static bool ready_to_run = false;
-class StackTraceInit {
- public:
-   StackTraceInit() {
-     // Extra call to force initialization
-     _Unwind_Backtrace(nop_backtrace, NULL);
-     ready_to_run = true;
-   }
-};
-
-static StackTraceInit module_initializer;  // Force initialization
-
-static _Unwind_Reason_Code GetOneFrame(struct _Unwind_Context *uc, void *opq) {
-  trace_arg_t *targ = (trace_arg_t *) opq;
-
-  if (targ->skip_count > 0) {
-    targ->skip_count--;
-  } else {
-    targ->result[targ->count++] = (void *) _Unwind_GetIP(uc);
-  }
-
-  if (targ->count == targ->max_depth)
-    return _URC_END_OF_STACK;
-
-  return _URC_NO_REASON;
-}
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  if (!ready_to_run)
-    return 0;
-
-  trace_arg_t targ;
-
-  skip_count += 1;         // Do not include the "GetStackTrace" frame
-
-  targ.result = result;
-  targ.max_depth = max_depth;
-  targ.skip_count = skip_count;
-  targ.count = 0;
-
-  _Unwind_Backtrace(GetOneFrame, &targ);
-
-  return targ.count;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 191
Src/ThirdParty/glog/src/stl_logging_unittest.cc

@@ -1,191 +0,0 @@
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "utilities.h"
-#include "config.h"
-
-#ifdef HAVE_USING_OPERATOR
-
-#include "glog/stl_logging.h"
-
-#include <iostream>
-#include <map>
-#include <string>
-#include <strstream>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_map>
-# include <ext/hash_set>
-#endif
-
-#include "glog/logging.h"
-#include "googletest.h"
-
-using namespace std;
-#ifdef __GNUC__
-using namespace __gnu_cxx;
-#endif
-
-struct user_hash {
-  size_t operator()(int x) const { return x; }
-};
-
-void TestSTLLogging() {
-  {
-    // Test a sequence.
-    vector<int> v;
-    v.push_back(10);
-    v.push_back(20);
-    v.push_back(30);
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    // Just ostrstream s1; leaks heap.
-    ss << v << ends;
-    CHECK_STREQ(ss.str(), "10 20 30");
-    vector<int> copied_v(v);
-    CHECK_EQ(v, copied_v);  // This must compile.
-  }
-
-  {
-    // Test a sorted pair associative container.
-    map< int, string > m;
-    m[20] = "twenty";
-    m[10] = "ten";
-    m[30] = "thirty";
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << m << ends;
-    CHECK_STREQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)");
-    map< int, string > copied_m(m);
-    CHECK_EQ(m, copied_m);  // This must compile.
-  }
-
-#ifdef __GNUC__
-  {
-    // Test a hashed simple associative container.
-    hash_set<int> hs;
-    hs.insert(10);
-    hs.insert(20);
-    hs.insert(30);
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << hs << ends;
-    CHECK_STREQ(ss.str(), "10 20 30");
-    hash_set<int> copied_hs(hs);
-    CHECK_EQ(hs, copied_hs);  // This must compile.
-  }
-#endif
-
-#ifdef __GNUC__
-  {
-    // Test a hashed pair associative container.
-    hash_map<int, string> hm;
-    hm[10] = "ten";
-    hm[20] = "twenty";
-    hm[30] = "thirty";
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << hm << ends;
-    CHECK_STREQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)");
-    hash_map<int, string> copied_hm(hm);
-    CHECK_EQ(hm, copied_hm);  // this must compile
-  }
-#endif
-
-  {
-    // Test a long sequence.
-    vector<int> v;
-    string expected;
-    for (int i = 0; i < 100; i++) {
-      v.push_back(i);
-      if (i > 0) expected += ' ';
-      char buf[256];
-      sprintf(buf, "%d", i);
-      expected += buf;
-    }
-    v.push_back(100);
-    expected += " ...";
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << v << ends;
-    CHECK_STREQ(ss.str(), expected.c_str());
-  }
-
-  {
-    // Test a sorted pair associative container.
-    // Use a non-default comparison functor.
-    map< int, string, greater<int> > m;
-    m[20] = "twenty";
-    m[10] = "ten";
-    m[30] = "thirty";
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << m << ends;
-    CHECK_STREQ(ss.str(), "(30, thirty) (20, twenty) (10, ten)");
-    map< int, string, greater<int> > copied_m(m);
-    CHECK_EQ(m, copied_m);  // This must compile.
-  }
-
-#ifdef __GNUC__
-  {
-    // Test a hashed simple associative container.
-    // Use a user defined hash function.
-    hash_set<int, user_hash> hs;
-    hs.insert(10);
-    hs.insert(20);
-    hs.insert(30);
-    char ss_buf[1000];
-    ostrstream ss(ss_buf, sizeof(ss_buf));
-    ss << hs << ends;
-    CHECK_STREQ(ss.str(), "10 20 30");
-    hash_set<int, user_hash> copied_hs(hs);
-    CHECK_EQ(hs, copied_hs);  // This must compile.
-  }
-#endif
-}
-
-int main(int argc, char** argv) {
-  TestSTLLogging();
-  std::cout << "PASS\n";
-  return 0;
-}
-
-#else
-
-#include <iostream>
-
-int main(int argc, char** argv) {
-  std::cout << "We don't support stl_logging for this compiler.\n"
-            << "(we need compiler support of 'using ::operator<<' "
-            << "for this feature.)\n";
-  return 0;
-}
-
-#endif  // HAVE_USING_OPERATOR

+ 0 - 681
Src/ThirdParty/glog/src/symbolize.cc

@@ -1,681 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-// Stack-footprint reduction work done by Raksit Ashok
-//
-// Implementation note:
-//
-// We don't use heaps but only use stacks.  We want to reduce the
-// stack consumption so that the symbolizer can run on small stacks.
-//
-// Here are some numbers collected with GCC 4.1.0 on x86:
-// - sizeof(Elf32_Sym)  = 16
-// - sizeof(Elf32_Shdr) = 40
-// - sizeof(Elf64_Sym)  = 24
-// - sizeof(Elf64_Shdr) = 64
-//
-// This implementation is intended to be async-signal-safe but uses
-// some functions which are not guaranteed to be so, such as memchr()
-// and memmove().  We assume they are async-signal-safe.
-//
-
-#include "utilities.h"
-
-#if defined(HAVE_SYMBOLIZE)
-
-#include <limits>
-
-#include "symbolize.h"
-#include "demangle.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// We don't use assert() since it's not guaranteed to be
-// async-signal-safe.  Instead we define a minimal assertion
-// macro. So far, we don't need pretty printing for __FILE__, etc.
-
-// A wrapper for abort() to make it callable in ? :.
-static int AssertFail() {
-  abort();
-  return 0;  // Should not reach.
-}
-
-#define SAFE_ASSERT(expr) ((expr) ? 0 : AssertFail())
-
-static SymbolizeCallback g_symbolize_callback = NULL;
-void InstallSymbolizeCallback(SymbolizeCallback callback) {
-  g_symbolize_callback = callback;
-}
-
-// This function wraps the Demangle function to provide an interface
-// where the input symbol is demangled in-place.
-// To keep stack consumption low, we would like this function to not
-// get inlined.
-static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, int out_size) {
-  char demangled[256];  // Big enough for sane demangled symbols.
-  if (Demangle(out, demangled, sizeof(demangled))) {
-    // Demangling succeeded. Copy to out if the space allows.
-    int len = strlen(demangled);
-    if (len + 1 <= out_size) {  // +1 for '\0'.
-      SAFE_ASSERT(len < sizeof(demangled));
-      memmove(out, demangled, len + 1);
-    }
-  }
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#if defined(__ELF__)
-
-#include <dlfcn.h>
-#include <elf.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <link.h>  // For ElfW() macro.
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "symbolize.h"
-#include "config.h"
-#include "glog/raw_logging.h"
-
-// Re-runs fn until it doesn't cause EINTR.
-#define NO_INTR(fn)   do {} while ((fn) < 0 && errno == EINTR)
-
-_START_GOOGLE_NAMESPACE_
-
-// Read up to "count" bytes from file descriptor "fd" into the buffer
-// starting at "buf" while handling short reads and EINTR.  On
-// success, return the number of bytes read.  Otherwise, return -1.
-static ssize_t ReadPersistent(const int fd, void *buf, const size_t count) {
-  SAFE_ASSERT(fd >= 0);
-  SAFE_ASSERT(count >= 0 && count <= std::numeric_limits<ssize_t>::max());
-  char *buf0 = reinterpret_cast<char *>(buf);
-  ssize_t num_bytes = 0;
-  while (num_bytes < count) {
-    ssize_t len;
-    NO_INTR(len = read(fd, buf0 + num_bytes, count - num_bytes));
-    if (len < 0) {  // There was an error other than EINTR.
-      return -1;
-    }
-    if (len == 0) {  // Reached EOF.
-      break;
-    }
-    num_bytes += len;
-  }
-  SAFE_ASSERT(num_bytes <= count);
-  return num_bytes;
-}
-
-// Read up to "count" bytes from "offset" in the file pointed by file
-// descriptor "fd" into the buffer starting at "buf".  On success,
-// return the number of bytes read.  Otherwise, return -1.
-static ssize_t ReadFromOffset(const int fd, void *buf,
-                              const size_t count, const off_t offset) {
-  off_t off = lseek(fd, offset, SEEK_SET);
-  if (off == (off_t)-1) {
-    return -1;
-  }
-  return ReadPersistent(fd, buf, count);
-}
-
-// Try reading exactly "count" bytes from "offset" bytes in a file
-// pointed by "fd" into the buffer starting at "buf" while handling
-// short reads and EINTR.  On success, return true. Otherwise, return
-// false.
-static bool ReadFromOffsetExact(const int fd, void *buf,
-                                const size_t count, const off_t offset) {
-  ssize_t len = ReadFromOffset(fd, buf, count, offset);
-  return len == count;
-}
-
-// Returns elf_header.e_type if the file pointed by fd is an ELF binary.
-static int FileGetElfType(const int fd) {
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return -1;
-  }
-  if (memcmp(elf_header.e_ident, ELFMAG, SELFMAG) != 0) {
-    return -1;
-  }
-  return elf_header.e_type;
-}
-
-// Read the section headers in the given ELF binary, and if a section
-// of the specified type is found, set the output to this section header
-// and return true.  Otherwise, return false.
-// To keep stack consumption low, we would like this function to not get
-// inlined.
-static ATTRIBUTE_NOINLINE bool
-GetSectionHeaderByType(const int fd, ElfW(Half) sh_num, const off_t sh_offset,
-                       ElfW(Word) type, ElfW(Shdr) *out) {
-  // Read at most 16 section headers at a time to save read calls.
-  ElfW(Shdr) buf[16];
-  for (int i = 0; i < sh_num;) {
-    const ssize_t num_bytes_left = (sh_num - i) * sizeof(buf[0]);
-    const ssize_t num_bytes_to_read =
-        (sizeof(buf) > num_bytes_left) ? num_bytes_left : sizeof(buf);
-    const ssize_t len = ReadFromOffset(fd, buf, num_bytes_to_read,
-                                       sh_offset + i * sizeof(buf[0]));
-    SAFE_ASSERT(len % sizeof(buf[0]) == 0);
-    const ssize_t num_headers_in_buf = len / sizeof(buf[0]);
-    SAFE_ASSERT(num_headers_in_buf <= sizeof(buf) / sizeof(buf[0]));
-    for (int j = 0; j < num_headers_in_buf; ++j) {
-      if (buf[j].sh_type == type) {
-        *out = buf[j];
-        return true;
-      }
-    }
-    i += num_headers_in_buf;
-  }
-  return false;
-}
-
-// There is no particular reason to limit section name to 63 characters,
-// but there has (as yet) been no need for anything longer either.
-const int kMaxSectionNameLen = 64;
-
-// name_len should include terminating '\0'.
-bool GetSectionHeaderByName(int fd, const char *name, size_t name_len,
-                            ElfW(Shdr) *out) {
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return false;
-  }
-
-  ElfW(Shdr) shstrtab;
-  off_t shstrtab_offset = (elf_header.e_shoff +
-                           elf_header.e_shentsize * elf_header.e_shstrndx);
-  if (!ReadFromOffsetExact(fd, &shstrtab, sizeof(shstrtab), shstrtab_offset)) {
-    return false;
-  }
-
-  for (int i = 0; i < elf_header.e_shnum; ++i) {
-    off_t section_header_offset = (elf_header.e_shoff +
-                                   elf_header.e_shentsize * i);
-    if (!ReadFromOffsetExact(fd, out, sizeof(*out), section_header_offset)) {
-      return false;
-    }
-    char header_name[kMaxSectionNameLen];
-    if (sizeof(header_name) < name_len) {
-      RAW_LOG(WARNING, "Section name '%s' is too long (%"PRIuS"); "
-              "section will not be found (even if present).", name, name_len);
-      // No point in even trying.
-      return false;
-    }
-    off_t name_offset = shstrtab.sh_offset + out->sh_name;
-    ssize_t n_read = ReadFromOffset(fd, &header_name, name_len, name_offset);
-    if (n_read == -1) {
-      return false;
-    } else if (n_read != name_len) {
-      // Short read -- name could be at end of file.
-      continue;
-    }
-    if (memcmp(header_name, name, name_len) == 0) {
-      return true;
-    }
-  }
-  return false;
-}
-
-// Read a symbol table and look for the symbol containing the
-// pc. Iterate over symbols in a symbol table and look for the symbol
-// containing "pc".  On success, return true and write the symbol name
-// to out.  Otherwise, return false.
-// To keep stack consumption low, we would like this function to not get
-// inlined.
-static ATTRIBUTE_NOINLINE bool
-FindSymbol(uint64_t pc, const int fd, char *out, int out_size,
-           uint64_t symbol_offset, const ElfW(Shdr) *strtab,
-           const ElfW(Shdr) *symtab) {
-  if (symtab == NULL) {
-    return false;
-  }
-  const int num_symbols = symtab->sh_size / symtab->sh_entsize;
-  for (int i = 0; i < num_symbols;) {
-    off_t offset = symtab->sh_offset + i * symtab->sh_entsize;
-
-    // If we are reading Elf64_Sym's, we want to limit this array to
-    // 32 elements (to keep stack consumption low), otherwise we can
-    // have a 64 element Elf32_Sym array.
-#if __WORDSIZE == 64
-#define NUM_SYMBOLS 32
-#else
-#define NUM_SYMBOLS 64
-#endif
-
-    // Read at most NUM_SYMBOLS symbols at once to save read() calls.
-    ElfW(Sym) buf[NUM_SYMBOLS];
-    const ssize_t len = ReadFromOffset(fd, &buf, sizeof(buf), offset);
-    SAFE_ASSERT(len % sizeof(buf[0]) == 0);
-    const ssize_t num_symbols_in_buf = len / sizeof(buf[0]);
-    SAFE_ASSERT(num_symbols_in_buf <= sizeof(buf)/sizeof(buf[0]));
-    for (int j = 0; j < num_symbols_in_buf; ++j) {
-      const ElfW(Sym)& symbol = buf[j];
-      uint64_t start_address = symbol.st_value;
-      start_address += symbol_offset;
-      uint64_t end_address = start_address + symbol.st_size;
-      if (symbol.st_value != 0 &&  // Skip null value symbols.
-          symbol.st_shndx != 0 &&  // Skip undefined symbols.
-          start_address <= pc && pc < end_address) {
-        ssize_t len1 = ReadFromOffset(fd, out, out_size,
-                                      strtab->sh_offset + symbol.st_name);
-        if (len1 <= 0 || memchr(out, '\0', out_size) == NULL) {
-          return false;
-        }
-        return true;  // Obtained the symbol name.
-      }
-    }
-    i += num_symbols_in_buf;
-  }
-  return false;
-}
-
-// Get the symbol name of "pc" from the file pointed by "fd".  Process
-// both regular and dynamic symbol tables if necessary.  On success,
-// write the symbol name to "out" and return true.  Otherwise, return
-// false.
-static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
-                                    char *out, int out_size,
-                                    uint64_t map_start_address) {
-  // Read the ELF header.
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return false;
-  }
-
-  uint64_t symbol_offset = 0;
-  if (elf_header.e_type == ET_DYN) {  // DSO needs offset adjustment.
-    symbol_offset = map_start_address;
-  }
-
-  ElfW(Shdr) symtab, strtab;
-
-  // Consult a regular symbol table first.
-  if (!GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff,
-                              SHT_SYMTAB, &symtab)) {
-    return false;
-  }
-  if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff +
-                           symtab.sh_link * sizeof(symtab))) {
-    return false;
-  }
-  if (FindSymbol(pc, fd, out, out_size, symbol_offset,
-                 &strtab, &symtab)) {
-    return true;  // Found the symbol in a regular symbol table.
-  }
-
-  // If the symbol is not found, then consult a dynamic symbol table.
-  if (!GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff,
-                              SHT_DYNSYM, &symtab)) {
-    return false;
-  }
-  if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff +
-                           symtab.sh_link * sizeof(symtab))) {
-    return false;
-  }
-  if (FindSymbol(pc, fd, out, out_size, symbol_offset,
-                 &strtab, &symtab)) {
-    return true;  // Found the symbol in a dynamic symbol table.
-  }
-
-  return false;
-}
-
-namespace {
-// Thin wrapper around a file descriptor so that the file descriptor
-// gets closed for sure.
-struct FileDescriptor {
-  const int fd_;
-  explicit FileDescriptor(int fd) : fd_(fd) {}
-  ~FileDescriptor() {
-    if (fd_ >= 0) {
-      NO_INTR(close(fd_));
-    }
-  }
-  int get() { return fd_; }
-
- private:
-  explicit FileDescriptor(const FileDescriptor&);
-  void operator=(const FileDescriptor&);
-};
-
-// Helper class for reading lines from file.
-//
-// Note: we don't use ProcMapsIterator since the object is big (it has
-// a 5k array member) and uses async-unsafe functions such as sscanf()
-// and snprintf().
-class LineReader {
- public:
-  explicit LineReader(int fd, char *buf, int buf_len) : fd_(fd),
-    buf_(buf), buf_len_(buf_len), bol_(buf), eol_(buf), eod_(buf) {
-  }
-
-  // Read '\n'-terminated line from file.  On success, modify "bol"
-  // and "eol", then return true.  Otherwise, return false.
-  //
-  // Note: if the last line doesn't end with '\n', the line will be
-  // dropped.  It's an intentional behavior to make the code simple.
-  bool ReadLine(const char **bol, const char **eol) {
-    if (BufferIsEmpty()) {  // First time.
-      const ssize_t num_bytes = ReadPersistent(fd_, buf_, buf_len_);
-      if (num_bytes <= 0) {  // EOF or error.
-        return false;
-      }
-      eod_ = buf_ + num_bytes;
-      bol_ = buf_;
-    } else {
-      bol_ = eol_ + 1;  // Advance to the next line in the buffer.
-      SAFE_ASSERT(bol_ <= eod_);  // "bol_" can point to "eod_".
-      if (!HasCompleteLine()) {
-        const int incomplete_line_length = eod_ - bol_;
-        // Move the trailing incomplete line to the beginning.
-        memmove(buf_, bol_, incomplete_line_length);
-        // Read text from file and append it.
-        char * const append_pos = buf_ + incomplete_line_length;
-        const int capacity_left = buf_len_ - incomplete_line_length;
-        const ssize_t num_bytes = ReadPersistent(fd_, append_pos,
-                                                 capacity_left);
-        if (num_bytes <= 0) {  // EOF or error.
-          return false;
-        }
-        eod_ = append_pos + num_bytes;
-        bol_ = buf_;
-      }
-    }
-    eol_ = FindLineFeed();
-    if (eol_ == NULL) {  // '\n' not found.  Malformed line.
-      return false;
-    }
-    *eol_ = '\0';  // Replace '\n' with '\0'.
-
-    *bol = bol_;
-    *eol = eol_;
-    return true;
-  }
-
-  // Beginning of line.
-  const char *bol() {
-    return bol_;
-  }
-
-  // End of line.
-  const char *eol() {
-    return eol_;
-  }
-
- private:
-  explicit LineReader(const LineReader&);
-  void operator=(const LineReader&);
-
-  char *FindLineFeed() {
-    return reinterpret_cast<char *>(memchr(bol_, '\n', eod_ - bol_));
-  }
-
-  bool BufferIsEmpty() {
-    return buf_ == eod_;
-  }
-
-  bool HasCompleteLine() {
-    return !BufferIsEmpty() && FindLineFeed() != NULL;
-  }
-
-  const int fd_;
-  char * const buf_;
-  const int buf_len_;
-  char *bol_;
-  char *eol_;
-  const char *eod_;  // End of data in "buf_".
-};
-}  // namespace
-
-// Place the hex number read from "start" into "*hex".  The pointer to
-// the first non-hex character or "end" is returned.
-static char *GetHex(const char *start, const char *end, uint64_t *hex) {
-  *hex = 0;
-  const char *p;
-  for (p = start; p < end; ++p) {
-    int ch = *p;
-    if ((ch >= '0' && ch <= '9') ||
-        (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
-      *hex = (*hex << 4) | (ch < 'A' ? ch - '0' : (ch & 0xF) + 9);
-    } else {  // Encountered the first non-hex character.
-      break;
-    }
-  }
-  SAFE_ASSERT(p <= end);
-  return const_cast<char *>(p);
-}
-
-// Search for the object file (from /proc/self/maps) that contains
-// the specified pc. If found, open this file and return the file handle,
-// and also set start_address to the start address of where this object
-// file is mapped to in memory. Otherwise, return -1.
-static ATTRIBUTE_NOINLINE int
-OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
-                                             uint64_t &start_address) {
-  int object_fd;
-
-  // Open /proc/self/maps.
-  int maps_fd;
-  NO_INTR(maps_fd = open("/proc/self/maps", O_RDONLY));
-  FileDescriptor wrapped_maps_fd(maps_fd);
-  if (wrapped_maps_fd.get() < 0) {
-    return -1;
-  }
-
-  // Iterate over maps and look for the map containing the pc.  Then
-  // look into the symbol tables inside.
-  char buf[1024];  // Big enough for line of sane /proc/self/maps
-  LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf));
-  while (true) {
-    const char *cursor;
-    const char *eol;
-    if (!reader.ReadLine(&cursor, &eol)) {  // EOF or malformed line.
-      return -1;
-    }
-
-    // Start parsing line in /proc/self/maps.  Here is an example:
-    //
-    // 08048000-0804c000 r-xp 00000000 08:01 2142121    /bin/cat
-    //
-    // We want start address (08048000), end address (0804c000), flags
-    // (r-xp) and file name (/bin/cat).
-
-    // Read start address.
-    cursor = GetHex(cursor, eol, &start_address);
-    if (cursor == eol || *cursor != '-') {
-      return -1;  // Malformed line.
-    }
-    ++cursor;  // Skip '-'.
-
-    // Read end address.
-    uint64_t end_address;
-    cursor = GetHex(cursor, eol, &end_address);
-    if (cursor == eol || *cursor != ' ') {
-      return -1;  // Malformed line.
-    }
-    ++cursor;  // Skip ' '.
-
-    // Check start and end addresses.
-    if (!(start_address <= pc && pc < end_address)) {
-      continue;  // We skip this map.  PC isn't in this map.
-    }
-
-    // Read flags.  Skip flags until we encounter a space or eol.
-    const char * const flags_start = cursor;
-    while (cursor < eol && *cursor != ' ') {
-      ++cursor;
-    }
-    // We expect at least four letters for flags (ex. "r-xp").
-    if (cursor == eol || cursor < flags_start + 4) {
-      return -1;  // Malformed line.
-    }
-
-    // Check flags.  We are only interested in "r-x" maps.
-    if (memcmp(flags_start, "r-x", 3) != 0) {  // Not a "r-x" map.
-      continue;  // We skip this map.
-    }
-    ++cursor;  // Skip ' '.
-
-    // Skip to file name.  "cursor" now points to file offset.  We need to
-    // skip at least three spaces for file offset, dev, and inode.
-    int num_spaces = 0;
-    while (cursor < eol) {
-      if (*cursor == ' ') {
-        ++num_spaces;
-      } else if (num_spaces >= 3) {
-        // The first non-space character after  skipping three spaces
-        // is the beginning of the file name.
-        break;
-      }
-      ++cursor;
-    }
-    if (cursor == eol) {
-      return -1;  // Malformed line.
-    }
-
-    // Finally, "cursor" now points to file name of our interest.
-    NO_INTR(object_fd = open(cursor, O_RDONLY));
-    if (object_fd < 0) {
-      return -1;
-    }
-    return object_fd;
-  }
-}
-
-// The implementation of our symbolization routine.  If it
-// successfully finds the symbol containing "pc" and obtains the
-// symbol name, returns true and write the symbol name to "out".
-// Otherwise, returns false. If Callback function is installed via
-// InstallSymbolizeCallback(), the function is also called in this function,
-// and "out" is used as its output.
-// To keep stack consumption low, we would like this function to not
-// get inlined.
-static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
-                                                    int out_size) {
-  uint64_t pc0 = reinterpret_cast<uintptr_t>(pc);
-  uint64_t start_address = 0;
-
-  int object_fd = OpenObjectFileContainingPcAndGetStartAddress(pc0,
-                                                               start_address);
-  if (object_fd == -1) {
-    return false;
-  }
-  FileDescriptor wrapped_object_fd(object_fd);
-  int elf_type = FileGetElfType(wrapped_object_fd.get());
-  if (elf_type == -1) {
-    return false;
-  }
-  if (g_symbolize_callback) {
-    // Run the call back if it's installed.
-    // Note: relocation (and much of the rest of this code) will be
-    // wrong for prelinked shared libraries and PIE executables.
-    uint64 relocation = (elf_type == ET_DYN) ? start_address : 0;
-    int num_bytes_written = g_symbolize_callback(wrapped_object_fd.get(),
-                                                 pc, out, out_size,
-                                                 relocation);
-    if (num_bytes_written > 0) {
-      out += num_bytes_written;
-      out_size -= num_bytes_written;
-    }
-  }
-  if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
-                               out, out_size, start_address)) {
-    return false;
-  }
-
-  // Symbolization succeeded.  Now we try to demangle the symbol.
-  DemangleInplace(out, out_size);
-  return true;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
-
-#include <dlfcn.h>
-#include <string.h>
-
-_START_GOOGLE_NAMESPACE_
-
-static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
-                                                    int out_size) {
-  Dl_info info;
-  if (dladdr(pc, &info)) {
-    if (strlen(info.dli_sname) < out_size) {
-      strcpy(out, info.dli_sname);
-      // Symbolization succeeded.  Now we try to demangle the symbol.
-      DemangleInplace(out, out_size);
-      return true;
-    }
-  }
-  return false;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#else
-# error BUG: HAVE_SYMBOLIZE was wrongly set
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-bool Symbolize(void *pc, char *out, int out_size) {
-  SAFE_ASSERT(out_size >= 0);
-  return SymbolizeAndDemangle(pc, out, out_size);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#else  /* HAVE_SYMBOLIZE */
-
-#include <assert.h>
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// TODO: Support other environments.
-bool Symbolize(void *pc, char *out, int out_size) {
-  assert(0);
-  return false;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif

+ 0 - 116
Src/ThirdParty/glog/src/symbolize.h

@@ -1,116 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// This library provides Symbolize() function that symbolizes program
-// counters to their corresponding symbol names on linux platforms.
-// This library has a minimal implementation of an ELF symbol table
-// reader (i.e. it doesn't depend on libelf, etc.).
-//
-// The algorithm used in Symbolize() is as follows.
-//
-//   1. Go through a list of maps in /proc/self/maps and find the map
-//   containing the program counter.
-//
-//   2. Open the mapped file and find a regular symbol table inside.
-//   Iterate over symbols in the symbol table and look for the symbol
-//   containing the program counter.  If such a symbol is found,
-//   obtain the symbol name, and demangle the symbol if possible.
-//   If the symbol isn't found in the regular symbol table (binary is
-//   stripped), try the same thing with a dynamic symbol table.
-//
-// Note that Symbolize() is originally implemented to be used in
-// FailureSignalHandler() in base/google.cc.  Hence it doesn't use
-// malloc() and other unsafe operations.  It should be both
-// thread-safe and async-signal-safe.
-
-#ifndef BASE_SYMBOLIZE_H_
-#define BASE_SYMBOLIZE_H_
-
-#include "utilities.h"
-#include "config.h"
-#include "glog/logging.h"
-
-#ifdef HAVE_SYMBOLIZE
-
-#if defined(__ELF__)  // defined by gcc on Linux
-#include <elf.h>
-#include <link.h>  // For ElfW() macro.
-
-// If there is no ElfW macro, let's define it by ourself.
-#ifndef ElfW
-# if SIZEOF_VOID_P == 4
-#  define ElfW(type) Elf32_##type
-# elif SIZEOF_VOID_P == 8
-#  define ElfW(type) Elf64_##type
-# else
-#  error "Unknown sizeof(void *)"
-# endif
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Gets the section header for the given name, if it exists. Returns true on
-// success. Otherwise, returns false.
-bool GetSectionHeaderByName(int fd, const char *name, size_t name_len,
-                            ElfW(Shdr) *out);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  /* __ELF__ */
-
-_START_GOOGLE_NAMESPACE_
-
-// Installs a callback function, which will be called right before a symbol name
-// is printed. The callback is intended to be used for showing a file name and a
-// line number preceding a symbol name.
-// "fd" is a file descriptor of the object file containing the program
-// counter "pc". The callback function should write output to "out"
-// and return the size of the output written. On error, the callback
-// function should return -1.
-typedef int (*SymbolizeCallback)(int fd, void *pc, char *out, size_t out_size,
-                                 uint64 relocation);
-void InstallSymbolizeCallback(SymbolizeCallback callback);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Symbolizes a program counter.  On success, returns true and write the
-// symbol name to "out".  The symbol name is demangled if possible
-// (supports symbols generated by GCC 3.x or newer).  Otherwise,
-// returns false.
-bool Symbolize(void *pc, char *out, int out_size);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_SYMBOLIZE_H_

+ 0 - 365
Src/ThirdParty/glog/src/symbolize_unittest.cc

@@ -1,365 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Unit tests for functions in symbolize.cc.
-
-#include "utilities.h"
-
-#include <signal.h>
-#include <iostream>
-
-#include "glog/logging.h"
-#include "symbolize.h"
-#include "googletest.h"
-#include "config.h"
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-#if defined(HAVE_STACKTRACE) && defined(__ELF__)
-
-#define always_inline
-
-// This unit tests make sense only with GCC.
-// Uses lots of GCC specific features.
-#if defined(__GNUC__) && !defined(__OPENCC__)
-#  if __GNUC__ >= 4
-#    define TEST_WITH_MODERN_GCC
-#    if __i386__  // always_inline isn't supported for x86_64 with GCC 4.1.0.
-#      undef always_inline
-#      define always_inline __attribute__((always_inline))
-#      define HAVE_ALWAYS_INLINE
-#    endif  // __i386__
-#  else
-#  endif  // __GNUC__ >= 4
-#  if defined(__i386__) || defined(__x86_64__)
-#    define TEST_X86_32_AND_64 1
-#  endif  // defined(__i386__) || defined(__x86_64__)
-#endif
-
-// A wrapper function for Symbolize() to make the unit test simple.
-static const char *TrySymbolize(void *pc) {
-  static char symbol[4096];
-  if (Symbolize(pc, symbol, sizeof(symbol))) {
-    return symbol;
-  } else {
-    return NULL;
-  }
-}
-
-// Make them C linkage to avoid mangled names.
-extern "C" {
-void nonstatic_func() {
-  volatile int a = 0;
-  ++a;
-}
-
-static void static_func() {
-  volatile int a = 0;
-  ++a;
-}
-}
-
-TEST(Symbolize, Symbolize) {
-  // We do C-style cast since GCC 2.95.3 doesn't allow
-  // reinterpret_cast<void *>(&func).
-
-  // Compilers should give us pointers to them.
-  EXPECT_STREQ("nonstatic_func", TrySymbolize((void *)(&nonstatic_func)));
-  EXPECT_STREQ("static_func", TrySymbolize((void *)(&static_func)));
-
-  EXPECT_TRUE(NULL == TrySymbolize(NULL));
-}
-
-struct Foo {
-  static void func(int x);
-};
-
-void ATTRIBUTE_NOINLINE Foo::func(int x) {
-  volatile int a = x;
-  ++a;
-}
-
-// With a modern GCC, Symbolize() should return demangled symbol
-// names.  Function parameters should be omitted.
-#ifdef TEST_WITH_MODERN_GCC
-TEST(Symbolize, SymbolizeWithDemangling) {
-  Foo::func(100);
-  EXPECT_STREQ("Foo::func()", TrySymbolize((void *)(&Foo::func)));
-}
-#endif
-
-// Tests that verify that Symbolize footprint is within some limit.
-
-// To measure the stack footprint of the Symbolize function, we create
-// a signal handler (for SIGUSR1 say) that calls the Symbolize function
-// on an alternate stack. This alternate stack is initialized to some
-// known pattern (0x55, 0x55, 0x55, ...). We then self-send this signal,
-// and after the signal handler returns, look at the alternate stack
-// buffer to see what portion has been touched.
-//
-// This trick gives us the the stack footprint of the signal handler.
-// But the signal handler, even before the call to Symbolize, consumes
-// some stack already. We however only want the stack usage of the
-// Symbolize function. To measure this accurately, we install two signal
-// handlers: one that does nothing and just returns, and another that
-// calls Symbolize. The difference between the stack consumption of these
-// two signals handlers should give us the Symbolize stack foorprint.
-
-static void *g_pc_to_symbolize;
-static char g_symbolize_buffer[4096];
-static char *g_symbolize_result;
-
-static void EmptySignalHandler(int signo) {}
-
-static void SymbolizeSignalHandler(int signo) {
-  if (Symbolize(g_pc_to_symbolize, g_symbolize_buffer,
-                sizeof(g_symbolize_buffer))) {
-    g_symbolize_result = g_symbolize_buffer;
-  } else {
-    g_symbolize_result = NULL;
-  }
-}
-
-const int kAlternateStackSize = 8096;
-const char kAlternateStackFillValue = 0x55;
-
-// These helper functions look at the alternate stack buffer, and figure
-// out what portion of this buffer has been touched - this is the stack
-// consumption of the signal handler running on this alternate stack.
-static ATTRIBUTE_NOINLINE bool StackGrowsDown(int *x) {
-  int y;
-  return &y < x;
-}
-static int GetStackConsumption(const char* alt_stack) {
-  int x;
-  if (StackGrowsDown(&x)) {
-    for (int i = 0; i < kAlternateStackSize; i++) {
-      if (alt_stack[i] != kAlternateStackFillValue) {
-        return (kAlternateStackSize - i);
-      }
-    }
-  } else {
-    for (int i = (kAlternateStackSize - 1); i >= 0; i--) {
-      if (alt_stack[i] != kAlternateStackFillValue) {
-        return i;
-      }
-    }
-  }
-  return -1;
-}
-
-#ifdef HAVE_SIGALTSTACK
-
-// Call Symbolize and figure out the stack footprint of this call.
-static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) {
-
-  g_pc_to_symbolize = pc;
-
-  // The alt-signal-stack cannot be heap allocated because there is a
-  // bug in glibc-2.2 where some signal handler setup code looks at the
-  // current stack pointer to figure out what thread is currently running.
-  // Therefore, the alternate stack must be allocated from the main stack
-  // itself.
-  char altstack[kAlternateStackSize];
-  memset(altstack, kAlternateStackFillValue, kAlternateStackSize);
-
-  // Set up the alt-signal-stack (and save the older one).
-  stack_t sigstk;
-  memset(&sigstk, 0, sizeof(stack_t));
-  stack_t old_sigstk;
-  sigstk.ss_sp = altstack;
-  sigstk.ss_size = kAlternateStackSize;
-  sigstk.ss_flags = 0;
-  CHECK_ERR(sigaltstack(&sigstk, &old_sigstk));
-
-  // Set up SIGUSR1 and SIGUSR2 signal handlers (and save the older ones).
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(struct sigaction));
-  struct sigaction old_sa1, old_sa2;
-  sigemptyset(&sa.sa_mask);
-  sa.sa_flags = SA_ONSTACK;
-
-  // SIGUSR1 maps to EmptySignalHandler.
-  sa.sa_handler = EmptySignalHandler;
-  CHECK_ERR(sigaction(SIGUSR1, &sa, &old_sa1));
-
-  // SIGUSR2 maps to SymbolizeSignalHanlder.
-  sa.sa_handler = SymbolizeSignalHandler;
-  CHECK_ERR(sigaction(SIGUSR2, &sa, &old_sa2));
-
-  // Send SIGUSR1 signal and measure the stack consumption of the empty
-  // signal handler.
-  CHECK_ERR(kill(getpid(), SIGUSR1));
-  int stack_consumption1 = GetStackConsumption(altstack);
-
-  // Send SIGUSR2 signal and measure the stack consumption of the symbolize
-  // signal handler.
-  CHECK_ERR(kill(getpid(), SIGUSR2));
-  int stack_consumption2 = GetStackConsumption(altstack);
-
-  // The difference between the two stack consumption values is the
-  // stack footprint of the Symbolize function.
-  if (stack_consumption1 != -1 && stack_consumption2 != -1) {
-    *stack_consumed = stack_consumption2 - stack_consumption1;
-  } else {
-    *stack_consumed = -1;
-  }
-
-  // Log the stack consumption values.
-  LOG(INFO) << "Stack consumption of empty signal handler: "
-            << stack_consumption1;
-  LOG(INFO) << "Stack consumption of symbolize signal handler: "
-            << stack_consumption2;
-  LOG(INFO) << "Stack consumption of Symbolize: " << *stack_consumed;
-
-  // Now restore the old alt-signal-stack and signal handlers.
-  CHECK_ERR(sigaltstack(&old_sigstk, NULL));
-  CHECK_ERR(sigaction(SIGUSR1, &old_sa1, NULL));
-  CHECK_ERR(sigaction(SIGUSR2, &old_sa2, NULL));
-
-  return g_symbolize_result;
-}
-
-// Symbolize stack consumption should be within 2kB.
-const int kStackConsumptionUpperLimit = 2048;
-
-TEST(Symbolize, SymbolizeStackConsumption) {
-  int stack_consumed;
-  const char* symbol;
-
-  symbol = SymbolizeStackConsumption((void *)(&nonstatic_func),
-                                     &stack_consumed);
-  EXPECT_STREQ("nonstatic_func", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-
-  symbol = SymbolizeStackConsumption((void *)(&static_func),
-                                     &stack_consumed);
-  EXPECT_STREQ("static_func", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-}
-
-#ifdef TEST_WITH_MODERN_GCC
-TEST(Symbolize, SymbolizeWithDemanglingStackConsumption) {
-  Foo::func(100);
-  int stack_consumed;
-  const char* symbol;
-
-  symbol = SymbolizeStackConsumption((void *)(&Foo::func), &stack_consumed);
-
-  EXPECT_STREQ("Foo::func()", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-}
-#endif
-
-#endif  // HAVE_SIGALTSTACK
-
-// x86 specific tests.  Uses some inline assembler.
-extern "C" {
-inline void* always_inline inline_func() {
-  register void *pc = NULL;
-#ifdef TEST_X86_32_AND_64
-  __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc));
-#endif
-  return pc;
-}
-
-void* ATTRIBUTE_NOINLINE non_inline_func() {
-  register void *pc = NULL;
-#ifdef TEST_X86_32_AND_64
-  __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc));
-#endif
-  return pc;
-}
-
-void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
-#if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE)
-  void *pc = non_inline_func();
-  const char *symbol = TrySymbolize(pc);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, "non_inline_func");
-  cout << "Test case TestWithPCInsideNonInlineFunction passed." << endl;
-#endif
-}
-
-void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
-#if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE)
-  void *pc = inline_func();  // Must be inlined.
-  const char *symbol = TrySymbolize(pc);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, __FUNCTION__);
-  cout << "Test case TestWithPCInsideInlineFunction passed." << endl;
-#endif
-}
-}
-
-// Test with a return address.
-void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
-#if defined(HAVE_ATTRIBUTE_NOINLINE)
-  void *return_address = __builtin_return_address(0);
-  const char *symbol = TrySymbolize(return_address);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, "main");
-  cout << "Test case TestWithReturnAddress passed." << endl;
-#endif
-}
-
-int main(int argc, char **argv) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  InitGoogleTest(&argc, argv);
-#ifdef HAVE_SYMBOLIZE
-  // We don't want to get affected by the callback interface, that may be
-  // used to install some callback function at InitGoogle() time.
-  InstallSymbolizeCallback(NULL);
-
-  TestWithPCInsideInlineFunction();
-  TestWithPCInsideNonInlineFunction();
-  TestWithReturnAddress();
-  return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
-}
-
-#else
-int main() {
-#ifdef HAVE_SYMBOLIZE
-  printf("PASS (no symbolize_unittest support)\n");
-#else
-  printf("PASS (no symbolize support)\n");
-#endif
-  return 0;
-}
-#endif  // HAVE_STACKTRACE

+ 0 - 335
Src/ThirdParty/glog/src/utilities.cc

@@ -1,335 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-
-#include "utilities.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <signal.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-
-#include "base/googleinit.h"
-
-using std::string;
-
-_START_GOOGLE_NAMESPACE_
-
-static const char* g_program_invocation_short_name = NULL;
-static pthread_t g_main_thread_id;
-
-_END_GOOGLE_NAMESPACE_
-
-// The following APIs are all internal.
-#ifdef HAVE_STACKTRACE
-
-#include "stacktrace.h"
-#include "symbolize.h"
-#include "base/commandlineflags.h"
-
-GLOG_DEFINE_bool(symbolize_stacktrace, true,
-                 "Symbolize the stack trace in the tombstone");
-
-_START_GOOGLE_NAMESPACE_
-
-typedef void DebugWriter(const char*, void*);
-
-// The %p field width for printf() functions is two characters per byte.
-// For some environments, add two extra bytes for the leading "0x".
-static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
-
-static void DebugWriteToStderr(const char* data, void *unused) {
-  // This one is signal-safe.
-  write(STDERR_FILENO, data, strlen(data));
-}
-
-void DebugWriteToString(const char* data, void *arg) {
-  reinterpret_cast<string*>(arg)->append(data);
-}
-
-#ifdef HAVE_SYMBOLIZE
-// Print a program counter and its symbol name.
-static void DumpPCAndSymbol(DebugWriter *writerfn, void *arg, void *pc,
-                            const char * const prefix) {
-  char tmp[1024];
-  const char *symbol = "(unknown)";
-  // Symbolizes the previous address of pc because pc may be in the
-  // next function.  The overrun happens when the function ends with
-  // a call to a function annotated noreturn (e.g. CHECK).
-  if (Symbolize(reinterpret_cast<char *>(pc) - 1, tmp, sizeof(tmp))) {
-      symbol = tmp;
-  }
-  char buf[1024];
-  snprintf(buf, sizeof(buf), "%s@ %*p  %s\n",
-           prefix, kPrintfPointerFieldWidth, pc, symbol);
-  writerfn(buf, arg);
-}
-#endif
-
-static void DumpPC(DebugWriter *writerfn, void *arg, void *pc,
-                   const char * const prefix) {
-  char buf[100];
-  snprintf(buf, sizeof(buf), "%s@ %*p\n",
-           prefix, kPrintfPointerFieldWidth, pc);
-  writerfn(buf, arg);
-}
-
-// Dump current stack trace as directed by writerfn
-static void DumpStackTrace(int skip_count, DebugWriter *writerfn, void *arg) {
-  // Print stack trace
-  void* stack[32];
-  int depth = GetStackTrace(stack, ARRAYSIZE(stack), skip_count+1);
-  for (int i = 0; i < depth; i++) {
-#if defined(HAVE_SYMBOLIZE)
-    if (FLAGS_symbolize_stacktrace) {
-      DumpPCAndSymbol(writerfn, arg, stack[i], "    ");
-    } else {
-      DumpPC(writerfn, arg, stack[i], "    ");
-    }
-#else
-    DumpPC(writerfn, arg, stack[i], "    ");
-#endif
-  }
-}
-
-static void DumpStackTraceAndExit() {
-  DumpStackTrace(1, DebugWriteToStderr, NULL);
-
-  // Set the default signal handler for SIGABRT, to avoid invoking our
-  // own signal handler installed by InstallFailedSignalHandler().
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_handler = SIG_DFL;
-  sigaction(SIGABRT, &sig_action, NULL);
-
-  abort();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // HAVE_STACKTRACE
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-const char* ProgramInvocationShortName() {
-  if (g_program_invocation_short_name != NULL) {
-    return g_program_invocation_short_name;
-  } else {
-    // TODO(hamaji): Use /proc/self/cmdline and so?
-    return "UNKNOWN";
-  }
-}
-
-bool IsGoogleLoggingInitialized() {
-  return g_program_invocation_short_name != NULL;
-}
-
-bool is_default_thread() {
-  if (g_program_invocation_short_name == NULL) {
-    // InitGoogleLogging() not yet called, so unlikely to be in a different
-    // thread
-    return true;
-  } else {
-    return pthread_equal(pthread_self(), g_main_thread_id);
-  }
-}
-
-#ifdef OS_WINDOWS
-struct timeval {
-  long tv_sec, tv_usec;
-};
-
-// Based on: http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/os_win32.c&q=GetSystemTimeAsFileTime%20license:bsd
-// See COPYING for copyright information.
-static int gettimeofday(struct timeval *tv, void* tz) {
-#define EPOCHFILETIME (116444736000000000ULL)
-  FILETIME ft;
-  LARGE_INTEGER li;
-  uint64 tt;
-
-  GetSystemTimeAsFileTime(&ft);
-  li.LowPart = ft.dwLowDateTime;
-  li.HighPart = ft.dwHighDateTime;
-  tt = (li.QuadPart - EPOCHFILETIME) / 10;
-  tv->tv_sec = tt / 1000000;
-  tv->tv_usec = tt % 1000000;
-
-  return 0;
-}
-#endif
-
-int64 CycleClock_Now() {
-  // TODO(hamaji): temporary impementation - it might be too slow.
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  return static_cast<int64>(tv.tv_sec) * 1000000 + tv.tv_usec;
-}
-
-int64 UsecToCycles(int64 usec) {
-  return usec;
-}
-
-WallTime WallTime_Now() {
-  // Now, cycle clock is retuning microseconds since the epoch.
-  return CycleClock_Now() * 0.000001;
-}
-
-static int32 g_main_thread_pid = getpid();
-int32 GetMainThreadPid() {
-  return g_main_thread_pid;
-}
-
-pid_t GetTID() {
-  // On Linux and FreeBSD, we try to use gettid().
-#if defined OS_LINUX || defined OS_FREEBSD || defined OS_MACOSX
-#ifndef __NR_gettid
-#ifdef OS_MACOSX
-#define __NR_gettid SYS_gettid
-#elif ! defined __i386__
-#error "Must define __NR_gettid for non-x86 platforms"
-#else
-#define __NR_gettid 224
-#endif
-#endif
-  static bool lacks_gettid = false;
-  if (!lacks_gettid) {
-    pid_t tid = syscall(__NR_gettid);
-    if (tid != -1) {
-      return tid;
-    }
-    // Technically, this variable has to be volatile, but there is a small
-    // performance penalty in accessing volatile variables and there should
-    // not be any serious adverse effect if a thread does not immediately see
-    // the value change to "true".
-    lacks_gettid = true;
-  }
-#endif  // OS_LINUX || OS_FREEBSD
-
-  // If gettid() could not be used, we use one of the following.
-#if defined OS_LINUX
-  return getpid();  // Linux:  getpid returns thread ID when gettid is absent
-#elif defined OS_WINDOWS || defined OS_CYGWIN
-  return GetCurrentThreadId();
-#else
-  // If none of the techniques above worked, we use pthread_self().
-  return (pid_t)(uintptr_t)pthread_self();
-#endif
-}
-
-const char* const_basename(const char* filepath) {
-  const char* base = strrchr(filepath, '/');
-#ifdef OS_WINDOWS  // Look for either path separator in Windows
-  if (!base)
-    base = strrchr(filepath, '\\');
-#endif
-  return base ? (base+1) : filepath;
-}
-
-static string g_my_user_name;
-const string& MyUserName() {
-  return g_my_user_name;
-}
-static void MyUserNameInitializer() {
-  // TODO(hamaji): Probably this is not portable.
-#if defined(OS_WINDOWS)
-  const char* user = getenv("USERNAME");
-#else
-  const char* user = getenv("USER");
-#endif
-  if (user != NULL) {
-    g_my_user_name = user;
-  } else {
-    g_my_user_name = "invalid-user";
-  }
-}
-REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer());
-
-#ifdef HAVE_STACKTRACE
-void DumpStackTraceToString(string* stacktrace) {
-  DumpStackTrace(1, DebugWriteToString, stacktrace);
-}
-#endif
-
-// We use an atomic operation to prevent problems with calling CrashReason
-// from inside the Mutex implementation (potentially through RAW_CHECK).
-static const CrashReason* g_reason = 0;
-
-void SetCrashReason(const CrashReason* r) {
-  sync_val_compare_and_swap(&g_reason,
-                            reinterpret_cast<const CrashReason*>(0),
-                            r);
-}
-
-}  // namespace glog_internal_namespace_
-
-void InitGoogleLogging(const char* argv0) {
-  CHECK(!IsGoogleLoggingInitialized())
-      << "You called InitGoogleLogging() twice!";
-  const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
-  if (!slash)  slash = strrchr(argv0, '\\');
-#endif
-  g_program_invocation_short_name = slash ? slash + 1 : argv0;
-  g_main_thread_id = pthread_self();
-
-#ifdef HAVE_STACKTRACE
-  InstallFailureFunction(&DumpStackTraceAndExit);
-#endif
-}
-
-void ShutdownGoogleLogging() {
-  CHECK(IsGoogleLoggingInitialized())
-      << "You called ShutdownGoogleLogging() without InitGoogleLogging() first!";
-#ifdef HAVE_SYSLOG_H
-  closelog();
-#endif
-}
-
-_END_GOOGLE_NAMESPACE_
-
-// Make an implementation of stacktrace compiled.
-#ifdef STACKTRACE_H
-# include STACKTRACE_H
-#endif

+ 0 - 222
Src/ThirdParty/glog/src/utilities.h

@@ -1,222 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-//
-// Define utilties for glog internal usage.
-
-#ifndef UTILITIES_H__
-#define UTILITIES_H__
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
-# define OS_WINDOWS
-#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
-# define OS_CYGWIN
-#elif defined(linux) || defined(__linux) || defined(__linux__)
-# define OS_LINUX
-#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-# define OS_MACOSX
-#elif defined(__FreeBSD__)
-# define OS_FREEBSD
-#elif defined(__NetBSD__)
-# define OS_NETBSD
-#elif defined(__OpenBSD__)
-# define OS_OPENBSD
-#else
-// TODO(hamaji): Add other platforms.
-#endif
-
-// printf macros for size_t, in the style of inttypes.h
-#ifdef _LP64
-#define __PRIS_PREFIX "z"
-#else
-#define __PRIS_PREFIX
-#endif
-
-// Use these macros after a % in a printf format string
-// to get correct 32/64 bit behavior, like this:
-// size_t size = records.size();
-// printf("%"PRIuS"\n", size);
-
-#define PRIdS __PRIS_PREFIX "d"
-#define PRIxS __PRIS_PREFIX "x"
-#define PRIuS __PRIS_PREFIX "u"
-#define PRIXS __PRIS_PREFIX "X"
-#define PRIoS __PRIS_PREFIX "o"
-
-#include "base/mutex.h"  // This must go first so we get _XOPEN_SOURCE
-
-#include <string>
-
-#if defined(OS_WINDOWS)
-# include "port.h"
-#endif
-
-#include "config.h"
-#include "glog/logging.h"
-
-// There are three different ways we can try to get the stack trace:
-//
-// 1) The libunwind library.  This is still in development, and as a
-//    separate library adds a new dependency, but doesn't need a frame
-//    pointer.  It also doesn't call malloc.
-//
-// 2) Our hand-coded stack-unwinder.  This depends on a certain stack
-//    layout, which is used by gcc (and those systems using a
-//    gcc-compatible ABI) on x86 systems, at least since gcc 2.95.
-//    It uses the frame pointer to do its work.
-//
-// 3) The gdb unwinder -- also the one used by the c++ exception code.
-//    It's obviously well-tested, but has a fatal flaw: it can call
-//    malloc() from the unwinder.  This is a problem because we're
-//    trying to use the unwinder to instrument malloc().
-//
-// Note: if you add a new implementation here, make sure it works
-// correctly when GetStackTrace() is called with max_depth == 0.
-// Some code may do that.
-
-#if defined(HAVE_LIB_UNWIND)
-# define STACKTRACE_H "stacktrace_libunwind-inl.h"
-#elif !defined(NO_FRAME_POINTER)
-# if defined(__i386__) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_x86-inl.h"
-# elif defined(__x86_64__) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_x86_64-inl.h"
-# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_powerpc-inl.h"
-# endif
-#endif
-
-#if !defined(STACKTRACE_H) && defined(HAVE_EXECINFO_H)
-# define STACKTRACE_H "stacktrace_generic-inl.h"
-#endif
-
-#if defined(STACKTRACE_H)
-# define HAVE_STACKTRACE
-#endif
-
-// defined by gcc
-#if defined(__ELF__) && defined(OS_LINUX)
-# define HAVE_SYMBOLIZE
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
-// Use dladdr to symbolize.
-# define HAVE_SYMBOLIZE
-#endif
-
-#ifndef ARRAYSIZE
-// There is a better way, but this is good enough for our purpose.
-# define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-#ifdef HAVE___ATTRIBUTE__
-# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
-# define HAVE_ATTRIBUTE_NOINLINE
-#else
-# define ATTRIBUTE_NOINLINE
-#endif
-
-const char* ProgramInvocationShortName();
-
-bool IsGoogleLoggingInitialized();
-
-bool is_default_thread();
-
-int64 CycleClock_Now();
-
-int64 UsecToCycles(int64 usec);
-
-typedef double WallTime;
-WallTime WallTime_Now();
-
-int32 GetMainThreadPid();
-
-pid_t GetTID();
-
-const std::string& MyUserName();
-
-// Get the part of filepath after the last path separator.
-// (Doesn't modify filepath, contrary to basename() in libgen.h.)
-const char* const_basename(const char* filepath);
-
-// Wrapper of __sync_val_compare_and_swap. If the GCC extension isn't
-// defined, we try the CPU specific logics (we only support x86 and
-// x86_64 for now) first, then use a naive implementation, which has a
-// race condition.
-template<typename T>
-inline T sync_val_compare_and_swap(T* ptr, T oldval, T newval) {
-#if defined(HAVE___SYNC_VAL_COMPARE_AND_SWAP)
-  return __sync_val_compare_and_swap(ptr, oldval, newval);
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-  T ret;
-  __asm__ __volatile__("lock; cmpxchg %1, (%2);"
-                       :"=a"(ret)
-                        // GCC may produces %sil or %dil for
-                        // constraint "r", but some of apple's gas
-                        // dosn't know the 8 bit registers.
-                        // We use "q" to avoid these registers.
-                       :"q"(newval), "q"(ptr), "a"(oldval)
-                       :"memory", "cc");
-  return ret;
-#else
-  T ret = *ptr;
-  if (ret == oldval) {
-    *ptr = newval;
-  }
-  return ret;
-#endif
-}
-
-void DumpStackTraceToString(std::string* stacktrace);
-
-struct CrashReason {
-  CrashReason() : filename(0), line_number(0), message(0), depth(0) {}
-
-  const char* filename;
-  int line_number;
-  const char* message;
-
-  // We'll also store a bit of stack trace context at the time of crash as
-  // it may not be available later on.
-  void* stack[32];
-  int depth;
-};
-
-void SetCrashReason(const CrashReason* r);
-
-}  // namespace glog_internal_namespace_
-
-_END_GOOGLE_NAMESPACE_
-
-using namespace GOOGLE_NAMESPACE::glog_internal_namespace_;
-
-#endif  // UTILITIES_H__

+ 0 - 54
Src/ThirdParty/glog/src/utilities_unittest.cc

@@ -1,54 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-
-#include "utilities.h"
-#include "googletest.h"
-#include "glog/logging.h"
-
-using namespace GOOGLE_NAMESPACE;
-
-TEST(utilities, sync_val_compare_and_swap) {
-  bool now_entering = false;
-  EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true));
-  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
-  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
-}
-
-TEST(utilities, InitGoogleLoggingDeathTest) {
-  ASSERT_DEATH(InitGoogleLogging("foobar"), "");
-}
-
-int main(int argc, char **argv) {
-  InitGoogleLogging(argv[0]);
-  InitGoogleTest(&argc, argv);
-
-  CHECK_EQ(RUN_ALL_TESTS(), 0);
-}

+ 0 - 249
Src/ThirdParty/glog/src/vlog_is_on.cc

@@ -1,249 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Broken out from logging.cc by Soren Lassen
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <cstdio>
-#include <string>
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-// glog doesn't have annotation
-#define ANNOTATE_BENIGN_RACE(address, description)
-
-using std::string;
-
-GLOG_DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this."
-" Overridable by --vmodule.");
-
-GLOG_DEFINE_string(vmodule, "", "per-module verbose level."
-" Argument is a comma-separated list of <module name>=<log level>."
-" <module name> is a glob pattern, matched against the filename base"
-" (that is, name ignoring .cc/.h./-inl.h)."
-" <log level> overrides any value given by --v.");
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-// Implementation of fnmatch that does not need 0-termination
-// of arguments and does not allocate any memory,
-// but we only support "*" and "?" wildcards, not the "[...]" patterns.
-// It's not a static function for the unittest.
-GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
-                                       size_t patt_len,
-                                       const char* str,
-                                       size_t str_len) {
-  int p = 0;
-  int s = 0;
-  while (1) {
-    if (p == patt_len  &&  s == str_len) return true;
-    if (p == patt_len) return false;
-    if (s == str_len) return p+1 == patt_len  &&  pattern[p] == '*';
-    if (pattern[p] == str[s]  ||  pattern[p] == '?') {
-      p += 1;
-      s += 1;
-      continue;
-    }
-    if (pattern[p] == '*') {
-      if (p+1 == patt_len) return true;
-      do {
-        if (SafeFNMatch_(pattern+(p+1), patt_len-(p+1), str+s, str_len-s)) {
-          return true;
-        }
-        s += 1;
-      } while (s != str_len);
-      return false;
-    }
-    return false;
-  }
-}
-
-}  // namespace glog_internal_namespace_
-
-using glog_internal_namespace_::SafeFNMatch_;
-
-int32 kLogSiteUninitialized = 1000;
-
-// List of per-module log levels from FLAGS_vmodule.
-// Once created each element is never deleted/modified
-// except for the vlog_level: other threads will read VModuleInfo blobs
-// w/o locks and we'll store pointers to vlog_level at VLOG locations
-// that will never go away.
-// We can't use an STL struct here as we wouldn't know
-// when it's safe to delete/update it: other threads need to use it w/o locks.
-struct VModuleInfo {
-  string module_pattern;
-  mutable int32 vlog_level;  // Conceptually this is an AtomicWord, but it's
-                             // too much work to use AtomicWord type here
-                             // w/o much actual benefit.
-  const VModuleInfo* next;
-};
-
-// This protects the following global variables.
-static Mutex vmodule_lock;
-// Pointer to head of the VModuleInfo list.
-// It's a map from module pattern to logging level for those module(s).
-static VModuleInfo* vmodule_list = 0;
-// Boolean initialization flag.
-static bool inited_vmodule = false;
-
-// L >= vmodule_lock.
-static void VLOG2Initializer() {
-  vmodule_lock.AssertHeld();
-  // Can now parse --vmodule flag and initialize mapping of module-specific
-  // logging levels.
-  inited_vmodule = false;
-  const char* vmodule = FLAGS_vmodule.c_str();
-  const char* sep;
-  VModuleInfo* head = NULL;
-  VModuleInfo* tail = NULL;
-  while ((sep = strchr(vmodule, '=')) != NULL) {
-    string pattern(vmodule, sep - vmodule);
-    int module_level;
-    if (sscanf(sep, "=%d", &module_level) == 1) {
-      VModuleInfo* info = new VModuleInfo;
-      info->module_pattern = pattern;
-      info->vlog_level = module_level;
-      if (head)  tail->next = info;
-      else  head = info;
-      tail = info;
-    }
-    // Skip past this entry
-    vmodule = strchr(sep, ',');
-    if (vmodule == NULL) break;
-    vmodule++;  // Skip past ","
-  }
-  if (head) {  // Put them into the list at the head:
-    tail->next = vmodule_list;
-    vmodule_list = head;
-  }
-  inited_vmodule = true;
-}
-
-// This can be called very early, so we use SpinLock and RAW_VLOG here.
-int SetVLOGLevel(const char* module_pattern, int log_level) {
-  int result = FLAGS_v;
-  int const pattern_len = strlen(module_pattern);
-  bool found = false;
-  MutexLock l(&vmodule_lock);  // protect whole read-modify-write
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (info->module_pattern == module_pattern) {
-      if (!found) {
-        result = info->vlog_level;
-        found = true;
-      }
-      info->vlog_level = log_level;
-    } else if (!found  &&
-               SafeFNMatch_(info->module_pattern.c_str(),
-                            info->module_pattern.size(),
-                            module_pattern, pattern_len)) {
-      result = info->vlog_level;
-      found = true;
-    }
-  }
-  if (!found) {
-    VModuleInfo* info = new VModuleInfo;
-    info->module_pattern = module_pattern;
-    info->vlog_level = log_level;
-    info->next = vmodule_list;
-    vmodule_list = info;
-  }
-  RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
-  return result;
-}
-
-// NOTE: Individual VLOG statements cache the integer log level pointers.
-// NOTE: This function must not allocate memory or require any locks.
-bool InitVLOG3__(int32** site_flag, int32* site_default,
-                 const char* fname, int32 verbose_level) {
-  MutexLock l(&vmodule_lock);
-  bool read_vmodule_flag = inited_vmodule;
-  if (!read_vmodule_flag) {
-    VLOG2Initializer();
-  }
-
-  // protect the errno global in case someone writes:
-  // VLOG(..) << "The last error was " << strerror(errno)
-  int old_errno = errno;
-
-  // site_default normally points to FLAGS_v
-  int32* site_flag_value = site_default;
-
-  // Get basename for file
-  const char* base = strrchr(fname, '/');
-  base = base ? (base+1) : fname;
-  const char* base_end = strchr(base, '.');
-  size_t base_length = base_end ? (base_end - base) : strlen(base);
-
-  // Trim out trailing "-inl" if any
-  if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {
-    base_length -= 4;
-  }
-
-  // TODO: Trim out _unittest suffix?  Perhaps it is better to have
-  // the extra control and just leave it there.
-
-  // find target in vector of modules, replace site_flag_value with
-  // a module-specific verbose level, if any.
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(),
-                     base, base_length)) {
-      site_flag_value = &info->vlog_level;
-        // value at info->vlog_level is now what controls
-        // the VLOG at the caller site forever
-      break;
-    }
-  }
-
-  // Cache the vlog value pointer if --vmodule flag has been parsed.
-  ANNOTATE_BENIGN_RACE(site_flag,
-                       "*site_flag may be written by several threads,"
-                       " but the value will be the same");
-  if (read_vmodule_flag) *site_flag = site_flag_value;
-
-  // restore the errno in case something recoverable went wrong during
-  // the initialization of the VLOG mechanism (see above note "protect the..")
-  errno = old_errno;
-  return *site_flag_value >= verbose_level;
-}
-
-_END_GOOGLE_NAMESPACE_

+ 0 - 136
Src/ThirdParty/glog/src/windows/config.h

@@ -1,136 +0,0 @@
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE google
-
-/* Define if you have the `dladdr' function */
-#undef HAVE_DLADDR
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#undef HAVE_EXECINFO_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <libunwind.h> header file. */
-#undef HAVE_LIBUNWIND_H
-
-/* define if you have google gflags library */
-#undef HAVE_LIB_GFLAGS
-
-/* define if you have libunwind */
-#undef HAVE_LIB_UNWIND
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* define if the compiler implements namespaces */
-#undef HAVE_NAMESPACES
-
-/* Define if you have POSIX threads libraries and header files. */
-#undef HAVE_PTHREAD
-
-/* define if the compiler implements pthread_rwlock_* */
-#undef HAVE_RWLOCK
-
-/* Define if you have the `sigaltstack' function */
-#undef HAVE_SIGALTSTACK
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <syscall.h> header file. */
-#undef HAVE_SYSCALL_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#undef HAVE_SYS_SYSCALL_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <ucontext.h> header file. */
-#undef HAVE_UCONTEXT_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* define if the compiler supports using expression for operator */
-#undef HAVE_USING_OPERATOR
-
-/* define if your compiler has __attribute__ */
-#undef HAVE___ATTRIBUTE__
-
-/* define if your compiler has __builtin_expect */
-#undef HAVE___BUILTIN_EXPECT
-
-/* define if your compiler has __sync_val_compare_and_swap */
-#undef HAVE___SYNC_VAL_COMPARE_AND_SWAP
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* How to access the PC from a struct ucontext */
-#undef PC_FROM_UCONTEXT
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* The size of `void *', as computed by sizeof. */
-#undef SIZEOF_VOID_P
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* the namespace where STL code like vector<> is defined */
-#undef STL_NAMESPACE
-
-/* Version number of package */
-#undef VERSION
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {
-
-/* Always the empty-string on non-windows systems. On windows, should be
-   "__declspec(dllexport)". This way, when we compile the dll, we export our
-   functions/classes. It's safe to define this here because config.h is only
-   used internally, to compile the DLL, and every DLL source file #includes
-   "config.h" before anything else. */
-#ifndef GOOGLE_GLOG_DLL_DECL
-# define GOOGLE_GLOG_IS_A_DLL  1   /* not set if you're statically linking */
-# define GOOGLE_GLOG_DLL_DECL  __declspec(dllexport)
-# define GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS  __declspec(dllimport)
-#endif

+ 0 - 88
Src/ThirdParty/glog/src/windows/glog/log_severity.h

@@ -1,88 +0,0 @@
-// This file is automatically generated from src/glog/log_severity.h
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef BASE_LOG_SEVERITY_H__
-#define BASE_LOG_SEVERITY_H__
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// Variables of type LogSeverity are widely taken to lie in the range
-// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
-// you ever need to change their values or add a new severity.
-typedef int LogSeverity;
-
-const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
-
-// DFATAL is FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
-#define DFATAL_LEVEL ERROR
-#else
-#define DFATAL_LEVEL FATAL
-#endif
-
-extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
-
-// NDEBUG usage helpers related to (RAW_)DCHECK:
-//
-// DEBUG_MODE is for small !NDEBUG uses like
-//   if (DEBUG_MODE) foo.CheckThatFoo();
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     foo.CheckThatFoo();
-//   #endif
-//
-// IF_DEBUG_MODE is for small !NDEBUG uses like
-//   IF_DEBUG_MODE( string error; )
-//   DCHECK(Foo(&error)) << error;
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     string error;
-//     DCHECK(Foo(&error)) << error;
-//   #endif
-//
-#ifdef NDEBUG
-enum { DEBUG_MODE = 0 };
-#define IF_DEBUG_MODE(x)
-#else
-enum { DEBUG_MODE = 1 };
-#define IF_DEBUG_MODE(x) x
-#endif
-
-#endif  // BASE_LOG_SEVERITY_H__

+ 0 - 1510
Src/ThirdParty/glog/src/windows/glog/logging.h

@@ -1,1510 +0,0 @@
-// This file is automatically generated from src/glog/logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-//
-// This file contains #include information about logging-related stuff.
-// Pretty much everybody needs to #include this file so that they can
-// log various happenings.
-//
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <string>
-#if 0
-# include <unistd.h>
-#endif
-#ifdef __DEPRECATED
-// Make GCC quiet.
-# undef __DEPRECATED
-# include <strstream>
-# define __DEPRECATED
-#else
-# include <strstream>
-#endif
-#include <vector>
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at logging.h.in to see how they're calculated (based on your config).
-#if 0
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 0
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 0
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-#if 0
-#include <gflags/gflags.h>
-#endif
-
-namespace google {
-
-#if 0      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 0   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 1    // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-}
-
-// The global value of GOOGLE_STRIP_LOG. All the messages logged to
-// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed.
-// If it can be determined at compile time that the message will not be
-// printed, the statement will be compiled out.
-//
-// Example: to strip out all INFO and WARNING messages, use the value
-// of 2 below. To make an exception for WARNING messages from a single
-// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including
-// base/logging.h
-#ifndef GOOGLE_STRIP_LOG
-#define GOOGLE_STRIP_LOG 0
-#endif
-
-// GCC can be told that a certain branch is not likely to be taken (for
-// instance, a CHECK failure), and use that information in static analysis.
-// Giving it this information can help it optimize for the common case in
-// the absence of better information (ie. -fprofile-arcs).
-//
-#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
-#if 0
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#else
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
-#endif
-#endif
-
-// Make a bunch of macros for logging.  The way to log things is to stream
-// things to LOG(<a particular severity level>).  E.g.,
-//
-//   LOG(INFO) << "Found " << num_cookies << " cookies";
-//
-// You can capture log messages in a string, rather than reporting them
-// immediately:
-//
-//   vector<string> errors;
-//   LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
-//
-// This pushes back the new error onto 'errors'; if given a NULL pointer,
-// it reports the error via LOG(ERROR).
-//
-// You can also do conditional logging:
-//
-//   LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-// You can also do occasional logging (log every n'th occurrence of an
-// event):
-//
-//   LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed.  Note that the special COUNTER value is used to
-// identify which repetition is happening.
-//
-// You can also do occasional conditional logging (log every n'th
-// occurrence of an event, when condition is satisfied):
-//
-//   LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
-//                                           << "th big cookie";
-//
-// You can log messages the first N times your code executes a line. E.g.
-//
-//   LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie";
-//
-// Outputs log messages for the first 20 times it is executed.
-//
-// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available.
-// These log to syslog as well as to the normal logs.  If you use these at
-// all, you need to be aware that syslog can drastically reduce performance,
-// especially if it is configured for remote logging!  Don't use these
-// unless you fully understand this and have a concrete need to use them.
-// Even then, try to minimize your use of them.
-//
-// There are also "debug mode" logging macros like the ones above:
-//
-//   DLOG(INFO) << "Found cookies";
-//
-//   DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-//   DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
-//
-// All "debug mode" logging is compiled away to nothing for non-debug mode
-// compiles.
-//
-// We also have
-//
-//   LOG_ASSERT(assertion);
-//   DLOG_ASSERT(assertion);
-//
-// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
-//
-// There are "verbose level" logging macros.  They look like
-//
-//   VLOG(1) << "I'm printed when you run the program with --v=1 or more";
-//   VLOG(2) << "I'm printed when you run the program with --v=2 or more";
-//
-// These always log at the INFO log level (when they log at all).
-// The verbose logging can also be turned on module-by-module.  For instance,
-//    --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-// will cause:
-//   a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc}
-//   b. VLOG(1) and lower messages to be printed from file.{h,cc}
-//   c. VLOG(3) and lower messages to be printed from files prefixed with "gfs"
-//   d. VLOG(0) and lower messages to be printed from elsewhere
-//
-// The wildcarding functionality shown by (c) supports both '*' (match
-// 0 or more characters) and '?' (match any single character) wildcards.
-//
-// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
-//
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished with just VLOG(2) << ...;
-//   }
-//
-// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level"
-// condition macros for sample cases, when some extra computation and
-// preparation for logs is not needed.
-//   VLOG_IF(1, (size > 1024))
-//      << "I'm printed when size is more than 1024 and when you run the "
-//         "program with --v=1 or more";
-//   VLOG_EVERY_N(1, 10)
-//      << "I'm printed every 10th occurrence, and when you run the program "
-//         "with --v=1 or more. Present occurence is " << COUNTER;
-//   VLOG_IF_EVERY_N(1, (size > 1024), 10)
-//      << "I'm printed on every 10th occurence of case when size is more "
-//         " than 1024, when you run the program with --v=1 or more. ";
-//         "Present occurence is " << COUNTER;
-//
-// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
-// Note that messages of a given severity are logged not only in the
-// logfile for that severity, but also in all logfiles of lower severity.
-// E.g., a message of severity FATAL will be logged to the logfiles of
-// severity FATAL, ERROR, WARNING, and INFO.
-//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
-// Very important: logging a message at the FATAL severity level causes
-// the program to terminate (after the message is logged).
-//
-// Unless otherwise specified, logs will be written to the filename
-// "<program name>.<hostname>.<user name>.log.<severity level>.", followed
-// by the date, time, and pid (you can't prevent the date, time, and pid
-// from being in the filename).
-//
-// The logging code takes two flags:
-//     --v=#           set the verbose level
-//     --logtostderr   log all the messages to stderr instead of to logfiles
-
-// LOG LINE PREFIX FORMAT
-//
-// Log lines have this form:
-//
-//     Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
-//
-// where the fields are defined as follows:
-//
-//   L                A single character, representing the log level
-//                    (eg 'I' for INFO)
-//   mm               The month (zero padded; ie May is '05')
-//   dd               The day (zero padded)
-//   hh:mm:ss.uuuuuu  Time in hours, minutes and fractional seconds
-//   threadid         The space-padded thread ID as returned by GetTID()
-//                    (this matches the PID on Linux)
-//   file             The file name
-//   line             The line number
-//   msg              The user-supplied message
-//
-// Example:
-//
-//   I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
-//   I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
-//
-// NOTE: although the microseconds are useful for comparing events on
-// a single machine, clocks on different machines may not be well
-// synchronized.  Hence, use caution when comparing the low bits of
-// timestamps from different machines.
-
-#ifndef DECLARE_VARIABLE
-#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#define DECLARE_VARIABLE(type, name, tn)                                      \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                              \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, name, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(google::int32, name, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                          \
-  namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead {  \
-  extern GOOGLE_GLOG_DLL_DECL std::string FLAGS_##name;                       \
-  }                                                                           \
-  using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
-#endif
-
-// Set whether log messages go to stderr instead of logfiles
-DECLARE_bool(logtostderr);
-
-// Set whether log messages go to stderr in addition to logfiles.
-DECLARE_bool(alsologtostderr);
-
-// Log messages at a level >= this flag are automatically sent to
-// stderr in addition to log files.
-DECLARE_int32(stderrthreshold);
-
-// Set whether the log prefix should be prepended to each line of output.
-DECLARE_bool(log_prefix);
-
-// Log messages at a level <= this flag are buffered.
-// Log messages at a higher level are flushed immediately.
-DECLARE_int32(logbuflevel);
-
-// Sets the maximum number of seconds which logs may be buffered for.
-DECLARE_int32(logbufsecs);
-
-// Log suppression level: messages logged at a lower level than this
-// are suppressed.
-DECLARE_int32(minloglevel);
-
-// If specified, logfiles are written into this directory instead of the
-// default logging directory.
-DECLARE_string(log_dir);
-
-// Sets the path of the directory into which to put additional links
-// to the log files.
-DECLARE_string(log_link);
-
-DECLARE_int32(v);  // in vlog_is_on.cc
-
-// Sets the maximum log file size (in MB).
-DECLARE_int32(max_log_size);
-
-// Sets whether to avoid logging to the disk if the disk is full.
-DECLARE_bool(stop_logging_if_full_disk);
-
-#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef DECLARE_VARIABLE
-#undef DECLARE_bool
-#undef DECLARE_int32
-#undef DECLARE_string
-#endif
-
-// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
-// security reasons. See LOG(severtiy) below.
-
-// A few definitions of macros that don't generate much code.  Since
-// LOG(INFO) and its ilk are used all over our code, it's
-// better to have compact code for these operations.
-
-#if GOOGLE_STRIP_LOG == 0
-#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_INFO(message) google::LogMessage( \
-      __FILE__, __LINE__, google::INFO, message)
-#else
-#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
-#define LOG_TO_STRING_INFO(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 1
-#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING)
-#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
-      __FILE__, __LINE__, google::WARNING, message)
-#else
-#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
-#define LOG_TO_STRING_WARNING(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 2
-#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR)
-#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
-      __FILE__, __LINE__, google::ERROR, message)
-#else
-#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
-#define LOG_TO_STRING_ERROR(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL, message)
-#else
-#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
-#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
-#endif
-
-// For DFATAL, we want to use LogMessage (as opposed to
-// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
-#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
-#elif GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
-      __FILE__, __LINE__, google::FATAL)
-#else
-#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
-#endif
-
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
-#define SYSLOG_INFO(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
-// A very useful logging macro to log windows errors:
-#define LOG_SYSRESULT(result) \
-  if (FAILED(result)) { \
-    LPTSTR message = NULL; \
-    LPTSTR msg = reinterpret_cast<LPTSTR>(&message); \
-    DWORD message_length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
-                         FORMAT_MESSAGE_FROM_SYSTEM, \
-                         0, result, 0, msg, 100, NULL); \
-    if (message_length > 0) { \
-      google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
-          &google::LogMessage::SendToLog).stream() << message; \
-      LocalFree(message); \
-    } \
-  }
-#endif
-
-// We use the preprocessor's merging operator, "##", so that, e.g.,
-// LOG(INFO) becomes the token GOOGLE_LOG_INFO.  There's some funny
-// subtle difference between ostream member streaming functions (e.g.,
-// ostream::operator<<(int) and ostream non-member streaming functions
-// (e.g., ::operator<<(ostream&, string&): it turns out that it's
-// impossible to stream something like a string directly to an unnamed
-// ostream. We employ a neat hack by calling the stream() member
-// function of LogMessage which seems to avoid the problem.
-#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
-#define SYSLOG(severity) SYSLOG_ ## severity(0).stream()
-
-namespace google {
-
-// They need the definitions of integer types.
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Initialize google's logging library. You will see the program name
-// specified by argv0 in log outputs.
-GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
-
-// Shutdown google's logging library.
-GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
-
-// Install a function which will be called after LOG(FATAL).
-GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
-
-class LogSink;  // defined below
-
-// If a non-NULL sink pointer is given, we push this message to that sink.
-// For LOG_TO_SINK we then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and passing/storing them
-// somewhere more specific than the global log of the process.
-// Argument types:
-//   LogSink* sink;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-#define LOG_TO_SINK(sink, severity) \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), true).stream()
-#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)                  \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::severity,                                  \
-      static_cast<google::LogSink*>(sink), false).stream()
-
-// If a non-NULL string pointer is given, we write this message to that string.
-// We then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and storing them somewhere more
-// specific than the global log of the process.
-// Argument types:
-//   string* message;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-// NOTE: LOG(severity) expands to LogMessage().stream() for the specified
-// severity.
-#define LOG_TO_STRING(severity, message) \
-  LOG_TO_STRING_##severity(static_cast<string*>(message)).stream()
-
-// If a non-NULL pointer is given, we push the message onto the end
-// of a vector of strings; otherwise, we report it with LOG(severity).
-// This is handy for capturing messages and perhaps passing them back
-// to the caller, rather than reporting them immediately.
-// Argument types:
-//   LogSeverity severity;
-//   vector<string> *outvec;
-// The cast is to disambiguate NULL arguments.
-#define LOG_STRING(severity, outvec) \
-  LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
-
-#define LOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-#define SYSLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & SYSLOG(severity)
-
-#define LOG_ASSERT(condition)  \
-  LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-#define SYSLOG_ASSERT(condition) \
-  SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-
-// CHECK dies with a fatal error if condition is not true.  It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode.  Therefore, it is safe to do things like:
-//    CHECK(fp->Write(x) == 4)
-#define CHECK(condition)  \
-      LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-             << "Check failed: " #condition " "
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
-  CheckOpString(std::string* str) : str_(str) { }
-  // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
-  // so there's no point in cleaning up str_.
-  operator bool() const {
-    return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
-  }
-  std::string* str_;
-};
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// CHECK* macros. It's not encouraged though.
-template <class T>
-inline const T&       GetReferenceableValue(const T&           t) { return t; }
-inline char           GetReferenceableValue(char               t) { return t; }
-inline unsigned char  GetReferenceableValue(unsigned char      t) { return t; }
-inline signed char    GetReferenceableValue(signed char        t) { return t; }
-inline short          GetReferenceableValue(short              t) { return t; }
-inline unsigned short GetReferenceableValue(unsigned short     t) { return t; }
-inline int            GetReferenceableValue(int                t) { return t; }
-inline unsigned int   GetReferenceableValue(unsigned int       t) { return t; }
-inline long           GetReferenceableValue(long               t) { return t; }
-inline unsigned long  GetReferenceableValue(unsigned long      t) { return t; }
-inline long long      GetReferenceableValue(long long          t) { return t; }
-inline unsigned long long GetReferenceableValue(unsigned long long t) {
-  return t;
-}
-
-// This is a dummy class to define the following operator.
-struct DummyClassToDefineOperator {};
-
-}
-
-// Define global operator<< to declare using ::operator<<.
-// This declaration will allow use to use CHECK macros for user
-// defined classes which have operator<< (e.g., stl_logging.h).
-inline std::ostream& operator<<(
-    std::ostream& out, const google::DummyClassToDefineOperator&) {
-  return out;
-}
-
-namespace google {
-
-// Build the error message string.
-template<class t1, class t2>
-std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
-  // It means that we cannot use stl_logging if compiler doesn't
-  // support using expression for operator.
-  // TODO(hamaji): Figure out a way to fix.
-#if 1
-  using ::operator<<;
-#endif
-  std::strstream ss;
-  ss << names << " (" << v1 << " vs. " << v2 << ")";
-  return new std::string(ss.str(), ss.pcount());
-}
-
-// Helper functions for CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
-  template <class t1, class t2> \
-  inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
-                                        const char* names) { \
-    if (v1 op v2) return NULL; \
-    else return MakeCheckOpString(v1, v2, names); \
-  } \
-  inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
-    return Check##name##Impl<int, int>(v1, v2, names); \
-  }
-
-// Use _EQ, _NE, _LE, etc. in case the file including base/logging.h
-// provides its own #defines for the simpler names EQ, NE, LE, etc.
-// This happens if, for example, those are used as token names in a
-// yacc grammar.
-DEFINE_CHECK_OP_IMPL(_EQ, ==)
-DEFINE_CHECK_OP_IMPL(_NE, !=)
-DEFINE_CHECK_OP_IMPL(_LE, <=)
-DEFINE_CHECK_OP_IMPL(_LT, < )
-DEFINE_CHECK_OP_IMPL(_GE, >=)
-DEFINE_CHECK_OP_IMPL(_GT, > )
-#undef DEFINE_CHECK_OP_IMPL
-
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-
-#if defined(STATIC_ANALYSIS)
-// Only for static analysis tool to know that it is equivalent to assert
-#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
-// In debug mode, avoid constructing CheckOpStrings if possible,
-// to reduce the overhead of CHECK statments by 2x.
-// Real DCHECK-heavy tests have seen 1.5x speedups.
-
-// The meaning of "string" might be different between now and 
-// when this macro gets invoked (e.g., if someone is experimenting
-// with other string implementations that get defined after this
-// file is included).  Save the current meaning now and use it 
-// in the macro.
-typedef std::string _Check_string;
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::_Check_string* _result =                \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__,                                             \
-        google::CheckOpString(_result)).stream()
-#else
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::CheckOpString _result =                 \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__, _result).stream()
-#endif  // STATIC_ANALYSIS, !NDEBUG
-
-#if GOOGLE_STRIP_LOG <= 3
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
-#else
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::NullStreamFatal)
-#endif // STRIP_LOG <= 3
-
-// Equality/Inequality checks - compare two values, and log a FATAL message
-// including the two values when the result is not as expected.  The values
-// must have operator<<(ostream, ...) defined.
-//
-// You may append to the error message like so:
-//   CHECK_NE(1, 2) << ": The world must be ending!";
-//
-// We are very careful to ensure that each argument is evaluated exactly
-// once, and that anything which is legal to pass as a function argument is
-// legal here.  In particular, the arguments may be temporary expressions
-// which will end up being destroyed at the end of the apparent statement,
-// for example:
-//   CHECK_EQ(string("abc")[1], 'b');
-//
-// WARNING: These don't compile correctly if one of the arguments is a pointer
-// and the other is NULL. To work around this, simply static_cast NULL to the
-// type of the desired pointer.
-
-#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
-
-// Check that the input is non NULL.  This very useful in constructor
-// initializer lists.
-
-#define CHECK_NOTNULL(val) \
-  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
-  GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
-      const char* s1, const char* s2, const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
-  while (google::CheckOpString _result = \
-         google::Check##func##expected##Impl((s1), (s2), \
-                                     #s1 " " #op " " #s2)) \
-    LOG(FATAL) << *_result.str_
-
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_DOUBLE_EQ(val1, val2)              \
-  do {                                           \
-    CHECK_LE((val1), (val2)+0.000000000000001L); \
-    CHECK_GE((val1), (val2)-0.000000000000001L); \
-  } while (0)
-
-#define CHECK_NEAR(val1, val2, margin)           \
-  do {                                           \
-    CHECK_LE((val1), (val2)+(margin));           \
-    CHECK_GE((val1), (val2)-(margin));           \
-  } while (0)
-
-// perror()..googly style!
-//
-// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and
-// CHECK equivalents with the addition that they postpend a description
-// of the current state of errno to their output lines.
-
-#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream()
-
-#define GOOGLE_PLOG(severity, counter)  \
-  google::ErrnoLogMessage( \
-      __FILE__, __LINE__, google::severity, counter, \
-      &google::LogMessage::SendToLog)
-
-#define PLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & PLOG(severity)
-
-// A CHECK() macro that postpends errno if the condition is false. E.g.
-//
-// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... }
-#define PCHECK(condition)  \
-      PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-              << "Check failed: " #condition " "
-
-// A CHECK() macro that lets you assert the success of a function that
-// returns -1 and sets errno in case of an error. E.g.
-//
-// CHECK_ERR(mkdir(path, 0700));
-//
-// or
-//
-// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename;
-#define CHECK_ERR(invocation)                                          \
-PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1))    \
-        << #invocation
-
-// Use macro expansion to create, for each use of LOG_EVERY_N(), static
-// variables with the __LINE__ expansion as part of the variable name.
-#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line)
-#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line
-
-#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__)
-#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__)
-
-#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (condition && \
-      ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-                 &what_to_do).stream()
-
-#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::ErrnoLogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0; \
-  if (LOG_OCCURRENCES <= n) \
-    ++LOG_OCCURRENCES; \
-  if (LOG_OCCURRENCES <= n) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-namespace glog_internal_namespace_ {
-template <bool>
-struct CompileAssert {
-};
-struct CrashReason;
-}  // namespace glog_internal_namespace_
-
-#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
-  typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
-#define LOG_EVERY_N(severity, n)                                        \
-  GOOGLE_GLOG_COMPILE_ASSERT(google::severity <          \
-                             google::NUM_SEVERITIES,     \
-                             INVALID_REQUESTED_LOG_SEVERITY);           \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define SYSLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToSyslogAndLog)
-
-#define PLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_PLOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_FIRST_N(severity, n) \
-  SOME_KIND_OF_LOG_FIRST_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_IF_EVERY_N(severity, condition, n) \
-  SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), google::LogMessage::SendToLog)
-
-// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
-enum PRIVATE_Counter {COUNTER};
-
-
-// Plus some debug-logging macros that get compiled to nothing for production
-
-#ifndef NDEBUG
-
-#define DLOG(severity) LOG(severity)
-#define DVLOG(verboselevel) VLOG(verboselevel)
-#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
-#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  LOG_IF_EVERY_N(severity, condition, n)
-#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-
-// debug-only checking.  not executed in NDEBUG mode.
-#define DCHECK(condition) CHECK(condition)
-#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
-#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
-#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
-#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
-#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
-#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
-#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
-#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
-#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
-#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
-#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-
-#else  // NDEBUG
-
-#define DLOG(severity) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DVLOG(verboselevel) \
-  (true || !VLOG_IS_ON(verboselevel)) ?\
-    (void) 0 : google::LogMessageVoidify() & LOG(INFO)
-
-#define DLOG_IF(severity, condition) \
-  (true || !(condition)) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_EVERY_N(severity, n) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  (true || !(condition))? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_ASSERT(condition) \
-  true ? (void) 0 : LOG_ASSERT(condition)
-
-#define DCHECK(condition) \
-  while (false) \
-    CHECK(condition)
-
-#define DCHECK_EQ(val1, val2) \
-  while (false) \
-    CHECK_EQ(val1, val2)
-
-#define DCHECK_NE(val1, val2) \
-  while (false) \
-    CHECK_NE(val1, val2)
-
-#define DCHECK_LE(val1, val2) \
-  while (false) \
-    CHECK_LE(val1, val2)
-
-#define DCHECK_LT(val1, val2) \
-  while (false) \
-    CHECK_LT(val1, val2)
-
-#define DCHECK_GE(val1, val2) \
-  while (false) \
-    CHECK_GE(val1, val2)
-
-#define DCHECK_GT(val1, val2) \
-  while (false) \
-    CHECK_GT(val1, val2)
-
-#define DCHECK_NOTNULL(val) (val)
-
-#define DCHECK_STREQ(str1, str2) \
-  while (false) \
-    CHECK_STREQ(str1, str2)
-
-#define DCHECK_STRCASEEQ(str1, str2) \
-  while (false) \
-    CHECK_STRCASEEQ(str1, str2)
-
-#define DCHECK_STRNE(str1, str2) \
-  while (false) \
-    CHECK_STRNE(str1, str2)
-
-#define DCHECK_STRCASENE(str1, str2) \
-  while (false) \
-    CHECK_STRCASENE(str1, str2)
-
-
-#endif  // NDEBUG
-
-// Log only in verbose mode.
-
-#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
-
-#define VLOG_IF(verboselevel, condition) \
-  LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel))
-
-#define VLOG_EVERY_N(verboselevel, n) \
-  LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
-
-#define VLOG_IF_EVERY_N(verboselevel, condition, n) \
-  LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n)
-
-//
-// This class more or less represents a particular log message.  You
-// create an instance of LogMessage and then stream stuff to it.
-// When you finish streaming to it, ~LogMessage is called and the
-// full message gets streamed to the appropriate destination.
-//
-// You shouldn't actually use LogMessage's constructor to log things,
-// though.  You should use the LOG() macro (and variants thereof)
-// above.
-class GOOGLE_GLOG_DLL_DECL LogMessage {
-public:
-  enum {
-    // Passing kNoLogPrefix for the line number disables the
-    // log-message prefix. Useful for using the LogMessage
-    // infrastructure as a printing utility. See also the --log_prefix
-    // flag for controlling the log-message prefix on an
-    // application-wide basis.
-    kNoLogPrefix = -1
-  };
-
-  // LogStream inherit from non-DLL-exported class (std::ostrstream)
-  // and VC++ produces a warning for this situation.
-  // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
-  // 2005 if you are deriving from a type in the Standard C++ Library"
-  // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-  // Let's just ignore the warning.
-#ifdef _MSC_VER
-# pragma warning(disable: 4275)
-#endif
-  class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostrstream {
-#ifdef _MSC_VER
-# pragma warning(default: 4275)
-#endif
-  public:
-    LogStream(char *buf, int len, int ctr)
-      : ostrstream(buf, len),
-        ctr_(ctr) {
-      self_ = this;
-    }
-
-    int ctr() const { return ctr_; }
-    void set_ctr(int ctr) { ctr_ = ctr; }
-    LogStream* self() const { return self_; }
-
-  private:
-    int ctr_;  // Counter hack (for the LOG_EVERY_X() macro)
-    LogStream *self_;  // Consistency check hack
-  };
-
-public:
-  // icc 8 requires this typedef to avoid an internal compiler error.
-  typedef void (LogMessage::*SendMethod)();
-
-  LogMessage(const char* file, int line, LogSeverity severity, int ctr,
-             SendMethod send_method);
-
-  // Two special constructors that generate reduced amounts of code at
-  // LOG call sites for common cases.
-
-  // Used for LOG(INFO): Implied are:
-  // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog.
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 19 bytes per call site.
-  LogMessage(const char* file, int line);
-
-  // Used for LOG(severity) where severity != INFO.  Implied
-  // are: ctr = 0, send_method = &LogMessage::SendToLog
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 17 bytes per call site.
-  LogMessage(const char* file, int line, LogSeverity severity);
-
-  // Constructor to log this message to a specified sink (if not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
-  // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
-  LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
-             bool also_send_to_log);
-
-  // Constructor where we also give a vector<string> pointer
-  // for storing the messages (if the pointer is not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::vector<std::string>* outvec);
-
-  // Constructor where we also give a string pointer for storing the
-  // message (if the pointer is not NULL).  Implied are: ctr = 0,
-  // send_method = &LogMessage::WriteToStringAndLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::string* message);
-
-  // A special constructor used for check failures
-  LogMessage(const char* file, int line, const CheckOpString& result);
-
-  ~LogMessage();
-
-  // Flush a buffered message to the sink set in the constructor.  Always
-  // called by the destructor, it may also be called from elsewhere if
-  // needed.  Only the first call is actioned; any later ones are ignored.
-  void Flush();
-
-  // An arbitrary limit on the length of a single log message.  This
-  // is so that streaming can be done more efficiently.
-  static const size_t kMaxLogMessageLen;
-
-  // Theses should not be called directly outside of logging.*,
-  // only passed as SendMethod arguments to other LogMessage methods:
-  void SendToLog();  // Actually dispatch to the logs
-  void SendToSyslogAndLog();  // Actually dispatch to syslog and the logs
-
-  // Call abort() or similar to perform LOG(FATAL) crash.
-  static void Fail() ;
-
-  std::ostream& stream() { return *(data_->stream_); }
-
-  int preserved_errno() const { return data_->preserved_errno_; }
-
-  // Must be called without the log_mutex held.  (L < log_mutex)
-  static int64 num_messages(int severity);
-
-private:
-  // Fully internal SendMethod cases:
-  void SendToSinkAndLog();  // Send to sink if provided and dispatch to the logs
-  void SendToSink();  // Send to sink if provided, do nothing otherwise.
-
-  // Write to string if provided and dispatch to the logs.
-  void WriteToStringAndLog();
-
-  void SaveOrSendToLog();  // Save to stringvec if provided, else to logs
-
-  void Init(const char* file, int line, LogSeverity severity,
-            void (LogMessage::*send_method)());
-
-  // Used to fill in crash information during LOG(FATAL) failures.
-  void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
-
-  // Counts of messages sent at each priority:
-  static int64 num_messages_[NUM_SEVERITIES];  // under log_mutex
-
-  // We keep the data in a separate struct so that each instance of
-  // LogMessage uses less stack space.
-  struct GOOGLE_GLOG_DLL_DECL LogMessageData {
-    LogMessageData() {};
-
-    int preserved_errno_;      // preserved errno
-    char* buf_;
-    char* message_text_;  // Complete message text (points to selected buffer)
-    LogStream* stream_alloc_;
-    LogStream* stream_;
-    char severity_;      // What level is this LogMessage logged at?
-    int line_;                 // line number where logging call is.
-    void (LogMessage::*send_method_)();  // Call this in destructor to send
-    union {  // At most one of these is used: union to keep the size low.
-      LogSink* sink_;             // NULL or sink to send message to
-      std::vector<std::string>* outvec_; // NULL or vector to push message onto
-      std::string* message_;             // NULL or string to write message into
-    };
-    time_t timestamp_;            // Time of creation of LogMessage
-    struct ::tm tm_time_;         // Time of creation of LogMessage
-    size_t num_prefix_chars_;     // # of chars of prefix in this message
-    size_t num_chars_to_log_;     // # of chars of msg to send to log
-    size_t num_chars_to_syslog_;  // # of chars of msg to send to syslog
-    const char* basename_;        // basename of file that called LOG
-    const char* fullname_;        // fullname of file that called LOG
-    bool has_been_flushed_;       // false => data has not been flushed
-    bool first_fatal_;            // true => this was first fatal msg
-
-    ~LogMessageData();
-   private:
-    LogMessageData(const LogMessageData&);
-    void operator=(const LogMessageData&);
-  };
-
-  static LogMessageData fatal_msg_data_exclusive_;
-  static LogMessageData fatal_msg_data_shared_;
-
-  LogMessageData* allocated_;
-  LogMessageData* data_;
-
-  friend class LogDestination;
-
-  LogMessage(const LogMessage&);
-  void operator=(const LogMessage&);
-};
-
-// This class happens to be thread-hostile because all instances share
-// a single data buffer, but since it can only be created just before
-// the process dies, we don't worry so much.
-class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
- public:
-  LogMessageFatal(const char* file, int line);
-  LogMessageFatal(const char* file, int line, const CheckOpString& result);
-  ~LogMessageFatal() ;
-};
-
-// A non-macro interface to the log facility; (useful
-// when the logging level is not a compile-time constant).
-inline void LogAtLevel(int const severity, std::string const &msg) {
-  LogMessage(__FILE__, __LINE__, severity).stream() << msg;
-}
-
-// A macro alternative of LogAtLevel. New code may want to use this
-// version since there are two advantages: 1. this version outputs the
-// file name and the line number where this macro is put like other
-// LOG macros, 2. this macro can be used as C++ stream.
-#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
-
-// A small helper for CHECK_NOTNULL().
-template <typename T>
-T* CheckNotNull(const char *file, int line, const char *names, T* t) {
-  if (t == NULL) {
-    LogMessageFatal(file, line, new std::string(names));
-  }
-  return t;
-}
-
-// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
-// only works if ostream is a LogStream. If the ostream is not a
-// LogStream you'll get an assert saying as much at runtime.
-GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
-                                              const PRIVATE_Counter&);
-
-
-// Derived class for PLOG*() above.
-class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
- public:
-
-  ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
-                  void (LogMessage::*send_method)());
-
-  // Postpends ": strerror(errno) [errno]".
-  ~ErrnoLogMessage();
-
- private:
-  ErrnoLogMessage(const ErrnoLogMessage&);
-  void operator=(const ErrnoLogMessage&);
-};
-
-
-// This class is used to explicitly ignore values in the conditional
-// logging macros.  This avoids compiler warnings like "value computed
-// is not used" and "statement has no effect".
-
-class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
- public:
-  LogMessageVoidify() { }
-  // This has to be an operator with a precedence lower than << but
-  // higher than ?:
-  void operator&(std::ostream&) { }
-};
-
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level. Thread-hostile because it ignores
-// locking -- used for catastrophic failures.
-GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
-
-//
-// Set the destination to which a particular severity level of log
-// messages is sent.  If base_filename is "", it means "don't log this
-// severity".  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
-                                            const char* base_filename);
-
-//
-// Set the basename of the symlink to the latest log file at a given
-// severity.  If symlink_basename is empty, do not make a symlink.  If
-// you don't call this function, the symlink basename is the
-// invocation name of the program.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
-                                        const char* symlink_basename);
-
-//
-// Used to send logs to some other kind of destination
-// Users should subclass LogSink and override send to do whatever they want.
-// Implementations must be thread-safe because a shared instance will
-// be called from whichever thread ran the LOG(XXX) line.
-class GOOGLE_GLOG_DLL_DECL LogSink {
- public:
-  virtual ~LogSink();
-
-  // Sink's logging logic (message_len is such as to exclude '\n' at the end).
-  // This method can't use LOG() or CHECK() as logging system mutex(s) are held
-  // during this call.
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct ::tm* tm_time,
-                    const char* message, size_t message_len) = 0;
-
-  // Redefine this to implement waiting for
-  // the sink's logging logic to complete.
-  // It will be called after each send() returns,
-  // but before that LogMessage exits or crashes.
-  // By default this function does nothing.
-  // Using this function one can implement complex logic for send()
-  // that itself involves logging; and do all this w/o causing deadlocks and
-  // inconsistent rearrangement of log messages.
-  // E.g. if a LogSink has thread-specific actions, the send() method
-  // can simply add the message to a queue and wake up another thread that
-  // handles real logging while itself making some LOG() calls;
-  // WaitTillSent() can be implemented to wait for that logic to complete.
-  // See our unittest for an example.
-  virtual void WaitTillSent();
-
-  // Returns the normal text output of the log message.
-  // Can be useful to implement send().
-  static std::string ToString(LogSeverity severity, const char* file, int line,
-                              const struct ::tm* tm_time,
-                              const char* message, size_t message_len);
-};
-
-// Add or remove a LogSink as a consumer of logging data.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
-GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
-
-//
-// Specify an "extension" added to the filename specified via
-// SetLogDestination.  This applies to all severity levels.  It's
-// often used to append the port we're listening on to the logfile
-// name.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
-    const char* filename_extension);
-
-//
-// Make it so that all log messages of at least a particular severity
-// are logged to stderr (in addition to logging to the usual log
-// file(s)).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
-
-//
-// Make it so that all log messages go only to stderr.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
-//
-// Make it so that all log messages of at least a particular severity are
-// logged via email to a list of addresses (in addition to logging to the
-// usual log file(s)).  The list of addresses is just a string containing
-// the email addresses to send to (separated by spaces, say).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
-                                          const char* addresses);
-
-// A simple function that sends email. dest is a commma-separated
-// list of addressess.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
-                                    const char *subject, const char *body);
-
-GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
-
-// For tests only:  Clear the internal [cached] list of logging directories to
-// force a refresh the next time GetLoggingDirectories is called.
-// Thread-hostile.
-void TestOnly_ClearLoggingDirectoriesList();
-
-// Returns a set of existing temporary directories, which will be a
-// subset of the directories returned by GetLogginDirectories().
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
-    std::vector<std::string>* list);
-
-// Print any fatal message again -- useful to call from signal handler
-// so that the last thing in the output is the fatal message.
-// Thread-hostile, but a race is unlikely.
-GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
-
-// Truncate a log file that may be the append-only output of multiple
-// processes and hence can't simply be renamed/reopened (typically a
-// stdout/stderr).  If the file "path" is > "limit" bytes, copy the
-// last "keep" bytes to offset 0 and truncate the rest. Since we could
-// be racing with other writers, this approach has the potential to
-// lose very small amounts of data. For security, only follow symlinks
-// if the path is /proc/self/fd/*
-GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
-                                          int64 limit, int64 keep);
-
-// Truncate stdout and stderr if they are over the value specified by
-// --max_log_size; keep the final 1MB.  This function has the same
-// race condition as TruncateLogFile.
-GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
-
-// Return the string representation of the provided LogSeverity level.
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
-
-// ---------------------------------------------------------------------
-// Implementation details that are not useful to most clients
-// ---------------------------------------------------------------------
-
-// A Logger is the interface used by logging modules to emit entries
-// to a log.  A typical implementation will dump formatted data to a
-// sequence of files.  We also provide interfaces that will forward
-// the data to another thread so that the invoker never blocks.
-// Implementations should be thread-safe since the logging system
-// will write to them from multiple threads.
-
-namespace base {
-
-class GOOGLE_GLOG_DLL_DECL Logger {
- public:
-  virtual ~Logger();
-
-  // Writes "message[0,message_len-1]" corresponding to an event that
-  // occurred at "timestamp".  If "force_flush" is true, the log file
-  // is flushed immediately.
-  //
-  // The input message has already been formatted as deemed
-  // appropriate by the higher level logging facility.  For example,
-  // textual log messages already contain timestamps, and the
-  // file:linenumber header.
-  virtual void Write(bool force_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int message_len) = 0;
-
-  // Flush any buffered messages
-  virtual void Flush() = 0;
-
-  // Get the current LOG file size.
-  // The returned value is approximate since some
-  // logged data may not have been flushed to disk yet.
-  virtual uint32 LogSize() = 0;
-};
-
-// Get the logger for the specified severity level.  The logger
-// remains the property of the logging module and should not be
-// deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
-
-// Set the logger for the specified severity level.  The logger
-// becomes the property of the logging module and should not
-// be deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
-
-}
-
-// glibc has traditionally implemented two incompatible versions of
-// strerror_r(). There is a poorly defined convention for picking the
-// version that we want, but it is not clear whether it even works with
-// all versions of glibc.
-// So, instead, we provide this wrapper that automatically detects the
-// version that is in use, and then implements POSIX semantics.
-// N.B. In addition to what POSIX says, we also guarantee that "buf" will
-// be set to an empty string, if this function failed. This means, in most
-// cases, you do not need to check the error code and you can directly
-// use the value of "buf". It will never have an undefined value.
-GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
-
-
-// A class for which we define operator<<, which does nothing.
-class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
- public:
-  // Initialize the LogStream so the messages can be written somewhere
-  // (they'll never be actually displayed). This will be needed if a
-  // NullStream& is implicitly converted to LogStream&, in which case
-  // the overloaded NullStream::operator<< will not be invoked.
-  NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream(const char* /*file*/, int /*line*/,
-             const CheckOpString& /*result*/) :
-      LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream &stream() { return *this; }
- private:
-  // A very short buffer for messages (which we discard anyway). This
-  // will be needed if NullStream& converted to LogStream& (e.g. as a
-  // result of a conditional expression).
-  char message_buffer_[2];
-};
-
-// Do nothing. This operator is inline, allowing the message to be
-// compiled away. The message will not be compiled away if we do
-// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when
-// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly
-// converted to LogStream and the message will be computed and then
-// quietly discarded.
-template<class T>
-inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
-
-// Similar to NullStream, but aborts the program (without stack
-// trace), like LogMessageFatal.
-class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
- public:
-  NullStreamFatal() { }
-  NullStreamFatal(const char* file, int line, const CheckOpString& result) :
-      NullStream(file, line, result) { }
-   ~NullStreamFatal() { _exit(1); }
-};
-
-// Install a signal handler that will dump signal information and a stack
-// trace when the program crashes on certain signals.  We'll install the
-// signal handler for the following signals.
-//
-// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
-//
-// By default, the signal handler will write the failure dump to the
-// standard error.  You can customize the destination by installing your
-// own writer function by InstallFailureWriter() below.
-//
-// Note on threading:
-//
-// The function should be called before threads are created, if you want
-// to use the failure signal handler for all threads.  The stack trace
-// will be shown only for the thread that receives the signal.  In other
-// words, stack traces of other threads won't be shown.
-GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
-
-// Installs a function that is used for writing the failure dump.  "data"
-// is the pointer to the beginning of a message to be written, and "size"
-// is the size of the message.  You should not expect the data is
-// terminated with '\0'.
-GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
-    void (*writer)(const char* data, int size));
-
-}
-
-#endif // _LOGGING_H_

+ 0 - 189
Src/ThirdParty/glog/src/windows/glog/raw_logging.h

@@ -1,189 +0,0 @@
-// This file is automatically generated from src/glog/raw_logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// Thread-safe logging routines that do not allocate any memory or
-// acquire any locks, and can therefore be used by low-level memory
-// allocation and synchronization code.
-
-#ifndef BASE_RAW_LOGGING_H_
-#define BASE_RAW_LOGGING_H_
-
-#include <time.h>
-
-namespace google {
-
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// This is similar to LOG(severity) << format... and VLOG(level) << format..,
-// but
-// * it is to be used ONLY by low-level modules that can't use normal LOG()
-// * it is desiged to be a low-level logger that does not allocate any
-//   memory and does not need any locks, hence:
-// * it logs straight and ONLY to STDERR w/o buffering
-// * it uses an explicit format and arguments list
-// * it will silently chop off really long message strings
-// Usage example:
-//   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
-//   RAW_VLOG(3, "status is %i", status);
-// These will print an almost standard log lines like this to stderr only:
-//   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
-//   I0821 211317 file.cc:142] RAW: status is 20
-#define RAW_LOG(severity, ...) \
-  do { \
-    switch (google::severity) {  \
-      case 0: \
-        RAW_LOG_INFO(__VA_ARGS__); \
-        break; \
-      case 1: \
-        RAW_LOG_WARNING(__VA_ARGS__); \
-        break; \
-      case 2: \
-        RAW_LOG_ERROR(__VA_ARGS__); \
-        break; \
-      case 3: \
-        RAW_LOG_FATAL(__VA_ARGS__); \
-        break; \
-      default: \
-        break; \
-    } \
-  } while (0)
-
-// The following STRIP_LOG testing is performed in the header file so that it's
-// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0
-#define RAW_VLOG(verboselevel, ...) \
-  do { \
-    if (VLOG_IS_ON(verboselevel)) { \
-      RAW_LOG_INFO(__VA_ARGS__); \
-    } \
-  } while (0)
-#else
-#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
-                                   __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING,   \
-                                      __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 1
-
-#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 2
-
-#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_FATAL(...) \
-  do { \
-    google::RawLogStub__(0, __VA_ARGS__);        \
-    exit(1); \
-  } while (0)
-#endif // STRIP_LOG <= 3
-
-// Similar to CHECK(condition) << message,
-// but for low-level modules: we use only RAW_LOG that does not allocate memory.
-// We do not want to provide args list here to encourage this usage:
-//   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
-// so that the args are not computed when not needed.
-#define RAW_CHECK(condition, message)                                   \
-  do {                                                                  \
-    if (!(condition)) {                                                 \
-      RAW_LOG(FATAL, "Check %s failed: %s", #condition, message);       \
-    }                                                                   \
-  } while (0)
-
-// Debug versions of RAW_LOG and RAW_CHECK
-#ifndef NDEBUG
-
-#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
-
-#else  // NDEBUG
-
-#define RAW_DLOG(severity, ...)                                 \
-  while (false)                                                 \
-    RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) \
-  while (false) \
-    RAW_CHECK(condition, message)
-
-#endif  // NDEBUG
-
-// Stub log function used to work around for unused variable warnings when
-// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int ignored, ...) {
-}
-
-// Helper function to implement RAW_LOG and RAW_VLOG
-// Logs format... at "severity" level, reporting it
-// as called from file:line.
-// This does not allocate memory or acquire locks.
-GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
-                                   const char* file,
-                                   int line,
-                                   const char* format, ...)
-   ;
-
-// Hack to propagate time information into this module so that
-// this module does not have to directly call localtime_r(),
-// which could allocate memory.
-GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
-
-}
-
-#endif  // BASE_RAW_LOGGING_H_

+ 0 - 158
Src/ThirdParty/glog/src/windows/glog/stl_logging.h

@@ -1,158 +0,0 @@
-// This file is automatically generated from src/glog/stl_logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Stream output operators for STL containers; to be used for logging *only*.
-// Inclusion of this file lets you do:
-//
-// list<string> x;
-// LOG(INFO) << "data: " << x;
-// vector<int> v1, v2;
-// CHECK_EQ(v1, v2);
-//
-// Note that if you want to use these operators from the non-global namespace,
-// you may get an error since they are not in namespace std (and they are not
-// in namespace std since that would result in undefined behavior). You may
-// need to write
-//
-//   using ::operator<<;
-//
-// to fix these errors.
-
-#ifndef UTIL_GTL_STL_LOGGING_INL_H_
-#define UTIL_GTL_STL_LOGGING_INL_H_
-
-#if !1
-# error We do not support stl_logging for this compiler
-#endif
-
-#include <deque>
-#include <list>
-#include <map>
-#include <ostream>
-#include <set>
-#include <utility>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_set>
-# include <ext/hash_map>
-# include <ext/slist>
-#endif
-
-template<class First, class Second>
-inline std::ostream& operator<<(std::ostream& out,
-                                const std::pair<First, Second>& p) {
-  out << '(' << p.first << ", " << p.second << ')';
-  return out;
-}
-
-namespace google {
-
-template<class Iter>
-inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
-  using ::operator<<;
-  // Output at most 100 elements -- appropriate if used for logging.
-  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
-    if (i > 0) out << ' ';
-    out << *begin;
-  }
-  if (begin != end) {
-    out << " ...";
-  }
-}
-
-}
-
-#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
-template<class T1, class T2> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_TWO_ARG_CONTAINER(std::vector)
-OUTPUT_TWO_ARG_CONTAINER(std::deque)
-OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
-OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
-#endif
-
-#undef OUTPUT_TWO_ARG_CONTAINER
-
-#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_THREE_ARG_CONTAINER(std::set)
-OUTPUT_THREE_ARG_CONTAINER(std::multiset)
-
-#undef OUTPUT_THREE_ARG_CONTAINER
-
-#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_FOUR_ARG_CONTAINER(std::map)
-OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
-#ifdef __GNUC__
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
-#endif
-
-#undef OUTPUT_FOUR_ARG_CONTAINER
-
-#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4, class T5> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-#ifdef __GNUC__
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
-#endif
-
-#undef OUTPUT_FIVE_ARG_CONTAINER
-
-#endif  // UTIL_GTL_STL_LOGGING_INL_H_

+ 0 - 133
Src/ThirdParty/glog/src/windows/glog/vlog_is_on.h

@@ -1,133 +0,0 @@
-// This file is automatically generated from src/glog/vlog_is_on.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Defines the VLOG_IS_ON macro that controls the variable-verbosity
-// conditional logging.
-//
-// It's used by VLOG and VLOG_IF in logging.h
-// and by RAW_VLOG in raw_logging.h to trigger the logging.
-//
-// It can also be used directly e.g. like this:
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished e.g. via just VLOG(2) << ...;
-//   }
-//
-// The truth value that VLOG_IS_ON(level) returns is determined by 
-// the three verbosity level flags:
-//   --v=<n>  Gives the default maximal active V-logging level;
-//            0 is the default.
-//            Normally positive values are used for V-logging levels.
-//   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
-//                    the value given by --v.
-//                    E.g. "my_module=2,foo*=3" would change the logging level
-//                    for all code in source files "my_module.*" and "foo*.*"
-//                    ("-inl" suffixes are also disregarded for this matching).
-//
-// SetVLOGLevel helper function is provided to do limited dynamic control over
-// V-logging by overriding the per-module settings given via --vmodule flag.
-//
-// CAVEAT: --vmodule functionality is not available in non gcc compilers.
-//
-
-#ifndef BASE_VLOG_IS_ON_H_
-#define BASE_VLOG_IS_ON_H_
-
-#include "glog/log_severity.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-#if defined(__GNUC__)
-// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
-// (Normally) the first time every VLOG_IS_ON(n) site is hit,
-// we determine what variable will dynamically control logging at this site:
-// it's either FLAGS_v or an appropriate internal variable
-// matching the current source file that represents results of
-// parsing of --vmodule flag and/or SetVLOGLevel calls.
-#define VLOG_IS_ON(verboselevel)                                \
-  __extension__  \
-  ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
-     google::int32 verbose_level__ = (verboselevel);                    \
-     (*vlocal__ >= verbose_level__) &&                          \
-     ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
-      (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
-                   __FILE__, verbose_level__))); })
-#else
-// GNU extensions not available, so we do not support --vmodule.
-// Dynamic value of FLAGS_v always controls the logging level.
-#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
-#endif
-
-// Set VLOG(_IS_ON) level for module_pattern to log_level.
-// This lets us dynamically control what is normally set by the --vmodule flag.
-// Returns the level that previously applied to module_pattern.
-// NOTE: To change the log level for VLOG(_IS_ON) sites
-//	 that have already executed after/during InitGoogleLogging,
-//	 one needs to supply the exact --vmodule pattern that applied to them.
-//       (If no --vmodule pattern applied to them
-//       the value of FLAGS_v will continue to control them.)
-extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
-                                             int log_level);
-
-// Various declarations needed for VLOG_IS_ON above: =========================
-
-// Special value used to indicate that a VLOG_IS_ON site has not been
-// initialized.  We make this a large value, so the common-case check
-// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
-// passes in such cases and InitVLOG3__ is then triggered.
-extern google::int32 kLogSiteUninitialized;
-
-// Helper routine which determines the logging info for a particalur VLOG site.
-//   site_flag     is the address of the site-local pointer to the controlling
-//                 verbosity level
-//   site_default  is the default to use for *site_flag
-//   fname         is the current source file name
-//   verbose_level is the argument to VLOG_IS_ON
-// We will return the return value for VLOG_IS_ON
-// and if possible set *site_flag appropriately.
-extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
-    google::int32** site_flag,
-    google::int32* site_default,
-    const char* fname,
-    google::int32 verbose_level);
-
-#endif  // BASE_VLOG_IS_ON_H_

+ 0 - 64
Src/ThirdParty/glog/src/windows/port.cc

@@ -1,64 +0,0 @@
-/* Copyright (c) 2008, Google Inc.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- * Copied from google-perftools and modified by Shinichiro Hamaji
- */
-
-#ifndef _WIN32
-# error You should only be including windows/port.cc in a windows environment!
-#endif
-
-#include "config.h"
-#include <stdarg.h>    // for va_list, va_start, va_end
-#include <string.h>    // for strstr()
-#include <assert.h>
-#include <string>
-#include <vector>
-#include "port.h"
-
-using std::string;
-using std::vector;
-
-// These call the windows _vsnprintf, but always NUL-terminate.
-int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
-  if (size == 0)        // not even room for a \0?
-    return -1;          // not what C99 says to do, but what windows does
-  str[size-1] = '\0';
-  return _vsnprintf(str, size-1, format, ap);
-}
-
-int snprintf(char *str, size_t size, const char *format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  const int r = vsnprintf(str, size, format, ap);
-  va_end(ap);
-  return r;
-}

+ 0 - 149
Src/ThirdParty/glog/src/windows/port.h

@@ -1,149 +0,0 @@
-/* Copyright (c) 2008, Google Inc.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- * Copied from google-perftools and modified by Shinichiro Hamaji
- *
- * These are some portability typedefs and defines to make it a bit
- * easier to compile this code under VC++.
- *
- * Several of these are taken from glib:
- *    http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html
- */
-
-#ifndef CTEMPLATE_WINDOWS_PORT_H_
-#define CTEMPLATE_WINDOWS_PORT_H_
-
-#include "config.h"
-
-#ifdef _WIN32
-
-#define WIN32_LEAN_AND_MEAN  /* We always want minimal includes */
-#include <windows.h>
-#include <winsock.h>         /* for gethostname */
-#include <io.h>              /* because we so often use open/close/etc */
-#include <direct.h>          /* for _getcwd() */
-#include <process.h>         /* for _getpid() */
-#include <stdio.h>           /* read in vsnprintf decl. before redifining it */
-#include <stdarg.h>          /* template_dictionary.cc uses va_copy */
-#include <string.h>          /* for _strnicmp(), strerror_s() */
-#include <time.h>            /* for localtime_s() */
-/* Note: the C++ #includes are all together at the bottom.  This file is
- * used by both C and C++ code, so we put all the C++ together.
- */
-
-/* 4244: otherwise we get problems when substracting two size_t's to an int
- * 4251: it's complaining about a private struct I've chosen not to dllexport
- * 4355: we use this in a constructor, but we do it safely
- * 4715: for some reason VC++ stopped realizing you can't return after abort()
- * 4800: we know we're casting ints/char*'s to bools, and we're ok with that
- * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
- */
-#pragma warning(disable:4244 4251 4355 4715 4800 4996)
-
-/* file I/O */
-#define PATH_MAX 1024
-#define access  _access
-#define getcwd  _getcwd
-#define open    _open
-#define read    _read
-#define write   _write
-#define lseek   _lseek
-#define close   _close
-#define popen   _popen
-#define pclose  _pclose
-#define R_OK    04           /* read-only (for access()) */
-#define S_ISDIR(m)  (((m) & _S_IFMT) == _S_IFDIR)
-#ifndef __MINGW32__
-enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
-#endif
-#define S_IRUSR S_IREAD
-#define S_IWUSR S_IWRITE
-
-/* Not quite as lightweight as a hard-link, but more than good enough for us. */
-#define link(oldpath, newpath)  CopyFileA(oldpath, newpath, false)
-
-#define strcasecmp   _stricmp
-#define strncasecmp  _strnicmp
-
-/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */
-#define hash  hash_compare
-
-/* Sleep is in ms, on windows */
-#define sleep(secs)  Sleep((secs) * 1000)
-
-/* We can't just use _vsnprintf and _snprintf as drop-in-replacements,
- * because they don't always NUL-terminate. :-(  We also can't use the
- * name vsnprintf, since windows defines that (but not snprintf (!)).
- */
-extern int snprintf(char *str, size_t size,
-                                       const char *format, ...);
-extern int safe_vsnprintf(char *str, size_t size,
-                          const char *format, va_list ap);
-#define vsnprintf(str, size, format, ap)  safe_vsnprintf(str, size, format, ap)
-#define va_copy(dst, src)  (dst) = (src)
-
-/* Windows doesn't support specifying the number of buckets as a
- * hash_map constructor arg, so we leave this blank.
- */
-#define CTEMPLATE_SMALL_HASHTABLE
-
-#define DEFAULT_TEMPLATE_ROOTDIR  ".."
-
-// ----------------------------------- SYSTEM/PROCESS
-typedef int pid_t;
-#define getpid  _getpid
-
-// ----------------------------------- THREADS
-typedef DWORD pthread_t;
-typedef DWORD pthread_key_t;
-typedef LONG pthread_once_t;
-enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
-#define pthread_self  GetCurrentThreadId
-#define pthread_equal(pthread_t_1, pthread_t_2)  ((pthread_t_1)==(pthread_t_2))
-
-inline struct tm* localtime_r(const time_t* timep, struct tm* result) {
-  localtime_s(result, timep);
-  return result;
-}
-
-inline char* strerror_r(int errnum, char* buf, size_t buflen) {
-  strerror_s(buf, buflen, errnum);
-  return buf;
-}
-
-#ifndef __cplusplus
-/* I don't see how to get inlining for C code in MSVC.  Ah well. */
-#define inline
-#endif
-
-#endif  /* _WIN32 */
-
-#endif  /* CTEMPLATE_WINDOWS_PORT_H_ */

+ 0 - 118
Src/ThirdParty/glog/src/windows/preprocess.sh

@@ -1,118 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2008, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# ---
-# Author: Craig Silverstein
-# Copied from google-perftools and modified by Shinichiro Hamaji
-#
-# This script is meant to be run at distribution-generation time, for
-# instance by autogen.sh.  It does some of the work configure would
-# normally do, for windows systems.  In particular, it expands all the
-# @...@ variables found in .in files, and puts them here, in the windows
-# directory.
-#
-# This script should be run before any new release.
-
-if [ -z "$1" ]; then
-   echo "USAGE: $0 <src/ directory>"
-   exit 1
-fi
-
-DLLDEF_MACRO_NAME="GLOG_DLL_DECL"
-
-# The text we put in every .h files we create.  As a courtesy, we'll
-# include a helpful comment for windows users as to how to use
-# GLOG_DLL_DECL.  Apparently sed expands \n into a newline.  Good!
-DLLDEF_DEFINES="\
-// NOTE: if you are statically linking the template library into your binary\n\
-// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\
-// as a compiler flag in your project file to turn off the dllimports.\n\
-#ifndef $DLLDEF_MACRO_NAME\n\
-# define $DLLDEF_MACRO_NAME  __declspec(dllimport)\n\
-#endif"
-
-# Read all the windows config info into variables
-# In order for the 'set' to take, this requires putting all in a subshell.
-(
-  while read define varname value; do
-    [ "$define" != "#define" ] && continue
-    eval "$varname='$value'"
-  done
-
-  # Process all the .in files in the "glog" subdirectory
-  mkdir -p "$1/windows/glog"
-  for file in `echo "$1"/glog/*.in`; do
-     echo "Processing $file"
-     outfile="$1/windows/glog/`basename $file .in`"
-
-     echo "\
-// This file is automatically generated from $file
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-" > "$outfile"
-     # Besides replacing @...@, we also need to turn on dllimport
-     # We also need to replace hash by hash_compare (annoying we hard-code :-( )
-     sed -e "s!@ac_windows_dllexport@!$DLLDEF_MACRO_NAME!g" \
-         -e "s!@ac_windows_dllexport_defines@!$DLLDEF_DEFINES!g" \
-         -e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \
-         -e "s!@ac_cv_cxx_hash_namespace@!$HASH_NAMESPACE!g" \
-         -e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \
-         -e "s!@ac_cv_have_stdint_h@!0!g" \
-         -e "s!@ac_cv_have_systypes_h@!0!g" \
-         -e "s!@ac_cv_have_inttypes_h@!0!g" \
-         -e "s!@ac_cv_have_unistd_h@!0!g" \
-         -e "s!@ac_cv_have_uint16_t@!0!g" \
-         -e "s!@ac_cv_have_u_int16_t@!0!g" \
-         -e "s!@ac_cv_have___uint16@!1!g" \
-         -e "s!@ac_cv_have_libgflags@!0!g" \
-         -e "s!@ac_cv_have___builtin_expect@!0!g" \
-         -e "s!@ac_cv_cxx_using_operator@!1!g" \
-         -e "s!@ac_cv___attribute___noreturn@!!g" \
-         -e "s!@ac_cv___attribute___printf_4_5@!!g" \
-         -e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
-         -e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \
-         -e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \
-         -e "s!@ac_google_start_namespace@!$_START_GOOGLE_NAMESPACE_!g" \
-         -e "s!@ac_htmlparser_namespace@!$HTMLPARSER_NAMESPACE!g" \
-         -e "s!\\bhash\\b!hash_compare!g" \
-         "$file" >> "$outfile"
-  done
-) < "$1/windows/config.h"
-
-# log_severity.h isn't a .in file.
-echo "\
-// This file is automatically generated from $1/glog/log_severity.h
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-" > "$1/windows/glog/log_severity.h"
-cat "$1/glog/log_severity.h" >> "$1/windows/glog/log_severity.h"
-
-echo "DONE"

+ 0 - 154
Src/ThirdParty/glog/stl_logging.h

@@ -1,154 +0,0 @@
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Stream output operators for STL containers; to be used for logging *only*.
-// Inclusion of this file lets you do:
-//
-// list<string> x;
-// LOG(INFO) << "data: " << x;
-// vector<int> v1, v2;
-// CHECK_EQ(v1, v2);
-//
-// Note that if you want to use these operators from the non-global namespace,
-// you may get an error since they are not in namespace std (and they are not
-// in namespace std since that would result in undefined behavior). You may
-// need to write
-//
-//   using ::operator<<;
-//
-// to fix these errors.
-
-#ifndef UTIL_GTL_STL_LOGGING_INL_H_
-#define UTIL_GTL_STL_LOGGING_INL_H_
-
-#if !1
-# error We do not support stl_logging for this compiler
-#endif
-
-#include <deque>
-#include <list>
-#include <map>
-#include <ostream>
-#include <set>
-#include <utility>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_set>
-# include <ext/hash_map>
-# include <ext/slist>
-#endif
-
-template<class First, class Second>
-inline std::ostream& operator<<(std::ostream& out,
-                                const std::pair<First, Second>& p) {
-  out << '(' << p.first << ", " << p.second << ')';
-  return out;
-}
-
-namespace google {
-
-template<class Iter>
-inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
-  using ::operator<<;
-  // Output at most 100 elements -- appropriate if used for logging.
-  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
-    if (i > 0) out << ' ';
-    out << *begin;
-  }
-  if (begin != end) {
-    out << " ...";
-  }
-}
-
-}
-
-#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
-template<class T1, class T2> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_TWO_ARG_CONTAINER(std::vector)
-OUTPUT_TWO_ARG_CONTAINER(std::deque)
-OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
-OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
-#endif
-
-#undef OUTPUT_TWO_ARG_CONTAINER
-
-#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_THREE_ARG_CONTAINER(std::set)
-OUTPUT_THREE_ARG_CONTAINER(std::multiset)
-
-#undef OUTPUT_THREE_ARG_CONTAINER
-
-#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_FOUR_ARG_CONTAINER(std::map)
-OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
-#ifdef __GNUC__
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
-#endif
-
-#undef OUTPUT_FOUR_ARG_CONTAINER
-
-#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4, class T5> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-#ifdef __GNUC__
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
-#endif
-
-#undef OUTPUT_FIVE_ARG_CONTAINER
-
-#endif  // UTIL_GTL_STL_LOGGING_INL_H_

+ 0 - 129
Src/ThirdParty/glog/vlog_is_on.h

@@ -1,129 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Defines the VLOG_IS_ON macro that controls the variable-verbosity
-// conditional logging.
-//
-// It's used by VLOG and VLOG_IF in logging.h
-// and by RAW_VLOG in raw_logging.h to trigger the logging.
-//
-// It can also be used directly e.g. like this:
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished e.g. via just VLOG(2) << ...;
-//   }
-//
-// The truth value that VLOG_IS_ON(level) returns is determined by 
-// the three verbosity level flags:
-//   --v=<n>  Gives the default maximal active V-logging level;
-//            0 is the default.
-//            Normally positive values are used for V-logging levels.
-//   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
-//                    the value given by --v.
-//                    E.g. "my_module=2,foo*=3" would change the logging level
-//                    for all code in source files "my_module.*" and "foo*.*"
-//                    ("-inl" suffixes are also disregarded for this matching).
-//
-// SetVLOGLevel helper function is provided to do limited dynamic control over
-// V-logging by overriding the per-module settings given via --vmodule flag.
-//
-// CAVEAT: --vmodule functionality is not available in non gcc compilers.
-//
-
-#ifndef BASE_VLOG_IS_ON_H_
-#define BASE_VLOG_IS_ON_H_
-
-#include "glog/log_severity.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-#if defined(__GNUC__)
-// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
-// (Normally) the first time every VLOG_IS_ON(n) site is hit,
-// we determine what variable will dynamically control logging at this site:
-// it's either FLAGS_v or an appropriate internal variable
-// matching the current source file that represents results of
-// parsing of --vmodule flag and/or SetVLOGLevel calls.
-#define VLOG_IS_ON(verboselevel)                                \
-  __extension__  \
-  ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
-     google::int32 verbose_level__ = (verboselevel);                    \
-     (*vlocal__ >= verbose_level__) &&                          \
-     ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
-      (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
-                   __FILE__, verbose_level__))); })
-#else
-// GNU extensions not available, so we do not support --vmodule.
-// Dynamic value of FLAGS_v always controls the logging level.
-#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
-#endif
-
-// Set VLOG(_IS_ON) level for module_pattern to log_level.
-// This lets us dynamically control what is normally set by the --vmodule flag.
-// Returns the level that previously applied to module_pattern.
-// NOTE: To change the log level for VLOG(_IS_ON) sites
-//	 that have already executed after/during InitGoogleLogging,
-//	 one needs to supply the exact --vmodule pattern that applied to them.
-//       (If no --vmodule pattern applied to them
-//       the value of FLAGS_v will continue to control them.)
-extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
-                                             int log_level);
-
-// Various declarations needed for VLOG_IS_ON above: =========================
-
-// Special value used to indicate that a VLOG_IS_ON site has not been
-// initialized.  We make this a large value, so the common-case check
-// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
-// passes in such cases and InitVLOG3__ is then triggered.
-extern google::int32 kLogSiteUninitialized;
-
-// Helper routine which determines the logging info for a particalur VLOG site.
-//   site_flag     is the address of the site-local pointer to the controlling
-//                 verbosity level
-//   site_default  is the default to use for *site_flag
-//   fname         is the current source file name
-//   verbose_level is the argument to VLOG_IS_ON
-// We will return the return value for VLOG_IS_ON
-// and if possible set *site_flag appropriately.
-extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
-    google::int32** site_flag,
-    google::int32* site_default,
-    const char* fname,
-    google::int32 verbose_level);
-
-#endif  // BASE_VLOG_IS_ON_H_

+ 0 - 5
Src/ThirdParty/gmock/CMakeLists.txt

@@ -1,5 +0,0 @@
-SET(Gmock src/gmock-all.cc)
-
-INCLUDE_DIRECTORIES(.)
-
-ADD_LIBRARY(Gmock ${Gmock})

+ 0 - 1076
Src/ThirdParty/gmock/gmock-actions.h

@@ -1,1076 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some commonly used actions.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
-
-#include <algorithm>
-#include <string>
-
-#ifndef _WIN32_WCE
-# include <errno.h>
-#endif
-
-#include "gmock/internal/gmock-internal-utils.h"
-#include "gmock/internal/gmock-port.h"
-
-namespace testing {
-
-// To implement an action Foo, define:
-//   1. a class FooAction that implements the ActionInterface interface, and
-//   2. a factory function that creates an Action object from a
-//      const FooAction*.
-//
-// The two-level delegation design follows that of Matcher, providing
-// consistency for extension developers.  It also eases ownership
-// management as Action objects can now be copied like plain values.
-
-namespace internal {
-
-template <typename F1, typename F2>
-class ActionAdaptor;
-
-// BuiltInDefaultValue<T>::Get() returns the "built-in" default
-// value for type T, which is NULL when T is a pointer type, 0 when T
-// is a numeric type, false when T is bool, or "" when T is string or
-// std::string.  For any other type T, this value is undefined and the
-// function will abort the process.
-template <typename T>
-class BuiltInDefaultValue {
- public:
-  // This function returns true iff type T has a built-in default value.
-  static bool Exists() { return false; }
-  static T Get() {
-    Assert(false, __FILE__, __LINE__,
-           "Default action undefined for the function return type.");
-    return internal::Invalid<T>();
-    // The above statement will never be reached, but is required in
-    // order for this function to compile.
-  }
-};
-
-// This partial specialization says that we use the same built-in
-// default value for T and const T.
-template <typename T>
-class BuiltInDefaultValue<const T> {
- public:
-  static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }
-  static T Get() { return BuiltInDefaultValue<T>::Get(); }
-};
-
-// This partial specialization defines the default values for pointer
-// types.
-template <typename T>
-class BuiltInDefaultValue<T*> {
- public:
-  static bool Exists() { return true; }
-  static T* Get() { return NULL; }
-};
-
-// The following specializations define the default values for
-// specific types we care about.
-#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
-  template <> \
-  class BuiltInDefaultValue<type> { \
-   public: \
-    static bool Exists() { return true; } \
-    static type Get() { return value; } \
-  }
-
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, );  // NOLINT
-#if GTEST_HAS_GLOBAL_STRING
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
-#endif  // GTEST_HAS_GLOBAL_STRING
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0');
-
-// There's no need for a default action for signed wchar_t, as that
-// type is the same as wchar_t for gcc, and invalid for MSVC.
-//
-// There's also no need for a default action for unsigned wchar_t, as
-// that type is the same as unsigned int for gcc, and invalid for
-// MSVC.
-#if GMOCK_WCHAR_T_IS_NATIVE_
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U);  // NOLINT
-#endif
-
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U);  // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0);     // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL);  // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L);     // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
-
-#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
-
-}  // namespace internal
-
-// When an unexpected function call is encountered, Google Mock will
-// let it return a default value if the user has specified one for its
-// return type, or if the return type has a built-in default value;
-// otherwise Google Mock won't know what value to return and will have
-// to abort the process.
-//
-// The DefaultValue<T> class allows a user to specify the
-// default value for a type T that is both copyable and publicly
-// destructible (i.e. anything that can be used as a function return
-// type).  The usage is:
-//
-//   // Sets the default value for type T to be foo.
-//   DefaultValue<T>::Set(foo);
-template <typename T>
-class DefaultValue {
- public:
-  // Sets the default value for type T; requires T to be
-  // copy-constructable and have a public destructor.
-  static void Set(T x) {
-    delete value_;
-    value_ = new T(x);
-  }
-
-  // Unsets the default value for type T.
-  static void Clear() {
-    delete value_;
-    value_ = NULL;
-  }
-
-  // Returns true iff the user has set the default value for type T.
-  static bool IsSet() { return value_ != NULL; }
-
-  // Returns true if T has a default return value set by the user or there
-  // exists a built-in default value.
-  static bool Exists() {
-    return IsSet() || internal::BuiltInDefaultValue<T>::Exists();
-  }
-
-  // Returns the default value for type T if the user has set one;
-  // otherwise returns the built-in default value if there is one;
-  // otherwise aborts the process.
-  static T Get() {
-    return value_ == NULL ?
-        internal::BuiltInDefaultValue<T>::Get() : *value_;
-  }
- private:
-  static const T* value_;
-};
-
-// This partial specialization allows a user to set default values for
-// reference types.
-template <typename T>
-class DefaultValue<T&> {
- public:
-  // Sets the default value for type T&.
-  static void Set(T& x) {  // NOLINT
-    address_ = &x;
-  }
-
-  // Unsets the default value for type T&.
-  static void Clear() {
-    address_ = NULL;
-  }
-
-  // Returns true iff the user has set the default value for type T&.
-  static bool IsSet() { return address_ != NULL; }
-
-  // Returns true if T has a default return value set by the user or there
-  // exists a built-in default value.
-  static bool Exists() {
-    return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();
-  }
-
-  // Returns the default value for type T& if the user has set one;
-  // otherwise returns the built-in default value if there is one;
-  // otherwise aborts the process.
-  static T& Get() {
-    return address_ == NULL ?
-        internal::BuiltInDefaultValue<T&>::Get() : *address_;
-  }
- private:
-  static T* address_;
-};
-
-// This specialization allows DefaultValue<void>::Get() to
-// compile.
-template <>
-class DefaultValue<void> {
- public:
-  static bool Exists() { return true; }
-  static void Get() {}
-};
-
-// Points to the user-set default value for type T.
-template <typename T>
-const T* DefaultValue<T>::value_ = NULL;
-
-// Points to the user-set default value for type T&.
-template <typename T>
-T* DefaultValue<T&>::address_ = NULL;
-
-// Implement this interface to define an action for function type F.
-template <typename F>
-class ActionInterface {
- public:
-  typedef typename internal::Function<F>::Result Result;
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  ActionInterface() {}
-  virtual ~ActionInterface() {}
-
-  // Performs the action.  This method is not const, as in general an
-  // action can have side effects and be stateful.  For example, a
-  // get-the-next-element-from-the-collection action will need to
-  // remember the current element.
-  virtual Result Perform(const ArgumentTuple& args) = 0;
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
-};
-
-// An Action<F> is a copyable and IMMUTABLE (except by assignment)
-// object that represents an action to be taken when a mock function
-// of type F is called.  The implementation of Action<T> is just a
-// linked_ptr to const ActionInterface<T>, so copying is fairly cheap.
-// Don't inherit from Action!
-//
-// You can view an object implementing ActionInterface<F> as a
-// concrete action (including its current state), and an Action<F>
-// object as a handle to it.
-template <typename F>
-class Action {
- public:
-  typedef typename internal::Function<F>::Result Result;
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  // Constructs a null Action.  Needed for storing Action objects in
-  // STL containers.
-  Action() : impl_(NULL) {}
-
-  // Constructs an Action from its implementation.  A NULL impl is
-  // used to represent the "do-default" action.
-  explicit Action(ActionInterface<F>* impl) : impl_(impl) {}
-
-  // Copy constructor.
-  Action(const Action& action) : impl_(action.impl_) {}
-
-  // This constructor allows us to turn an Action<Func> object into an
-  // Action<F>, as long as F's arguments can be implicitly converted
-  // to Func's and Func's return type can be implicitly converted to
-  // F's.
-  template <typename Func>
-  explicit Action(const Action<Func>& action);
-
-  // Returns true iff this is the DoDefault() action.
-  bool IsDoDefault() const { return impl_.get() == NULL; }
-
-  // Performs the action.  Note that this method is const even though
-  // the corresponding method in ActionInterface is not.  The reason
-  // is that a const Action<F> means that it cannot be re-bound to
-  // another concrete action, not that the concrete action it binds to
-  // cannot change state.  (Think of the difference between a const
-  // pointer and a pointer to const.)
-  Result Perform(const ArgumentTuple& args) const {
-    internal::Assert(
-        !IsDoDefault(), __FILE__, __LINE__,
-        "You are using DoDefault() inside a composite action like "
-        "DoAll() or WithArgs().  This is not supported for technical "
-        "reasons.  Please instead spell out the default action, or "
-        "assign the default action to an Action variable and use "
-        "the variable in various places.");
-    return impl_->Perform(args);
-  }
-
- private:
-  template <typename F1, typename F2>
-  friend class internal::ActionAdaptor;
-
-  internal::linked_ptr<ActionInterface<F> > impl_;
-};
-
-// The PolymorphicAction class template makes it easy to implement a
-// polymorphic action (i.e. an action that can be used in mock
-// functions of than one type, e.g. Return()).
-//
-// To define a polymorphic action, a user first provides a COPYABLE
-// implementation class that has a Perform() method template:
-//
-//   class FooAction {
-//    public:
-//     template <typename Result, typename ArgumentTuple>
-//     Result Perform(const ArgumentTuple& args) const {
-//       // Processes the arguments and returns a result, using
-//       // tr1::get<N>(args) to get the N-th (0-based) argument in the tuple.
-//     }
-//     ...
-//   };
-//
-// Then the user creates the polymorphic action using
-// MakePolymorphicAction(object) where object has type FooAction.  See
-// the definition of Return(void) and SetArgumentPointee<N>(value) for
-// complete examples.
-template <typename Impl>
-class PolymorphicAction {
- public:
-  explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}
-
-  template <typename F>
-  operator Action<F>() const {
-    return Action<F>(new MonomorphicImpl<F>(impl_));
-  }
-
- private:
-  template <typename F>
-  class MonomorphicImpl : public ActionInterface<F> {
-   public:
-    typedef typename internal::Function<F>::Result Result;
-    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
-
-    virtual Result Perform(const ArgumentTuple& args) {
-      return impl_.template Perform<Result>(args);
-    }
-
-   private:
-    Impl impl_;
-
-    GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
-  };
-
-  Impl impl_;
-
-  GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
-};
-
-// Creates an Action from its implementation and returns it.  The
-// created Action object owns the implementation.
-template <typename F>
-Action<F> MakeAction(ActionInterface<F>* impl) {
-  return Action<F>(impl);
-}
-
-// Creates a polymorphic action from its implementation.  This is
-// easier to use than the PolymorphicAction<Impl> constructor as it
-// doesn't require you to explicitly write the template argument, e.g.
-//
-//   MakePolymorphicAction(foo);
-// vs
-//   PolymorphicAction<TypeOfFoo>(foo);
-template <typename Impl>
-inline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {
-  return PolymorphicAction<Impl>(impl);
-}
-
-namespace internal {
-
-// Allows an Action<F2> object to pose as an Action<F1>, as long as F2
-// and F1 are compatible.
-template <typename F1, typename F2>
-class ActionAdaptor : public ActionInterface<F1> {
- public:
-  typedef typename internal::Function<F1>::Result Result;
-  typedef typename internal::Function<F1>::ArgumentTuple ArgumentTuple;
-
-  explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}
-
-  virtual Result Perform(const ArgumentTuple& args) {
-    return impl_->Perform(args);
-  }
-
- private:
-  const internal::linked_ptr<ActionInterface<F2> > impl_;
-
-  GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
-};
-
-// Implements the polymorphic Return(x) action, which can be used in
-// any function that returns the type of x, regardless of the argument
-// types.
-//
-// Note: The value passed into Return must be converted into
-// Function<F>::Result when this action is cast to Action<F> rather than
-// when that action is performed. This is important in scenarios like
-//
-// MOCK_METHOD1(Method, T(U));
-// ...
-// {
-//   Foo foo;
-//   X x(&foo);
-//   EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));
-// }
-//
-// In the example above the variable x holds reference to foo which leaves
-// scope and gets destroyed.  If copying X just copies a reference to foo,
-// that copy will be left with a hanging reference.  If conversion to T
-// makes a copy of foo, the above code is safe. To support that scenario, we
-// need to make sure that the type conversion happens inside the EXPECT_CALL
-// statement, and conversion of the result of Return to Action<T(U)> is a
-// good place for that.
-//
-template <typename R>
-class ReturnAction {
- public:
-  // Constructs a ReturnAction object from the value to be returned.
-  // 'value' is passed by value instead of by const reference in order
-  // to allow Return("string literal") to compile.
-  explicit ReturnAction(R value) : value_(value) {}
-
-  // This template type conversion operator allows Return(x) to be
-  // used in ANY function that returns x's type.
-  template <typename F>
-  operator Action<F>() const {
-    // Assert statement belongs here because this is the best place to verify
-    // conditions on F. It produces the clearest error messages
-    // in most compilers.
-    // Impl really belongs in this scope as a local class but can't
-    // because MSVC produces duplicate symbols in different translation units
-    // in this case. Until MS fixes that bug we put Impl into the class scope
-    // and put the typedef both here (for use in assert statement) and
-    // in the Impl class. But both definitions must be the same.
-    typedef typename Function<F>::Result Result;
-    GTEST_COMPILE_ASSERT_(
-        !internal::is_reference<Result>::value,
-        use_ReturnRef_instead_of_Return_to_return_a_reference);
-    return Action<F>(new Impl<F>(value_));
-  }
-
- private:
-  // Implements the Return(x) action for a particular function type F.
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename Function<F>::Result Result;
-    typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-
-    // The implicit cast is necessary when Result has more than one
-    // single-argument constructor (e.g. Result is std::vector<int>) and R
-    // has a type conversion operator template.  In that case, value_(value)
-    // won't compile as the compiler doesn't known which constructor of
-    // Result to call.  ImplicitCast_ forces the compiler to convert R to
-    // Result without considering explicit constructors, thus resolving the
-    // ambiguity. value_ is then initialized using its copy constructor.
-    explicit Impl(R value)
-        : value_(::testing::internal::ImplicitCast_<Result>(value)) {}
-
-    virtual Result Perform(const ArgumentTuple&) { return value_; }
-
-   private:
-    GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
-                          Result_cannot_be_a_reference_type);
-    Result value_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  R value_;
-
-  GTEST_DISALLOW_ASSIGN_(ReturnAction);
-};
-
-// Implements the ReturnNull() action.
-class ReturnNullAction {
- public:
-  // Allows ReturnNull() to be used in any pointer-returning function.
-  template <typename Result, typename ArgumentTuple>
-  static Result Perform(const ArgumentTuple&) {
-    GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,
-                          ReturnNull_can_be_used_to_return_a_pointer_only);
-    return NULL;
-  }
-};
-
-// Implements the Return() action.
-class ReturnVoidAction {
- public:
-  // Allows Return() to be used in any void-returning function.
-  template <typename Result, typename ArgumentTuple>
-  static void Perform(const ArgumentTuple&) {
-    CompileAssertTypesEqual<void, Result>();
-  }
-};
-
-// Implements the polymorphic ReturnRef(x) action, which can be used
-// in any function that returns a reference to the type of x,
-// regardless of the argument types.
-template <typename T>
-class ReturnRefAction {
- public:
-  // Constructs a ReturnRefAction object from the reference to be returned.
-  explicit ReturnRefAction(T& ref) : ref_(ref) {}  // NOLINT
-
-  // This template type conversion operator allows ReturnRef(x) to be
-  // used in ANY function that returns a reference to x's type.
-  template <typename F>
-  operator Action<F>() const {
-    typedef typename Function<F>::Result Result;
-    // Asserts that the function return type is a reference.  This
-    // catches the user error of using ReturnRef(x) when Return(x)
-    // should be used, and generates some helpful error message.
-    GTEST_COMPILE_ASSERT_(internal::is_reference<Result>::value,
-                          use_Return_instead_of_ReturnRef_to_return_a_value);
-    return Action<F>(new Impl<F>(ref_));
-  }
-
- private:
-  // Implements the ReturnRef(x) action for a particular function type F.
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename Function<F>::Result Result;
-    typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-
-    explicit Impl(T& ref) : ref_(ref) {}  // NOLINT
-
-    virtual Result Perform(const ArgumentTuple&) {
-      return ref_;
-    }
-
-   private:
-    T& ref_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  T& ref_;
-
-  GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
-};
-
-// Implements the polymorphic ReturnRefOfCopy(x) action, which can be
-// used in any function that returns a reference to the type of x,
-// regardless of the argument types.
-template <typename T>
-class ReturnRefOfCopyAction {
- public:
-  // Constructs a ReturnRefOfCopyAction object from the reference to
-  // be returned.
-  explicit ReturnRefOfCopyAction(const T& value) : value_(value) {}  // NOLINT
-
-  // This template type conversion operator allows ReturnRefOfCopy(x) to be
-  // used in ANY function that returns a reference to x's type.
-  template <typename F>
-  operator Action<F>() const {
-    typedef typename Function<F>::Result Result;
-    // Asserts that the function return type is a reference.  This
-    // catches the user error of using ReturnRefOfCopy(x) when Return(x)
-    // should be used, and generates some helpful error message.
-    GTEST_COMPILE_ASSERT_(
-        internal::is_reference<Result>::value,
-        use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);
-    return Action<F>(new Impl<F>(value_));
-  }
-
- private:
-  // Implements the ReturnRefOfCopy(x) action for a particular function type F.
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename Function<F>::Result Result;
-    typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-
-    explicit Impl(const T& value) : value_(value) {}  // NOLINT
-
-    virtual Result Perform(const ArgumentTuple&) {
-      return value_;
-    }
-
-   private:
-    T value_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  const T value_;
-
-  GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction);
-};
-
-// Implements the polymorphic DoDefault() action.
-class DoDefaultAction {
- public:
-  // This template type conversion operator allows DoDefault() to be
-  // used in any function.
-  template <typename F>
-  operator Action<F>() const { return Action<F>(NULL); }
-};
-
-// Implements the Assign action to set a given pointer referent to a
-// particular value.
-template <typename T1, typename T2>
-class AssignAction {
- public:
-  AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}
-
-  template <typename Result, typename ArgumentTuple>
-  void Perform(const ArgumentTuple& /* args */) const {
-    *ptr_ = value_;
-  }
-
- private:
-  T1* const ptr_;
-  const T2 value_;
-
-  GTEST_DISALLOW_ASSIGN_(AssignAction);
-};
-
-#if !GTEST_OS_WINDOWS_MOBILE
-
-// Implements the SetErrnoAndReturn action to simulate return from
-// various system calls and libc functions.
-template <typename T>
-class SetErrnoAndReturnAction {
- public:
-  SetErrnoAndReturnAction(int errno_value, T result)
-      : errno_(errno_value),
-        result_(result) {}
-  template <typename Result, typename ArgumentTuple>
-  Result Perform(const ArgumentTuple& /* args */) const {
-    errno = errno_;
-    return result_;
-  }
-
- private:
-  const int errno_;
-  const T result_;
-
-  GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
-};
-
-#endif  // !GTEST_OS_WINDOWS_MOBILE
-
-// Implements the SetArgumentPointee<N>(x) action for any function
-// whose N-th argument (0-based) is a pointer to x's type.  The
-// template parameter kIsProto is true iff type A is ProtocolMessage,
-// proto2::Message, or a sub-class of those.
-template <size_t N, typename A, bool kIsProto>
-class SetArgumentPointeeAction {
- public:
-  // Constructs an action that sets the variable pointed to by the
-  // N-th function argument to 'value'.
-  explicit SetArgumentPointeeAction(const A& value) : value_(value) {}
-
-  template <typename Result, typename ArgumentTuple>
-  void Perform(const ArgumentTuple& args) const {
-    CompileAssertTypesEqual<void, Result>();
-    *::std::tr1::get<N>(args) = value_;
-  }
-
- private:
-  const A value_;
-
-  GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
-};
-
-template <size_t N, typename Proto>
-class SetArgumentPointeeAction<N, Proto, true> {
- public:
-  // Constructs an action that sets the variable pointed to by the
-  // N-th function argument to 'proto'.  Both ProtocolMessage and
-  // proto2::Message have the CopyFrom() method, so the same
-  // implementation works for both.
-  explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) {
-    proto_->CopyFrom(proto);
-  }
-
-  template <typename Result, typename ArgumentTuple>
-  void Perform(const ArgumentTuple& args) const {
-    CompileAssertTypesEqual<void, Result>();
-    ::std::tr1::get<N>(args)->CopyFrom(*proto_);
-  }
-
- private:
-  const internal::linked_ptr<Proto> proto_;
-
-  GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
-};
-
-// Implements the InvokeWithoutArgs(f) action.  The template argument
-// FunctionImpl is the implementation type of f, which can be either a
-// function pointer or a functor.  InvokeWithoutArgs(f) can be used as an
-// Action<F> as long as f's type is compatible with F (i.e. f can be
-// assigned to a tr1::function<F>).
-template <typename FunctionImpl>
-class InvokeWithoutArgsAction {
- public:
-  // The c'tor makes a copy of function_impl (either a function
-  // pointer or a functor).
-  explicit InvokeWithoutArgsAction(FunctionImpl function_impl)
-      : function_impl_(function_impl) {}
-
-  // Allows InvokeWithoutArgs(f) to be used as any action whose type is
-  // compatible with f.
-  template <typename Result, typename ArgumentTuple>
-  Result Perform(const ArgumentTuple&) { return function_impl_(); }
-
- private:
-  FunctionImpl function_impl_;
-
-  GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
-};
-
-// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.
-template <class Class, typename MethodPtr>
-class InvokeMethodWithoutArgsAction {
- public:
-  InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr)
-      : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
-
-  template <typename Result, typename ArgumentTuple>
-  Result Perform(const ArgumentTuple&) const {
-    return (obj_ptr_->*method_ptr_)();
-  }
-
- private:
-  Class* const obj_ptr_;
-  const MethodPtr method_ptr_;
-
-  GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
-};
-
-// Implements the IgnoreResult(action) action.
-template <typename A>
-class IgnoreResultAction {
- public:
-  explicit IgnoreResultAction(const A& action) : action_(action) {}
-
-  template <typename F>
-  operator Action<F>() const {
-    // Assert statement belongs here because this is the best place to verify
-    // conditions on F. It produces the clearest error messages
-    // in most compilers.
-    // Impl really belongs in this scope as a local class but can't
-    // because MSVC produces duplicate symbols in different translation units
-    // in this case. Until MS fixes that bug we put Impl into the class scope
-    // and put the typedef both here (for use in assert statement) and
-    // in the Impl class. But both definitions must be the same.
-    typedef typename internal::Function<F>::Result Result;
-
-    // Asserts at compile time that F returns void.
-    CompileAssertTypesEqual<void, Result>();
-
-    return Action<F>(new Impl<F>(action_));
-  }
-
- private:
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename internal::Function<F>::Result Result;
-    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-    explicit Impl(const A& action) : action_(action) {}
-
-    virtual void Perform(const ArgumentTuple& args) {
-      // Performs the action and ignores its result.
-      action_.Perform(args);
-    }
-
-   private:
-    // Type OriginalFunction is the same as F except that its return
-    // type is IgnoredValue.
-    typedef typename internal::Function<F>::MakeResultIgnoredValue
-        OriginalFunction;
-
-    const Action<OriginalFunction> action_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  const A action_;
-
-  GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
-};
-
-// A ReferenceWrapper<T> object represents a reference to type T,
-// which can be either const or not.  It can be explicitly converted
-// from, and implicitly converted to, a T&.  Unlike a reference,
-// ReferenceWrapper<T> can be copied and can survive template type
-// inference.  This is used to support by-reference arguments in the
-// InvokeArgument<N>(...) action.  The idea was from "reference
-// wrappers" in tr1, which we don't have in our source tree yet.
-template <typename T>
-class ReferenceWrapper {
- public:
-  // Constructs a ReferenceWrapper<T> object from a T&.
-  explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {}  // NOLINT
-
-  // Allows a ReferenceWrapper<T> object to be implicitly converted to
-  // a T&.
-  operator T&() const { return *pointer_; }
- private:
-  T* pointer_;
-};
-
-// Allows the expression ByRef(x) to be printed as a reference to x.
-template <typename T>
-void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {
-  T& value = ref;
-  UniversalPrinter<T&>::Print(value, os);
-}
-
-// Does two actions sequentially.  Used for implementing the DoAll(a1,
-// a2, ...) action.
-template <typename Action1, typename Action2>
-class DoBothAction {
- public:
-  DoBothAction(Action1 action1, Action2 action2)
-      : action1_(action1), action2_(action2) {}
-
-  // This template type conversion operator allows DoAll(a1, ..., a_n)
-  // to be used in ANY function of compatible type.
-  template <typename F>
-  operator Action<F>() const {
-    return Action<F>(new Impl<F>(action1_, action2_));
-  }
-
- private:
-  // Implements the DoAll(...) action for a particular function type F.
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename Function<F>::Result Result;
-    typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-    typedef typename Function<F>::MakeResultVoid VoidResult;
-
-    Impl(const Action<VoidResult>& action1, const Action<F>& action2)
-        : action1_(action1), action2_(action2) {}
-
-    virtual Result Perform(const ArgumentTuple& args) {
-      action1_.Perform(args);
-      return action2_.Perform(args);
-    }
-
-   private:
-    const Action<VoidResult> action1_;
-    const Action<F> action2_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  Action1 action1_;
-  Action2 action2_;
-
-  GTEST_DISALLOW_ASSIGN_(DoBothAction);
-};
-
-}  // namespace internal
-
-// An Unused object can be implicitly constructed from ANY value.
-// This is handy when defining actions that ignore some or all of the
-// mock function arguments.  For example, given
-//
-//   MOCK_METHOD3(Foo, double(const string& label, double x, double y));
-//   MOCK_METHOD3(Bar, double(int index, double x, double y));
-//
-// instead of
-//
-//   double DistanceToOriginWithLabel(const string& label, double x, double y) {
-//     return sqrt(x*x + y*y);
-//   }
-//   double DistanceToOriginWithIndex(int index, double x, double y) {
-//     return sqrt(x*x + y*y);
-//   }
-//   ...
-//   EXEPCT_CALL(mock, Foo("abc", _, _))
-//       .WillOnce(Invoke(DistanceToOriginWithLabel));
-//   EXEPCT_CALL(mock, Bar(5, _, _))
-//       .WillOnce(Invoke(DistanceToOriginWithIndex));
-//
-// you could write
-//
-//   // We can declare any uninteresting argument as Unused.
-//   double DistanceToOrigin(Unused, double x, double y) {
-//     return sqrt(x*x + y*y);
-//   }
-//   ...
-//   EXEPCT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin));
-//   EXEPCT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));
-typedef internal::IgnoredValue Unused;
-
-// This constructor allows us to turn an Action<From> object into an
-// Action<To>, as long as To's arguments can be implicitly converted
-// to From's and From's return type cann be implicitly converted to
-// To's.
-template <typename To>
-template <typename From>
-Action<To>::Action(const Action<From>& from)
-    : impl_(new internal::ActionAdaptor<To, From>(from)) {}
-
-// Creates an action that returns 'value'.  'value' is passed by value
-// instead of const reference - otherwise Return("string literal")
-// will trigger a compiler error about using array as initializer.
-template <typename R>
-internal::ReturnAction<R> Return(R value) {
-  return internal::ReturnAction<R>(value);
-}
-
-// Creates an action that returns NULL.
-inline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {
-  return MakePolymorphicAction(internal::ReturnNullAction());
-}
-
-// Creates an action that returns from a void function.
-inline PolymorphicAction<internal::ReturnVoidAction> Return() {
-  return MakePolymorphicAction(internal::ReturnVoidAction());
-}
-
-// Creates an action that returns the reference to a variable.
-template <typename R>
-inline internal::ReturnRefAction<R> ReturnRef(R& x) {  // NOLINT
-  return internal::ReturnRefAction<R>(x);
-}
-
-// Creates an action that returns the reference to a copy of the
-// argument.  The copy is created when the action is constructed and
-// lives as long as the action.
-template <typename R>
-inline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {
-  return internal::ReturnRefOfCopyAction<R>(x);
-}
-
-// Creates an action that does the default action for the give mock function.
-inline internal::DoDefaultAction DoDefault() {
-  return internal::DoDefaultAction();
-}
-
-// Creates an action that sets the variable pointed by the N-th
-// (0-based) function argument to 'value'.
-template <size_t N, typename T>
-PolymorphicAction<
-  internal::SetArgumentPointeeAction<
-    N, T, internal::IsAProtocolMessage<T>::value> >
-SetArgPointee(const T& x) {
-  return MakePolymorphicAction(internal::SetArgumentPointeeAction<
-      N, T, internal::IsAProtocolMessage<T>::value>(x));
-}
-
-#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
-// This overload allows SetArgPointee() to accept a string literal.
-// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish
-// this overload from the templated version and emit a compile error.
-template <size_t N>
-PolymorphicAction<
-  internal::SetArgumentPointeeAction<N, const char*, false> >
-SetArgPointee(const char* p) {
-  return MakePolymorphicAction(internal::SetArgumentPointeeAction<
-      N, const char*, false>(p));
-}
-
-template <size_t N>
-PolymorphicAction<
-  internal::SetArgumentPointeeAction<N, const wchar_t*, false> >
-SetArgPointee(const wchar_t* p) {
-  return MakePolymorphicAction(internal::SetArgumentPointeeAction<
-      N, const wchar_t*, false>(p));
-}
-#endif
-
-// The following version is DEPRECATED.
-template <size_t N, typename T>
-PolymorphicAction<
-  internal::SetArgumentPointeeAction<
-    N, T, internal::IsAProtocolMessage<T>::value> >
-SetArgumentPointee(const T& x) {
-  return MakePolymorphicAction(internal::SetArgumentPointeeAction<
-      N, T, internal::IsAProtocolMessage<T>::value>(x));
-}
-
-// Creates an action that sets a pointer referent to a given value.
-template <typename T1, typename T2>
-PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
-  return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
-}
-
-#if !GTEST_OS_WINDOWS_MOBILE
-
-// Creates an action that sets errno and returns the appropriate error.
-template <typename T>
-PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
-SetErrnoAndReturn(int errval, T result) {
-  return MakePolymorphicAction(
-      internal::SetErrnoAndReturnAction<T>(errval, result));
-}
-
-#endif  // !GTEST_OS_WINDOWS_MOBILE
-
-// Various overloads for InvokeWithoutArgs().
-
-// Creates an action that invokes 'function_impl' with no argument.
-template <typename FunctionImpl>
-PolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >
-InvokeWithoutArgs(FunctionImpl function_impl) {
-  return MakePolymorphicAction(
-      internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));
-}
-
-// Creates an action that invokes the given method on the given object
-// with no argument.
-template <class Class, typename MethodPtr>
-PolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >
-InvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {
-  return MakePolymorphicAction(
-      internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(
-          obj_ptr, method_ptr));
-}
-
-// Creates an action that performs an_action and throws away its
-// result.  In other words, it changes the return type of an_action to
-// void.  an_action MUST NOT return void, or the code won't compile.
-template <typename A>
-inline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {
-  return internal::IgnoreResultAction<A>(an_action);
-}
-
-// Creates a reference wrapper for the given L-value.  If necessary,
-// you can explicitly specify the type of the reference.  For example,
-// suppose 'derived' is an object of type Derived, ByRef(derived)
-// would wrap a Derived&.  If you want to wrap a const Base& instead,
-// where Base is a base class of Derived, just write:
-//
-//   ByRef<const Base>(derived)
-template <typename T>
-inline internal::ReferenceWrapper<T> ByRef(T& l_value) {  // NOLINT
-  return internal::ReferenceWrapper<T>(l_value);
-}
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_

+ 0 - 146
Src/ThirdParty/gmock/gmock-cardinalities.h

@@ -1,146 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some commonly used cardinalities.  More
-// cardinalities can be defined by the user implementing the
-// CardinalityInterface interface if necessary.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
-
-#include <limits.h>
-#include <ostream>  // NOLINT
-#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-
-// To implement a cardinality Foo, define:
-//   1. a class FooCardinality that implements the
-//      CardinalityInterface interface, and
-//   2. a factory function that creates a Cardinality object from a
-//      const FooCardinality*.
-//
-// The two-level delegation design follows that of Matcher, providing
-// consistency for extension developers.  It also eases ownership
-// management as Cardinality objects can now be copied like plain values.
-
-// The implementation of a cardinality.
-class CardinalityInterface {
- public:
-  virtual ~CardinalityInterface() {}
-
-  // Conservative estimate on the lower/upper bound of the number of
-  // calls allowed.
-  virtual int ConservativeLowerBound() const { return 0; }
-  virtual int ConservativeUpperBound() const { return INT_MAX; }
-
-  // Returns true iff call_count calls will satisfy this cardinality.
-  virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
-
-  // Returns true iff call_count calls will saturate this cardinality.
-  virtual bool IsSaturatedByCallCount(int call_count) const = 0;
-
-  // Describes self to an ostream.
-  virtual void DescribeTo(::std::ostream* os) const = 0;
-};
-
-// A Cardinality is a copyable and IMMUTABLE (except by assignment)
-// object that specifies how many times a mock function is expected to
-// be called.  The implementation of Cardinality is just a linked_ptr
-// to const CardinalityInterface, so copying is fairly cheap.
-// Don't inherit from Cardinality!
-class Cardinality {
- public:
-  // Constructs a null cardinality.  Needed for storing Cardinality
-  // objects in STL containers.
-  Cardinality() {}
-
-  // Constructs a Cardinality from its implementation.
-  explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
-
-  // Conservative estimate on the lower/upper bound of the number of
-  // calls allowed.
-  int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
-  int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
-
-  // Returns true iff call_count calls will satisfy this cardinality.
-  bool IsSatisfiedByCallCount(int call_count) const {
-    return impl_->IsSatisfiedByCallCount(call_count);
-  }
-
-  // Returns true iff call_count calls will saturate this cardinality.
-  bool IsSaturatedByCallCount(int call_count) const {
-    return impl_->IsSaturatedByCallCount(call_count);
-  }
-
-  // Returns true iff call_count calls will over-saturate this
-  // cardinality, i.e. exceed the maximum number of allowed calls.
-  bool IsOverSaturatedByCallCount(int call_count) const {
-    return impl_->IsSaturatedByCallCount(call_count) &&
-        !impl_->IsSatisfiedByCallCount(call_count);
-  }
-
-  // Describes self to an ostream
-  void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
-
-  // Describes the given actual call count to an ostream.
-  static void DescribeActualCallCountTo(int actual_call_count,
-                                        ::std::ostream* os);
- private:
-  internal::linked_ptr<const CardinalityInterface> impl_;
-};
-
-// Creates a cardinality that allows at least n calls.
-Cardinality AtLeast(int n);
-
-// Creates a cardinality that allows at most n calls.
-Cardinality AtMost(int n);
-
-// Creates a cardinality that allows any number of calls.
-Cardinality AnyNumber();
-
-// Creates a cardinality that allows between min and max calls.
-Cardinality Between(int min, int max);
-
-// Creates a cardinality that allows exactly n calls.
-Cardinality Exactly(int n);
-
-// Creates a cardinality from its implementation.
-inline Cardinality MakeCardinality(const CardinalityInterface* c) {
-  return Cardinality(c);
-}
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_

+ 0 - 2419
Src/ThirdParty/gmock/gmock-generated-actions.h

@@ -1,2419 +0,0 @@
-// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
-
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some commonly used variadic actions.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
-
-#include "gmock/gmock-actions.h"
-#include "gmock/internal/gmock-port.h"
-
-namespace testing {
-namespace internal {
-
-// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
-// function or method with the unpacked values, where F is a function
-// type that takes N arguments.
-template <typename Result, typename ArgumentTuple>
-class InvokeHelper;
-
-template <typename R>
-class InvokeHelper<R, ::std::tr1::tuple<> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<>&) {
-    return function();
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<>&) {
-    return (obj_ptr->*method_ptr)();
-  }
-};
-
-template <typename R, typename A1>
-class InvokeHelper<R, ::std::tr1::tuple<A1> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,
-      A3>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,
-      A4>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5, A6>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args), get<5>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5, A6, A7>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,
-                            A7>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args), get<5>(args), get<6>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5, A6, A7, A8>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,
-                            A8>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5, A6, A7, A8, A9>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
-                            A9>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
-        get<8>(args));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9,
-    typename A10>
-class InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
-    A10> > {
- public:
-  template <typename Function>
-  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,
-      A5, A6, A7, A8, A9, A10>& args) {
-    using ::std::tr1::get;
-    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
-        get<9>(args));
-  }
-
-  template <class Class, typename MethodPtr>
-  static R InvokeMethod(Class* obj_ptr,
-                        MethodPtr method_ptr,
-                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
-                            A9, A10>& args) {
-    using ::std::tr1::get;
-    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),
-        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),
-        get<8>(args), get<9>(args));
-  }
-};
-
-// CallableHelper has static methods for invoking "callables",
-// i.e. function pointers and functors.  It uses overloading to
-// provide a uniform interface for invoking different kinds of
-// callables.  In particular, you can use:
-//
-//   CallableHelper<R>::Call(callable, a1, a2, ..., an)
-//
-// to invoke an n-ary callable, where R is its return type.  If an
-// argument, say a2, needs to be passed by reference, you should write
-// ByRef(a2) instead of a2 in the above expression.
-template <typename R>
-class CallableHelper {
- public:
-  // Calls a nullary callable.
-  template <typename Function>
-  static R Call(Function function) { return function(); }
-
-  // Calls a unary callable.
-
-  // We deliberately pass a1 by value instead of const reference here
-  // in case it is a C-string literal.  If we had declared the
-  // parameter as 'const A1& a1' and write Call(function, "Hi"), the
-  // compiler would've thought A1 is 'char[3]', which causes trouble
-  // when you need to copy a value of type A1.  By declaring the
-  // parameter as 'A1 a1', the compiler will correctly infer that A1
-  // is 'const char*' when it sees Call(function, "Hi").
-  //
-  // Since this function is defined inline, the compiler can get rid
-  // of the copying of the arguments.  Therefore the performance won't
-  // be hurt.
-  template <typename Function, typename A1>
-  static R Call(Function function, A1 a1) { return function(a1); }
-
-  // Calls a binary callable.
-  template <typename Function, typename A1, typename A2>
-  static R Call(Function function, A1 a1, A2 a2) {
-    return function(a1, a2);
-  }
-
-  // Calls a ternary callable.
-  template <typename Function, typename A1, typename A2, typename A3>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3) {
-    return function(a1, a2, a3);
-  }
-
-  // Calls a 4-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {
-    return function(a1, a2, a3, a4);
-  }
-
-  // Calls a 5-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
-    return function(a1, a2, a3, a4, a5);
-  }
-
-  // Calls a 6-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5, typename A6>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
-    return function(a1, a2, a3, a4, a5, a6);
-  }
-
-  // Calls a 7-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5, typename A6, typename A7>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
-      A7 a7) {
-    return function(a1, a2, a3, a4, a5, a6, a7);
-  }
-
-  // Calls a 8-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5, typename A6, typename A7, typename A8>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
-      A7 a7, A8 a8) {
-    return function(a1, a2, a3, a4, a5, a6, a7, a8);
-  }
-
-  // Calls a 9-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5, typename A6, typename A7, typename A8,
-      typename A9>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
-      A7 a7, A8 a8, A9 a9) {
-    return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);
-  }
-
-  // Calls a 10-ary callable.
-  template <typename Function, typename A1, typename A2, typename A3,
-      typename A4, typename A5, typename A6, typename A7, typename A8,
-      typename A9, typename A10>
-  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,
-      A7 a7, A8 a8, A9 a9, A10 a10) {
-    return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
-  }
-
-};  // class CallableHelper
-
-// An INTERNAL macro for extracting the type of a tuple field.  It's
-// subject to change without notice - DO NOT USE IN USER CODE!
-#define GMOCK_FIELD_(Tuple, N) \
-    typename ::std::tr1::tuple_element<N, Tuple>::type
-
-// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
-// type of an n-ary function whose i-th (1-based) argument type is the
-// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
-// type, and whose return type is Result.  For example,
-//   SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type
-// is int(bool, long).
-//
-// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
-// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
-// For example,
-//   SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(
-//       ::std::tr1::make_tuple(true, 'a', 2.5))
-// returns ::std::tr1::tuple (2.5, true).
-//
-// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
-// in the range [0, 10].  Duplicates are allowed and they don't have
-// to be in an ascending or descending order.
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5, int k6, int k7, int k8, int k9, int k10>
-class SelectArgs {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
-      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
-      GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),
-      GMOCK_FIELD_(ArgumentTuple, k10));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
-        get<k8>(args), get<k9>(args), get<k10>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple>
-class SelectArgs<Result, ArgumentTuple,
-                 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type();
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& /* args */) {
-    using ::std::tr1::get;
-    return SelectedArgs();
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5, int k6>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
-      GMOCK_FIELD_(ArgumentTuple, k6));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args), get<k6>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5, int k6, int k7>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
-      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5, int k6, int k7, int k8>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
-      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
-      GMOCK_FIELD_(ArgumentTuple, k8));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
-        get<k8>(args));
-  }
-};
-
-template <typename Result, typename ArgumentTuple, int k1, int k2, int k3,
-    int k4, int k5, int k6, int k7, int k8, int k9>
-class SelectArgs<Result, ArgumentTuple,
-                 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {
- public:
-  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),
-      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),
-      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),
-      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),
-      GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
-  typedef typename Function<type>::ArgumentTuple SelectedArgs;
-  static SelectedArgs Select(const ArgumentTuple& args) {
-    using ::std::tr1::get;
-    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
-        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
-        get<k8>(args), get<k9>(args));
-  }
-};
-
-#undef GMOCK_FIELD_
-
-// Implements the WithArgs action.
-template <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,
-    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
-    int k9 = -1, int k10 = -1>
-class WithArgsAction {
- public:
-  explicit WithArgsAction(const InnerAction& action) : action_(action) {}
-
-  template <typename F>
-  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }
-
- private:
-  template <typename F>
-  class Impl : public ActionInterface<F> {
-   public:
-    typedef typename Function<F>::Result Result;
-    typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-
-    explicit Impl(const InnerAction& action) : action_(action) {}
-
-    virtual Result Perform(const ArgumentTuple& args) {
-      return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,
-          k5, k6, k7, k8, k9, k10>::Select(args));
-    }
-
-   private:
-    typedef typename SelectArgs<Result, ArgumentTuple,
-        k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;
-
-    Action<InnerFunctionType> action_;
-  };
-
-  const InnerAction action_;
-
-  GTEST_DISALLOW_ASSIGN_(WithArgsAction);
-};
-
-// A macro from the ACTION* family (defined later in this file)
-// defines an action that can be used in a mock function.  Typically,
-// these actions only care about a subset of the arguments of the mock
-// function.  For example, if such an action only uses the second
-// argument, it can be used in any mock function that takes >= 2
-// arguments where the type of the second argument is compatible.
-//
-// Therefore, the action implementation must be prepared to take more
-// arguments than it needs.  The ExcessiveArg type is used to
-// represent those excessive arguments.  In order to keep the compiler
-// error messages tractable, we define it in the testing namespace
-// instead of testing::internal.  However, this is an INTERNAL TYPE
-// and subject to change without notice, so a user MUST NOT USE THIS
-// TYPE DIRECTLY.
-struct ExcessiveArg {};
-
-// A helper class needed for implementing the ACTION* macros.
-template <typename Result, class Impl>
-class ActionHelper {
- public:
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
-        get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
-        get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,
-      A3>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
-        get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3,
-      A4>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
-        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
-        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4,
-      typename A5>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
-      A5>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
-        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
-        get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4,
-      typename A5, typename A6>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
-      A5, A6>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
-        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
-        get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4,
-      typename A5, typename A6, typename A7>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
-      A5, A6, A7>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
-        A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4,
-      typename A5, typename A6, typename A7, typename A8>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
-      A5, A6, A7, A8>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
-        A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
-        ExcessiveArg());
-  }
-
-  template <typename A0, typename A1, typename A2, typename A3, typename A4,
-      typename A5, typename A6, typename A7, typename A8, typename A9>
-  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,
-      A5, A6, A7, A8, A9>& args) {
-    using ::std::tr1::get;
-    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
-        A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
-        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
-        get<9>(args));
-  }
-};
-
-}  // namespace internal
-
-// Various overloads for Invoke().
-
-// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes
-// the selected arguments of the mock function to an_action and
-// performs it.  It serves as an adaptor between actions with
-// different argument lists.  C++ doesn't support default arguments for
-// function templates, so we have to overload it.
-template <int k1, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1>(action);
-}
-
-template <int k1, int k2, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2>(action);
-}
-
-template <int k1, int k2, int k3, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);
-}
-
-template <int k1, int k2, int k3, int k4, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
-    typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,
-      k7>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,
-      k8>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    int k9, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
-      k9>(action);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    int k9, int k10, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
-    k9, k10>
-WithArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,
-      k9, k10>(action);
-}
-
-// Creates an action that does actions a1, a2, ..., sequentially in
-// each invocation.
-template <typename Action1, typename Action2>
-inline internal::DoBothAction<Action1, Action2>
-DoAll(Action1 a1, Action2 a2) {
-  return internal::DoBothAction<Action1, Action2>(a1, a2);
-}
-
-template <typename Action1, typename Action2, typename Action3>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    Action3> >
-DoAll(Action1 a1, Action2 a2, Action3 a3) {
-  return DoAll(a1, DoAll(a2, a3));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, Action4> > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {
-  return DoAll(a1, DoAll(a2, a3, a4));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    Action5> > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5, typename Action6>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    internal::DoBothAction<Action5, Action6> > > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5, a6));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5, typename Action6, typename Action7>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    internal::DoBothAction<Action5, internal::DoBothAction<Action6,
-    Action7> > > > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
-    Action7 a7) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5, typename Action6, typename Action7,
-    typename Action8>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    internal::DoBothAction<Action5, internal::DoBothAction<Action6,
-    internal::DoBothAction<Action7, Action8> > > > > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
-    Action7 a7, Action8 a8) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5, typename Action6, typename Action7,
-    typename Action8, typename Action9>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    internal::DoBothAction<Action5, internal::DoBothAction<Action6,
-    internal::DoBothAction<Action7, internal::DoBothAction<Action8,
-    Action9> > > > > > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
-    Action7 a7, Action8 a8, Action9 a9) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));
-}
-
-template <typename Action1, typename Action2, typename Action3,
-    typename Action4, typename Action5, typename Action6, typename Action7,
-    typename Action8, typename Action9, typename Action10>
-inline internal::DoBothAction<Action1, internal::DoBothAction<Action2,
-    internal::DoBothAction<Action3, internal::DoBothAction<Action4,
-    internal::DoBothAction<Action5, internal::DoBothAction<Action6,
-    internal::DoBothAction<Action7, internal::DoBothAction<Action8,
-    internal::DoBothAction<Action9, Action10> > > > > > > > >
-DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
-    Action7 a7, Action8 a8, Action9 a9, Action10 a10) {
-  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));
-}
-
-}  // namespace testing
-
-// The ACTION* family of macros can be used in a namespace scope to
-// define custom actions easily.  The syntax:
-//
-//   ACTION(name) { statements; }
-//
-// will define an action with the given name that executes the
-// statements.  The value returned by the statements will be used as
-// the return value of the action.  Inside the statements, you can
-// refer to the K-th (0-based) argument of the mock function by
-// 'argK', and refer to its type by 'argK_type'.  For example:
-//
-//   ACTION(IncrementArg1) {
-//     arg1_type temp = arg1;
-//     return ++(*temp);
-//   }
-//
-// allows you to write
-//
-//   ...WillOnce(IncrementArg1());
-//
-// You can also refer to the entire argument tuple and its type by
-// 'args' and 'args_type', and refer to the mock function type and its
-// return type by 'function_type' and 'return_type'.
-//
-// Note that you don't need to specify the types of the mock function
-// arguments.  However rest assured that your code is still type-safe:
-// you'll get a compiler error if *arg1 doesn't support the ++
-// operator, or if the type of ++(*arg1) isn't compatible with the
-// mock function's return type, for example.
-//
-// Sometimes you'll want to parameterize the action.   For that you can use
-// another macro:
-//
-//   ACTION_P(name, param_name) { statements; }
-//
-// For example:
-//
-//   ACTION_P(Add, n) { return arg0 + n; }
-//
-// will allow you to write:
-//
-//   ...WillOnce(Add(5));
-//
-// Note that you don't need to provide the type of the parameter
-// either.  If you need to reference the type of a parameter named
-// 'foo', you can write 'foo_type'.  For example, in the body of
-// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type
-// of 'n'.
-//
-// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support
-// multi-parameter actions.
-//
-// For the purpose of typing, you can view
-//
-//   ACTION_Pk(Foo, p1, ..., pk) { ... }
-//
-// as shorthand for
-//
-//   template <typename p1_type, ..., typename pk_type>
-//   FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }
-//
-// In particular, you can provide the template type arguments
-// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);
-// although usually you can rely on the compiler to infer the types
-// for you automatically.  You can assign the result of expression
-// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,
-// pk_type>.  This can be useful when composing actions.
-//
-// You can also overload actions with different numbers of parameters:
-//
-//   ACTION_P(Plus, a) { ... }
-//   ACTION_P2(Plus, a, b) { ... }
-//
-// While it's tempting to always use the ACTION* macros when defining
-// a new action, you should also consider implementing ActionInterface
-// or using MakePolymorphicAction() instead, especially if you need to
-// use the action a lot.  While these approaches require more work,
-// they give you more control on the types of the mock function
-// arguments and the action parameters, which in general leads to
-// better compiler error messages that pay off in the long run.  They
-// also allow overloading actions based on parameter types (as opposed
-// to just based on the number of parameters).
-//
-// CAVEAT:
-//
-// ACTION*() can only be used in a namespace scope.  The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates.  The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using ACTION*() inside
-// a function.
-//
-// MORE INFORMATION:
-//
-// To learn more about using these macros, please search for 'ACTION'
-// on http://code.google.com/p/googlemock/wiki/CookBook.
-
-// An internal macro needed for implementing ACTION*().
-#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
-    const args_type& args GTEST_ATTRIBUTE_UNUSED_,\
-    arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_,\
-    arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_,\
-    arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_,\
-    arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_,\
-    arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_,\
-    arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_,\
-    arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_,\
-    arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_,\
-    arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_,\
-    arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_
-
-// Sometimes you want to give an action explicit template parameters
-// that cannot be inferred from its value parameters.  ACTION() and
-// ACTION_P*() don't support that.  ACTION_TEMPLATE() remedies that
-// and can be viewed as an extension to ACTION() and ACTION_P*().
-//
-// The syntax:
-//
-//   ACTION_TEMPLATE(ActionName,
-//                   HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
-//                   AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
-//
-// defines an action template that takes m explicit template
-// parameters and n value parameters.  name_i is the name of the i-th
-// template parameter, and kind_i specifies whether it's a typename,
-// an integral constant, or a template.  p_i is the name of the i-th
-// value parameter.
-//
-// Example:
-//
-//   // DuplicateArg<k, T>(output) converts the k-th argument of the mock
-//   // function to type T and copies it to *output.
-//   ACTION_TEMPLATE(DuplicateArg,
-//                   HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
-//                   AND_1_VALUE_PARAMS(output)) {
-//     *output = T(std::tr1::get<k>(args));
-//   }
-//   ...
-//     int n;
-//     EXPECT_CALL(mock, Foo(_, _))
-//         .WillOnce(DuplicateArg<1, unsigned char>(&n));
-//
-// To create an instance of an action template, write:
-//
-//   ActionName<t1, ..., t_m>(v1, ..., v_n)
-//
-// where the ts are the template arguments and the vs are the value
-// arguments.  The value argument types are inferred by the compiler.
-// If you want to explicitly specify the value argument types, you can
-// provide additional template arguments:
-//
-//   ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
-//
-// where u_i is the desired type of v_i.
-//
-// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the
-// number of value parameters, but not on the number of template
-// parameters.  Without the restriction, the meaning of the following
-// is unclear:
-//
-//   OverloadedAction<int, bool>(x);
-//
-// Are we using a single-template-parameter action where 'bool' refers
-// to the type of x, or are we using a two-template-parameter action
-// where the compiler is asked to infer the type of x?
-//
-// Implementation notes:
-//
-// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and
-// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for
-// implementing ACTION_TEMPLATE.  The main trick we use is to create
-// new macro invocations when expanding a macro.  For example, we have
-//
-//   #define ACTION_TEMPLATE(name, template_params, value_params)
-//       ... GMOCK_INTERNAL_DECL_##template_params ...
-//
-// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)
-// to expand to
-//
-//       ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...
-//
-// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the
-// preprocessor will continue to expand it to
-//
-//       ... typename T ...
-//
-// This technique conforms to the C++ standard and is portable.  It
-// allows us to implement action templates using O(N) code, where N is
-// the maximum number of template/value parameters supported.  Without
-// using it, we'd have to devote O(N^2) amount of code to implement all
-// combinations of m and n.
-
-// Declares the template parameters.
-#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
-#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
-    name1) kind0 name0, kind1 name1
-#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2) kind0 name0, kind1 name1, kind2 name2
-#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
-    kind3 name3
-#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
-    kind2 name2, kind3 name3, kind4 name4
-#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
-    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
-#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
-    name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
-    kind5 name5, kind6 name6
-#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
-    kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
-    kind4 name4, kind5 name5, kind6 name6, kind7 name7
-#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
-    kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
-    kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
-    kind8 name8
-#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
-    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
-    name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
-    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
-    kind6 name6, kind7 name7, kind8 name8, kind9 name9
-
-// Lists the template parameters.
-#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
-#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
-    name1) name0, name1
-#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2) name0, name1, name2
-#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3) name0, name1, name2, name3
-#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
-    name4
-#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
-    name2, name3, name4, name5
-#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
-    name6) name0, name1, name2, name3, name4, name5, name6
-#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
-    kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
-#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
-    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
-    kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
-    name6, name7, name8
-#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
-    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
-    name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
-    name3, name4, name5, name6, name7, name8, name9
-
-// Declares the types of value parameters.
-#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
-    typename p0##_type, typename p1##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
-    typename p0##_type, typename p1##_type, typename p2##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
-    typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
-    typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type, typename p4##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
-    typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type, typename p4##_type, typename p5##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type, typename p4##_type, typename p5##_type, \
-    typename p6##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type, typename p4##_type, typename p5##_type, \
-    typename p6##_type, typename p7##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
-    typename p3##_type, typename p4##_type, typename p5##_type, \
-    typename p6##_type, typename p7##_type, typename p8##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
-    typename p2##_type, typename p3##_type, typename p4##_type, \
-    typename p5##_type, typename p6##_type, typename p7##_type, \
-    typename p8##_type, typename p9##_type
-
-// Initializes the value parameters.
-#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
-    ()
-#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
-    (p0##_type gmock_p0) : p0(gmock_p0)
-#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
-    (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)
-#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)
-#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3)
-#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)
-#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)
-#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-        p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)
-#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-        p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-        p7(gmock_p7)
-#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-        p6##_type gmock_p6, p7##_type gmock_p7, \
-        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-        p8(gmock_p8)
-#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8, p9)\
-    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-        p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
-        p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-        p8(gmock_p8), p9(gmock_p9)
-
-// Declares the fields for storing the value parameters.
-#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
-#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
-    p1##_type p1;
-#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
-    p1##_type p1; p2##_type p2;
-#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
-    p1##_type p1; p2##_type p2; p3##_type p3;
-#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
-    p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
-#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
-    p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
-    p5##_type p5;
-#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
-    p5##_type p5; p6##_type p6;
-#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
-    p5##_type p5; p6##_type p6; p7##_type p7;
-#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
-    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
-#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
-    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
-    p9##_type p9;
-
-// Lists the value parameters.
-#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0
-#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
-#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
-#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
-#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
-    p2, p3, p4
-#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
-    p1, p2, p3, p4, p5
-#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6) p0, p1, p2, p3, p4, p5, p6
-#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7) p0, p1, p2, p3, p4, p5, p6, p7
-#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
-#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
-
-// Lists the value parameter types.
-#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
-    p1##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
-    p1##_type, p2##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
-    p0##_type, p1##_type, p2##_type, p3##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
-    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
-    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
-    p6##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-    p5##_type, p6##_type, p7##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-    p5##_type, p6##_type, p7##_type, p8##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-    p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
-
-// Declares the value parameters.
-#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
-#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
-    p1##_type p1
-#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
-    p1##_type p1, p2##_type p2
-#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
-    p1##_type p1, p2##_type p2, p3##_type p3
-#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
-    p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
-#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
-    p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
-    p5##_type p5
-#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
-    p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
-    p5##_type p5, p6##_type p6
-#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
-    p5##_type p5, p6##_type p6, p7##_type p7
-#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
-#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
-    p9##_type p9
-
-// The suffix of the class template implementing the action template.
-#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
-#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P
-#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
-#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3
-#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4
-#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5
-#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
-#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
-#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7) P8
-#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8) P9
-#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
-    p7, p8, p9) P10
-
-// The name of the class template implementing the action template.
-#define GMOCK_ACTION_CLASS_(name, value_params)\
-    GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
-
-#define ACTION_TEMPLATE(name, template_params, value_params)\
-  template <GMOCK_INTERNAL_DECL_##template_params\
-            GMOCK_INTERNAL_DECL_TYPE_##value_params>\
-  class GMOCK_ACTION_CLASS_(name, value_params) {\
-   public:\
-    GMOCK_ACTION_CLASS_(name, value_params)\
-        GMOCK_INTERNAL_INIT_##value_params {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      GMOCK_INTERNAL_DEFN_##value_params\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(\
-          new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
-    }\
-    GMOCK_INTERNAL_DEFN_##value_params\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
-  };\
-  template <GMOCK_INTERNAL_DECL_##template_params\
-            GMOCK_INTERNAL_DECL_TYPE_##value_params>\
-  inline GMOCK_ACTION_CLASS_(name, value_params)<\
-      GMOCK_INTERNAL_LIST_##template_params\
-      GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\
-          GMOCK_INTERNAL_DECL_##value_params) {\
-    return GMOCK_ACTION_CLASS_(name, value_params)<\
-        GMOCK_INTERNAL_LIST_##template_params\
-        GMOCK_INTERNAL_LIST_TYPE_##value_params>(\
-            GMOCK_INTERNAL_LIST_##value_params);\
-  }\
-  template <GMOCK_INTERNAL_DECL_##template_params\
-            GMOCK_INTERNAL_DECL_TYPE_##value_params>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type,\
-      typename arg3_type, typename arg4_type, typename arg5_type,\
-      typename arg6_type, typename arg7_type, typename arg8_type,\
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      GMOCK_ACTION_CLASS_(name, value_params)<\
-          GMOCK_INTERNAL_LIST_##template_params\
-          GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\
-              gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION(name)\
-  class name##Action {\
-   public:\
-    name##Action() {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl() {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>());\
-    }\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##Action);\
-  };\
-  inline name##Action name() {\
-    return name##Action();\
-  }\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##Action::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P(name, p0)\
-  template <typename p0##_type>\
-  class name##ActionP {\
-   public:\
-    name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0));\
-    }\
-    p0##_type p0;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP);\
-  };\
-  template <typename p0##_type>\
-  inline name##ActionP<p0##_type> name(p0##_type p0) {\
-    return name##ActionP<p0##_type>(p0);\
-  }\
-  template <typename p0##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P2(name, p0, p1)\
-  template <typename p0##_type, typename p1##_type>\
-  class name##ActionP2 {\
-   public:\
-    name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
-        p1(gmock_p1) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
-          p1(gmock_p1) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
-  };\
-  template <typename p0##_type, typename p1##_type>\
-  inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
-      p1##_type p1) {\
-    return name##ActionP2<p0##_type, p1##_type>(p0, p1);\
-  }\
-  template <typename p0##_type, typename p1##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P3(name, p0, p1, p2)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  class name##ActionP3 {\
-   public:\
-    name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \
-          p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
-      p1##_type p1, p2##_type p2) {\
-    return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP3<p0##_type, p1##_type, \
-          p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P4(name, p0, p1, p2, p3)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  class name##ActionP4 {\
-   public:\
-    name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-          p3(gmock_p3) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  inline name##ActionP4<p0##_type, p1##_type, p2##_type, \
-      p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
-      p3##_type p3) {\
-    return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \
-        p2, p3);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP4<p0##_type, p1##_type, p2##_type, \
-          p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P5(name, p0, p1, p2, p3, p4)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  class name##ActionP5 {\
-   public:\
-    name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, \
-        p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \
-          p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4) {\
-    return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type>(p0, p1, p2, p3, p4);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-          p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  class name##ActionP6 {\
-   public:\
-    name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, \
-          p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
-      p3##_type p3, p4##_type p4, p5##_type p5) {\
-    return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-          p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  class name##ActionP7 {\
-   public:\
-    name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
-        p6(gmock_p6) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
-          p6));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
-      p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
-      p6##_type p6) {\
-    return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-          p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  class name##ActionP8 {\
-   public:\
-    name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, \
-        p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-        p7(gmock_p7) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \
-          p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \
-          p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
-          p6, p7));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
-      p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
-      p6##_type p6, p7##_type p7) {\
-    return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
-        p6, p7);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-          p5##_type, p6##_type, \
-          p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  class name##ActionP9 {\
-   public:\
-    name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
-        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-        p8(gmock_p8) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7, \
-          p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-          p7(gmock_p7), p8(gmock_p8) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-      p8##_type p8;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
-          p6, p7, p8));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-    p8##_type p8;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type, \
-      p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
-      p8##_type p8) {\
-    return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
-        p3, p4, p5, p6, p7, p8);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-          p5##_type, p6##_type, p7##_type, \
-          p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  class name##ActionP10 {\
-   public:\
-    name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
-        p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-        p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
-    template <typename F>\
-    class gmock_Impl : public ::testing::ActionInterface<F> {\
-     public:\
-      typedef F function_type;\
-      typedef typename ::testing::internal::Function<F>::Result return_type;\
-      typedef typename ::testing::internal::Function<F>::ArgumentTuple\
-          args_type;\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
-          p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-          p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\
-      virtual return_type Perform(const args_type& args) {\
-        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\
-            Perform(this, args);\
-      }\
-      template <typename arg0_type, typename arg1_type, typename arg2_type, \
-          typename arg3_type, typename arg4_type, typename arg5_type, \
-          typename arg6_type, typename arg7_type, typename arg8_type, \
-          typename arg9_type>\
-      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \
-          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
-          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
-          arg9_type arg9) const;\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-      p8##_type p8;\
-      p9##_type p9;\
-     private:\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename F> operator ::testing::Action<F>() const {\
-      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
-          p6, p7, p8, p9));\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-    p8##_type p8;\
-    p9##_type p9;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
-      p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
-      p9##_type p9) {\
-    return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
-        p1, p2, p3, p4, p5, p6, p7, p8, p9);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  template <typename F>\
-  template <typename arg0_type, typename arg1_type, typename arg2_type, \
-      typename arg3_type, typename arg4_type, typename arg5_type, \
-      typename arg6_type, typename arg7_type, typename arg8_type, \
-      typename arg9_type>\
-  typename ::testing::internal::Function<F>::Result\
-      name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-          p5##_type, p6##_type, p7##_type, p8##_type, \
-          p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\
-          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
-
-// TODO(wan@google.com): move the following to a different .h file
-// such that we don't have to run 'pump' every time the code is
-// updated.
-namespace testing {
-
-// The ACTION*() macros trigger warning C4100 (unreferenced formal
-// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in
-// the macro definition, as the warnings are generated when the macro
-// is expanded and macro expansion cannot contain #pragma.  Therefore
-// we suppress them here.
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
-#endif
-
-// Various overloads for InvokeArgument<N>().
-//
-// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
-// (0-based) argument, which must be a k-ary callable, of the mock
-// function, with arguments a1, a2, ..., a_k.
-//
-// Notes:
-//
-//   1. The arguments are passed by value by default.  If you need to
-//   pass an argument by reference, wrap it inside ByRef().  For
-//   example,
-//
-//     InvokeArgument<1>(5, string("Hello"), ByRef(foo))
-//
-//   passes 5 and string("Hello") by value, and passes foo by
-//   reference.
-//
-//   2. If the callable takes an argument by reference but ByRef() is
-//   not used, it will receive the reference to a copy of the value,
-//   instead of the original value.  For example, when the 0-th
-//   argument of the mock function takes a const string&, the action
-//
-//     InvokeArgument<0>(string("Hello"))
-//
-//   makes a copy of the temporary string("Hello") object and passes a
-//   reference of the copy, instead of the original temporary object,
-//   to the callable.  This makes it easy for a user to define an
-//   InvokeArgument action from temporary values and have it performed
-//   later.
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_0_VALUE_PARAMS()) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args));
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_1_VALUE_PARAMS(p0)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_2_VALUE_PARAMS(p0, p1)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_3_VALUE_PARAMS(p0, p1, p2)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
-}
-
-ACTION_TEMPLATE(InvokeArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
-  return internal::CallableHelper<return_type>::Call(
-      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
-}
-
-// Various overloads for ReturnNew<T>().
-//
-// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new
-// instance of type T, constructed on the heap with constructor arguments
-// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_0_VALUE_PARAMS()) {
-  return new T();
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_1_VALUE_PARAMS(p0)) {
-  return new T(p0);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_2_VALUE_PARAMS(p0, p1)) {
-  return new T(p0, p1);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_3_VALUE_PARAMS(p0, p1, p2)) {
-  return new T(p0, p1, p2);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
-  return new T(p0, p1, p2, p3);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
-  return new T(p0, p1, p2, p3, p4);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
-  return new T(p0, p1, p2, p3, p4, p5);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
-  return new T(p0, p1, p2, p3, p4, p5, p6);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
-  return new T(p0, p1, p2, p3, p4, p5, p6, p7);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
-  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);
-}
-
-ACTION_TEMPLATE(ReturnNew,
-                HAS_1_TEMPLATE_PARAMS(typename, T),
-                AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
-  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
-}
-
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_

+ 0 - 929
Src/ThirdParty/gmock/gmock-generated-function-mockers.h

@@ -1,929 +0,0 @@
-// This file was GENERATED by command:
-//     pump.py gmock-generated-function-mockers.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements function mockers of various arities.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
-
-#include "gmock/gmock-spec-builders.h"
-#include "gmock/internal/gmock-internal-utils.h"
-
-namespace testing {
-namespace internal {
-
-template <typename F>
-class FunctionMockerBase;
-
-// Note: class FunctionMocker really belongs to the ::testing
-// namespace.  However if we define it in ::testing, MSVC will
-// complain when classes in ::testing::internal declare it as a
-// friend class template.  To workaround this compiler bug, we define
-// FunctionMocker in ::testing::internal and import it into ::testing.
-template <typename F>
-class FunctionMocker;
-
-template <typename R>
-class FunctionMocker<R()> : public
-    internal::FunctionMockerBase<R()> {
- public:
-  typedef R F();
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With() {
-    return this->current_spec();
-  }
-
-  R Invoke() {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple());
-  }
-};
-
-template <typename R, typename A1>
-class FunctionMocker<R(A1)> : public
-    internal::FunctionMockerBase<R(A1)> {
- public:
-  typedef R F(A1);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1));
-  }
-};
-
-template <typename R, typename A1, typename A2>
-class FunctionMocker<R(A1, A2)> : public
-    internal::FunctionMockerBase<R(A1, A2)> {
- public:
-  typedef R F(A1, A2);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-class FunctionMocker<R(A1, A2, A3)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3)> {
- public:
-  typedef R F(A1, A2, A3);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-class FunctionMocker<R(A1, A2, A3, A4)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4)> {
- public:
-  typedef R F(A1, A2, A3, A4);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5>
-class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
-        m5));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6>
-class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5, A6);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
-      const Matcher<A6>& m6) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
-        m6));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7>
-class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5, A6, A7);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
-      const Matcher<A6>& m6, const Matcher<A7>& m7) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
-        m6, m7));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8>
-class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
-      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
-        m6, m7, m8));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9>
-class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
-      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
-      const Matcher<A9>& m9) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
-        m6, m7, m8, m9));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
-  }
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9,
-    typename A10>
-class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
-    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {
- public:
-  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-
-  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,
-      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,
-      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,
-      const Matcher<A9>& m9, const Matcher<A10>& m10) {
-    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,
-        m6, m7, m8, m9, m10));
-    return this->current_spec();
-  }
-
-  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
-      A10 a10) {
-    // Even though gcc and MSVC don't enforce it, 'this->' is required
-    // by the C++ standard [14.6.4] here, as the base class type is
-    // dependent on the template argument (and thus shouldn't be
-    // looked into when resolving InvokeWith).
-    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
-        a10));
-  }
-};
-
-}  // namespace internal
-
-// The style guide prohibits "using" statements in a namespace scope
-// inside a header file.  However, the FunctionMocker class template
-// is meant to be defined in the ::testing namespace.  The following
-// line is just a trick for working around a bug in MSVC 8.0, which
-// cannot handle it if we define FunctionMocker in ::testing.
-using internal::FunctionMocker;
-
-// The result type of function type F.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_RESULT_(tn, F) tn ::testing::internal::Function<F>::Result
-
-// The type of argument N of function type F.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_ARG_(tn, F, N) tn ::testing::internal::Function<F>::Argument##N
-
-// The matcher type for argument N of function type F.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MATCHER_(tn, F, N) const ::testing::Matcher<GMOCK_ARG_(tn, F, N)>&
-
-// The variable for mocking the given method.
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_MOCKER_(arity, constness, Method) \
-    GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD0_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method() constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 0, \
-        this_method_does_not_take_0_arguments); \
-    GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method() constness { \
-    GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(0, constness, Method).With(); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(0, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD1_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 1, \
-        this_method_does_not_take_1_argument); \
-    GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1) constness { \
-    GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(1, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD2_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 2, \
-        this_method_does_not_take_2_arguments); \
-    GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2) constness { \
-    GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(2, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD3_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 3, \
-        this_method_does_not_take_3_arguments); \
-    GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3) constness { \
-    GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(3, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD4_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 4, \
-        this_method_does_not_take_4_arguments); \
-    GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4) constness { \
-    GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(4, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD5_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 5, \
-        this_method_does_not_take_5_arguments); \
-    GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5) constness { \
-    GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(5, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD6_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5, \
-                                 GMOCK_ARG_(tn, F, 6) gmock_a6) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 6, \
-        this_method_does_not_take_6_arguments); \
-    GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
-                     GMOCK_MATCHER_(tn, F, 6) gmock_a6) constness { \
-    GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(6, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD7_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5, \
-                                 GMOCK_ARG_(tn, F, 6) gmock_a6, \
-                                 GMOCK_ARG_(tn, F, 7) gmock_a7) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 7, \
-        this_method_does_not_take_7_arguments); \
-    GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
-                     GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
-                     GMOCK_MATCHER_(tn, F, 7) gmock_a7) constness { \
-    GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(7, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD8_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5, \
-                                 GMOCK_ARG_(tn, F, 6) gmock_a6, \
-                                 GMOCK_ARG_(tn, F, 7) gmock_a7, \
-                                 GMOCK_ARG_(tn, F, 8) gmock_a8) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 8, \
-        this_method_does_not_take_8_arguments); \
-    GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
-                     GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
-                     GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
-                     GMOCK_MATCHER_(tn, F, 8) gmock_a8) constness { \
-    GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(8, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD9_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5, \
-                                 GMOCK_ARG_(tn, F, 6) gmock_a6, \
-                                 GMOCK_ARG_(tn, F, 7) gmock_a7, \
-                                 GMOCK_ARG_(tn, F, 8) gmock_a8, \
-                                 GMOCK_ARG_(tn, F, 9) gmock_a9) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 9, \
-        this_method_does_not_take_9_arguments); \
-    GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
-        gmock_a9); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
-                     GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
-                     GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
-                     GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
-                     GMOCK_MATCHER_(tn, F, 9) gmock_a9) constness { \
-    GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
-        gmock_a9); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(9, constness, Method)
-
-// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
-#define GMOCK_METHOD10_(tn, constness, ct, Method, F) \
-  GMOCK_RESULT_(tn, F) ct Method(GMOCK_ARG_(tn, F, 1) gmock_a1, \
-                                 GMOCK_ARG_(tn, F, 2) gmock_a2, \
-                                 GMOCK_ARG_(tn, F, 3) gmock_a3, \
-                                 GMOCK_ARG_(tn, F, 4) gmock_a4, \
-                                 GMOCK_ARG_(tn, F, 5) gmock_a5, \
-                                 GMOCK_ARG_(tn, F, 6) gmock_a6, \
-                                 GMOCK_ARG_(tn, F, 7) gmock_a7, \
-                                 GMOCK_ARG_(tn, F, 8) gmock_a8, \
-                                 GMOCK_ARG_(tn, F, 9) gmock_a9, \
-                                 GMOCK_ARG_(tn, F, 10) gmock_a10) constness { \
-    GTEST_COMPILE_ASSERT_(::std::tr1::tuple_size< \
-        tn ::testing::internal::Function<F>::ArgumentTuple>::value == 10, \
-        this_method_does_not_take_10_arguments); \
-    GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
-    return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
-        gmock_a10); \
-  } \
-  ::testing::MockSpec<F>& \
-      gmock_##Method(GMOCK_MATCHER_(tn, F, 1) gmock_a1, \
-                     GMOCK_MATCHER_(tn, F, 2) gmock_a2, \
-                     GMOCK_MATCHER_(tn, F, 3) gmock_a3, \
-                     GMOCK_MATCHER_(tn, F, 4) gmock_a4, \
-                     GMOCK_MATCHER_(tn, F, 5) gmock_a5, \
-                     GMOCK_MATCHER_(tn, F, 6) gmock_a6, \
-                     GMOCK_MATCHER_(tn, F, 7) gmock_a7, \
-                     GMOCK_MATCHER_(tn, F, 8) gmock_a8, \
-                     GMOCK_MATCHER_(tn, F, 9) gmock_a9, \
-                     GMOCK_MATCHER_(tn, F, 10) gmock_a10) constness { \
-    GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
-    return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
-        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
-        gmock_a10); \
-  } \
-  mutable ::testing::FunctionMocker<F> GMOCK_MOCKER_(10, constness, Method)
-
-#define MOCK_METHOD0(m, F) GMOCK_METHOD0_(, , , m, F)
-#define MOCK_METHOD1(m, F) GMOCK_METHOD1_(, , , m, F)
-#define MOCK_METHOD2(m, F) GMOCK_METHOD2_(, , , m, F)
-#define MOCK_METHOD3(m, F) GMOCK_METHOD3_(, , , m, F)
-#define MOCK_METHOD4(m, F) GMOCK_METHOD4_(, , , m, F)
-#define MOCK_METHOD5(m, F) GMOCK_METHOD5_(, , , m, F)
-#define MOCK_METHOD6(m, F) GMOCK_METHOD6_(, , , m, F)
-#define MOCK_METHOD7(m, F) GMOCK_METHOD7_(, , , m, F)
-#define MOCK_METHOD8(m, F) GMOCK_METHOD8_(, , , m, F)
-#define MOCK_METHOD9(m, F) GMOCK_METHOD9_(, , , m, F)
-#define MOCK_METHOD10(m, F) GMOCK_METHOD10_(, , , m, F)
-
-#define MOCK_CONST_METHOD0(m, F) GMOCK_METHOD0_(, const, , m, F)
-#define MOCK_CONST_METHOD1(m, F) GMOCK_METHOD1_(, const, , m, F)
-#define MOCK_CONST_METHOD2(m, F) GMOCK_METHOD2_(, const, , m, F)
-#define MOCK_CONST_METHOD3(m, F) GMOCK_METHOD3_(, const, , m, F)
-#define MOCK_CONST_METHOD4(m, F) GMOCK_METHOD4_(, const, , m, F)
-#define MOCK_CONST_METHOD5(m, F) GMOCK_METHOD5_(, const, , m, F)
-#define MOCK_CONST_METHOD6(m, F) GMOCK_METHOD6_(, const, , m, F)
-#define MOCK_CONST_METHOD7(m, F) GMOCK_METHOD7_(, const, , m, F)
-#define MOCK_CONST_METHOD8(m, F) GMOCK_METHOD8_(, const, , m, F)
-#define MOCK_CONST_METHOD9(m, F) GMOCK_METHOD9_(, const, , m, F)
-#define MOCK_CONST_METHOD10(m, F) GMOCK_METHOD10_(, const, , m, F)
-
-#define MOCK_METHOD0_T(m, F) GMOCK_METHOD0_(typename, , , m, F)
-#define MOCK_METHOD1_T(m, F) GMOCK_METHOD1_(typename, , , m, F)
-#define MOCK_METHOD2_T(m, F) GMOCK_METHOD2_(typename, , , m, F)
-#define MOCK_METHOD3_T(m, F) GMOCK_METHOD3_(typename, , , m, F)
-#define MOCK_METHOD4_T(m, F) GMOCK_METHOD4_(typename, , , m, F)
-#define MOCK_METHOD5_T(m, F) GMOCK_METHOD5_(typename, , , m, F)
-#define MOCK_METHOD6_T(m, F) GMOCK_METHOD6_(typename, , , m, F)
-#define MOCK_METHOD7_T(m, F) GMOCK_METHOD7_(typename, , , m, F)
-#define MOCK_METHOD8_T(m, F) GMOCK_METHOD8_(typename, , , m, F)
-#define MOCK_METHOD9_T(m, F) GMOCK_METHOD9_(typename, , , m, F)
-#define MOCK_METHOD10_T(m, F) GMOCK_METHOD10_(typename, , , m, F)
-
-#define MOCK_CONST_METHOD0_T(m, F) GMOCK_METHOD0_(typename, const, , m, F)
-#define MOCK_CONST_METHOD1_T(m, F) GMOCK_METHOD1_(typename, const, , m, F)
-#define MOCK_CONST_METHOD2_T(m, F) GMOCK_METHOD2_(typename, const, , m, F)
-#define MOCK_CONST_METHOD3_T(m, F) GMOCK_METHOD3_(typename, const, , m, F)
-#define MOCK_CONST_METHOD4_T(m, F) GMOCK_METHOD4_(typename, const, , m, F)
-#define MOCK_CONST_METHOD5_T(m, F) GMOCK_METHOD5_(typename, const, , m, F)
-#define MOCK_CONST_METHOD6_T(m, F) GMOCK_METHOD6_(typename, const, , m, F)
-#define MOCK_CONST_METHOD7_T(m, F) GMOCK_METHOD7_(typename, const, , m, F)
-#define MOCK_CONST_METHOD8_T(m, F) GMOCK_METHOD8_(typename, const, , m, F)
-#define MOCK_CONST_METHOD9_T(m, F) GMOCK_METHOD9_(typename, const, , m, F)
-#define MOCK_CONST_METHOD10_T(m, F) GMOCK_METHOD10_(typename, const, , m, F)
-
-#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD0_(, , ct, m, F)
-#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD1_(, , ct, m, F)
-#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD2_(, , ct, m, F)
-#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD3_(, , ct, m, F)
-#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD4_(, , ct, m, F)
-#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD5_(, , ct, m, F)
-#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD6_(, , ct, m, F)
-#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD7_(, , ct, m, F)
-#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD8_(, , ct, m, F)
-#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD9_(, , ct, m, F)
-#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, F) GMOCK_METHOD10_(, , ct, m, F)
-
-#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD0_(, const, ct, m, F)
-#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD1_(, const, ct, m, F)
-#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD2_(, const, ct, m, F)
-#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD3_(, const, ct, m, F)
-#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD4_(, const, ct, m, F)
-#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD5_(, const, ct, m, F)
-#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD6_(, const, ct, m, F)
-#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD7_(, const, ct, m, F)
-#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD8_(, const, ct, m, F)
-#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD9_(, const, ct, m, F)
-#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD10_(, const, ct, m, F)
-
-#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD0_(typename, , ct, m, F)
-#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD1_(typename, , ct, m, F)
-#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD2_(typename, , ct, m, F)
-#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD3_(typename, , ct, m, F)
-#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD4_(typename, , ct, m, F)
-#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD5_(typename, , ct, m, F)
-#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD6_(typename, , ct, m, F)
-#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD7_(typename, , ct, m, F)
-#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD8_(typename, , ct, m, F)
-#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD9_(typename, , ct, m, F)
-#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD10_(typename, , ct, m, F)
-
-#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD0_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD1_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD2_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD3_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD4_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD5_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD6_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD7_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD8_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD9_(typename, const, ct, m, F)
-#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, F) \
-    GMOCK_METHOD10_(typename, const, ct, m, F)
-
-// A MockFunction<F> class has one mock method whose type is F.  It is
-// useful when you just want your test code to emit some messages and
-// have Google Mock verify the right messages are sent (and perhaps at
-// the right times).  For example, if you are exercising code:
-//
-//   Foo(1);
-//   Foo(2);
-//   Foo(3);
-//
-// and want to verify that Foo(1) and Foo(3) both invoke
-// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
-//
-// TEST(FooTest, InvokesBarCorrectly) {
-//   MyMock mock;
-//   MockFunction<void(string check_point_name)> check;
-//   {
-//     InSequence s;
-//
-//     EXPECT_CALL(mock, Bar("a"));
-//     EXPECT_CALL(check, Call("1"));
-//     EXPECT_CALL(check, Call("2"));
-//     EXPECT_CALL(mock, Bar("a"));
-//   }
-//   Foo(1);
-//   check.Call("1");
-//   Foo(2);
-//   check.Call("2");
-//   Foo(3);
-// }
-//
-// The expectation spec says that the first Bar("a") must happen
-// before check point "1", the second Bar("a") must happen after check
-// point "2", and nothing should happen between the two check
-// points. The explicit check points make it easy to tell which
-// Bar("a") is called by which call to Foo().
-template <typename F>
-class MockFunction;
-
-template <typename R>
-class MockFunction<R()> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD0_T(Call, R());
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0>
-class MockFunction<R(A0)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD1_T(Call, R(A0));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1>
-class MockFunction<R(A0, A1)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD2_T(Call, R(A0, A1));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2>
-class MockFunction<R(A0, A1, A2)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD3_T(Call, R(A0, A1, A2));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3>
-class MockFunction<R(A0, A1, A2, A3)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4>
-class MockFunction<R(A0, A1, A2, A3, A4)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4, typename A5>
-class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4, typename A5, typename A6>
-class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4, typename A5, typename A6, typename A7>
-class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4, typename A5, typename A6, typename A7, typename A8>
-class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-template <typename R, typename A0, typename A1, typename A2, typename A3,
-    typename A4, typename A5, typename A6, typename A7, typename A8,
-    typename A9>
-class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
- public:
-  MockFunction() {}
-
-  MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
-};
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_

+ 0 - 2054
Src/ThirdParty/gmock/gmock-generated-matchers.h

@@ -1,2054 +0,0 @@
-// This file was GENERATED by command:
-//     pump.py gmock-generated-matchers.h.pump
-// DO NOT EDIT BY HAND!!!
-
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some commonly used variadic matchers.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
-
-#include <sstream>
-#include <string>
-#include <vector>
-#include "gmock/gmock-matchers.h"
-
-namespace testing {
-namespace internal {
-
-// The type of the i-th (0-based) field of Tuple.
-#define GMOCK_FIELD_TYPE_(Tuple, i) \
-    typename ::std::tr1::tuple_element<i, Tuple>::type
-
-// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
-// tuple of type Tuple.  It has two members:
-//
-//   type: a tuple type whose i-th field is the ki-th field of Tuple.
-//   GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
-//
-// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
-//
-//   type is tuple<int, bool>, and
-//   GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
-
-template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
-    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
-    int k9 = -1>
-class TupleFields;
-
-// This generic version is used when there are 10 selectors.
-template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
-    int k7, int k8, int k9>
-class TupleFields {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
-      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
-      GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
-      GMOCK_FIELD_TYPE_(Tuple, k9)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
-        get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
-  }
-};
-
-// The following specialization is used for 0 ~ 9 selectors.
-
-template <class Tuple>
-class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<> type;
-  static type GetSelectedFields(const Tuple& /* t */) {
-    using ::std::tr1::get;
-    return type();
-  }
-};
-
-template <class Tuple, int k0>
-class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1>
-class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2>
-class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3>
-class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3, int k4>
-class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
-class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
-      GMOCK_FIELD_TYPE_(Tuple, k5)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
-        get<k5>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
-class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
-      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
-        get<k5>(t), get<k6>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
-    int k7>
-class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
-      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
-      GMOCK_FIELD_TYPE_(Tuple, k7)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
-        get<k5>(t), get<k6>(t), get<k7>(t));
-  }
-};
-
-template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
-    int k7, int k8>
-class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
- public:
-  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
-      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
-      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
-      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
-      GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
-  static type GetSelectedFields(const Tuple& t) {
-    using ::std::tr1::get;
-    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
-        get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
-  }
-};
-
-#undef GMOCK_FIELD_TYPE_
-
-// Implements the Args() matcher.
-template <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
-    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
-    int k9 = -1>
-class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
- public:
-  // ArgsTuple may have top-level const or reference modifiers.
-  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;
-  typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,
-      k6, k7, k8, k9>::type SelectedArgs;
-  typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;
-
-  template <typename InnerMatcher>
-  explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)
-      : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}
-
-  virtual bool MatchAndExplain(ArgsTuple args,
-                               MatchResultListener* listener) const {
-    const SelectedArgs& selected_args = GetSelectedArgs(args);
-    if (!listener->IsInterested())
-      return inner_matcher_.Matches(selected_args);
-
-    PrintIndices(listener->stream());
-    *listener << "are " << PrintToString(selected_args);
-
-    StringMatchResultListener inner_listener;
-    const bool match = inner_matcher_.MatchAndExplain(selected_args,
-                                                      &inner_listener);
-    PrintIfNotEmpty(inner_listener.str(), listener->stream());
-    return match;
-  }
-
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "are a tuple ";
-    PrintIndices(os);
-    inner_matcher_.DescribeTo(os);
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "are a tuple ";
-    PrintIndices(os);
-    inner_matcher_.DescribeNegationTo(os);
-  }
-
- private:
-  static SelectedArgs GetSelectedArgs(ArgsTuple args) {
-    return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,
-        k9>::GetSelectedFields(args);
-  }
-
-  // Prints the indices of the selected fields.
-  static void PrintIndices(::std::ostream* os) {
-    *os << "whose fields (";
-    const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };
-    for (int i = 0; i < 10; i++) {
-      if (indices[i] < 0)
-        break;
-
-      if (i >= 1)
-        *os << ", ";
-
-      *os << "#" << indices[i];
-    }
-    *os << ") ";
-  }
-
-  const MonomorphicInnerMatcher inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
-};
-
-template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
-    int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,
-    int k8 = -1, int k9 = -1>
-class ArgsMatcher {
- public:
-  explicit ArgsMatcher(const InnerMatcher& inner_matcher)
-      : inner_matcher_(inner_matcher) {}
-
-  template <typename ArgsTuple>
-  operator Matcher<ArgsTuple>() const {
-    return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,
-        k6, k7, k8, k9>(inner_matcher_));
-  }
-
- private:
-  const InnerMatcher inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
-};
-
-// Implements ElementsAre() of 1-10 arguments.
-
-template <typename T1>
-class ElementsAreMatcher1 {
- public:
-  explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    // Nokia's Symbian Compiler has a nasty bug where the object put
-    // in a one-element local array is not destructed when the array
-    // goes out of scope.  This leads to obvious badness as we've
-    // added the linked_ptr in it to our other linked_ptrs list.
-    // Hence we implement ElementsAreMatcher1 specially to avoid using
-    // a local array.
-    const Matcher<const Element&> matcher =
-        MatcherCast<const Element&>(e1_);
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1));
-  }
-
- private:
-  const T1& e1_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
-};
-
-template <typename T1, typename T2>
-class ElementsAreMatcher2 {
- public:
-  ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
-};
-
-template <typename T1, typename T2, typename T3>
-class ElementsAreMatcher3 {
- public:
-  ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1),
-      e2_(e2), e3_(e3) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
-};
-
-template <typename T1, typename T2, typename T3, typename T4>
-class ElementsAreMatcher4 {
- public:
-  ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3,
-      const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-class ElementsAreMatcher5 {
- public:
-  ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-class ElementsAreMatcher6 {
- public:
-  ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4),
-      e5_(e5), e6_(e6) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-      MatcherCast<const Element&>(e6_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-  const T6& e6_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-class ElementsAreMatcher7 {
- public:
-  ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3),
-      e4_(e4), e5_(e5), e6_(e6), e7_(e7) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-      MatcherCast<const Element&>(e6_),
-      MatcherCast<const Element&>(e7_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 7));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-  const T6& e6_;
-  const T7& e7_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-class ElementsAreMatcher8 {
- public:
-  ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1),
-      e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-      MatcherCast<const Element&>(e6_),
-      MatcherCast<const Element&>(e7_),
-      MatcherCast<const Element&>(e8_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 8));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-  const T6& e6_;
-  const T7& e7_;
-  const T8& e8_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-class ElementsAreMatcher9 {
- public:
-  ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5, const T6& e6, const T7& e7, const T8& e8,
-      const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
-      e7_(e7), e8_(e8), e9_(e9) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-      MatcherCast<const Element&>(e6_),
-      MatcherCast<const Element&>(e7_),
-      MatcherCast<const Element&>(e8_),
-      MatcherCast<const Element&>(e9_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 9));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-  const T6& e6_;
-  const T7& e7_;
-  const T8& e8_;
-  const T9& e9_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
-};
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-class ElementsAreMatcher10 {
- public:
-  ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-      const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
-      const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6),
-      e7_(e7), e8_(e8), e9_(e9), e10_(e10) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&> matchers[] = {
-      MatcherCast<const Element&>(e1_),
-      MatcherCast<const Element&>(e2_),
-      MatcherCast<const Element&>(e3_),
-      MatcherCast<const Element&>(e4_),
-      MatcherCast<const Element&>(e5_),
-      MatcherCast<const Element&>(e6_),
-      MatcherCast<const Element&>(e7_),
-      MatcherCast<const Element&>(e8_),
-      MatcherCast<const Element&>(e9_),
-      MatcherCast<const Element&>(e10_),
-    };
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 10));
-  }
-
- private:
-  const T1& e1_;
-  const T2& e2_;
-  const T3& e3_;
-  const T4& e4_;
-  const T5& e5_;
-  const T6& e6_;
-  const T7& e7_;
-  const T8& e8_;
-  const T9& e9_;
-  const T10& e10_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
-};
-
-}  // namespace internal
-
-// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
-// fields of it matches a_matcher.  C++ doesn't support default
-// arguments for function templates, so we have to overload it.
-template <typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher>(matcher);
-}
-
-template <int k1, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1>(matcher);
-}
-
-template <int k1, int k2, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);
-}
-
-template <int k1, int k2, int k3, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7,
-    typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,
-      k7>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,
-      k8>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    int k9, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
-      k9>(matcher);
-}
-
-template <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,
-    int k9, int k10, typename InnerMatcher>
-inline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,
-    k10>
-Args(const InnerMatcher& matcher) {
-  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,
-      k9, k10>(matcher);
-}
-
-// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
-// (n + 1) elements, where the i-th element in the container must
-// match the i-th argument in the list.  Each argument of
-// ElementsAre() can be either a value or a matcher.  We support up to
-// 10 arguments.
-//
-// NOTE: Since ElementsAre() cares about the order of the elements, it
-// must not be used with containers whose elements's order is
-// undefined (e.g. hash_map).
-
-inline internal::ElementsAreMatcher0 ElementsAre() {
-  return internal::ElementsAreMatcher0();
-}
-
-template <typename T1>
-inline internal::ElementsAreMatcher1<T1> ElementsAre(const T1& e1) {
-  return internal::ElementsAreMatcher1<T1>(e1);
-}
-
-template <typename T1, typename T2>
-inline internal::ElementsAreMatcher2<T1, T2> ElementsAre(const T1& e1,
-    const T2& e2) {
-  return internal::ElementsAreMatcher2<T1, T2>(e1, e2);
-}
-
-template <typename T1, typename T2, typename T3>
-inline internal::ElementsAreMatcher3<T1, T2, T3> ElementsAre(const T1& e1,
-    const T2& e2, const T3& e3) {
-  return internal::ElementsAreMatcher3<T1, T2, T3>(e1, e2, e3);
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-inline internal::ElementsAreMatcher4<T1, T2, T3, T4> ElementsAre(const T1& e1,
-    const T2& e2, const T3& e3, const T4& e4) {
-  return internal::ElementsAreMatcher4<T1, T2, T3, T4>(e1, e2, e3, e4);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-inline internal::ElementsAreMatcher5<T1, T2, T3, T4,
-    T5> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5) {
-  return internal::ElementsAreMatcher5<T1, T2, T3, T4, T5>(e1, e2, e3, e4, e5);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6>
-inline internal::ElementsAreMatcher6<T1, T2, T3, T4, T5,
-    T6> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5, const T6& e6) {
-  return internal::ElementsAreMatcher6<T1, T2, T3, T4, T5, T6>(e1, e2, e3, e4,
-      e5, e6);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7>
-inline internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6,
-    T7> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5, const T6& e6, const T7& e7) {
-  return internal::ElementsAreMatcher7<T1, T2, T3, T4, T5, T6, T7>(e1, e2, e3,
-      e4, e5, e6, e7);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8>
-inline internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7,
-    T8> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
-  return internal::ElementsAreMatcher8<T1, T2, T3, T4, T5, T6, T7, T8>(e1, e2,
-      e3, e4, e5, e6, e7, e8);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9>
-inline internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8,
-    T9> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
-  return internal::ElementsAreMatcher9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(e1,
-      e2, e3, e4, e5, e6, e7, e8, e9);
-}
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-    typename T6, typename T7, typename T8, typename T9, typename T10>
-inline internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
-    T10> ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
-    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
-    const T10& e10) {
-  return internal::ElementsAreMatcher10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
-      T10>(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
-}
-
-// ElementsAreArray(array) and ElementAreArray(array, count) are like
-// ElementsAre(), except that they take an array of values or
-// matchers.  The former form infers the size of 'array', which must
-// be a static C-style array.  In the latter form, 'array' can either
-// be a static array or a pointer to a dynamically created array.
-
-template <typename T>
-inline internal::ElementsAreArrayMatcher<T> ElementsAreArray(
-    const T* first, size_t count) {
-  return internal::ElementsAreArrayMatcher<T>(first, count);
-}
-
-template <typename T, size_t N>
-inline internal::ElementsAreArrayMatcher<T>
-ElementsAreArray(const T (&array)[N]) {
-  return internal::ElementsAreArrayMatcher<T>(array, N);
-}
-
-// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
-// sub-matchers.  AllOf is called fully qualified to prevent ADL from firing.
-
-template <typename Matcher1, typename Matcher2>
-inline internal::BothOfMatcher<Matcher1, Matcher2>
-AllOf(Matcher1 m1, Matcher2 m2) {
-  return internal::BothOfMatcher<Matcher1, Matcher2>(m1, m2);
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    Matcher3> >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, Matcher4> > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    Matcher5> > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    internal::BothOfMatcher<Matcher5, Matcher6> > > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
-    Matcher7> > > > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
-    internal::BothOfMatcher<Matcher7, Matcher8> > > > > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8, typename Matcher9>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
-    internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
-    Matcher9> > > > > > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8, m9));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8, typename Matcher9, typename Matcher10>
-inline internal::BothOfMatcher<Matcher1, internal::BothOfMatcher<Matcher2,
-    internal::BothOfMatcher<Matcher3, internal::BothOfMatcher<Matcher4,
-    internal::BothOfMatcher<Matcher5, internal::BothOfMatcher<Matcher6,
-    internal::BothOfMatcher<Matcher7, internal::BothOfMatcher<Matcher8,
-    internal::BothOfMatcher<Matcher9, Matcher10> > > > > > > > >
-AllOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
-  return ::testing::AllOf(m1, ::testing::AllOf(m2, m3, m4, m5, m6, m7, m8, m9,
-      m10));
-}
-
-// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
-// sub-matchers.  AnyOf is called fully qualified to prevent ADL from firing.
-
-template <typename Matcher1, typename Matcher2>
-inline internal::EitherOfMatcher<Matcher1, Matcher2>
-AnyOf(Matcher1 m1, Matcher2 m2) {
-  return internal::EitherOfMatcher<Matcher1, Matcher2>(m1, m2);
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    Matcher3> >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, Matcher4> > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    Matcher5> > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    internal::EitherOfMatcher<Matcher5, Matcher6> > > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
-    Matcher7> > > > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
-    internal::EitherOfMatcher<Matcher7, Matcher8> > > > > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8, typename Matcher9>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
-    internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
-    Matcher9> > > > > > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8, m9));
-}
-
-template <typename Matcher1, typename Matcher2, typename Matcher3,
-    typename Matcher4, typename Matcher5, typename Matcher6, typename Matcher7,
-    typename Matcher8, typename Matcher9, typename Matcher10>
-inline internal::EitherOfMatcher<Matcher1, internal::EitherOfMatcher<Matcher2,
-    internal::EitherOfMatcher<Matcher3, internal::EitherOfMatcher<Matcher4,
-    internal::EitherOfMatcher<Matcher5, internal::EitherOfMatcher<Matcher6,
-    internal::EitherOfMatcher<Matcher7, internal::EitherOfMatcher<Matcher8,
-    internal::EitherOfMatcher<Matcher9, Matcher10> > > > > > > > >
-AnyOf(Matcher1 m1, Matcher2 m2, Matcher3 m3, Matcher4 m4, Matcher5 m5,
-    Matcher6 m6, Matcher7 m7, Matcher8 m8, Matcher9 m9, Matcher10 m10) {
-  return ::testing::AnyOf(m1, ::testing::AnyOf(m2, m3, m4, m5, m6, m7, m8, m9,
-      m10));
-}
-
-}  // namespace testing
-
-
-// The MATCHER* family of macros can be used in a namespace scope to
-// define custom matchers easily.
-//
-// Basic Usage
-// ===========
-//
-// The syntax
-//
-//   MATCHER(name, description_string) { statements; }
-//
-// defines a matcher with the given name that executes the statements,
-// which must return a bool to indicate if the match succeeds.  Inside
-// the statements, you can refer to the value being matched by 'arg',
-// and refer to its type by 'arg_type'.
-//
-// The description string documents what the matcher does, and is used
-// to generate the failure message when the match fails.  Since a
-// MATCHER() is usually defined in a header file shared by multiple
-// C++ source files, we require the description to be a C-string
-// literal to avoid possible side effects.  It can be empty, in which
-// case we'll use the sequence of words in the matcher name as the
-// description.
-//
-// For example:
-//
-//   MATCHER(IsEven, "") { return (arg % 2) == 0; }
-//
-// allows you to write
-//
-//   // Expects mock_foo.Bar(n) to be called where n is even.
-//   EXPECT_CALL(mock_foo, Bar(IsEven()));
-//
-// or,
-//
-//   // Verifies that the value of some_expression is even.
-//   EXPECT_THAT(some_expression, IsEven());
-//
-// If the above assertion fails, it will print something like:
-//
-//   Value of: some_expression
-//   Expected: is even
-//     Actual: 7
-//
-// where the description "is even" is automatically calculated from the
-// matcher name IsEven.
-//
-// Argument Type
-// =============
-//
-// Note that the type of the value being matched (arg_type) is
-// determined by the context in which you use the matcher and is
-// supplied to you by the compiler, so you don't need to worry about
-// declaring it (nor can you).  This allows the matcher to be
-// polymorphic.  For example, IsEven() can be used to match any type
-// where the value of "(arg % 2) == 0" can be implicitly converted to
-// a bool.  In the "Bar(IsEven())" example above, if method Bar()
-// takes an int, 'arg_type' will be int; if it takes an unsigned long,
-// 'arg_type' will be unsigned long; and so on.
-//
-// Parameterizing Matchers
-// =======================
-//
-// Sometimes you'll want to parameterize the matcher.  For that you
-// can use another macro:
-//
-//   MATCHER_P(name, param_name, description_string) { statements; }
-//
-// For example:
-//
-//   MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
-//
-// will allow you to write:
-//
-//   EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
-//
-// which may lead to this message (assuming n is 10):
-//
-//   Value of: Blah("a")
-//   Expected: has absolute value 10
-//     Actual: -9
-//
-// Note that both the matcher description and its parameter are
-// printed, making the message human-friendly.
-//
-// In the matcher definition body, you can write 'foo_type' to
-// reference the type of a parameter named 'foo'.  For example, in the
-// body of MATCHER_P(HasAbsoluteValue, value) above, you can write
-// 'value_type' to refer to the type of 'value'.
-//
-// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to
-// support multi-parameter matchers.
-//
-// Describing Parameterized Matchers
-// =================================
-//
-// The last argument to MATCHER*() is a string-typed expression.  The
-// expression can reference all of the matcher's parameters and a
-// special bool-typed variable named 'negation'.  When 'negation' is
-// false, the expression should evaluate to the matcher's description;
-// otherwise it should evaluate to the description of the negation of
-// the matcher.  For example,
-//
-//   using testing::PrintToString;
-//
-//   MATCHER_P2(InClosedRange, low, hi,
-//       string(negation ? "is not" : "is") + " in range [" +
-//       PrintToString(low) + ", " + PrintToString(hi) + "]") {
-//     return low <= arg && arg <= hi;
-//   }
-//   ...
-//   EXPECT_THAT(3, InClosedRange(4, 6));
-//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));
-//
-// would generate two failures that contain the text:
-//
-//   Expected: is in range [4, 6]
-//   ...
-//   Expected: is not in range [2, 4]
-//
-// If you specify "" as the description, the failure message will
-// contain the sequence of words in the matcher name followed by the
-// parameter values printed as a tuple.  For example,
-//
-//   MATCHER_P2(InClosedRange, low, hi, "") { ... }
-//   ...
-//   EXPECT_THAT(3, InClosedRange(4, 6));
-//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));
-//
-// would generate two failures that contain the text:
-//
-//   Expected: in closed range (4, 6)
-//   ...
-//   Expected: not (in closed range (2, 4))
-//
-// Types of Matcher Parameters
-// ===========================
-//
-// For the purpose of typing, you can view
-//
-//   MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
-//
-// as shorthand for
-//
-//   template <typename p1_type, ..., typename pk_type>
-//   FooMatcherPk<p1_type, ..., pk_type>
-//   Foo(p1_type p1, ..., pk_type pk) { ... }
-//
-// When you write Foo(v1, ..., vk), the compiler infers the types of
-// the parameters v1, ..., and vk for you.  If you are not happy with
-// the result of the type inference, you can specify the types by
-// explicitly instantiating the template, as in Foo<long, bool>(5,
-// false).  As said earlier, you don't get to (or need to) specify
-// 'arg_type' as that's determined by the context in which the matcher
-// is used.  You can assign the result of expression Foo(p1, ..., pk)
-// to a variable of type FooMatcherPk<p1_type, ..., pk_type>.  This
-// can be useful when composing matchers.
-//
-// While you can instantiate a matcher template with reference types,
-// passing the parameters by pointer usually makes your code more
-// readable.  If, however, you still want to pass a parameter by
-// reference, be aware that in the failure message generated by the
-// matcher you will see the value of the referenced object but not its
-// address.
-//
-// Explaining Match Results
-// ========================
-//
-// Sometimes the matcher description alone isn't enough to explain why
-// the match has failed or succeeded.  For example, when expecting a
-// long string, it can be very helpful to also print the diff between
-// the expected string and the actual one.  To achieve that, you can
-// optionally stream additional information to a special variable
-// named result_listener, whose type is a pointer to class
-// MatchResultListener:
-//
-//   MATCHER_P(EqualsLongString, str, "") {
-//     if (arg == str) return true;
-//
-//     *result_listener << "the difference: "
-///                     << DiffStrings(str, arg);
-//     return false;
-//   }
-//
-// Overloading Matchers
-// ====================
-//
-// You can overload matchers with different numbers of parameters:
-//
-//   MATCHER_P(Blah, a, description_string1) { ... }
-//   MATCHER_P2(Blah, a, b, description_string2) { ... }
-//
-// Caveats
-// =======
-//
-// When defining a new matcher, you should also consider implementing
-// MatcherInterface or using MakePolymorphicMatcher().  These
-// approaches require more work than the MATCHER* macros, but also
-// give you more control on the types of the value being matched and
-// the matcher parameters, which may leads to better compiler error
-// messages when the matcher is used wrong.  They also allow
-// overloading matchers based on parameter types (as opposed to just
-// based on the number of parameters).
-//
-// MATCHER*() can only be used in a namespace scope.  The reason is
-// that C++ doesn't yet allow function-local types to be used to
-// instantiate templates.  The up-coming C++0x standard will fix this.
-// Once that's done, we'll consider supporting using MATCHER*() inside
-// a function.
-//
-// More Information
-// ================
-//
-// To learn more about using these macros, please search for 'MATCHER'
-// on http://code.google.com/p/googlemock/wiki/CookBook.
-
-#define MATCHER(name, description)\
-  class name##Matcher {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl()\
-           {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<>()));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>());\
-    }\
-    name##Matcher() {\
-    }\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##Matcher);\
-  };\
-  inline name##Matcher name() {\
-    return name##Matcher();\
-  }\
-  template <typename arg_type>\
-  bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P(name, p0, description)\
-  template <typename p0##_type>\
-  class name##MatcherP {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      explicit gmock_Impl(p0##_type gmock_p0)\
-           : p0(gmock_p0) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type>(p0)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0));\
-    }\
-    name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\
-    }\
-    p0##_type p0;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
-  };\
-  template <typename p0##_type>\
-  inline name##MatcherP<p0##_type> name(p0##_type p0) {\
-    return name##MatcherP<p0##_type>(p0);\
-  }\
-  template <typename p0##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P2(name, p0, p1, description)\
-  template <typename p0##_type, typename p1##_type>\
-  class name##MatcherP2 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
-           : p0(gmock_p0), p1(gmock_p1) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1));\
-    }\
-    name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \
-        p1(gmock_p1) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
-  };\
-  template <typename p0##_type, typename p1##_type>\
-  inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
-      p1##_type p1) {\
-    return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\
-  }\
-  template <typename p0##_type, typename p1##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP2<p0##_type, \
-      p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P3(name, p0, p1, p2, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  class name##MatcherP3 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
-                    p2)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2));\
-    }\
-    name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
-      p1##_type p1, p2##_type p2) {\
-    return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP3<p0##_type, p1##_type, \
-      p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P4(name, p0, p1, p2, p3, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  class name##MatcherP4 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \
-                    p3##_type>(p0, p1, p2, p3)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3));\
-    }\
-    name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \
-      p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
-      p3##_type p3) {\
-    return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
-        p1, p2, p3);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \
-      p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  class name##MatcherP5 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type>(p0, p1, p2, p3, p4)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\
-    }\
-    name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, \
-        p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4) {\
-    return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type>(p0, p1, p2, p3, p4);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  class name##MatcherP6 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4), p5(gmock_p5) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\
-    }\
-    name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \
-      p3##_type p3, p4##_type p4, p5##_type p5) {\
-    return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-      p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  class name##MatcherP7 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
-                    p6)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\
-    }\
-    name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \
-        p6(gmock_p6) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \
-      p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
-      p6##_type p6) {\
-    return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-      p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  class name##MatcherP8 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
-                    p3, p4, p5, p6, p7)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\
-    }\
-    name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, \
-        p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-        p7(gmock_p7) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \
-      p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \
-      p6##_type p6, p7##_type p7) {\
-    return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \
-        p6, p7);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-      p5##_type, p6##_type, \
-      p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  class name##MatcherP9 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-               p8(gmock_p8) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-      p8##_type p8;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type, p5##_type, p6##_type, p7##_type, \
-                    p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\
-    }\
-    name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
-        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \
-        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-        p8(gmock_p8) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-    p8##_type p8;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type, \
-      p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \
-      p8##_type p8) {\
-    return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \
-        p3, p4, p5, p6, p7, p8);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
-      p5##_type, p6##_type, p7##_type, \
-      p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  class name##MatcherP10 {\
-   public:\
-    template <typename arg_type>\
-    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\
-     public:\
-      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
-          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
-          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
-          p9##_type gmock_p9)\
-           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \
-               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \
-               p8(gmock_p8), p9(gmock_p9) {}\
-      virtual bool MatchAndExplain(\
-          arg_type arg, ::testing::MatchResultListener* result_listener) const;\
-      virtual void DescribeTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(false);\
-      }\
-      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\
-        *gmock_os << FormatDescription(true);\
-      }\
-      p0##_type p0;\
-      p1##_type p1;\
-      p2##_type p2;\
-      p3##_type p3;\
-      p4##_type p4;\
-      p5##_type p5;\
-      p6##_type p6;\
-      p7##_type p7;\
-      p8##_type p8;\
-      p9##_type p9;\
-     private:\
-      ::testing::internal::string FormatDescription(bool negation) const {\
-        const ::testing::internal::string gmock_description = (description);\
-        if (!gmock_description.empty())\
-          return gmock_description;\
-        return ::testing::internal::FormatMatcherDescription(\
-            negation, #name,\
-            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
-                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
-                    p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
-                    p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
-      }\
-      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
-    };\
-    template <typename arg_type>\
-    operator ::testing::Matcher<arg_type>() const {\
-      return ::testing::Matcher<arg_type>(\
-          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\
-    }\
-    name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
-        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
-        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
-        p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \
-        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \
-        p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\
-    }\
-    p0##_type p0;\
-    p1##_type p1;\
-    p2##_type p2;\
-    p3##_type p3;\
-    p4##_type p4;\
-    p5##_type p5;\
-    p6##_type p6;\
-    p7##_type p7;\
-    p8##_type p8;\
-    p9##_type p9;\
-   private:\
-    GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
-  };\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
-      p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
-      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
-      p9##_type p9) {\
-    return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
-        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \
-        p1, p2, p3, p4, p5, p6, p7, p8, p9);\
-  }\
-  template <typename p0##_type, typename p1##_type, typename p2##_type, \
-      typename p3##_type, typename p4##_type, typename p5##_type, \
-      typename p6##_type, typename p7##_type, typename p8##_type, \
-      typename p9##_type>\
-  template <typename arg_type>\
-  bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \
-      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
-      p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\
-      arg_type arg,\
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
-          const
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_

+ 0 - 274
Src/ThirdParty/gmock/gmock-generated-nice-strict.h

@@ -1,274 +0,0 @@
-// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
-
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Implements class templates NiceMock and StrictMock.
-//
-// Given a mock class MockFoo that is created using Google Mock,
-// NiceMock<MockFoo> is a subclass of MockFoo that allows
-// uninteresting calls (i.e. calls to mock methods that have no
-// EXPECT_CALL specs), and StrictMock<MockFoo> is a subclass of
-// MockFoo that treats all uninteresting calls as errors.
-//
-// NiceMock and StrictMock "inherits" the constructors of their
-// respective base class, with up-to 10 arguments.  Therefore you can
-// write NiceMock<MockFoo>(5, "a") to construct a nice mock where
-// MockFoo has a constructor that accepts (int, const char*), for
-// example.
-//
-// A known limitation is that NiceMock<MockFoo> and
-// StrictMock<MockFoo> only works for mock methods defined using the
-// MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.  If a
-// mock method is defined in a base class of MockFoo, the "nice" or
-// "strict" modifier may not affect it, depending on the compiler.  In
-// particular, nesting NiceMock and StrictMock is NOT supported.
-//
-// Another known limitation is that the constructors of the base mock
-// cannot have arguments passed by non-const reference, which are
-// banned by the Google C++ style guide anyway.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
-
-#include "gmock/gmock-spec-builders.h"
-#include "gmock/internal/gmock-port.h"
-
-namespace testing {
-
-template <class MockClass>
-class NiceMock : public MockClass {
- public:
-  // We don't factor out the constructor body to a common method, as
-  // we have to avoid a possible clash with members of MockClass.
-  NiceMock() {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  // C++ doesn't (yet) allow inheritance of constructors, so we have
-  // to define it for each arity.
-  template <typename A1>
-  explicit NiceMock(const A1& a1) : MockClass(a1) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-  template <typename A1, typename A2>
-  NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3,
-      const A4& a4) : MockClass(a1, a2, a3, a4) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
-      a6, a7) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
-      a2, a3, a4, a5, a6, a7, a8) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8, typename A9>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8,
-      const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8, typename A9, typename A10>
-  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
-      const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
-    ::testing::Mock::AllowUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  virtual ~NiceMock() {
-    ::testing::Mock::UnregisterCallReaction(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
-};
-
-template <class MockClass>
-class StrictMock : public MockClass {
- public:
-  // We don't factor out the constructor body to a common method, as
-  // we have to avoid a possible clash with members of MockClass.
-  StrictMock() {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1>
-  explicit StrictMock(const A1& a1) : MockClass(a1) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-  template <typename A1, typename A2>
-  StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3,
-      const A4& a4) : MockClass(a1, a2, a3, a4) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5) : MockClass(a1, a2, a3, a4, a5) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,
-      a6, a7) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,
-      a2, a3, a4, a5, a6, a7, a8) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8, typename A9>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8,
-      const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  template <typename A1, typename A2, typename A3, typename A4, typename A5,
-      typename A6, typename A7, typename A8, typename A9, typename A10>
-  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,
-      const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,
-      const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
-    ::testing::Mock::FailUninterestingCalls(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
-  virtual ~StrictMock() {
-    ::testing::Mock::UnregisterCallReaction(
-        internal::ImplicitCast_<MockClass*>(this));
-  }
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
-};
-
-// The following specializations catch some (relatively more common)
-// user errors of nesting nice and strict mocks.  They do NOT catch
-// all possible errors.
-
-// These specializations are declared but not defined, as NiceMock and
-// StrictMock cannot be nested.
-template <typename MockClass>
-class NiceMock<NiceMock<MockClass> >;
-template <typename MockClass>
-class NiceMock<StrictMock<MockClass> >;
-template <typename MockClass>
-class StrictMock<NiceMock<MockClass> >;
-template <typename MockClass>
-class StrictMock<StrictMock<MockClass> >;
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_

+ 0 - 3066
Src/ThirdParty/gmock/gmock-matchers.h

@@ -1,3066 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some commonly used argument matchers.  More
-// matchers can be defined by the user implementing the
-// MatcherInterface<T> interface if necessary.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
-
-#include <algorithm>
-#include <limits>
-#include <ostream>  // NOLINT
-#include <sstream>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "gmock/internal/gmock-internal-utils.h"
-#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-
-// To implement a matcher Foo for type T, define:
-//   1. a class FooMatcherImpl that implements the
-//      MatcherInterface<T> interface, and
-//   2. a factory function that creates a Matcher<T> object from a
-//      FooMatcherImpl*.
-//
-// The two-level delegation design makes it possible to allow a user
-// to write "v" instead of "Eq(v)" where a Matcher is expected, which
-// is impossible if we pass matchers by pointers.  It also eases
-// ownership management as Matcher objects can now be copied like
-// plain values.
-
-// MatchResultListener is an abstract class.  Its << operator can be
-// used by a matcher to explain why a value matches or doesn't match.
-//
-// TODO(wan@google.com): add method
-//   bool InterestedInWhy(bool result) const;
-// to indicate whether the listener is interested in why the match
-// result is 'result'.
-class MatchResultListener {
- public:
-  // Creates a listener object with the given underlying ostream.  The
-  // listener does not own the ostream.
-  explicit MatchResultListener(::std::ostream* os) : stream_(os) {}
-  virtual ~MatchResultListener() = 0;  // Makes this class abstract.
-
-  // Streams x to the underlying ostream; does nothing if the ostream
-  // is NULL.
-  template <typename T>
-  MatchResultListener& operator<<(const T& x) {
-    if (stream_ != NULL)
-      *stream_ << x;
-    return *this;
-  }
-
-  // Returns the underlying ostream.
-  ::std::ostream* stream() { return stream_; }
-
-  // Returns true iff the listener is interested in an explanation of
-  // the match result.  A matcher's MatchAndExplain() method can use
-  // this information to avoid generating the explanation when no one
-  // intends to hear it.
-  bool IsInterested() const { return stream_ != NULL; }
-
- private:
-  ::std::ostream* const stream_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
-};
-
-inline MatchResultListener::~MatchResultListener() {
-}
-
-// The implementation of a matcher.
-template <typename T>
-class MatcherInterface {
- public:
-  virtual ~MatcherInterface() {}
-
-  // Returns true iff the matcher matches x; also explains the match
-  // result to 'listener', in the form of a non-restrictive relative
-  // clause ("which ...", "whose ...", etc) that describes x.  For
-  // example, the MatchAndExplain() method of the Pointee(...) matcher
-  // should generate an explanation like "which points to ...".
-  //
-  // You should override this method when defining a new matcher.
-  //
-  // It's the responsibility of the caller (Google Mock) to guarantee
-  // that 'listener' is not NULL.  This helps to simplify a matcher's
-  // implementation when it doesn't care about the performance, as it
-  // can talk to 'listener' without checking its validity first.
-  // However, in order to implement dummy listeners efficiently,
-  // listener->stream() may be NULL.
-  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
-
-  // Describes this matcher to an ostream.  The function should print
-  // a verb phrase that describes the property a value matching this
-  // matcher should have.  The subject of the verb phrase is the value
-  // being matched.  For example, the DescribeTo() method of the Gt(7)
-  // matcher prints "is greater than 7".
-  virtual void DescribeTo(::std::ostream* os) const = 0;
-
-  // Describes the negation of this matcher to an ostream.  For
-  // example, if the description of this matcher is "is greater than
-  // 7", the negated description could be "is not greater than 7".
-  // You are not required to override this when implementing
-  // MatcherInterface, but it is highly advised so that your matcher
-  // can produce good error messages.
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "not (";
-    DescribeTo(os);
-    *os << ")";
-  }
-};
-
-namespace internal {
-
-// A match result listener that ignores the explanation.
-class DummyMatchResultListener : public MatchResultListener {
- public:
-  DummyMatchResultListener() : MatchResultListener(NULL) {}
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
-};
-
-// A match result listener that forwards the explanation to a given
-// ostream.  The difference between this and MatchResultListener is
-// that the former is concrete.
-class StreamMatchResultListener : public MatchResultListener {
- public:
-  explicit StreamMatchResultListener(::std::ostream* os)
-      : MatchResultListener(os) {}
-
- private:
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
-};
-
-// A match result listener that stores the explanation in a string.
-class StringMatchResultListener : public MatchResultListener {
- public:
-  StringMatchResultListener() : MatchResultListener(&ss_) {}
-
-  // Returns the explanation heard so far.
-  internal::string str() const { return ss_.str(); }
-
- private:
-  ::std::stringstream ss_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);
-};
-
-// An internal class for implementing Matcher<T>, which will derive
-// from it.  We put functionalities common to all Matcher<T>
-// specializations here to avoid code duplication.
-template <typename T>
-class MatcherBase {
- public:
-  // Returns true iff the matcher matches x; also explains the match
-  // result to 'listener'.
-  bool MatchAndExplain(T x, MatchResultListener* listener) const {
-    return impl_->MatchAndExplain(x, listener);
-  }
-
-  // Returns true iff this matcher matches x.
-  bool Matches(T x) const {
-    DummyMatchResultListener dummy;
-    return MatchAndExplain(x, &dummy);
-  }
-
-  // Describes this matcher to an ostream.
-  void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
-
-  // Describes the negation of this matcher to an ostream.
-  void DescribeNegationTo(::std::ostream* os) const {
-    impl_->DescribeNegationTo(os);
-  }
-
-  // Explains why x matches, or doesn't match, the matcher.
-  void ExplainMatchResultTo(T x, ::std::ostream* os) const {
-    StreamMatchResultListener listener(os);
-    MatchAndExplain(x, &listener);
-  }
-
- protected:
-  MatcherBase() {}
-
-  // Constructs a matcher from its implementation.
-  explicit MatcherBase(const MatcherInterface<T>* impl)
-      : impl_(impl) {}
-
-  virtual ~MatcherBase() {}
-
- private:
-  // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
-  // interfaces.  The former dynamically allocates a chunk of memory
-  // to hold the reference count, while the latter tracks all
-  // references using a circular linked list without allocating
-  // memory.  It has been observed that linked_ptr performs better in
-  // typical scenarios.  However, shared_ptr can out-perform
-  // linked_ptr when there are many more uses of the copy constructor
-  // than the default constructor.
-  //
-  // If performance becomes a problem, we should see if using
-  // shared_ptr helps.
-  ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;
-};
-
-}  // namespace internal
-
-// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
-// object that can check whether a value of type T matches.  The
-// implementation of Matcher<T> is just a linked_ptr to const
-// MatcherInterface<T>, so copying is fairly cheap.  Don't inherit
-// from Matcher!
-template <typename T>
-class Matcher : public internal::MatcherBase<T> {
- public:
-  // Constructs a null matcher.  Needed for storing Matcher objects in STL
-  // containers.  A default-constructed matcher is not yet initialized.  You
-  // cannot use it until a valid value has been assigned to it.
-  Matcher() {}
-
-  // Constructs a matcher from its implementation.
-  explicit Matcher(const MatcherInterface<T>* impl)
-      : internal::MatcherBase<T>(impl) {}
-
-  // Implicit constructor here allows people to write
-  // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
-  Matcher(T value);  // NOLINT
-};
-
-// The following two specializations allow the user to write str
-// instead of Eq(str) and "foo" instead of Eq("foo") when a string
-// matcher is expected.
-template <>
-class Matcher<const internal::string&>
-    : public internal::MatcherBase<const internal::string&> {
- public:
-  Matcher() {}
-
-  explicit Matcher(const MatcherInterface<const internal::string&>* impl)
-      : internal::MatcherBase<const internal::string&>(impl) {}
-
-  // Allows the user to write str instead of Eq(str) sometimes, where
-  // str is a string object.
-  Matcher(const internal::string& s);  // NOLINT
-
-  // Allows the user to write "foo" instead of Eq("foo") sometimes.
-  Matcher(const char* s);  // NOLINT
-};
-
-template <>
-class Matcher<internal::string>
-    : public internal::MatcherBase<internal::string> {
- public:
-  Matcher() {}
-
-  explicit Matcher(const MatcherInterface<internal::string>* impl)
-      : internal::MatcherBase<internal::string>(impl) {}
-
-  // Allows the user to write str instead of Eq(str) sometimes, where
-  // str is a string object.
-  Matcher(const internal::string& s);  // NOLINT
-
-  // Allows the user to write "foo" instead of Eq("foo") sometimes.
-  Matcher(const char* s);  // NOLINT
-};
-
-// The PolymorphicMatcher class template makes it easy to implement a
-// polymorphic matcher (i.e. a matcher that can match values of more
-// than one type, e.g. Eq(n) and NotNull()).
-//
-// To define a polymorphic matcher, a user should provide an Impl
-// class that has a DescribeTo() method and a DescribeNegationTo()
-// method, and define a member function (or member function template)
-//
-//   bool MatchAndExplain(const Value& value,
-//                        MatchResultListener* listener) const;
-//
-// See the definition of NotNull() for a complete example.
-template <class Impl>
-class PolymorphicMatcher {
- public:
-  explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
-
-  // Returns a mutable reference to the underlying matcher
-  // implementation object.
-  Impl& mutable_impl() { return impl_; }
-
-  // Returns an immutable reference to the underlying matcher
-  // implementation object.
-  const Impl& impl() const { return impl_; }
-
-  template <typename T>
-  operator Matcher<T>() const {
-    return Matcher<T>(new MonomorphicImpl<T>(impl_));
-  }
-
- private:
-  template <typename T>
-  class MonomorphicImpl : public MatcherInterface<T> {
-   public:
-    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      impl_.DescribeTo(os);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      impl_.DescribeNegationTo(os);
-    }
-
-    virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
-      return impl_.MatchAndExplain(x, listener);
-    }
-
-   private:
-    const Impl impl_;
-
-    GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
-  };
-
-  Impl impl_;
-
-  GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
-};
-
-// Creates a matcher from its implementation.  This is easier to use
-// than the Matcher<T> constructor as it doesn't require you to
-// explicitly write the template argument, e.g.
-//
-//   MakeMatcher(foo);
-// vs
-//   Matcher<const string&>(foo);
-template <typename T>
-inline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {
-  return Matcher<T>(impl);
-};
-
-// Creates a polymorphic matcher from its implementation.  This is
-// easier to use than the PolymorphicMatcher<Impl> constructor as it
-// doesn't require you to explicitly write the template argument, e.g.
-//
-//   MakePolymorphicMatcher(foo);
-// vs
-//   PolymorphicMatcher<TypeOfFoo>(foo);
-template <class Impl>
-inline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {
-  return PolymorphicMatcher<Impl>(impl);
-}
-
-// In order to be safe and clear, casting between different matcher
-// types is done explicitly via MatcherCast<T>(m), which takes a
-// matcher m and returns a Matcher<T>.  It compiles only when T can be
-// statically converted to the argument type of m.
-template <typename T, typename M>
-Matcher<T> MatcherCast(M m);
-
-// Implements SafeMatcherCast().
-//
-// We use an intermediate class to do the actual safe casting as Nokia's
-// Symbian compiler cannot decide between
-// template <T, M> ... (M) and
-// template <T, U> ... (const Matcher<U>&)
-// for function templates but can for member function templates.
-template <typename T>
-class SafeMatcherCastImpl {
- public:
-  // This overload handles polymorphic matchers only since monomorphic
-  // matchers are handled by the next one.
-  template <typename M>
-  static inline Matcher<T> Cast(M polymorphic_matcher) {
-    return Matcher<T>(polymorphic_matcher);
-  }
-
-  // This overload handles monomorphic matchers.
-  //
-  // In general, if type T can be implicitly converted to type U, we can
-  // safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is
-  // contravariant): just keep a copy of the original Matcher<U>, convert the
-  // argument from type T to U, and then pass it to the underlying Matcher<U>.
-  // The only exception is when U is a reference and T is not, as the
-  // underlying Matcher<U> may be interested in the argument's address, which
-  // is not preserved in the conversion from T to U.
-  template <typename U>
-  static inline Matcher<T> Cast(const Matcher<U>& matcher) {
-    // Enforce that T can be implicitly converted to U.
-    GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value),
-                          T_must_be_implicitly_convertible_to_U);
-    // Enforce that we are not converting a non-reference type T to a reference
-    // type U.
-    GTEST_COMPILE_ASSERT_(
-        internal::is_reference<T>::value || !internal::is_reference<U>::value,
-        cannot_convert_non_referentce_arg_to_reference);
-    // In case both T and U are arithmetic types, enforce that the
-    // conversion is not lossy.
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;
-    const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
-    const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
-    GTEST_COMPILE_ASSERT_(
-        kTIsOther || kUIsOther ||
-        (internal::LosslessArithmeticConvertible<RawT, RawU>::value),
-        conversion_of_arithmetic_types_must_be_lossless);
-    return MatcherCast<T>(matcher);
-  }
-};
-
-template <typename T, typename M>
-inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {
-  return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);
-}
-
-// A<T>() returns a matcher that matches any value of type T.
-template <typename T>
-Matcher<T> A();
-
-// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
-// and MUST NOT BE USED IN USER CODE!!!
-namespace internal {
-
-// If the explanation is not empty, prints it to the ostream.
-inline void PrintIfNotEmpty(const internal::string& explanation,
-                            std::ostream* os) {
-  if (explanation != "" && os != NULL) {
-    *os << ", " << explanation;
-  }
-}
-
-// Returns true if the given type name is easy to read by a human.
-// This is used to decide whether printing the type of a value might
-// be helpful.
-inline bool IsReadableTypeName(const string& type_name) {
-  // We consider a type name readable if it's short or doesn't contain
-  // a template or function type.
-  return (type_name.length() <= 20 ||
-          type_name.find_first_of("<(") == string::npos);
-}
-
-// Matches the value against the given matcher, prints the value and explains
-// the match result to the listener. Returns the match result.
-// 'listener' must not be NULL.
-// Value cannot be passed by const reference, because some matchers take a
-// non-const argument.
-template <typename Value, typename T>
-bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,
-                          MatchResultListener* listener) {
-  if (!listener->IsInterested()) {
-    // If the listener is not interested, we do not need to construct the
-    // inner explanation.
-    return matcher.Matches(value);
-  }
-
-  StringMatchResultListener inner_listener;
-  const bool match = matcher.MatchAndExplain(value, &inner_listener);
-
-  UniversalPrint(value, listener->stream());
-#if GTEST_HAS_RTTI
-  const string& type_name = GetTypeName<Value>();
-  if (IsReadableTypeName(type_name))
-    *listener->stream() << " (of type " << type_name << ")";
-#endif
-  PrintIfNotEmpty(inner_listener.str(), listener->stream());
-
-  return match;
-}
-
-// An internal helper class for doing compile-time loop on a tuple's
-// fields.
-template <size_t N>
-class TuplePrefix {
- public:
-  // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true
-  // iff the first N fields of matcher_tuple matches the first N
-  // fields of value_tuple, respectively.
-  template <typename MatcherTuple, typename ValueTuple>
-  static bool Matches(const MatcherTuple& matcher_tuple,
-                      const ValueTuple& value_tuple) {
-    using ::std::tr1::get;
-    return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple)
-        && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple));
-  }
-
-  // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
-  // describes failures in matching the first N fields of matchers
-  // against the first N fields of values.  If there is no failure,
-  // nothing will be streamed to os.
-  template <typename MatcherTuple, typename ValueTuple>
-  static void ExplainMatchFailuresTo(const MatcherTuple& matchers,
-                                     const ValueTuple& values,
-                                     ::std::ostream* os) {
-    using ::std::tr1::tuple_element;
-    using ::std::tr1::get;
-
-    // First, describes failures in the first N - 1 fields.
-    TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os);
-
-    // Then describes the failure (if any) in the (N - 1)-th (0-based)
-    // field.
-    typename tuple_element<N - 1, MatcherTuple>::type matcher =
-        get<N - 1>(matchers);
-    typedef typename tuple_element<N - 1, ValueTuple>::type Value;
-    Value value = get<N - 1>(values);
-    StringMatchResultListener listener;
-    if (!matcher.MatchAndExplain(value, &listener)) {
-      // TODO(wan): include in the message the name of the parameter
-      // as used in MOCK_METHOD*() when possible.
-      *os << "  Expected arg #" << N - 1 << ": ";
-      get<N - 1>(matchers).DescribeTo(os);
-      *os << "\n           Actual: ";
-      // We remove the reference in type Value to prevent the
-      // universal printer from printing the address of value, which
-      // isn't interesting to the user most of the time.  The
-      // matcher's MatchAndExplain() method handles the case when
-      // the address is interesting.
-      internal::UniversalPrint(value, os);
-      PrintIfNotEmpty(listener.str(), os);
-      *os << "\n";
-    }
-  }
-};
-
-// The base case.
-template <>
-class TuplePrefix<0> {
- public:
-  template <typename MatcherTuple, typename ValueTuple>
-  static bool Matches(const MatcherTuple& /* matcher_tuple */,
-                      const ValueTuple& /* value_tuple */) {
-    return true;
-  }
-
-  template <typename MatcherTuple, typename ValueTuple>
-  static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,
-                                     const ValueTuple& /* values */,
-                                     ::std::ostream* /* os */) {}
-};
-
-// TupleMatches(matcher_tuple, value_tuple) returns true iff all
-// matchers in matcher_tuple match the corresponding fields in
-// value_tuple.  It is a compiler error if matcher_tuple and
-// value_tuple have different number of fields or incompatible field
-// types.
-template <typename MatcherTuple, typename ValueTuple>
-bool TupleMatches(const MatcherTuple& matcher_tuple,
-                  const ValueTuple& value_tuple) {
-  using ::std::tr1::tuple_size;
-  // Makes sure that matcher_tuple and value_tuple have the same
-  // number of fields.
-  GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
-                        tuple_size<ValueTuple>::value,
-                        matcher_and_value_have_different_numbers_of_fields);
-  return TuplePrefix<tuple_size<ValueTuple>::value>::
-      Matches(matcher_tuple, value_tuple);
-}
-
-// Describes failures in matching matchers against values.  If there
-// is no failure, nothing will be streamed to os.
-template <typename MatcherTuple, typename ValueTuple>
-void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
-                                const ValueTuple& values,
-                                ::std::ostream* os) {
-  using ::std::tr1::tuple_size;
-  TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
-      matchers, values, os);
-}
-
-// The MatcherCastImpl class template is a helper for implementing
-// MatcherCast().  We need this helper in order to partially
-// specialize the implementation of MatcherCast() (C++ allows
-// class/struct templates to be partially specialized, but not
-// function templates.).
-
-// This general version is used when MatcherCast()'s argument is a
-// polymorphic matcher (i.e. something that can be converted to a
-// Matcher but is not one yet; for example, Eq(value)).
-template <typename T, typename M>
-class MatcherCastImpl {
- public:
-  static Matcher<T> Cast(M polymorphic_matcher) {
-    return Matcher<T>(polymorphic_matcher);
-  }
-};
-
-// This more specialized version is used when MatcherCast()'s argument
-// is already a Matcher.  This only compiles when type T can be
-// statically converted to type U.
-template <typename T, typename U>
-class MatcherCastImpl<T, Matcher<U> > {
- public:
-  static Matcher<T> Cast(const Matcher<U>& source_matcher) {
-    return Matcher<T>(new Impl(source_matcher));
-  }
-
- private:
-  class Impl : public MatcherInterface<T> {
-   public:
-    explicit Impl(const Matcher<U>& source_matcher)
-        : source_matcher_(source_matcher) {}
-
-    // We delegate the matching logic to the source matcher.
-    virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
-      return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
-    }
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      source_matcher_.DescribeTo(os);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      source_matcher_.DescribeNegationTo(os);
-    }
-
-   private:
-    const Matcher<U> source_matcher_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-};
-
-// This even more specialized version is used for efficiently casting
-// a matcher to its own type.
-template <typename T>
-class MatcherCastImpl<T, Matcher<T> > {
- public:
-  static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }
-};
-
-// Implements A<T>().
-template <typename T>
-class AnyMatcherImpl : public MatcherInterface<T> {
- public:
-  virtual bool MatchAndExplain(
-      T /* x */, MatchResultListener* /* listener */) const { return true; }
-  virtual void DescribeTo(::std::ostream* os) const { *os << "is anything"; }
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    // This is mostly for completeness' safe, as it's not very useful
-    // to write Not(A<bool>()).  However we cannot completely rule out
-    // such a possibility, and it doesn't hurt to be prepared.
-    *os << "never matches";
-  }
-};
-
-// Implements _, a matcher that matches any value of any
-// type.  This is a polymorphic matcher, so we need a template type
-// conversion operator to make it appearing as a Matcher<T> for any
-// type T.
-class AnythingMatcher {
- public:
-  template <typename T>
-  operator Matcher<T>() const { return A<T>(); }
-};
-
-// Implements a matcher that compares a given value with a
-// pre-supplied value using one of the ==, <=, <, etc, operators.  The
-// two values being compared don't have to have the same type.
-//
-// The matcher defined here is polymorphic (for example, Eq(5) can be
-// used to match an int, a short, a double, etc).  Therefore we use
-// a template type conversion operator in the implementation.
-//
-// We define this as a macro in order to eliminate duplicated source
-// code.
-//
-// The following template definition assumes that the Rhs parameter is
-// a "bare" type (i.e. neither 'const T' nor 'T&').
-#define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \
-    name, op, relation, negated_relation) \
-  template <typename Rhs> class name##Matcher { \
-   public: \
-    explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \
-    template <typename Lhs> \
-    operator Matcher<Lhs>() const { \
-      return MakeMatcher(new Impl<Lhs>(rhs_)); \
-    } \
-   private: \
-    template <typename Lhs> \
-    class Impl : public MatcherInterface<Lhs> { \
-     public: \
-      explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \
-      virtual bool MatchAndExplain(\
-          Lhs lhs, MatchResultListener* /* listener */) const { \
-        return lhs op rhs_; \
-      } \
-      virtual void DescribeTo(::std::ostream* os) const { \
-        *os << relation  " "; \
-        UniversalPrint(rhs_, os); \
-      } \
-      virtual void DescribeNegationTo(::std::ostream* os) const { \
-        *os << negated_relation  " "; \
-        UniversalPrint(rhs_, os); \
-      } \
-     private: \
-      Rhs rhs_; \
-      GTEST_DISALLOW_ASSIGN_(Impl); \
-    }; \
-    Rhs rhs_; \
-    GTEST_DISALLOW_ASSIGN_(name##Matcher); \
-  }
-
-// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
-// respectively.
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "is equal to", "isn't equal to");
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "is >=", "isn't >=");
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "is >", "isn't >");
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "is <=", "isn't <=");
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "is <", "isn't <");
-GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "isn't equal to", "is equal to");
-
-#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
-
-// Implements the polymorphic IsNull() matcher, which matches any raw or smart
-// pointer that is NULL.
-class IsNullMatcher {
- public:
-  template <typename Pointer>
-  bool MatchAndExplain(const Pointer& p,
-                       MatchResultListener* /* listener */) const {
-    return GetRawPointer(p) == NULL;
-  }
-
-  void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "isn't NULL";
-  }
-};
-
-// Implements the polymorphic NotNull() matcher, which matches any raw or smart
-// pointer that is not NULL.
-class NotNullMatcher {
- public:
-  template <typename Pointer>
-  bool MatchAndExplain(const Pointer& p,
-                       MatchResultListener* /* listener */) const {
-    return GetRawPointer(p) != NULL;
-  }
-
-  void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "is NULL";
-  }
-};
-
-// Ref(variable) matches any argument that is a reference to
-// 'variable'.  This matcher is polymorphic as it can match any
-// super type of the type of 'variable'.
-//
-// The RefMatcher template class implements Ref(variable).  It can
-// only be instantiated with a reference type.  This prevents a user
-// from mistakenly using Ref(x) to match a non-reference function
-// argument.  For example, the following will righteously cause a
-// compiler error:
-//
-//   int n;
-//   Matcher<int> m1 = Ref(n);   // This won't compile.
-//   Matcher<int&> m2 = Ref(n);  // This will compile.
-template <typename T>
-class RefMatcher;
-
-template <typename T>
-class RefMatcher<T&> {
-  // Google Mock is a generic framework and thus needs to support
-  // mocking any function types, including those that take non-const
-  // reference arguments.  Therefore the template parameter T (and
-  // Super below) can be instantiated to either a const type or a
-  // non-const type.
- public:
-  // RefMatcher() takes a T& instead of const T&, as we want the
-  // compiler to catch using Ref(const_value) as a matcher for a
-  // non-const reference.
-  explicit RefMatcher(T& x) : object_(x) {}  // NOLINT
-
-  template <typename Super>
-  operator Matcher<Super&>() const {
-    // By passing object_ (type T&) to Impl(), which expects a Super&,
-    // we make sure that Super is a super type of T.  In particular,
-    // this catches using Ref(const_value) as a matcher for a
-    // non-const reference, as you cannot implicitly convert a const
-    // reference to a non-const reference.
-    return MakeMatcher(new Impl<Super>(object_));
-  }
-
- private:
-  template <typename Super>
-  class Impl : public MatcherInterface<Super&> {
-   public:
-    explicit Impl(Super& x) : object_(x) {}  // NOLINT
-
-    // MatchAndExplain() takes a Super& (as opposed to const Super&)
-    // in order to match the interface MatcherInterface<Super&>.
-    virtual bool MatchAndExplain(
-        Super& x, MatchResultListener* listener) const {
-      *listener << "which is located @" << static_cast<const void*>(&x);
-      return &x == &object_;
-    }
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      *os << "references the variable ";
-      UniversalPrinter<Super&>::Print(object_, os);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      *os << "does not reference the variable ";
-      UniversalPrinter<Super&>::Print(object_, os);
-    }
-
-   private:
-    const Super& object_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  T& object_;
-
-  GTEST_DISALLOW_ASSIGN_(RefMatcher);
-};
-
-// Polymorphic helper functions for narrow and wide string matchers.
-inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
-  return String::CaseInsensitiveCStringEquals(lhs, rhs);
-}
-
-inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
-                                         const wchar_t* rhs) {
-  return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
-}
-
-// String comparison for narrow or wide strings that can have embedded NUL
-// characters.
-template <typename StringType>
-bool CaseInsensitiveStringEquals(const StringType& s1,
-                                 const StringType& s2) {
-  // Are the heads equal?
-  if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {
-    return false;
-  }
-
-  // Skip the equal heads.
-  const typename StringType::value_type nul = 0;
-  const size_t i1 = s1.find(nul), i2 = s2.find(nul);
-
-  // Are we at the end of either s1 or s2?
-  if (i1 == StringType::npos || i2 == StringType::npos) {
-    return i1 == i2;
-  }
-
-  // Are the tails equal?
-  return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));
-}
-
-// String matchers.
-
-// Implements equality-based string matchers like StrEq, StrCaseNe, and etc.
-template <typename StringType>
-class StrEqualityMatcher {
- public:
-  typedef typename StringType::const_pointer ConstCharPointer;
-
-  StrEqualityMatcher(const StringType& str, bool expect_eq,
-                     bool case_sensitive)
-      : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
-
-  // When expect_eq_ is true, returns true iff s is equal to string_;
-  // otherwise returns true iff s is not equal to string_.
-  bool MatchAndExplain(ConstCharPointer s,
-                       MatchResultListener* listener) const {
-    if (s == NULL) {
-      return !expect_eq_;
-    }
-    return MatchAndExplain(StringType(s), listener);
-  }
-
-  bool MatchAndExplain(const StringType& s,
-                       MatchResultListener* /* listener */) const {
-    const bool eq = case_sensitive_ ? s == string_ :
-        CaseInsensitiveStringEquals(s, string_);
-    return expect_eq_ == eq;
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    DescribeToHelper(expect_eq_, os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    DescribeToHelper(!expect_eq_, os);
-  }
-
- private:
-  void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
-    *os << (expect_eq ? "is " : "isn't ");
-    *os << "equal to ";
-    if (!case_sensitive_) {
-      *os << "(ignoring case) ";
-    }
-    UniversalPrint(string_, os);
-  }
-
-  const StringType string_;
-  const bool expect_eq_;
-  const bool case_sensitive_;
-
-  GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
-};
-
-// Implements the polymorphic HasSubstr(substring) matcher, which
-// can be used as a Matcher<T> as long as T can be converted to a
-// string.
-template <typename StringType>
-class HasSubstrMatcher {
- public:
-  typedef typename StringType::const_pointer ConstCharPointer;
-
-  explicit HasSubstrMatcher(const StringType& substring)
-      : substring_(substring) {}
-
-  // These overloaded methods allow HasSubstr(substring) to be used as a
-  // Matcher<T> as long as T can be converted to string.  Returns true
-  // iff s contains substring_ as a substring.
-  bool MatchAndExplain(ConstCharPointer s,
-                       MatchResultListener* listener) const {
-    return s != NULL && MatchAndExplain(StringType(s), listener);
-  }
-
-  bool MatchAndExplain(const StringType& s,
-                       MatchResultListener* /* listener */) const {
-    return s.find(substring_) != StringType::npos;
-  }
-
-  // Describes what this matcher matches.
-  void DescribeTo(::std::ostream* os) const {
-    *os << "has substring ";
-    UniversalPrint(substring_, os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "has no substring ";
-    UniversalPrint(substring_, os);
-  }
-
- private:
-  const StringType substring_;
-
-  GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
-};
-
-// Implements the polymorphic StartsWith(substring) matcher, which
-// can be used as a Matcher<T> as long as T can be converted to a
-// string.
-template <typename StringType>
-class StartsWithMatcher {
- public:
-  typedef typename StringType::const_pointer ConstCharPointer;
-
-  explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {
-  }
-
-  // These overloaded methods allow StartsWith(prefix) to be used as a
-  // Matcher<T> as long as T can be converted to string.  Returns true
-  // iff s starts with prefix_.
-  bool MatchAndExplain(ConstCharPointer s,
-                       MatchResultListener* listener) const {
-    return s != NULL && MatchAndExplain(StringType(s), listener);
-  }
-
-  bool MatchAndExplain(const StringType& s,
-                       MatchResultListener* /* listener */) const {
-    return s.length() >= prefix_.length() &&
-        s.substr(0, prefix_.length()) == prefix_;
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "starts with ";
-    UniversalPrint(prefix_, os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't start with ";
-    UniversalPrint(prefix_, os);
-  }
-
- private:
-  const StringType prefix_;
-
-  GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
-};
-
-// Implements the polymorphic EndsWith(substring) matcher, which
-// can be used as a Matcher<T> as long as T can be converted to a
-// string.
-template <typename StringType>
-class EndsWithMatcher {
- public:
-  typedef typename StringType::const_pointer ConstCharPointer;
-
-  explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}
-
-  // These overloaded methods allow EndsWith(suffix) to be used as a
-  // Matcher<T> as long as T can be converted to string.  Returns true
-  // iff s ends with suffix_.
-  bool MatchAndExplain(ConstCharPointer s,
-                       MatchResultListener* listener) const {
-    return s != NULL && MatchAndExplain(StringType(s), listener);
-  }
-
-  bool MatchAndExplain(const StringType& s,
-                       MatchResultListener* /* listener */) const {
-    return s.length() >= suffix_.length() &&
-        s.substr(s.length() - suffix_.length()) == suffix_;
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "ends with ";
-    UniversalPrint(suffix_, os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't end with ";
-    UniversalPrint(suffix_, os);
-  }
-
- private:
-  const StringType suffix_;
-
-  GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
-};
-
-// Implements polymorphic matchers MatchesRegex(regex) and
-// ContainsRegex(regex), which can be used as a Matcher<T> as long as
-// T can be converted to a string.
-class MatchesRegexMatcher {
- public:
-  MatchesRegexMatcher(const RE* regex, bool full_match)
-      : regex_(regex), full_match_(full_match) {}
-
-  // These overloaded methods allow MatchesRegex(regex) to be used as
-  // a Matcher<T> as long as T can be converted to string.  Returns
-  // true iff s matches regular expression regex.  When full_match_ is
-  // true, a full match is done; otherwise a partial match is done.
-  bool MatchAndExplain(const char* s,
-                       MatchResultListener* listener) const {
-    return s != NULL && MatchAndExplain(internal::string(s), listener);
-  }
-
-  bool MatchAndExplain(const internal::string& s,
-                       MatchResultListener* /* listener */) const {
-    return full_match_ ? RE::FullMatch(s, *regex_) :
-        RE::PartialMatch(s, *regex_);
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << (full_match_ ? "matches" : "contains")
-        << " regular expression ";
-    UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't " << (full_match_ ? "match" : "contain")
-        << " regular expression ";
-    UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
-  }
-
- private:
-  const internal::linked_ptr<const RE> regex_;
-  const bool full_match_;
-
-  GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
-};
-
-// Implements a matcher that compares the two fields of a 2-tuple
-// using one of the ==, <=, <, etc, operators.  The two fields being
-// compared don't have to have the same type.
-//
-// The matcher defined here is polymorphic (for example, Eq() can be
-// used to match a tuple<int, short>, a tuple<const long&, double>,
-// etc).  Therefore we use a template type conversion operator in the
-// implementation.
-//
-// We define this as a macro in order to eliminate duplicated source
-// code.
-#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
-  class name##2Matcher { \
-   public: \
-    template <typename T1, typename T2> \
-    operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \
-      return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \
-    } \
-    template <typename T1, typename T2> \
-    operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \
-      return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \
-    } \
-   private: \
-    template <typename Tuple> \
-    class Impl : public MatcherInterface<Tuple> { \
-     public: \
-      virtual bool MatchAndExplain( \
-          Tuple args, \
-          MatchResultListener* /* listener */) const { \
-        return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
-      } \
-      virtual void DescribeTo(::std::ostream* os) const { \
-        *os << "are " relation;                                 \
-      } \
-      virtual void DescribeNegationTo(::std::ostream* os) const { \
-        *os << "aren't " relation; \
-      } \
-    }; \
-  }
-
-// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, "an equal pair");
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
-    Ge, >=, "a pair where the first >= the second");
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
-    Gt, >, "a pair where the first > the second");
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
-    Le, <=, "a pair where the first <= the second");
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
-    Lt, <, "a pair where the first < the second");
-GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, "an unequal pair");
-
-#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
-
-// Implements the Not(...) matcher for a particular argument type T.
-// We do not nest it inside the NotMatcher class template, as that
-// will prevent different instantiations of NotMatcher from sharing
-// the same NotMatcherImpl<T> class.
-template <typename T>
-class NotMatcherImpl : public MatcherInterface<T> {
- public:
-  explicit NotMatcherImpl(const Matcher<T>& matcher)
-      : matcher_(matcher) {}
-
-  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
-    return !matcher_.MatchAndExplain(x, listener);
-  }
-
-  virtual void DescribeTo(::std::ostream* os) const {
-    matcher_.DescribeNegationTo(os);
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    matcher_.DescribeTo(os);
-  }
-
- private:
-  const Matcher<T> matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
-};
-
-// Implements the Not(m) matcher, which matches a value that doesn't
-// match matcher m.
-template <typename InnerMatcher>
-class NotMatcher {
- public:
-  explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
-
-  // This template type conversion operator allows Not(m) to be used
-  // to match any type m can match.
-  template <typename T>
-  operator Matcher<T>() const {
-    return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
-  }
-
- private:
-  InnerMatcher matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(NotMatcher);
-};
-
-// Implements the AllOf(m1, m2) matcher for a particular argument type
-// T. We do not nest it inside the BothOfMatcher class template, as
-// that will prevent different instantiations of BothOfMatcher from
-// sharing the same BothOfMatcherImpl<T> class.
-template <typename T>
-class BothOfMatcherImpl : public MatcherInterface<T> {
- public:
-  BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
-      : matcher1_(matcher1), matcher2_(matcher2) {}
-
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "(";
-    matcher1_.DescribeTo(os);
-    *os << ") and (";
-    matcher2_.DescribeTo(os);
-    *os << ")";
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "(";
-    matcher1_.DescribeNegationTo(os);
-    *os << ") or (";
-    matcher2_.DescribeNegationTo(os);
-    *os << ")";
-  }
-
-  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
-    // If either matcher1_ or matcher2_ doesn't match x, we only need
-    // to explain why one of them fails.
-    StringMatchResultListener listener1;
-    if (!matcher1_.MatchAndExplain(x, &listener1)) {
-      *listener << listener1.str();
-      return false;
-    }
-
-    StringMatchResultListener listener2;
-    if (!matcher2_.MatchAndExplain(x, &listener2)) {
-      *listener << listener2.str();
-      return false;
-    }
-
-    // Otherwise we need to explain why *both* of them match.
-    const internal::string s1 = listener1.str();
-    const internal::string s2 = listener2.str();
-
-    if (s1 == "") {
-      *listener << s2;
-    } else {
-      *listener << s1;
-      if (s2 != "") {
-        *listener << ", and " << s2;
-      }
-    }
-    return true;
-  }
-
- private:
-  const Matcher<T> matcher1_;
-  const Matcher<T> matcher2_;
-
-  GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
-};
-
-// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
-// matches a value that matches all of the matchers m_1, ..., and m_n.
-template <typename Matcher1, typename Matcher2>
-class BothOfMatcher {
- public:
-  BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
-      : matcher1_(matcher1), matcher2_(matcher2) {}
-
-  // This template type conversion operator allows a
-  // BothOfMatcher<Matcher1, Matcher2> object to match any type that
-  // both Matcher1 and Matcher2 can match.
-  template <typename T>
-  operator Matcher<T>() const {
-    return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
-                                               SafeMatcherCast<T>(matcher2_)));
-  }
-
- private:
-  Matcher1 matcher1_;
-  Matcher2 matcher2_;
-
-  GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
-};
-
-// Implements the AnyOf(m1, m2) matcher for a particular argument type
-// T.  We do not nest it inside the AnyOfMatcher class template, as
-// that will prevent different instantiations of AnyOfMatcher from
-// sharing the same EitherOfMatcherImpl<T> class.
-template <typename T>
-class EitherOfMatcherImpl : public MatcherInterface<T> {
- public:
-  EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)
-      : matcher1_(matcher1), matcher2_(matcher2) {}
-
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "(";
-    matcher1_.DescribeTo(os);
-    *os << ") or (";
-    matcher2_.DescribeTo(os);
-    *os << ")";
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "(";
-    matcher1_.DescribeNegationTo(os);
-    *os << ") and (";
-    matcher2_.DescribeNegationTo(os);
-    *os << ")";
-  }
-
-  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
-    // If either matcher1_ or matcher2_ matches x, we just need to
-    // explain why *one* of them matches.
-    StringMatchResultListener listener1;
-    if (matcher1_.MatchAndExplain(x, &listener1)) {
-      *listener << listener1.str();
-      return true;
-    }
-
-    StringMatchResultListener listener2;
-    if (matcher2_.MatchAndExplain(x, &listener2)) {
-      *listener << listener2.str();
-      return true;
-    }
-
-    // Otherwise we need to explain why *both* of them fail.
-    const internal::string s1 = listener1.str();
-    const internal::string s2 = listener2.str();
-
-    if (s1 == "") {
-      *listener << s2;
-    } else {
-      *listener << s1;
-      if (s2 != "") {
-        *listener << ", and " << s2;
-      }
-    }
-    return false;
-  }
-
- private:
-  const Matcher<T> matcher1_;
-  const Matcher<T> matcher2_;
-
-  GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
-};
-
-// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
-// matches a value that matches at least one of the matchers m_1, ...,
-// and m_n.
-template <typename Matcher1, typename Matcher2>
-class EitherOfMatcher {
- public:
-  EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
-      : matcher1_(matcher1), matcher2_(matcher2) {}
-
-  // This template type conversion operator allows a
-  // EitherOfMatcher<Matcher1, Matcher2> object to match any type that
-  // both Matcher1 and Matcher2 can match.
-  template <typename T>
-  operator Matcher<T>() const {
-    return Matcher<T>(new EitherOfMatcherImpl<T>(
-        SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
-  }
-
- private:
-  Matcher1 matcher1_;
-  Matcher2 matcher2_;
-
-  GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
-};
-
-// Used for implementing Truly(pred), which turns a predicate into a
-// matcher.
-template <typename Predicate>
-class TrulyMatcher {
- public:
-  explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
-
-  // This method template allows Truly(pred) to be used as a matcher
-  // for type T where T is the argument type of predicate 'pred'.  The
-  // argument is passed by reference as the predicate may be
-  // interested in the address of the argument.
-  template <typename T>
-  bool MatchAndExplain(T& x,  // NOLINT
-                       MatchResultListener* /* listener */) const {
-    // Without the if-statement, MSVC sometimes warns about converting
-    // a value to bool (warning 4800).
-    //
-    // We cannot write 'return !!predicate_(x);' as that doesn't work
-    // when predicate_(x) returns a class convertible to bool but
-    // having no operator!().
-    if (predicate_(x))
-      return true;
-    return false;
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "satisfies the given predicate";
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't satisfy the given predicate";
-  }
-
- private:
-  Predicate predicate_;
-
-  GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
-};
-
-// Used for implementing Matches(matcher), which turns a matcher into
-// a predicate.
-template <typename M>
-class MatcherAsPredicate {
- public:
-  explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
-
-  // This template operator() allows Matches(m) to be used as a
-  // predicate on type T where m is a matcher on type T.
-  //
-  // The argument x is passed by reference instead of by value, as
-  // some matcher may be interested in its address (e.g. as in
-  // Matches(Ref(n))(x)).
-  template <typename T>
-  bool operator()(const T& x) const {
-    // We let matcher_ commit to a particular type here instead of
-    // when the MatcherAsPredicate object was constructed.  This
-    // allows us to write Matches(m) where m is a polymorphic matcher
-    // (e.g. Eq(5)).
-    //
-    // If we write Matcher<T>(matcher_).Matches(x) here, it won't
-    // compile when matcher_ has type Matcher<const T&>; if we write
-    // Matcher<const T&>(matcher_).Matches(x) here, it won't compile
-    // when matcher_ has type Matcher<T>; if we just write
-    // matcher_.Matches(x), it won't compile when matcher_ is
-    // polymorphic, e.g. Eq(5).
-    //
-    // MatcherCast<const T&>() is necessary for making the code work
-    // in all of the above situations.
-    return MatcherCast<const T&>(matcher_).Matches(x);
-  }
-
- private:
-  M matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
-};
-
-// For implementing ASSERT_THAT() and EXPECT_THAT().  The template
-// argument M must be a type that can be converted to a matcher.
-template <typename M>
-class PredicateFormatterFromMatcher {
- public:
-  explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {}
-
-  // This template () operator allows a PredicateFormatterFromMatcher
-  // object to act as a predicate-formatter suitable for using with
-  // Google Test's EXPECT_PRED_FORMAT1() macro.
-  template <typename T>
-  AssertionResult operator()(const char* value_text, const T& x) const {
-    // We convert matcher_ to a Matcher<const T&> *now* instead of
-    // when the PredicateFormatterFromMatcher object was constructed,
-    // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
-    // know which type to instantiate it to until we actually see the
-    // type of x here.
-    //
-    // We write MatcherCast<const T&>(matcher_) instead of
-    // Matcher<const T&>(matcher_), as the latter won't compile when
-    // matcher_ has type Matcher<T> (e.g. An<int>()).
-    const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_);
-    StringMatchResultListener listener;
-    if (MatchPrintAndExplain(x, matcher, &listener))
-      return AssertionSuccess();
-
-    ::std::stringstream ss;
-    ss << "Value of: " << value_text << "\n"
-       << "Expected: ";
-    matcher.DescribeTo(&ss);
-    ss << "\n  Actual: " << listener.str();
-    return AssertionFailure() << ss.str();
-  }
-
- private:
-  const M matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
-};
-
-// A helper function for converting a matcher to a predicate-formatter
-// without the user needing to explicitly write the type.  This is
-// used for implementing ASSERT_THAT() and EXPECT_THAT().
-template <typename M>
-inline PredicateFormatterFromMatcher<M>
-MakePredicateFormatterFromMatcher(const M& matcher) {
-  return PredicateFormatterFromMatcher<M>(matcher);
-}
-
-// Implements the polymorphic floating point equality matcher, which
-// matches two float values using ULP-based approximation.  The
-// template is meant to be instantiated with FloatType being either
-// float or double.
-template <typename FloatType>
-class FloatingEqMatcher {
- public:
-  // Constructor for FloatingEqMatcher.
-  // The matcher's input will be compared with rhs.  The matcher treats two
-  // NANs as equal if nan_eq_nan is true.  Otherwise, under IEEE standards,
-  // equality comparisons between NANs will always return false.
-  FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :
-    rhs_(rhs), nan_eq_nan_(nan_eq_nan) {}
-
-  // Implements floating point equality matcher as a Matcher<T>.
-  template <typename T>
-  class Impl : public MatcherInterface<T> {
-   public:
-    Impl(FloatType rhs, bool nan_eq_nan) :
-      rhs_(rhs), nan_eq_nan_(nan_eq_nan) {}
-
-    virtual bool MatchAndExplain(T value,
-                                 MatchResultListener* /* listener */) const {
-      const FloatingPoint<FloatType> lhs(value), rhs(rhs_);
-
-      // Compares NaNs first, if nan_eq_nan_ is true.
-      if (nan_eq_nan_ && lhs.is_nan()) {
-        return rhs.is_nan();
-      }
-
-      return lhs.AlmostEquals(rhs);
-    }
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      // os->precision() returns the previously set precision, which we
-      // store to restore the ostream to its original configuration
-      // after outputting.
-      const ::std::streamsize old_precision = os->precision(
-          ::std::numeric_limits<FloatType>::digits10 + 2);
-      if (FloatingPoint<FloatType>(rhs_).is_nan()) {
-        if (nan_eq_nan_) {
-          *os << "is NaN";
-        } else {
-          *os << "never matches";
-        }
-      } else {
-        *os << "is approximately " << rhs_;
-      }
-      os->precision(old_precision);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      // As before, get original precision.
-      const ::std::streamsize old_precision = os->precision(
-          ::std::numeric_limits<FloatType>::digits10 + 2);
-      if (FloatingPoint<FloatType>(rhs_).is_nan()) {
-        if (nan_eq_nan_) {
-          *os << "isn't NaN";
-        } else {
-          *os << "is anything";
-        }
-      } else {
-        *os << "isn't approximately " << rhs_;
-      }
-      // Restore original precision.
-      os->precision(old_precision);
-    }
-
-   private:
-    const FloatType rhs_;
-    const bool nan_eq_nan_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  // The following 3 type conversion operators allow FloatEq(rhs) and
-  // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a
-  // Matcher<const float&>, or a Matcher<float&>, but nothing else.
-  // (While Google's C++ coding style doesn't allow arguments passed
-  // by non-const reference, we may see them in code not conforming to
-  // the style.  Therefore Google Mock needs to support them.)
-  operator Matcher<FloatType>() const {
-    return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_));
-  }
-
-  operator Matcher<const FloatType&>() const {
-    return MakeMatcher(new Impl<const FloatType&>(rhs_, nan_eq_nan_));
-  }
-
-  operator Matcher<FloatType&>() const {
-    return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_));
-  }
- private:
-  const FloatType rhs_;
-  const bool nan_eq_nan_;
-
-  GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
-};
-
-// Implements the Pointee(m) matcher for matching a pointer whose
-// pointee matches matcher m.  The pointer can be either raw or smart.
-template <typename InnerMatcher>
-class PointeeMatcher {
- public:
-  explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}
-
-  // This type conversion operator template allows Pointee(m) to be
-  // used as a matcher for any pointer type whose pointee type is
-  // compatible with the inner matcher, where type Pointer can be
-  // either a raw pointer or a smart pointer.
-  //
-  // The reason we do this instead of relying on
-  // MakePolymorphicMatcher() is that the latter is not flexible
-  // enough for implementing the DescribeTo() method of Pointee().
-  template <typename Pointer>
-  operator Matcher<Pointer>() const {
-    return MakeMatcher(new Impl<Pointer>(matcher_));
-  }
-
- private:
-  // The monomorphic implementation that works for a particular pointer type.
-  template <typename Pointer>
-  class Impl : public MatcherInterface<Pointer> {
-   public:
-    typedef typename PointeeOf<GTEST_REMOVE_CONST_(  // NOLINT
-        GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee;
-
-    explicit Impl(const InnerMatcher& matcher)
-        : matcher_(MatcherCast<const Pointee&>(matcher)) {}
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      *os << "points to a value that ";
-      matcher_.DescribeTo(os);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      *os << "does not point to a value that ";
-      matcher_.DescribeTo(os);
-    }
-
-    virtual bool MatchAndExplain(Pointer pointer,
-                                 MatchResultListener* listener) const {
-      if (GetRawPointer(pointer) == NULL)
-        return false;
-
-      *listener << "which points to ";
-      return MatchPrintAndExplain(*pointer, matcher_, listener);
-    }
-
-   private:
-    const Matcher<const Pointee&> matcher_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
-  const InnerMatcher matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
-};
-
-// Implements the Field() matcher for matching a field (i.e. member
-// variable) of an object.
-template <typename Class, typename FieldType>
-class FieldMatcher {
- public:
-  FieldMatcher(FieldType Class::*field,
-               const Matcher<const FieldType&>& matcher)
-      : field_(field), matcher_(matcher) {}
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "is an object whose given field ";
-    matcher_.DescribeTo(os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "is an object whose given field ";
-    matcher_.DescribeNegationTo(os);
-  }
-
-  template <typename T>
-  bool MatchAndExplain(const T& value, MatchResultListener* listener) const {
-    return MatchAndExplainImpl(
-        typename ::testing::internal::
-            is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
-        value, listener);
-  }
-
- private:
-  // The first argument of MatchAndExplainImpl() is needed to help
-  // Symbian's C++ compiler choose which overload to use.  Its type is
-  // true_type iff the Field() matcher is used to match a pointer.
-  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
-                           MatchResultListener* listener) const {
-    *listener << "whose given field is ";
-    return MatchPrintAndExplain(obj.*field_, matcher_, listener);
-  }
-
-  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
-                           MatchResultListener* listener) const {
-    if (p == NULL)
-      return false;
-
-    *listener << "which points to an object ";
-    // Since *p has a field, it must be a class/struct/union type and
-    // thus cannot be a pointer.  Therefore we pass false_type() as
-    // the first argument.
-    return MatchAndExplainImpl(false_type(), *p, listener);
-  }
-
-  const FieldType Class::*field_;
-  const Matcher<const FieldType&> matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(FieldMatcher);
-};
-
-// Implements the Property() matcher for matching a property
-// (i.e. return value of a getter method) of an object.
-template <typename Class, typename PropertyType>
-class PropertyMatcher {
- public:
-  // The property may have a reference type, so 'const PropertyType&'
-  // may cause double references and fail to compile.  That's why we
-  // need GTEST_REFERENCE_TO_CONST, which works regardless of
-  // PropertyType being a reference or not.
-  typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
-
-  PropertyMatcher(PropertyType (Class::*property)() const,
-                  const Matcher<RefToConstProperty>& matcher)
-      : property_(property), matcher_(matcher) {}
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "is an object whose given property ";
-    matcher_.DescribeTo(os);
-  }
-
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "is an object whose given property ";
-    matcher_.DescribeNegationTo(os);
-  }
-
-  template <typename T>
-  bool MatchAndExplain(const T&value, MatchResultListener* listener) const {
-    return MatchAndExplainImpl(
-        typename ::testing::internal::
-            is_pointer<GTEST_REMOVE_CONST_(T)>::type(),
-        value, listener);
-  }
-
- private:
-  // The first argument of MatchAndExplainImpl() is needed to help
-  // Symbian's C++ compiler choose which overload to use.  Its type is
-  // true_type iff the Property() matcher is used to match a pointer.
-  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,
-                           MatchResultListener* listener) const {
-    *listener << "whose given property is ";
-    // Cannot pass the return value (for example, int) to MatchPrintAndExplain,
-    // which takes a non-const reference as argument.
-    RefToConstProperty result = (obj.*property_)();
-    return MatchPrintAndExplain(result, matcher_, listener);
-  }
-
-  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
-                           MatchResultListener* listener) const {
-    if (p == NULL)
-      return false;
-
-    *listener << "which points to an object ";
-    // Since *p has a property method, it must be a class/struct/union
-    // type and thus cannot be a pointer.  Therefore we pass
-    // false_type() as the first argument.
-    return MatchAndExplainImpl(false_type(), *p, listener);
-  }
-
-  PropertyType (Class::*property_)() const;
-  const Matcher<RefToConstProperty> matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
-};
-
-// Type traits specifying various features of different functors for ResultOf.
-// The default template specifies features for functor objects.
-// Functor classes have to typedef argument_type and result_type
-// to be compatible with ResultOf.
-template <typename Functor>
-struct CallableTraits {
-  typedef typename Functor::result_type ResultType;
-  typedef Functor StorageType;
-
-  static void CheckIsValid(Functor /* functor */) {}
-  template <typename T>
-  static ResultType Invoke(Functor f, T arg) { return f(arg); }
-};
-
-// Specialization for function pointers.
-template <typename ArgType, typename ResType>
-struct CallableTraits<ResType(*)(ArgType)> {
-  typedef ResType ResultType;
-  typedef ResType(*StorageType)(ArgType);
-
-  static void CheckIsValid(ResType(*f)(ArgType)) {
-    GTEST_CHECK_(f != NULL)
-        << "NULL function pointer is passed into ResultOf().";
-  }
-  template <typename T>
-  static ResType Invoke(ResType(*f)(ArgType), T arg) {
-    return (*f)(arg);
-  }
-};
-
-// Implements the ResultOf() matcher for matching a return value of a
-// unary function of an object.
-template <typename Callable>
-class ResultOfMatcher {
- public:
-  typedef typename CallableTraits<Callable>::ResultType ResultType;
-
-  ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)
-      : callable_(callable), matcher_(matcher) {
-    CallableTraits<Callable>::CheckIsValid(callable_);
-  }
-
-  template <typename T>
-  operator Matcher<T>() const {
-    return Matcher<T>(new Impl<T>(callable_, matcher_));
-  }
-
- private:
-  typedef typename CallableTraits<Callable>::StorageType CallableStorageType;
-
-  template <typename T>
-  class Impl : public MatcherInterface<T> {
-   public:
-    Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)
-        : callable_(callable), matcher_(matcher) {}
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      *os << "is mapped by the given callable to a value that ";
-      matcher_.DescribeTo(os);
-    }
-
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      *os << "is mapped by the given callable to a value that ";
-      matcher_.DescribeNegationTo(os);
-    }
-
-    virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
-      *listener << "which is mapped by the given callable to ";
-      // Cannot pass the return value (for example, int) to
-      // MatchPrintAndExplain, which takes a non-const reference as argument.
-      ResultType result =
-          CallableTraits<Callable>::template Invoke<T>(callable_, obj);
-      return MatchPrintAndExplain(result, matcher_, listener);
-    }
-
-   private:
-    // Functors often define operator() as non-const method even though
-    // they are actualy stateless. But we need to use them even when
-    // 'this' is a const pointer. It's the user's responsibility not to
-    // use stateful callables with ResultOf(), which does't guarantee
-    // how many times the callable will be invoked.
-    mutable CallableStorageType callable_;
-    const Matcher<ResultType> matcher_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };  // class Impl
-
-  const CallableStorageType callable_;
-  const Matcher<ResultType> matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
-};
-
-// Implements an equality matcher for any STL-style container whose elements
-// support ==. This matcher is like Eq(), but its failure explanations provide
-// more detailed information that is useful when the container is used as a set.
-// The failure message reports elements that are in one of the operands but not
-// the other. The failure messages do not report duplicate or out-of-order
-// elements in the containers (which don't properly matter to sets, but can
-// occur if the containers are vectors or lists, for example).
-//
-// Uses the container's const_iterator, value_type, operator ==,
-// begin(), and end().
-template <typename Container>
-class ContainerEqMatcher {
- public:
-  typedef internal::StlContainerView<Container> View;
-  typedef typename View::type StlContainer;
-  typedef typename View::const_reference StlContainerReference;
-
-  // We make a copy of rhs in case the elements in it are modified
-  // after this matcher is created.
-  explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs)) {
-    // Makes sure the user doesn't instantiate this class template
-    // with a const or reference type.
-    (void)testing::StaticAssertTypeEq<Container,
-        GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();
-  }
-
-  void DescribeTo(::std::ostream* os) const {
-    *os << "equals ";
-    UniversalPrint(rhs_, os);
-  }
-  void DescribeNegationTo(::std::ostream* os) const {
-    *os << "does not equal ";
-    UniversalPrint(rhs_, os);
-  }
-
-  template <typename LhsContainer>
-  bool MatchAndExplain(const LhsContainer& lhs,
-                       MatchResultListener* listener) const {
-    // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
-    // that causes LhsContainer to be a const type sometimes.
-    typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>
-        LhsView;
-    typedef typename LhsView::type LhsStlContainer;
-    StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
-    if (lhs_stl_container == rhs_)
-      return true;
-
-    ::std::ostream* const os = listener->stream();
-    if (os != NULL) {
-      // Something is different. Check for extra values first.
-      bool printed_header = false;
-      for (typename LhsStlContainer::const_iterator it =
-               lhs_stl_container.begin();
-           it != lhs_stl_container.end(); ++it) {
-        if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
-            rhs_.end()) {
-          if (printed_header) {
-            *os << ", ";
-          } else {
-            *os << "which has these unexpected elements: ";
-            printed_header = true;
-          }
-          UniversalPrint(*it, os);
-        }
-      }
-
-      // Now check for missing values.
-      bool printed_header2 = false;
-      for (typename StlContainer::const_iterator it = rhs_.begin();
-           it != rhs_.end(); ++it) {
-        if (internal::ArrayAwareFind(
-                lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
-            lhs_stl_container.end()) {
-          if (printed_header2) {
-            *os << ", ";
-          } else {
-            *os << (printed_header ? ",\nand" : "which")
-                << " doesn't have these expected elements: ";
-            printed_header2 = true;
-          }
-          UniversalPrint(*it, os);
-        }
-      }
-    }
-
-    return false;
-  }
-
- private:
-  const StlContainer rhs_;
-
-  GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
-};
-
-// Implements Pointwise(tuple_matcher, rhs_container).  tuple_matcher
-// must be able to be safely cast to Matcher<tuple<const T1&, const
-// T2&> >, where T1 and T2 are the types of elements in the LHS
-// container and the RHS container respectively.
-template <typename TupleMatcher, typename RhsContainer>
-class PointwiseMatcher {
- public:
-  typedef internal::StlContainerView<RhsContainer> RhsView;
-  typedef typename RhsView::type RhsStlContainer;
-  typedef typename RhsStlContainer::value_type RhsValue;
-
-  // Like ContainerEq, we make a copy of rhs in case the elements in
-  // it are modified after this matcher is created.
-  PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)
-      : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {
-    // Makes sure the user doesn't instantiate this class template
-    // with a const or reference type.
-    (void)testing::StaticAssertTypeEq<RhsContainer,
-        GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>();
-  }
-
-  template <typename LhsContainer>
-  operator Matcher<LhsContainer>() const {
-    return MakeMatcher(new Impl<LhsContainer>(tuple_matcher_, rhs_));
-  }
-
-  template <typename LhsContainer>
-  class Impl : public MatcherInterface<LhsContainer> {
-   public:
-    typedef internal::StlContainerView<
-         GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;
-    typedef typename LhsView::type LhsStlContainer;
-    typedef typename LhsView::const_reference LhsStlContainerReference;
-    typedef typename LhsStlContainer::value_type LhsValue;
-    // We pass the LHS value and the RHS value to the inner matcher by
-    // reference, as they may be expensive to copy.  We must use tuple
-    // instead of pair here, as a pair cannot hold references (C++ 98,
-    // 20.2.2 [lib.pairs]).
-    typedef std::tr1::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
-
-    Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
-        // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
-        : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),
-          rhs_(rhs) {}
-
-    virtual void DescribeTo(::std::ostream* os) const {
-      *os << "contains " << rhs_.size()
-          << " values, where each value and its corresponding value in ";
-      UniversalPrinter<RhsStlContainer>::Print(rhs_, os);
-      *os << " ";
-      mono_tuple_matcher_.DescribeTo(os);
-    }
-    virtual void DescribeNegationTo(::std::ostream* os) const {
-      *os << "doesn't contain exactly " << rhs_.size()
-          << " values, or contains a value x at some index i"
-          << " where x and the i-th value of ";
-      UniversalPrint(rhs_, os);
-      *os << " ";
-      mono_tuple_matcher_.DescribeNegationTo(os);
-    }
-
-    virtual bool MatchAndExplain(LhsContainer lhs,
-                                 MatchResultListener* listener) const {
-      LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
-      const size_t actual_size = lhs_stl_container.size();
-      if (actual_size != rhs_.size()) {
-        *listener << "which contains " << actual_size << " values";
-        return false;
-      }
-
-      typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
-      typename RhsStlContainer::const_iterator right = rhs_.begin();
-      for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {
-        const InnerMatcherArg value_pair(*left, *right);
-
-        if (listener->IsInterested()) {
-          StringMatchResultListener inner_listener;
-          if (!mono_tuple_matcher_.MatchAndExplain(
-                  value_pair, &inner_listener)) {
-            *listener << "where the value pair (";
-            UniversalPrint(*left, listener->stream());
-            *listener << ", ";
-            UniversalPrint(*right, listener->stream());
-            *listener << ") at index #" << i << " don't match";
-            PrintIfNotEmpty(inner_listener.str(), listener->stream());
-            return false;
-          }
-        } else {
-          if (!mono_tuple_matcher_.Matches(value_pair))
-            return false;
-        }
-      }
-
-      return true;
-    }
-
-   private:
-    const Matcher<InnerMatcherArg> mono_tuple_matcher_;
-    const RhsStlContainer rhs_;
-
-    GTEST_DISALLOW_ASSIGN_(Impl);
-  };
-
- private:
-  const TupleMatcher tuple_matcher_;
-  const RhsStlContainer rhs_;
-
-  GTEST_DISALLOW_ASSIGN_(PointwiseMatcher);
-};
-
-// Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.
-template <typename Container>
-class QuantifierMatcherImpl : public MatcherInterface<Container> {
- public:
-  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-  typedef StlContainerView<RawContainer> View;
-  typedef typename View::type StlContainer;
-  typedef typename View::const_reference StlContainerReference;
-  typedef typename StlContainer::value_type Element;
-
-  template <typename InnerMatcher>
-  explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)
-      : inner_matcher_(
-           testing::SafeMatcherCast<const Element&>(inner_matcher)) {}
-
-  // Checks whether:
-  // * All elements in the container match, if all_elements_should_match.
-  // * Any element in the container matches, if !all_elements_should_match.
-  bool MatchAndExplainImpl(bool all_elements_should_match,
-                           Container container,
-                           MatchResultListener* listener) const {
-    StlContainerReference stl_container = View::ConstReference(container);
-    size_t i = 0;
-    for (typename StlContainer::const_iterator it = stl_container.begin();
-         it != stl_container.end(); ++it, ++i) {
-      StringMatchResultListener inner_listener;
-      const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
-
-      if (matches != all_elements_should_match) {
-        *listener << "whose element #" << i
-                  << (matches ? " matches" : " doesn't match");
-        PrintIfNotEmpty(inner_listener.str(), listener->stream());
-        return !all_elements_should_match;
-      }
-    }
-    return all_elements_should_match;
-  }
-
- protected:
-  const Matcher<const Element&> inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl);
-};
-
-// Implements Contains(element_matcher) for the given argument type Container.
-// Symmetric to EachMatcherImpl.
-template <typename Container>
-class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {
- public:
-  template <typename InnerMatcher>
-  explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
-      : QuantifierMatcherImpl<Container>(inner_matcher) {}
-
-  // Describes what this matcher does.
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "contains at least one element that ";
-    this->inner_matcher_.DescribeTo(os);
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't contain any element that ";
-    this->inner_matcher_.DescribeTo(os);
-  }
-
-  virtual bool MatchAndExplain(Container container,
-                               MatchResultListener* listener) const {
-    return this->MatchAndExplainImpl(false, container, listener);
-  }
-
- private:
-  GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
-};
-
-// Implements Each(element_matcher) for the given argument type Container.
-// Symmetric to ContainsMatcherImpl.
-template <typename Container>
-class EachMatcherImpl : public QuantifierMatcherImpl<Container> {
- public:
-  template <typename InnerMatcher>
-  explicit EachMatcherImpl(InnerMatcher inner_matcher)
-      : QuantifierMatcherImpl<Container>(inner_matcher) {}
-
-  // Describes what this matcher does.
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "only contains elements that ";
-    this->inner_matcher_.DescribeTo(os);
-  }
-
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "contains some element that ";
-    this->inner_matcher_.DescribeNegationTo(os);
-  }
-
-  virtual bool MatchAndExplain(Container container,
-                               MatchResultListener* listener) const {
-    return this->MatchAndExplainImpl(true, container, listener);
-  }
-
- private:
-  GTEST_DISALLOW_ASSIGN_(EachMatcherImpl);
-};
-
-// Implements polymorphic Contains(element_matcher).
-template <typename M>
-class ContainsMatcher {
- public:
-  explicit ContainsMatcher(M m) : inner_matcher_(m) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));
-  }
-
- private:
-  const M inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
-};
-
-// Implements polymorphic Each(element_matcher).
-template <typename M>
-class EachMatcher {
- public:
-  explicit EachMatcher(M m) : inner_matcher_(m) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    return MakeMatcher(new EachMatcherImpl<Container>(inner_matcher_));
-  }
-
- private:
-  const M inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(EachMatcher);
-};
-
-// Implements Key(inner_matcher) for the given argument pair type.
-// Key(inner_matcher) matches an std::pair whose 'first' field matches
-// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an
-// std::map that contains at least one element whose key is >= 5.
-template <typename PairType>
-class KeyMatcherImpl : public MatcherInterface<PairType> {
- public:
-  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
-  typedef typename RawPairType::first_type KeyType;
-
-  template <typename InnerMatcher>
-  explicit KeyMatcherImpl(InnerMatcher inner_matcher)
-      : inner_matcher_(
-          testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
-  }
-
-  // Returns true iff 'key_value.first' (the key) matches the inner matcher.
-  virtual bool MatchAndExplain(PairType key_value,
-                               MatchResultListener* listener) const {
-    StringMatchResultListener inner_listener;
-    const bool match = inner_matcher_.MatchAndExplain(key_value.first,
-                                                      &inner_listener);
-    const internal::string explanation = inner_listener.str();
-    if (explanation != "") {
-      *listener << "whose first field is a value " << explanation;
-    }
-    return match;
-  }
-
-  // Describes what this matcher does.
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "has a key that ";
-    inner_matcher_.DescribeTo(os);
-  }
-
-  // Describes what the negation of this matcher does.
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "doesn't have a key that ";
-    inner_matcher_.DescribeTo(os);
-  }
-
- private:
-  const Matcher<const KeyType&> inner_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
-};
-
-// Implements polymorphic Key(matcher_for_key).
-template <typename M>
-class KeyMatcher {
- public:
-  explicit KeyMatcher(M m) : matcher_for_key_(m) {}
-
-  template <typename PairType>
-  operator Matcher<PairType>() const {
-    return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));
-  }
-
- private:
-  const M matcher_for_key_;
-
-  GTEST_DISALLOW_ASSIGN_(KeyMatcher);
-};
-
-// Implements Pair(first_matcher, second_matcher) for the given argument pair
-// type with its two matchers. See Pair() function below.
-template <typename PairType>
-class PairMatcherImpl : public MatcherInterface<PairType> {
- public:
-  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
-  typedef typename RawPairType::first_type FirstType;
-  typedef typename RawPairType::second_type SecondType;
-
-  template <typename FirstMatcher, typename SecondMatcher>
-  PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
-      : first_matcher_(
-            testing::SafeMatcherCast<const FirstType&>(first_matcher)),
-        second_matcher_(
-            testing::SafeMatcherCast<const SecondType&>(second_matcher)) {
-  }
-
-  // Describes what this matcher does.
-  virtual void DescribeTo(::std::ostream* os) const {
-    *os << "has a first field that ";
-    first_matcher_.DescribeTo(os);
-    *os << ", and has a second field that ";
-    second_matcher_.DescribeTo(os);
-  }
-
-  // Describes what the negation of this matcher does.
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    *os << "has a first field that ";
-    first_matcher_.DescribeNegationTo(os);
-    *os << ", or has a second field that ";
-    second_matcher_.DescribeNegationTo(os);
-  }
-
-  // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
-  // matches second_matcher.
-  virtual bool MatchAndExplain(PairType a_pair,
-                               MatchResultListener* listener) const {
-    if (!listener->IsInterested()) {
-      // If the listener is not interested, we don't need to construct the
-      // explanation.
-      return first_matcher_.Matches(a_pair.first) &&
-             second_matcher_.Matches(a_pair.second);
-    }
-    StringMatchResultListener first_inner_listener;
-    if (!first_matcher_.MatchAndExplain(a_pair.first,
-                                        &first_inner_listener)) {
-      *listener << "whose first field does not match";
-      PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
-      return false;
-    }
-    StringMatchResultListener second_inner_listener;
-    if (!second_matcher_.MatchAndExplain(a_pair.second,
-                                         &second_inner_listener)) {
-      *listener << "whose second field does not match";
-      PrintIfNotEmpty(second_inner_listener.str(), listener->stream());
-      return false;
-    }
-    ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),
-                   listener);
-    return true;
-  }
-
- private:
-  void ExplainSuccess(const internal::string& first_explanation,
-                      const internal::string& second_explanation,
-                      MatchResultListener* listener) const {
-    *listener << "whose both fields match";
-    if (first_explanation != "") {
-      *listener << ", where the first field is a value " << first_explanation;
-    }
-    if (second_explanation != "") {
-      *listener << ", ";
-      if (first_explanation != "") {
-        *listener << "and ";
-      } else {
-        *listener << "where ";
-      }
-      *listener << "the second field is a value " << second_explanation;
-    }
-  }
-
-  const Matcher<const FirstType&> first_matcher_;
-  const Matcher<const SecondType&> second_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
-};
-
-// Implements polymorphic Pair(first_matcher, second_matcher).
-template <typename FirstMatcher, typename SecondMatcher>
-class PairMatcher {
- public:
-  PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
-      : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
-
-  template <typename PairType>
-  operator Matcher<PairType> () const {
-    return MakeMatcher(
-        new PairMatcherImpl<PairType>(
-            first_matcher_, second_matcher_));
-  }
-
- private:
-  const FirstMatcher first_matcher_;
-  const SecondMatcher second_matcher_;
-
-  GTEST_DISALLOW_ASSIGN_(PairMatcher);
-};
-
-// Implements ElementsAre() and ElementsAreArray().
-template <typename Container>
-class ElementsAreMatcherImpl : public MatcherInterface<Container> {
- public:
-  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-  typedef internal::StlContainerView<RawContainer> View;
-  typedef typename View::type StlContainer;
-  typedef typename View::const_reference StlContainerReference;
-  typedef typename StlContainer::value_type Element;
-
-  // Constructs the matcher from a sequence of element values or
-  // element matchers.
-  template <typename InputIter>
-  ElementsAreMatcherImpl(InputIter first, size_t a_count) {
-    matchers_.reserve(a_count);
-    InputIter it = first;
-    for (size_t i = 0; i != a_count; ++i, ++it) {
-      matchers_.push_back(MatcherCast<const Element&>(*it));
-    }
-  }
-
-  // Describes what this matcher does.
-  virtual void DescribeTo(::std::ostream* os) const {
-    if (count() == 0) {
-      *os << "is empty";
-    } else if (count() == 1) {
-      *os << "has 1 element that ";
-      matchers_[0].DescribeTo(os);
-    } else {
-      *os << "has " << Elements(count()) << " where\n";
-      for (size_t i = 0; i != count(); ++i) {
-        *os << "element #" << i << " ";
-        matchers_[i].DescribeTo(os);
-        if (i + 1 < count()) {
-          *os << ",\n";
-        }
-      }
-    }
-  }
-
-  // Describes what the negation of this matcher does.
-  virtual void DescribeNegationTo(::std::ostream* os) const {
-    if (count() == 0) {
-      *os << "isn't empty";
-      return;
-    }
-
-    *os << "doesn't have " << Elements(count()) << ", or\n";
-    for (size_t i = 0; i != count(); ++i) {
-      *os << "element #" << i << " ";
-      matchers_[i].DescribeNegationTo(os);
-      if (i + 1 < count()) {
-        *os << ", or\n";
-      }
-    }
-  }
-
-  virtual bool MatchAndExplain(Container container,
-                               MatchResultListener* listener) const {
-    StlContainerReference stl_container = View::ConstReference(container);
-    const size_t actual_count = stl_container.size();
-    if (actual_count != count()) {
-      // The element count doesn't match.  If the container is empty,
-      // there's no need to explain anything as Google Mock already
-      // prints the empty container.  Otherwise we just need to show
-      // how many elements there actually are.
-      if (actual_count != 0) {
-        *listener << "which has " << Elements(actual_count);
-      }
-      return false;
-    }
-
-    typename StlContainer::const_iterator it = stl_container.begin();
-    // explanations[i] is the explanation of the element at index i.
-    std::vector<internal::string> explanations(count());
-    for (size_t i = 0; i != count();  ++it, ++i) {
-      StringMatchResultListener s;
-      if (matchers_[i].MatchAndExplain(*it, &s)) {
-        explanations[i] = s.str();
-      } else {
-        // The container has the right size but the i-th element
-        // doesn't match its expectation.
-        *listener << "whose element #" << i << " doesn't match";
-        PrintIfNotEmpty(s.str(), listener->stream());
-        return false;
-      }
-    }
-
-    // Every element matches its expectation.  We need to explain why
-    // (the obvious ones can be skipped).
-    bool reason_printed = false;
-    for (size_t i = 0; i != count(); ++i) {
-      const internal::string& s = explanations[i];
-      if (!s.empty()) {
-        if (reason_printed) {
-          *listener << ",\nand ";
-        }
-        *listener << "whose element #" << i << " matches, " << s;
-        reason_printed = true;
-      }
-    }
-
-    return true;
-  }
-
- private:
-  static Message Elements(size_t count) {
-    return Message() << count << (count == 1 ? " element" : " elements");
-  }
-
-  size_t count() const { return matchers_.size(); }
-  std::vector<Matcher<const Element&> > matchers_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
-};
-
-// Implements ElementsAre() of 0 arguments.
-class ElementsAreMatcher0 {
- public:
-  ElementsAreMatcher0() {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    const Matcher<const Element&>* const matchers = NULL;
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 0));
-  }
-};
-
-// Implements ElementsAreArray().
-template <typename T>
-class ElementsAreArrayMatcher {
- public:
-  ElementsAreArrayMatcher(const T* first, size_t count) :
-      first_(first), count_(count) {}
-
-  template <typename Container>
-  operator Matcher<Container>() const {
-    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
-    typedef typename internal::StlContainerView<RawContainer>::type::value_type
-        Element;
-
-    return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_));
-  }
-
- private:
-  const T* const first_;
-  const size_t count_;
-
-  GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
-};
-
-// Returns the description for a matcher defined using the MATCHER*()
-// macro where the user-supplied description string is "", if
-// 'negation' is false; otherwise returns the description of the
-// negation of the matcher.  'param_values' contains a list of strings
-// that are the print-out of the matcher's parameters.
-string FormatMatcherDescription(bool negation, const char* matcher_name,
-                                const Strings& param_values);
-
-}  // namespace internal
-
-// Implements MatcherCast().
-template <typename T, typename M>
-inline Matcher<T> MatcherCast(M matcher) {
-  return internal::MatcherCastImpl<T, M>::Cast(matcher);
-}
-
-// _ is a matcher that matches anything of any type.
-//
-// This definition is fine as:
-//
-//   1. The C++ standard permits using the name _ in a namespace that
-//      is not the global namespace or ::std.
-//   2. The AnythingMatcher class has no data member or constructor,
-//      so it's OK to create global variables of this type.
-//   3. c-style has approved of using _ in this case.
-const internal::AnythingMatcher _ = {};
-// Creates a matcher that matches any value of the given type T.
-template <typename T>
-inline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }
-
-// Creates a matcher that matches any value of the given type T.
-template <typename T>
-inline Matcher<T> An() { return A<T>(); }
-
-// Creates a polymorphic matcher that matches anything equal to x.
-// Note: if the parameter of Eq() were declared as const T&, Eq("foo")
-// wouldn't compile.
-template <typename T>
-inline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }
-
-// Constructs a Matcher<T> from a 'value' of type T.  The constructed
-// matcher matches any value that's equal to 'value'.
-template <typename T>
-Matcher<T>::Matcher(T value) { *this = Eq(value); }
-
-// Creates a monomorphic matcher that matches anything with type Lhs
-// and equal to rhs.  A user may need to use this instead of Eq(...)
-// in order to resolve an overloading ambiguity.
-//
-// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
-// or Matcher<T>(x), but more readable than the latter.
-//
-// We could define similar monomorphic matchers for other comparison
-// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
-// it yet as those are used much less than Eq() in practice.  A user
-// can always write Matcher<T>(Lt(5)) to be explicit about the type,
-// for example.
-template <typename Lhs, typename Rhs>
-inline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }
-
-// Creates a polymorphic matcher that matches anything >= x.
-template <typename Rhs>
-inline internal::GeMatcher<Rhs> Ge(Rhs x) {
-  return internal::GeMatcher<Rhs>(x);
-}
-
-// Creates a polymorphic matcher that matches anything > x.
-template <typename Rhs>
-inline internal::GtMatcher<Rhs> Gt(Rhs x) {
-  return internal::GtMatcher<Rhs>(x);
-}
-
-// Creates a polymorphic matcher that matches anything <= x.
-template <typename Rhs>
-inline internal::LeMatcher<Rhs> Le(Rhs x) {
-  return internal::LeMatcher<Rhs>(x);
-}
-
-// Creates a polymorphic matcher that matches anything < x.
-template <typename Rhs>
-inline internal::LtMatcher<Rhs> Lt(Rhs x) {
-  return internal::LtMatcher<Rhs>(x);
-}
-
-// Creates a polymorphic matcher that matches anything != x.
-template <typename Rhs>
-inline internal::NeMatcher<Rhs> Ne(Rhs x) {
-  return internal::NeMatcher<Rhs>(x);
-}
-
-// Creates a polymorphic matcher that matches any NULL pointer.
-inline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {
-  return MakePolymorphicMatcher(internal::IsNullMatcher());
-}
-
-// Creates a polymorphic matcher that matches any non-NULL pointer.
-// This is convenient as Not(NULL) doesn't compile (the compiler
-// thinks that that expression is comparing a pointer with an integer).
-inline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {
-  return MakePolymorphicMatcher(internal::NotNullMatcher());
-}
-
-// Creates a polymorphic matcher that matches any argument that
-// references variable x.
-template <typename T>
-inline internal::RefMatcher<T&> Ref(T& x) {  // NOLINT
-  return internal::RefMatcher<T&>(x);
-}
-
-// Creates a matcher that matches any double argument approximately
-// equal to rhs, where two NANs are considered unequal.
-inline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {
-  return internal::FloatingEqMatcher<double>(rhs, false);
-}
-
-// Creates a matcher that matches any double argument approximately
-// equal to rhs, including NaN values when rhs is NaN.
-inline internal::FloatingEqMatcher<double> NanSensitiveDoubleEq(double rhs) {
-  return internal::FloatingEqMatcher<double>(rhs, true);
-}
-
-// Creates a matcher that matches any float argument approximately
-// equal to rhs, where two NANs are considered unequal.
-inline internal::FloatingEqMatcher<float> FloatEq(float rhs) {
-  return internal::FloatingEqMatcher<float>(rhs, false);
-}
-
-// Creates a matcher that matches any double argument approximately
-// equal to rhs, including NaN values when rhs is NaN.
-inline internal::FloatingEqMatcher<float> NanSensitiveFloatEq(float rhs) {
-  return internal::FloatingEqMatcher<float>(rhs, true);
-}
-
-// Creates a matcher that matches a pointer (raw or smart) that points
-// to a value that matches inner_matcher.
-template <typename InnerMatcher>
-inline internal::PointeeMatcher<InnerMatcher> Pointee(
-    const InnerMatcher& inner_matcher) {
-  return internal::PointeeMatcher<InnerMatcher>(inner_matcher);
-}
-
-// Creates a matcher that matches an object whose given field matches
-// 'matcher'.  For example,
-//   Field(&Foo::number, Ge(5))
-// matches a Foo object x iff x.number >= 5.
-template <typename Class, typename FieldType, typename FieldMatcher>
-inline PolymorphicMatcher<
-  internal::FieldMatcher<Class, FieldType> > Field(
-    FieldType Class::*field, const FieldMatcher& matcher) {
-  return MakePolymorphicMatcher(
-      internal::FieldMatcher<Class, FieldType>(
-          field, MatcherCast<const FieldType&>(matcher)));
-  // The call to MatcherCast() is required for supporting inner
-  // matchers of compatible types.  For example, it allows
-  //   Field(&Foo::bar, m)
-  // to compile where bar is an int32 and m is a matcher for int64.
-}
-
-// Creates a matcher that matches an object whose given property
-// matches 'matcher'.  For example,
-//   Property(&Foo::str, StartsWith("hi"))
-// matches a Foo object x iff x.str() starts with "hi".
-template <typename Class, typename PropertyType, typename PropertyMatcher>
-inline PolymorphicMatcher<
-  internal::PropertyMatcher<Class, PropertyType> > Property(
-    PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {
-  return MakePolymorphicMatcher(
-      internal::PropertyMatcher<Class, PropertyType>(
-          property,
-          MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
-  // The call to MatcherCast() is required for supporting inner
-  // matchers of compatible types.  For example, it allows
-  //   Property(&Foo::bar, m)
-  // to compile where bar() returns an int32 and m is a matcher for int64.
-}
-
-// Creates a matcher that matches an object iff the result of applying
-// a callable to x matches 'matcher'.
-// For example,
-//   ResultOf(f, StartsWith("hi"))
-// matches a Foo object x iff f(x) starts with "hi".
-// callable parameter can be a function, function pointer, or a functor.
-// Callable has to satisfy the following conditions:
-//   * It is required to keep no state affecting the results of
-//     the calls on it and make no assumptions about how many calls
-//     will be made. Any state it keeps must be protected from the
-//     concurrent access.
-//   * If it is a function object, it has to define type result_type.
-//     We recommend deriving your functor classes from std::unary_function.
-template <typename Callable, typename ResultOfMatcher>
-internal::ResultOfMatcher<Callable> ResultOf(
-    Callable callable, const ResultOfMatcher& matcher) {
-  return internal::ResultOfMatcher<Callable>(
-          callable,
-          MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(
-              matcher));
-  // The call to MatcherCast() is required for supporting inner
-  // matchers of compatible types.  For example, it allows
-  //   ResultOf(Function, m)
-  // to compile where Function() returns an int32 and m is a matcher for int64.
-}
-
-// String matchers.
-
-// Matches a string equal to str.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
-    StrEq(const internal::string& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
-      str, true, true));
-}
-
-// Matches a string not equal to str.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
-    StrNe(const internal::string& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
-      str, false, true));
-}
-
-// Matches a string equal to str, ignoring case.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
-    StrCaseEq(const internal::string& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
-      str, true, false));
-}
-
-// Matches a string not equal to str, ignoring case.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >
-    StrCaseNe(const internal::string& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(
-      str, false, false));
-}
-
-// Creates a matcher that matches any string, std::string, or C string
-// that contains the given substring.
-inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::string> >
-    HasSubstr(const internal::string& substring) {
-  return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::string>(
-      substring));
-}
-
-// Matches a string that starts with 'prefix' (case-sensitive).
-inline PolymorphicMatcher<internal::StartsWithMatcher<internal::string> >
-    StartsWith(const internal::string& prefix) {
-  return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::string>(
-      prefix));
-}
-
-// Matches a string that ends with 'suffix' (case-sensitive).
-inline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> >
-    EndsWith(const internal::string& suffix) {
-  return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>(
-      suffix));
-}
-
-// Matches a string that fully matches regular expression 'regex'.
-// The matcher takes ownership of 'regex'.
-inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
-    const internal::RE* regex) {
-  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
-}
-inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(
-    const internal::string& regex) {
-  return MatchesRegex(new internal::RE(regex));
-}
-
-// Matches a string that contains regular expression 'regex'.
-// The matcher takes ownership of 'regex'.
-inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
-    const internal::RE* regex) {
-  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
-}
-inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(
-    const internal::string& regex) {
-  return ContainsRegex(new internal::RE(regex));
-}
-
-#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
-// Wide string matchers.
-
-// Matches a string equal to str.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
-    StrEq(const internal::wstring& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
-      str, true, true));
-}
-
-// Matches a string not equal to str.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
-    StrNe(const internal::wstring& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
-      str, false, true));
-}
-
-// Matches a string equal to str, ignoring case.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
-    StrCaseEq(const internal::wstring& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
-      str, true, false));
-}
-
-// Matches a string not equal to str, ignoring case.
-inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >
-    StrCaseNe(const internal::wstring& str) {
-  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(
-      str, false, false));
-}
-
-// Creates a matcher that matches any wstring, std::wstring, or C wide string
-// that contains the given substring.
-inline PolymorphicMatcher<internal::HasSubstrMatcher<internal::wstring> >
-    HasSubstr(const internal::wstring& substring) {
-  return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::wstring>(
-      substring));
-}
-
-// Matches a string that starts with 'prefix' (case-sensitive).
-inline PolymorphicMatcher<internal::StartsWithMatcher<internal::wstring> >
-    StartsWith(const internal::wstring& prefix) {
-  return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::wstring>(
-      prefix));
-}
-
-// Matches a string that ends with 'suffix' (case-sensitive).
-inline PolymorphicMatcher<internal::EndsWithMatcher<internal::wstring> >
-    EndsWith(const internal::wstring& suffix) {
-  return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::wstring>(
-      suffix));
-}
-
-#endif  // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field == the second field.
-inline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field >= the second field.
-inline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field > the second field.
-inline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field <= the second field.
-inline internal::Le2Matcher Le() { return internal::Le2Matcher(); }
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field < the second field.
-inline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }
-
-// Creates a polymorphic matcher that matches a 2-tuple where the
-// first field != the second field.
-inline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }
-
-// Creates a matcher that matches any value of type T that m doesn't
-// match.
-template <typename InnerMatcher>
-inline internal::NotMatcher<InnerMatcher> Not(InnerMatcher m) {
-  return internal::NotMatcher<InnerMatcher>(m);
-}
-
-// Returns a matcher that matches anything that satisfies the given
-// predicate.  The predicate can be any unary function or functor
-// whose return type can be implicitly converted to bool.
-template <typename Predicate>
-inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >
-Truly(Predicate pred) {
-  return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));
-}
-
-// Returns a matcher that matches an equal container.
-// This matcher behaves like Eq(), but in the event of mismatch lists the
-// values that are included in one container but not the other. (Duplicate
-// values and order differences are not explained.)
-template <typename Container>
-inline PolymorphicMatcher<internal::ContainerEqMatcher<  // NOLINT
-                            GTEST_REMOVE_CONST_(Container)> >
-    ContainerEq(const Container& rhs) {
-  // This following line is for working around a bug in MSVC 8.0,
-  // which causes Container to be a const type sometimes.
-  typedef GTEST_REMOVE_CONST_(Container) RawContainer;
-  return MakePolymorphicMatcher(
-      internal::ContainerEqMatcher<RawContainer>(rhs));
-}
-
-// Matches an STL-style container or a native array that contains the
-// same number of elements as in rhs, where its i-th element and rhs's
-// i-th element (as a pair) satisfy the given pair matcher, for all i.
-// TupleMatcher must be able to be safely cast to Matcher<tuple<const
-// T1&, const T2&> >, where T1 and T2 are the types of elements in the
-// LHS container and the RHS container respectively.
-template <typename TupleMatcher, typename Container>
-inline internal::PointwiseMatcher<TupleMatcher,
-                                  GTEST_REMOVE_CONST_(Container)>
-Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
-  // This following line is for working around a bug in MSVC 8.0,
-  // which causes Container to be a const type sometimes.
-  typedef GTEST_REMOVE_CONST_(Container) RawContainer;
-  return internal::PointwiseMatcher<TupleMatcher, RawContainer>(
-      tuple_matcher, rhs);
-}
-
-// Matches an STL-style container or a native array that contains at
-// least one element matching the given value or matcher.
-//
-// Examples:
-//   ::std::set<int> page_ids;
-//   page_ids.insert(3);
-//   page_ids.insert(1);
-//   EXPECT_THAT(page_ids, Contains(1));
-//   EXPECT_THAT(page_ids, Contains(Gt(2)));
-//   EXPECT_THAT(page_ids, Not(Contains(4)));
-//
-//   ::std::map<int, size_t> page_lengths;
-//   page_lengths[1] = 100;
-//   EXPECT_THAT(page_lengths,
-//               Contains(::std::pair<const int, size_t>(1, 100)));
-//
-//   const char* user_ids[] = { "joe", "mike", "tom" };
-//   EXPECT_THAT(user_ids, Contains(Eq(::std::string("tom"))));
-template <typename M>
-inline internal::ContainsMatcher<M> Contains(M matcher) {
-  return internal::ContainsMatcher<M>(matcher);
-}
-
-// Matches an STL-style container or a native array that contains only
-// elements matching the given value or matcher.
-//
-// Each(m) is semantically equivalent to Not(Contains(Not(m))). Only
-// the messages are different.
-//
-// Examples:
-//   ::std::set<int> page_ids;
-//   // Each(m) matches an empty container, regardless of what m is.
-//   EXPECT_THAT(page_ids, Each(Eq(1)));
-//   EXPECT_THAT(page_ids, Each(Eq(77)));
-//
-//   page_ids.insert(3);
-//   EXPECT_THAT(page_ids, Each(Gt(0)));
-//   EXPECT_THAT(page_ids, Not(Each(Gt(4))));
-//   page_ids.insert(1);
-//   EXPECT_THAT(page_ids, Not(Each(Lt(2))));
-//
-//   ::std::map<int, size_t> page_lengths;
-//   page_lengths[1] = 100;
-//   page_lengths[2] = 200;
-//   page_lengths[3] = 300;
-//   EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));
-//   EXPECT_THAT(page_lengths, Each(Key(Le(3))));
-//
-//   const char* user_ids[] = { "joe", "mike", "tom" };
-//   EXPECT_THAT(user_ids, Not(Each(Eq(::std::string("tom")))));
-template <typename M>
-inline internal::EachMatcher<M> Each(M matcher) {
-  return internal::EachMatcher<M>(matcher);
-}
-
-// Key(inner_matcher) matches an std::pair whose 'first' field matches
-// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an
-// std::map that contains at least one element whose key is >= 5.
-template <typename M>
-inline internal::KeyMatcher<M> Key(M inner_matcher) {
-  return internal::KeyMatcher<M>(inner_matcher);
-}
-
-// Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field
-// matches first_matcher and whose 'second' field matches second_matcher.  For
-// example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), "foo"))) can be used
-// to match a std::map<int, string> that contains exactly one element whose key
-// is >= 5 and whose value equals "foo".
-template <typename FirstMatcher, typename SecondMatcher>
-inline internal::PairMatcher<FirstMatcher, SecondMatcher>
-Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
-  return internal::PairMatcher<FirstMatcher, SecondMatcher>(
-      first_matcher, second_matcher);
-}
-
-// Returns a predicate that is satisfied by anything that matches the
-// given matcher.
-template <typename M>
-inline internal::MatcherAsPredicate<M> Matches(M matcher) {
-  return internal::MatcherAsPredicate<M>(matcher);
-}
-
-// Returns true iff the value matches the matcher.
-template <typename T, typename M>
-inline bool Value(const T& value, M matcher) {
-  return testing::Matches(matcher)(value);
-}
-
-// Matches the value against the given matcher and explains the match
-// result to listener.
-template <typename T, typename M>
-inline bool ExplainMatchResult(
-    M matcher, const T& value, MatchResultListener* listener) {
-  return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);
-}
-
-// AllArgs(m) is a synonym of m.  This is useful in
-//
-//   EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
-//
-// which is easier to read than
-//
-//   EXPECT_CALL(foo, Bar(_, _)).With(Eq());
-template <typename InnerMatcher>
-inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }
-
-// These macros allow using matchers to check values in Google Test
-// tests.  ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
-// succeed iff the value matches the matcher.  If the assertion fails,
-// the value and the description of the matcher will be printed.
-#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
-    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
-#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
-    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_

+ 0 - 233
Src/ThirdParty/gmock/gmock-more-actions.h

@@ -1,233 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements some actions that depend on gmock-generated-actions.h.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
-
-#include <algorithm>
-
-#include "gmock/gmock-generated-actions.h"
-
-namespace testing {
-namespace internal {
-
-// Implements the Invoke(f) action.  The template argument
-// FunctionImpl is the implementation type of f, which can be either a
-// function pointer or a functor.  Invoke(f) can be used as an
-// Action<F> as long as f's type is compatible with F (i.e. f can be
-// assigned to a tr1::function<F>).
-template <typename FunctionImpl>
-class InvokeAction {
- public:
-  // The c'tor makes a copy of function_impl (either a function
-  // pointer or a functor).
-  explicit InvokeAction(FunctionImpl function_impl)
-      : function_impl_(function_impl) {}
-
-  template <typename Result, typename ArgumentTuple>
-  Result Perform(const ArgumentTuple& args) {
-    return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
-  }
-
- private:
-  FunctionImpl function_impl_;
-
-  GTEST_DISALLOW_ASSIGN_(InvokeAction);
-};
-
-// Implements the Invoke(object_ptr, &Class::Method) action.
-template <class Class, typename MethodPtr>
-class InvokeMethodAction {
- public:
-  InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)
-      : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}
-
-  template <typename Result, typename ArgumentTuple>
-  Result Perform(const ArgumentTuple& args) const {
-    return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
-        obj_ptr_, method_ptr_, args);
-  }
-
- private:
-  Class* const obj_ptr_;
-  const MethodPtr method_ptr_;
-
-  GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
-};
-
-}  // namespace internal
-
-// Various overloads for Invoke().
-
-// Creates an action that invokes 'function_impl' with the mock
-// function's arguments.
-template <typename FunctionImpl>
-PolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(
-    FunctionImpl function_impl) {
-  return MakePolymorphicAction(
-      internal::InvokeAction<FunctionImpl>(function_impl));
-}
-
-// Creates an action that invokes the given method on the given object
-// with the mock function's arguments.
-template <class Class, typename MethodPtr>
-PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
-    Class* obj_ptr, MethodPtr method_ptr) {
-  return MakePolymorphicAction(
-      internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));
-}
-
-// WithoutArgs(inner_action) can be used in a mock function with a
-// non-empty argument list to perform inner_action, which takes no
-// argument.  In other words, it adapts an action accepting no
-// argument to one that accepts (and ignores) arguments.
-template <typename InnerAction>
-inline internal::WithArgsAction<InnerAction>
-WithoutArgs(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction>(action);
-}
-
-// WithArg<k>(an_action) creates an action that passes the k-th
-// (0-based) argument of the mock function to an_action and performs
-// it.  It adapts an action accepting one argument to one that accepts
-// multiple arguments.  For convenience, we also provide
-// WithArgs<k>(an_action) (defined below) as a synonym.
-template <int k, typename InnerAction>
-inline internal::WithArgsAction<InnerAction, k>
-WithArg(const InnerAction& action) {
-  return internal::WithArgsAction<InnerAction, k>(action);
-}
-
-// The ACTION*() macros trigger warning C4100 (unreferenced formal
-// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in
-// the macro definition, as the warnings are generated when the macro
-// is expanded and macro expansion cannot contain #pragma.  Therefore
-// we suppress them here.
-#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
-#endif
-
-// Action ReturnArg<k>() returns the k-th argument of the mock function.
-ACTION_TEMPLATE(ReturnArg,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_0_VALUE_PARAMS()) {
-  return std::tr1::get<k>(args);
-}
-
-// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
-// mock function to *pointer.
-ACTION_TEMPLATE(SaveArg,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_1_VALUE_PARAMS(pointer)) {
-  *pointer = ::std::tr1::get<k>(args);
-}
-
-// Action SaveArgPointee<k>(pointer) saves the value pointed to
-// by the k-th (0-based) argument of the mock function to *pointer.
-ACTION_TEMPLATE(SaveArgPointee,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_1_VALUE_PARAMS(pointer)) {
-  *pointer = *::std::tr1::get<k>(args);
-}
-
-// Action SetArgReferee<k>(value) assigns 'value' to the variable
-// referenced by the k-th (0-based) argument of the mock function.
-ACTION_TEMPLATE(SetArgReferee,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_1_VALUE_PARAMS(value)) {
-  typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;
-  // Ensures that argument #k is a reference.  If you get a compiler
-  // error on the next line, you are using SetArgReferee<k>(value) in
-  // a mock function whose k-th (0-based) argument is not a reference.
-  GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
-                        SetArgReferee_must_be_used_with_a_reference_argument);
-  ::std::tr1::get<k>(args) = value;
-}
-
-// Action SetArrayArgument<k>(first, last) copies the elements in
-// source range [first, last) to the array pointed to by the k-th
-// (0-based) argument, which can be either a pointer or an
-// iterator. The action does not take ownership of the elements in the
-// source range.
-ACTION_TEMPLATE(SetArrayArgument,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_2_VALUE_PARAMS(first, last)) {
-  // Microsoft compiler deprecates ::std::copy, so we want to suppress warning
-  // 4996 (Function call with parameters that may be unsafe) there.
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4996)  // Temporarily disables warning 4996.
-#endif
-  ::std::copy(first, last, ::std::tr1::get<k>(args));
-#ifdef _MSC_VER
-# pragma warning(pop)           // Restores the warning state.
-#endif
-}
-
-// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock
-// function.
-ACTION_TEMPLATE(DeleteArg,
-                HAS_1_TEMPLATE_PARAMS(int, k),
-                AND_0_VALUE_PARAMS()) {
-  delete ::std::tr1::get<k>(args);
-}
-
-// This action returns the value pointed to by 'pointer'.
-ACTION_P(ReturnPointee, pointer) { return *pointer; }
-
-// Action Throw(exception) can be used in a mock function of any type
-// to throw the given exception.  Any copyable value can be thrown.
-#if GTEST_HAS_EXCEPTIONS
-
-// Suppresses the 'unreachable code' warning that VC generates in opt modes.
-# ifdef _MSC_VER
-#  pragma warning(push)          // Saves the current warning state.
-#  pragma warning(disable:4702)  // Temporarily disables warning 4702.
-# endif
-ACTION_P(Throw, exception) { throw exception; }
-# ifdef _MSC_VER
-#  pragma warning(pop)           // Restores the warning state.
-# endif
-
-#endif  // GTEST_HAS_EXCEPTIONS
-
-#ifdef _MSC_VER
-# pragma warning(pop)
-#endif
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_

+ 0 - 1749
Src/ThirdParty/gmock/gmock-spec-builders.h

@@ -1,1749 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file implements the ON_CALL() and EXPECT_CALL() macros.
-//
-// A user can use the ON_CALL() macro to specify the default action of
-// a mock method.  The syntax is:
-//
-//   ON_CALL(mock_object, Method(argument-matchers))
-//       .With(multi-argument-matcher)
-//       .WillByDefault(action);
-//
-//  where the .With() clause is optional.
-//
-// A user can use the EXPECT_CALL() macro to specify an expectation on
-// a mock method.  The syntax is:
-//
-//   EXPECT_CALL(mock_object, Method(argument-matchers))
-//       .With(multi-argument-matchers)
-//       .Times(cardinality)
-//       .InSequence(sequences)
-//       .After(expectations)
-//       .WillOnce(action)
-//       .WillRepeatedly(action)
-//       .RetiresOnSaturation();
-//
-// where all clauses are optional, and .InSequence()/.After()/
-// .WillOnce() can appear any number of times.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
-
-#include <map>
-#include <set>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include "gmock/gmock-actions.h"
-#include "gmock/gmock-cardinalities.h"
-#include "gmock/gmock-matchers.h"
-#include "gmock/internal/gmock-internal-utils.h"
-#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-
-// An abstract handle of an expectation.
-class Expectation;
-
-// A set of expectation handles.
-class ExpectationSet;
-
-// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
-// and MUST NOT BE USED IN USER CODE!!!
-namespace internal {
-
-// Implements a mock function.
-template <typename F> class FunctionMocker;
-
-// Base class for expectations.
-class ExpectationBase;
-
-// Implements an expectation.
-template <typename F> class TypedExpectation;
-
-// Helper class for testing the Expectation class template.
-class ExpectationTester;
-
-// Base class for function mockers.
-template <typename F> class FunctionMockerBase;
-
-// Protects the mock object registry (in class Mock), all function
-// mockers, and all expectations.
-//
-// The reason we don't use more fine-grained protection is: when a
-// mock function Foo() is called, it needs to consult its expectations
-// to see which one should be picked.  If another thread is allowed to
-// call a mock function (either Foo() or a different one) at the same
-// time, it could affect the "retired" attributes of Foo()'s
-// expectations when InSequence() is used, and thus affect which
-// expectation gets picked.  Therefore, we sequence all mock function
-// calls to ensure the integrity of the mock objects' states.
-GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
-
-// Untyped base class for ActionResultHolder<R>.
-class UntypedActionResultHolderBase;
-
-// Abstract base class of FunctionMockerBase.  This is the
-// type-agnostic part of the function mocker interface.  Its pure
-// virtual methods are implemented by FunctionMockerBase.
-class UntypedFunctionMockerBase {
- public:
-  UntypedFunctionMockerBase();
-  virtual ~UntypedFunctionMockerBase();
-
-  // Verifies that all expectations on this mock function have been
-  // satisfied.  Reports one or more Google Test non-fatal failures
-  // and returns false if not.
-  // L >= g_gmock_mutex
-  bool VerifyAndClearExpectationsLocked();
-
-  // Clears the ON_CALL()s set on this mock function.
-  // L >= g_gmock_mutex
-  virtual void ClearDefaultActionsLocked() = 0;
-
-  // In all of the following Untyped* functions, it's the caller's
-  // responsibility to guarantee the correctness of the arguments'
-  // types.
-
-  // Performs the default action with the given arguments and returns
-  // the action's result.  The call description string will be used in
-  // the error message to describe the call in the case the default
-  // action fails.
-  // L = *
-  virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
-      const void* untyped_args,
-      const string& call_description) const = 0;
-
-  // Performs the given action with the given arguments and returns
-  // the action's result.
-  // L = *
-  virtual UntypedActionResultHolderBase* UntypedPerformAction(
-      const void* untyped_action,
-      const void* untyped_args) const = 0;
-
-  // Writes a message that the call is uninteresting (i.e. neither
-  // explicitly expected nor explicitly unexpected) to the given
-  // ostream.
-  // L < g_gmock_mutex
-  virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
-                                                ::std::ostream* os) const = 0;
-
-  // Returns the expectation that matches the given function arguments
-  // (or NULL is there's no match); when a match is found,
-  // untyped_action is set to point to the action that should be
-  // performed (or NULL if the action is "do default"), and
-  // is_excessive is modified to indicate whether the call exceeds the
-  // expected number.
-  // L < g_gmock_mutex
-  virtual const ExpectationBase* UntypedFindMatchingExpectation(
-      const void* untyped_args,
-      const void** untyped_action, bool* is_excessive,
-      ::std::ostream* what, ::std::ostream* why) = 0;
-
-  // Prints the given function arguments to the ostream.
-  virtual void UntypedPrintArgs(const void* untyped_args,
-                                ::std::ostream* os) const = 0;
-
-  // Sets the mock object this mock method belongs to, and registers
-  // this information in the global mock registry.  Will be called
-  // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
-  // method.
-  // TODO(wan@google.com): rename to SetAndRegisterOwner().
-  // L < g_gmock_mutex
-  void RegisterOwner(const void* mock_obj);
-
-  // Sets the mock object this mock method belongs to, and sets the
-  // name of the mock function.  Will be called upon each invocation
-  // of this mock function.
-  // L < g_gmock_mutex
-  void SetOwnerAndName(const void* mock_obj, const char* name);
-
-  // Returns the mock object this mock method belongs to.  Must be
-  // called after RegisterOwner() or SetOwnerAndName() has been
-  // called.
-  // L < g_gmock_mutex
-  const void* MockObject() const;
-
-  // Returns the name of this mock method.  Must be called after
-  // SetOwnerAndName() has been called.
-  // L < g_gmock_mutex
-  const char* Name() const;
-
-  // Returns the result of invoking this mock function with the given
-  // arguments.  This function can be safely called from multiple
-  // threads concurrently.  The caller is responsible for deleting the
-  // result.
-  // L < g_gmock_mutex
-  const UntypedActionResultHolderBase* UntypedInvokeWith(
-      const void* untyped_args);
-
- protected:
-  typedef std::vector<const void*> UntypedOnCallSpecs;
-
-  typedef std::vector<internal::linked_ptr<ExpectationBase> >
-  UntypedExpectations;
-
-  // Returns an Expectation object that references and co-owns exp,
-  // which must be an expectation on this mock function.
-  Expectation GetHandleOf(ExpectationBase* exp);
-
-  // Address of the mock object this mock method belongs to.  Only
-  // valid after this mock method has been called or
-  // ON_CALL/EXPECT_CALL has been invoked on it.
-  const void* mock_obj_;  // Protected by g_gmock_mutex.
-
-  // Name of the function being mocked.  Only valid after this mock
-  // method has been called.
-  const char* name_;  // Protected by g_gmock_mutex.
-
-  // All default action specs for this function mocker.
-  UntypedOnCallSpecs untyped_on_call_specs_;
-
-  // All expectations for this function mocker.
-  UntypedExpectations untyped_expectations_;
-};  // class UntypedFunctionMockerBase
-
-// Untyped base class for OnCallSpec<F>.
-class UntypedOnCallSpecBase {
- public:
-  // The arguments are the location of the ON_CALL() statement.
-  UntypedOnCallSpecBase(const char* a_file, int a_line)
-      : file_(a_file), line_(a_line), last_clause_(kNone) {}
-
-  // Where in the source file was the default action spec defined?
-  const char* file() const { return file_; }
-  int line() const { return line_; }
-
- protected:
-  // Gives each clause in the ON_CALL() statement a name.
-  enum Clause {
-    // Do not change the order of the enum members!  The run-time
-    // syntax checking relies on it.
-    kNone,
-    kWith,
-    kWillByDefault
-  };
-
-  // Asserts that the ON_CALL() statement has a certain property.
-  void AssertSpecProperty(bool property, const string& failure_message) const {
-    Assert(property, file_, line_, failure_message);
-  }
-
-  // Expects that the ON_CALL() statement has a certain property.
-  void ExpectSpecProperty(bool property, const string& failure_message) const {
-    Expect(property, file_, line_, failure_message);
-  }
-
-  const char* file_;
-  int line_;
-
-  // The last clause in the ON_CALL() statement as seen so far.
-  // Initially kNone and changes as the statement is parsed.
-  Clause last_clause_;
-};  // class UntypedOnCallSpecBase
-
-// This template class implements an ON_CALL spec.
-template <typename F>
-class OnCallSpec : public UntypedOnCallSpecBase {
- public:
-  typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
-
-  // Constructs an OnCallSpec object from the information inside
-  // the parenthesis of an ON_CALL() statement.
-  OnCallSpec(const char* a_file, int a_line,
-             const ArgumentMatcherTuple& matchers)
-      : UntypedOnCallSpecBase(a_file, a_line),
-        matchers_(matchers),
-        // By default, extra_matcher_ should match anything.  However,
-        // we cannot initialize it with _ as that triggers a compiler
-        // bug in Symbian's C++ compiler (cannot decide between two
-        // overloaded constructors of Matcher<const ArgumentTuple&>).
-        extra_matcher_(A<const ArgumentTuple&>()) {
-  }
-
-  // Implements the .With() clause.
-  OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
-    // Makes sure this is called at most once.
-    ExpectSpecProperty(last_clause_ < kWith,
-                       ".With() cannot appear "
-                       "more than once in an ON_CALL().");
-    last_clause_ = kWith;
-
-    extra_matcher_ = m;
-    return *this;
-  }
-
-  // Implements the .WillByDefault() clause.
-  OnCallSpec& WillByDefault(const Action<F>& action) {
-    ExpectSpecProperty(last_clause_ < kWillByDefault,
-                       ".WillByDefault() must appear "
-                       "exactly once in an ON_CALL().");
-    last_clause_ = kWillByDefault;
-
-    ExpectSpecProperty(!action.IsDoDefault(),
-                       "DoDefault() cannot be used in ON_CALL().");
-    action_ = action;
-    return *this;
-  }
-
-  // Returns true iff the given arguments match the matchers.
-  bool Matches(const ArgumentTuple& args) const {
-    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
-  }
-
-  // Returns the action specified by the user.
-  const Action<F>& GetAction() const {
-    AssertSpecProperty(last_clause_ == kWillByDefault,
-                       ".WillByDefault() must appear exactly "
-                       "once in an ON_CALL().");
-    return action_;
-  }
-
- private:
-  // The information in statement
-  //
-  //   ON_CALL(mock_object, Method(matchers))
-  //       .With(multi-argument-matcher)
-  //       .WillByDefault(action);
-  //
-  // is recorded in the data members like this:
-  //
-  //   source file that contains the statement => file_
-  //   line number of the statement            => line_
-  //   matchers                                => matchers_
-  //   multi-argument-matcher                  => extra_matcher_
-  //   action                                  => action_
-  ArgumentMatcherTuple matchers_;
-  Matcher<const ArgumentTuple&> extra_matcher_;
-  Action<F> action_;
-};  // class OnCallSpec
-
-// Possible reactions on uninteresting calls.  TODO(wan@google.com):
-// rename the enum values to the kFoo style.
-enum CallReaction {
-  ALLOW,
-  WARN,
-  FAIL
-};
-
-}  // namespace internal
-
-// Utilities for manipulating mock objects.
-class Mock {
- public:
-  // The following public methods can be called concurrently.
-
-  // Tells Google Mock to ignore mock_obj when checking for leaked
-  // mock objects.
-  static void AllowLeak(const void* mock_obj);
-
-  // Verifies and clears all expectations on the given mock object.
-  // If the expectations aren't satisfied, generates one or more
-  // Google Test non-fatal failures and returns false.
-  static bool VerifyAndClearExpectations(void* mock_obj);
-
-  // Verifies all expectations on the given mock object and clears its
-  // default actions and expectations.  Returns true iff the
-  // verification was successful.
-  static bool VerifyAndClear(void* mock_obj);
- private:
-  friend class internal::UntypedFunctionMockerBase;
-
-  // Needed for a function mocker to register itself (so that we know
-  // how to clear a mock object).
-  template <typename F>
-  friend class internal::FunctionMockerBase;
-
-  template <typename M>
-  friend class NiceMock;
-
-  template <typename M>
-  friend class StrictMock;
-
-  // Tells Google Mock to allow uninteresting calls on the given mock
-  // object.
-  // L < g_gmock_mutex
-  static void AllowUninterestingCalls(const void* mock_obj);
-
-  // Tells Google Mock to warn the user about uninteresting calls on
-  // the given mock object.
-  // L < g_gmock_mutex
-  static void WarnUninterestingCalls(const void* mock_obj);
-
-  // Tells Google Mock to fail uninteresting calls on the given mock
-  // object.
-  // L < g_gmock_mutex
-  static void FailUninterestingCalls(const void* mock_obj);
-
-  // Tells Google Mock the given mock object is being destroyed and
-  // its entry in the call-reaction table should be removed.
-  // L < g_gmock_mutex
-  static void UnregisterCallReaction(const void* mock_obj);
-
-  // Returns the reaction Google Mock will have on uninteresting calls
-  // made on the given mock object.
-  // L < g_gmock_mutex
-  static internal::CallReaction GetReactionOnUninterestingCalls(
-      const void* mock_obj);
-
-  // Verifies that all expectations on the given mock object have been
-  // satisfied.  Reports one or more Google Test non-fatal failures
-  // and returns false if not.
-  // L >= g_gmock_mutex
-  static bool VerifyAndClearExpectationsLocked(void* mock_obj);
-
-  // Clears all ON_CALL()s set on the given mock object.
-  // L >= g_gmock_mutex
-  static void ClearDefaultActionsLocked(void* mock_obj);
-
-  // Registers a mock object and a mock method it owns.
-  // L < g_gmock_mutex
-  static void Register(const void* mock_obj,
-                       internal::UntypedFunctionMockerBase* mocker);
-
-  // Tells Google Mock where in the source code mock_obj is used in an
-  // ON_CALL or EXPECT_CALL.  In case mock_obj is leaked, this
-  // information helps the user identify which object it is.
-  // L < g_gmock_mutex
-  static void RegisterUseByOnCallOrExpectCall(
-      const void* mock_obj, const char* file, int line);
-
-  // Unregisters a mock method; removes the owning mock object from
-  // the registry when the last mock method associated with it has
-  // been unregistered.  This is called only in the destructor of
-  // FunctionMockerBase.
-  // L >= g_gmock_mutex
-  static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker);
-};  // class Mock
-
-// An abstract handle of an expectation.  Useful in the .After()
-// clause of EXPECT_CALL() for setting the (partial) order of
-// expectations.  The syntax:
-//
-//   Expectation e1 = EXPECT_CALL(...)...;
-//   EXPECT_CALL(...).After(e1)...;
-//
-// sets two expectations where the latter can only be matched after
-// the former has been satisfied.
-//
-// Notes:
-//   - This class is copyable and has value semantics.
-//   - Constness is shallow: a const Expectation object itself cannot
-//     be modified, but the mutable methods of the ExpectationBase
-//     object it references can be called via expectation_base().
-//   - The constructors and destructor are defined out-of-line because
-//     the Symbian WINSCW compiler wants to otherwise instantiate them
-//     when it sees this class definition, at which point it doesn't have
-//     ExpectationBase available yet, leading to incorrect destruction
-//     in the linked_ptr (or compilation errors if using a checking
-//     linked_ptr).
-class Expectation {
- public:
-  // Constructs a null object that doesn't reference any expectation.
-  Expectation();
-
-  ~Expectation();
-
-  // This single-argument ctor must not be explicit, in order to support the
-  //   Expectation e = EXPECT_CALL(...);
-  // syntax.
-  //
-  // A TypedExpectation object stores its pre-requisites as
-  // Expectation objects, and needs to call the non-const Retire()
-  // method on the ExpectationBase objects they reference.  Therefore
-  // Expectation must receive a *non-const* reference to the
-  // ExpectationBase object.
-  Expectation(internal::ExpectationBase& exp);  // NOLINT
-
-  // The compiler-generated copy ctor and operator= work exactly as
-  // intended, so we don't need to define our own.
-
-  // Returns true iff rhs references the same expectation as this object does.
-  bool operator==(const Expectation& rhs) const {
-    return expectation_base_ == rhs.expectation_base_;
-  }
-
-  bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
-
- private:
-  friend class ExpectationSet;
-  friend class Sequence;
-  friend class ::testing::internal::ExpectationBase;
-  friend class ::testing::internal::UntypedFunctionMockerBase;
-
-  template <typename F>
-  friend class ::testing::internal::FunctionMockerBase;
-
-  template <typename F>
-  friend class ::testing::internal::TypedExpectation;
-
-  // This comparator is needed for putting Expectation objects into a set.
-  class Less {
-   public:
-    bool operator()(const Expectation& lhs, const Expectation& rhs) const {
-      return lhs.expectation_base_.get() < rhs.expectation_base_.get();
-    }
-  };
-
-  typedef ::std::set<Expectation, Less> Set;
-
-  Expectation(
-      const internal::linked_ptr<internal::ExpectationBase>& expectation_base);
-
-  // Returns the expectation this object references.
-  const internal::linked_ptr<internal::ExpectationBase>&
-  expectation_base() const {
-    return expectation_base_;
-  }
-
-  // A linked_ptr that co-owns the expectation this handle references.
-  internal::linked_ptr<internal::ExpectationBase> expectation_base_;
-};
-
-// A set of expectation handles.  Useful in the .After() clause of
-// EXPECT_CALL() for setting the (partial) order of expectations.  The
-// syntax:
-//
-//   ExpectationSet es;
-//   es += EXPECT_CALL(...)...;
-//   es += EXPECT_CALL(...)...;
-//   EXPECT_CALL(...).After(es)...;
-//
-// sets three expectations where the last one can only be matched
-// after the first two have both been satisfied.
-//
-// This class is copyable and has value semantics.
-class ExpectationSet {
- public:
-  // A bidirectional iterator that can read a const element in the set.
-  typedef Expectation::Set::const_iterator const_iterator;
-
-  // An object stored in the set.  This is an alias of Expectation.
-  typedef Expectation::Set::value_type value_type;
-
-  // Constructs an empty set.
-  ExpectationSet() {}
-
-  // This single-argument ctor must not be explicit, in order to support the
-  //   ExpectationSet es = EXPECT_CALL(...);
-  // syntax.
-  ExpectationSet(internal::ExpectationBase& exp) {  // NOLINT
-    *this += Expectation(exp);
-  }
-
-  // This single-argument ctor implements implicit conversion from
-  // Expectation and thus must not be explicit.  This allows either an
-  // Expectation or an ExpectationSet to be used in .After().
-  ExpectationSet(const Expectation& e) {  // NOLINT
-    *this += e;
-  }
-
-  // The compiler-generator ctor and operator= works exactly as
-  // intended, so we don't need to define our own.
-
-  // Returns true iff rhs contains the same set of Expectation objects
-  // as this does.
-  bool operator==(const ExpectationSet& rhs) const {
-    return expectations_ == rhs.expectations_;
-  }
-
-  bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }
-
-  // Implements the syntax
-  //   expectation_set += EXPECT_CALL(...);
-  ExpectationSet& operator+=(const Expectation& e) {
-    expectations_.insert(e);
-    return *this;
-  }
-
-  int size() const { return static_cast<int>(expectations_.size()); }
-
-  const_iterator begin() const { return expectations_.begin(); }
-  const_iterator end() const { return expectations_.end(); }
-
- private:
-  Expectation::Set expectations_;
-};
-
-
-// Sequence objects are used by a user to specify the relative order
-// in which the expectations should match.  They are copyable (we rely
-// on the compiler-defined copy constructor and assignment operator).
-class Sequence {
- public:
-  // Constructs an empty sequence.
-  Sequence() : last_expectation_(new Expectation) {}
-
-  // Adds an expectation to this sequence.  The caller must ensure
-  // that no other thread is accessing this Sequence object.
-  void AddExpectation(const Expectation& expectation) const;
-
- private:
-  // The last expectation in this sequence.  We use a linked_ptr here
-  // because Sequence objects are copyable and we want the copies to
-  // be aliases.  The linked_ptr allows the copies to co-own and share
-  // the same Expectation object.
-  internal::linked_ptr<Expectation> last_expectation_;
-};  // class Sequence
-
-// An object of this type causes all EXPECT_CALL() statements
-// encountered in its scope to be put in an anonymous sequence.  The
-// work is done in the constructor and destructor.  You should only
-// create an InSequence object on the stack.
-//
-// The sole purpose for this class is to support easy definition of
-// sequential expectations, e.g.
-//
-//   {
-//     InSequence dummy;  // The name of the object doesn't matter.
-//
-//     // The following expectations must match in the order they appear.
-//     EXPECT_CALL(a, Bar())...;
-//     EXPECT_CALL(a, Baz())...;
-//     ...
-//     EXPECT_CALL(b, Xyz())...;
-//   }
-//
-// You can create InSequence objects in multiple threads, as long as
-// they are used to affect different mock objects.  The idea is that
-// each thread can create and set up its own mocks as if it's the only
-// thread.  However, for clarity of your tests we recommend you to set
-// up mocks in the main thread unless you have a good reason not to do
-// so.
-class InSequence {
- public:
-  InSequence();
-  ~InSequence();
- private:
-  bool sequence_created_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);  // NOLINT
-} GTEST_ATTRIBUTE_UNUSED_;
-
-namespace internal {
-
-// Points to the implicit sequence introduced by a living InSequence
-// object (if any) in the current thread or NULL.
-extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
-
-// Base class for implementing expectations.
-//
-// There are two reasons for having a type-agnostic base class for
-// Expectation:
-//
-//   1. We need to store collections of expectations of different
-//   types (e.g. all pre-requisites of a particular expectation, all
-//   expectations in a sequence).  Therefore these expectation objects
-//   must share a common base class.
-//
-//   2. We can avoid binary code bloat by moving methods not depending
-//   on the template argument of Expectation to the base class.
-//
-// This class is internal and mustn't be used by user code directly.
-class ExpectationBase {
- public:
-  // source_text is the EXPECT_CALL(...) source that created this Expectation.
-  ExpectationBase(const char* file, int line, const string& source_text);
-
-  virtual ~ExpectationBase();
-
-  // Where in the source file was the expectation spec defined?
-  const char* file() const { return file_; }
-  int line() const { return line_; }
-  const char* source_text() const { return source_text_.c_str(); }
-  // Returns the cardinality specified in the expectation spec.
-  const Cardinality& cardinality() const { return cardinality_; }
-
-  // Describes the source file location of this expectation.
-  void DescribeLocationTo(::std::ostream* os) const {
-    *os << FormatFileLocation(file(), line()) << " ";
-  }
-
-  // Describes how many times a function call matching this
-  // expectation has occurred.
-  // L >= g_gmock_mutex
-  void DescribeCallCountTo(::std::ostream* os) const;
-
-  // If this mock method has an extra matcher (i.e. .With(matcher)),
-  // describes it to the ostream.
-  virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;
-
- protected:
-  friend class ::testing::Expectation;
-  friend class UntypedFunctionMockerBase;
-
-  enum Clause {
-    // Don't change the order of the enum members!
-    kNone,
-    kWith,
-    kTimes,
-    kInSequence,
-    kAfter,
-    kWillOnce,
-    kWillRepeatedly,
-    kRetiresOnSaturation
-  };
-
-  typedef std::vector<const void*> UntypedActions;
-
-  // Returns an Expectation object that references and co-owns this
-  // expectation.
-  virtual Expectation GetHandle() = 0;
-
-  // Asserts that the EXPECT_CALL() statement has the given property.
-  void AssertSpecProperty(bool property, const string& failure_message) const {
-    Assert(property, file_, line_, failure_message);
-  }
-
-  // Expects that the EXPECT_CALL() statement has the given property.
-  void ExpectSpecProperty(bool property, const string& failure_message) const {
-    Expect(property, file_, line_, failure_message);
-  }
-
-  // Explicitly specifies the cardinality of this expectation.  Used
-  // by the subclasses to implement the .Times() clause.
-  void SpecifyCardinality(const Cardinality& cardinality);
-
-  // Returns true iff the user specified the cardinality explicitly
-  // using a .Times().
-  bool cardinality_specified() const { return cardinality_specified_; }
-
-  // Sets the cardinality of this expectation spec.
-  void set_cardinality(const Cardinality& a_cardinality) {
-    cardinality_ = a_cardinality;
-  }
-
-  // The following group of methods should only be called after the
-  // EXPECT_CALL() statement, and only when g_gmock_mutex is held by
-  // the current thread.
-
-  // Retires all pre-requisites of this expectation.
-  // L >= g_gmock_mutex
-  void RetireAllPreRequisites();
-
-  // Returns true iff this expectation is retired.
-  // L >= g_gmock_mutex
-  bool is_retired() const {
-    g_gmock_mutex.AssertHeld();
-    return retired_;
-  }
-
-  // Retires this expectation.
-  // L >= g_gmock_mutex
-  void Retire() {
-    g_gmock_mutex.AssertHeld();
-    retired_ = true;
-  }
-
-  // Returns true iff this expectation is satisfied.
-  // L >= g_gmock_mutex
-  bool IsSatisfied() const {
-    g_gmock_mutex.AssertHeld();
-    return cardinality().IsSatisfiedByCallCount(call_count_);
-  }
-
-  // Returns true iff this expectation is saturated.
-  // L >= g_gmock_mutex
-  bool IsSaturated() const {
-    g_gmock_mutex.AssertHeld();
-    return cardinality().IsSaturatedByCallCount(call_count_);
-  }
-
-  // Returns true iff this expectation is over-saturated.
-  // L >= g_gmock_mutex
-  bool IsOverSaturated() const {
-    g_gmock_mutex.AssertHeld();
-    return cardinality().IsOverSaturatedByCallCount(call_count_);
-  }
-
-  // Returns true iff all pre-requisites of this expectation are satisfied.
-  // L >= g_gmock_mutex
-  bool AllPrerequisitesAreSatisfied() const;
-
-  // Adds unsatisfied pre-requisites of this expectation to 'result'.
-  // L >= g_gmock_mutex
-  void FindUnsatisfiedPrerequisites(ExpectationSet* result) const;
-
-  // Returns the number this expectation has been invoked.
-  // L >= g_gmock_mutex
-  int call_count() const {
-    g_gmock_mutex.AssertHeld();
-    return call_count_;
-  }
-
-  // Increments the number this expectation has been invoked.
-  // L >= g_gmock_mutex
-  void IncrementCallCount() {
-    g_gmock_mutex.AssertHeld();
-    call_count_++;
-  }
-
-  // Checks the action count (i.e. the number of WillOnce() and
-  // WillRepeatedly() clauses) against the cardinality if this hasn't
-  // been done before.  Prints a warning if there are too many or too
-  // few actions.
-  // L < mutex_
-  void CheckActionCountIfNotDone() const;
-
-  friend class ::testing::Sequence;
-  friend class ::testing::internal::ExpectationTester;
-
-  template <typename Function>
-  friend class TypedExpectation;
-
-  // Implements the .Times() clause.
-  void UntypedTimes(const Cardinality& a_cardinality);
-
-  // This group of fields are part of the spec and won't change after
-  // an EXPECT_CALL() statement finishes.
-  const char* file_;          // The file that contains the expectation.
-  int line_;                  // The line number of the expectation.
-  const string source_text_;  // The EXPECT_CALL(...) source text.
-  // True iff the cardinality is specified explicitly.
-  bool cardinality_specified_;
-  Cardinality cardinality_;            // The cardinality of the expectation.
-  // The immediate pre-requisites (i.e. expectations that must be
-  // satisfied before this expectation can be matched) of this
-  // expectation.  We use linked_ptr in the set because we want an
-  // Expectation object to be co-owned by its FunctionMocker and its
-  // successors.  This allows multiple mock objects to be deleted at
-  // different times.
-  ExpectationSet immediate_prerequisites_;
-
-  // This group of fields are the current state of the expectation,
-  // and can change as the mock function is called.
-  int call_count_;  // How many times this expectation has been invoked.
-  bool retired_;    // True iff this expectation has retired.
-  UntypedActions untyped_actions_;
-  bool extra_matcher_specified_;
-  bool repeated_action_specified_;  // True if a WillRepeatedly() was specified.
-  bool retires_on_saturation_;
-  Clause last_clause_;
-  mutable bool action_count_checked_;  // Under mutex_.
-  mutable Mutex mutex_;  // Protects action_count_checked_.
-
-  GTEST_DISALLOW_ASSIGN_(ExpectationBase);
-};  // class ExpectationBase
-
-// Impements an expectation for the given function type.
-template <typename F>
-class TypedExpectation : public ExpectationBase {
- public:
-  typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
-  typedef typename Function<F>::Result Result;
-
-  TypedExpectation(FunctionMockerBase<F>* owner,
-                   const char* a_file, int a_line, const string& a_source_text,
-                   const ArgumentMatcherTuple& m)
-      : ExpectationBase(a_file, a_line, a_source_text),
-        owner_(owner),
-        matchers_(m),
-        // By default, extra_matcher_ should match anything.  However,
-        // we cannot initialize it with _ as that triggers a compiler
-        // bug in Symbian's C++ compiler (cannot decide between two
-        // overloaded constructors of Matcher<const ArgumentTuple&>).
-        extra_matcher_(A<const ArgumentTuple&>()),
-        repeated_action_(DoDefault()) {}
-
-  virtual ~TypedExpectation() {
-    // Check the validity of the action count if it hasn't been done
-    // yet (for example, if the expectation was never used).
-    CheckActionCountIfNotDone();
-    for (UntypedActions::const_iterator it = untyped_actions_.begin();
-         it != untyped_actions_.end(); ++it) {
-      delete static_cast<const Action<F>*>(*it);
-    }
-  }
-
-  // Implements the .With() clause.
-  TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
-    if (last_clause_ == kWith) {
-      ExpectSpecProperty(false,
-                         ".With() cannot appear "
-                         "more than once in an EXPECT_CALL().");
-    } else {
-      ExpectSpecProperty(last_clause_ < kWith,
-                         ".With() must be the first "
-                         "clause in an EXPECT_CALL().");
-    }
-    last_clause_ = kWith;
-
-    extra_matcher_ = m;
-    extra_matcher_specified_ = true;
-    return *this;
-  }
-
-  // Implements the .Times() clause.
-  TypedExpectation& Times(const Cardinality& a_cardinality) {
-    ExpectationBase::UntypedTimes(a_cardinality);
-    return *this;
-  }
-
-  // Implements the .Times() clause.
-  TypedExpectation& Times(int n) {
-    return Times(Exactly(n));
-  }
-
-  // Implements the .InSequence() clause.
-  TypedExpectation& InSequence(const Sequence& s) {
-    ExpectSpecProperty(last_clause_ <= kInSequence,
-                       ".InSequence() cannot appear after .After(),"
-                       " .WillOnce(), .WillRepeatedly(), or "
-                       ".RetiresOnSaturation().");
-    last_clause_ = kInSequence;
-
-    s.AddExpectation(GetHandle());
-    return *this;
-  }
-  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
-    return InSequence(s1).InSequence(s2);
-  }
-  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
-                               const Sequence& s3) {
-    return InSequence(s1, s2).InSequence(s3);
-  }
-  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
-                               const Sequence& s3, const Sequence& s4) {
-    return InSequence(s1, s2, s3).InSequence(s4);
-  }
-  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
-                               const Sequence& s3, const Sequence& s4,
-                               const Sequence& s5) {
-    return InSequence(s1, s2, s3, s4).InSequence(s5);
-  }
-
-  // Implements that .After() clause.
-  TypedExpectation& After(const ExpectationSet& s) {
-    ExpectSpecProperty(last_clause_ <= kAfter,
-                       ".After() cannot appear after .WillOnce(),"
-                       " .WillRepeatedly(), or "
-                       ".RetiresOnSaturation().");
-    last_clause_ = kAfter;
-
-    for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {
-      immediate_prerequisites_ += *it;
-    }
-    return *this;
-  }
-  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {
-    return After(s1).After(s2);
-  }
-  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
-                          const ExpectationSet& s3) {
-    return After(s1, s2).After(s3);
-  }
-  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
-                          const ExpectationSet& s3, const ExpectationSet& s4) {
-    return After(s1, s2, s3).After(s4);
-  }
-  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
-                          const ExpectationSet& s3, const ExpectationSet& s4,
-                          const ExpectationSet& s5) {
-    return After(s1, s2, s3, s4).After(s5);
-  }
-
-  // Implements the .WillOnce() clause.
-  TypedExpectation& WillOnce(const Action<F>& action) {
-    ExpectSpecProperty(last_clause_ <= kWillOnce,
-                       ".WillOnce() cannot appear after "
-                       ".WillRepeatedly() or .RetiresOnSaturation().");
-    last_clause_ = kWillOnce;
-
-    untyped_actions_.push_back(new Action<F>(action));
-    if (!cardinality_specified()) {
-      set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
-    }
-    return *this;
-  }
-
-  // Implements the .WillRepeatedly() clause.
-  TypedExpectation& WillRepeatedly(const Action<F>& action) {
-    if (last_clause_ == kWillRepeatedly) {
-      ExpectSpecProperty(false,
-                         ".WillRepeatedly() cannot appear "
-                         "more than once in an EXPECT_CALL().");
-    } else {
-      ExpectSpecProperty(last_clause_ < kWillRepeatedly,
-                         ".WillRepeatedly() cannot appear "
-                         "after .RetiresOnSaturation().");
-    }
-    last_clause_ = kWillRepeatedly;
-    repeated_action_specified_ = true;
-
-    repeated_action_ = action;
-    if (!cardinality_specified()) {
-      set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
-    }
-
-    // Now that no more action clauses can be specified, we check
-    // whether their count makes sense.
-    CheckActionCountIfNotDone();
-    return *this;
-  }
-
-  // Implements the .RetiresOnSaturation() clause.
-  TypedExpectation& RetiresOnSaturation() {
-    ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
-                       ".RetiresOnSaturation() cannot appear "
-                       "more than once.");
-    last_clause_ = kRetiresOnSaturation;
-    retires_on_saturation_ = true;
-
-    // Now that no more action clauses can be specified, we check
-    // whether their count makes sense.
-    CheckActionCountIfNotDone();
-    return *this;
-  }
-
-  // Returns the matchers for the arguments as specified inside the
-  // EXPECT_CALL() macro.
-  const ArgumentMatcherTuple& matchers() const {
-    return matchers_;
-  }
-
-  // Returns the matcher specified by the .With() clause.
-  const Matcher<const ArgumentTuple&>& extra_matcher() const {
-    return extra_matcher_;
-  }
-
-  // Returns the action specified by the .WillRepeatedly() clause.
-  const Action<F>& repeated_action() const { return repeated_action_; }
-
-  // If this mock method has an extra matcher (i.e. .With(matcher)),
-  // describes it to the ostream.
-  virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
-    if (extra_matcher_specified_) {
-      *os << "    Expected args: ";
-      extra_matcher_.DescribeTo(os);
-      *os << "\n";
-    }
-  }
-
- private:
-  template <typename Function>
-  friend class FunctionMockerBase;
-
-  // Returns an Expectation object that references and co-owns this
-  // expectation.
-  virtual Expectation GetHandle() {
-    return owner_->GetHandleOf(this);
-  }
-
-  // The following methods will be called only after the EXPECT_CALL()
-  // statement finishes and when the current thread holds
-  // g_gmock_mutex.
-
-  // Returns true iff this expectation matches the given arguments.
-  // L >= g_gmock_mutex
-  bool Matches(const ArgumentTuple& args) const {
-    g_gmock_mutex.AssertHeld();
-    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
-  }
-
-  // Returns true iff this expectation should handle the given arguments.
-  // L >= g_gmock_mutex
-  bool ShouldHandleArguments(const ArgumentTuple& args) const {
-    g_gmock_mutex.AssertHeld();
-
-    // In case the action count wasn't checked when the expectation
-    // was defined (e.g. if this expectation has no WillRepeatedly()
-    // or RetiresOnSaturation() clause), we check it when the
-    // expectation is used for the first time.
-    CheckActionCountIfNotDone();
-    return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
-  }
-
-  // Describes the result of matching the arguments against this
-  // expectation to the given ostream.
-  // L >= g_gmock_mutex
-  void ExplainMatchResultTo(const ArgumentTuple& args,
-                            ::std::ostream* os) const {
-    g_gmock_mutex.AssertHeld();
-
-    if (is_retired()) {
-      *os << "         Expected: the expectation is active\n"
-          << "           Actual: it is retired\n";
-    } else if (!Matches(args)) {
-      if (!TupleMatches(matchers_, args)) {
-        ExplainMatchFailureTupleTo(matchers_, args, os);
-      }
-      StringMatchResultListener listener;
-      if (!extra_matcher_.MatchAndExplain(args, &listener)) {
-        *os << "    Expected args: ";
-        extra_matcher_.DescribeTo(os);
-        *os << "\n           Actual: don't match";
-
-        internal::PrintIfNotEmpty(listener.str(), os);
-        *os << "\n";
-      }
-    } else if (!AllPrerequisitesAreSatisfied()) {
-      *os << "         Expected: all pre-requisites are satisfied\n"
-          << "           Actual: the following immediate pre-requisites "
-          << "are not satisfied:\n";
-      ExpectationSet unsatisfied_prereqs;
-      FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
-      int i = 0;
-      for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
-           it != unsatisfied_prereqs.end(); ++it) {
-        it->expectation_base()->DescribeLocationTo(os);
-        *os << "pre-requisite #" << i++ << "\n";
-      }
-      *os << "                   (end of pre-requisites)\n";
-    } else {
-      // This line is here just for completeness' sake.  It will never
-      // be executed as currently the ExplainMatchResultTo() function
-      // is called only when the mock function call does NOT match the
-      // expectation.
-      *os << "The call matches the expectation.\n";
-    }
-  }
-
-  // Returns the action that should be taken for the current invocation.
-  // L >= g_gmock_mutex
-  const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker,
-                                    const ArgumentTuple& args) const {
-    g_gmock_mutex.AssertHeld();
-    const int count = call_count();
-    Assert(count >= 1, __FILE__, __LINE__,
-           "call_count() is <= 0 when GetCurrentAction() is "
-           "called - this should never happen.");
-
-    const int action_count = static_cast<int>(untyped_actions_.size());
-    if (action_count > 0 && !repeated_action_specified_ &&
-        count > action_count) {
-      // If there is at least one WillOnce() and no WillRepeatedly(),
-      // we warn the user when the WillOnce() clauses ran out.
-      ::std::stringstream ss;
-      DescribeLocationTo(&ss);
-      ss << "Actions ran out in " << source_text() << "...\n"
-         << "Called " << count << " times, but only "
-         << action_count << " WillOnce()"
-         << (action_count == 1 ? " is" : "s are") << " specified - ";
-      mocker->DescribeDefaultActionTo(args, &ss);
-      Log(WARNING, ss.str(), 1);
-    }
-
-    return count <= action_count ?
-        *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :
-        repeated_action();
-  }
-
-  // Given the arguments of a mock function call, if the call will
-  // over-saturate this expectation, returns the default action;
-  // otherwise, returns the next action in this expectation.  Also
-  // describes *what* happened to 'what', and explains *why* Google
-  // Mock does it to 'why'.  This method is not const as it calls
-  // IncrementCallCount().  A return value of NULL means the default
-  // action.
-  // L >= g_gmock_mutex
-  const Action<F>* GetActionForArguments(const FunctionMockerBase<F>* mocker,
-                                         const ArgumentTuple& args,
-                                         ::std::ostream* what,
-                                         ::std::ostream* why) {
-    g_gmock_mutex.AssertHeld();
-    if (IsSaturated()) {
-      // We have an excessive call.
-      IncrementCallCount();
-      *what << "Mock function called more times than expected - ";
-      mocker->DescribeDefaultActionTo(args, what);
-      DescribeCallCountTo(why);
-
-      // TODO(wan@google.com): allow the user to control whether
-      // unexpected calls should fail immediately or continue using a
-      // flag --gmock_unexpected_calls_are_fatal.
-      return NULL;
-    }
-
-    IncrementCallCount();
-    RetireAllPreRequisites();
-
-    if (retires_on_saturation_ && IsSaturated()) {
-      Retire();
-    }
-
-    // Must be done after IncrementCount()!
-    *what << "Mock function call matches " << source_text() <<"...\n";
-    return &(GetCurrentAction(mocker, args));
-  }
-
-  // All the fields below won't change once the EXPECT_CALL()
-  // statement finishes.
-  FunctionMockerBase<F>* const owner_;
-  ArgumentMatcherTuple matchers_;
-  Matcher<const ArgumentTuple&> extra_matcher_;
-  Action<F> repeated_action_;
-
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
-};  // class TypedExpectation
-
-// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
-// specifying the default behavior of, or expectation on, a mock
-// function.
-
-// Note: class MockSpec really belongs to the ::testing namespace.
-// However if we define it in ::testing, MSVC will complain when
-// classes in ::testing::internal declare it as a friend class
-// template.  To workaround this compiler bug, we define MockSpec in
-// ::testing::internal and import it into ::testing.
-
-// Logs a message including file and line number information.
-void LogWithLocation(testing::internal::LogSeverity severity,
-                     const char* file, int line,
-                     const string& message);
-
-template <typename F>
-class MockSpec {
- public:
-  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
-  typedef typename internal::Function<F>::ArgumentMatcherTuple
-      ArgumentMatcherTuple;
-
-  // Constructs a MockSpec object, given the function mocker object
-  // that the spec is associated with.
-  explicit MockSpec(internal::FunctionMockerBase<F>* function_mocker)
-      : function_mocker_(function_mocker) {}
-
-  // Adds a new default action spec to the function mocker and returns
-  // the newly created spec.
-  internal::OnCallSpec<F>& InternalDefaultActionSetAt(
-      const char* file, int line, const char* obj, const char* call) {
-    LogWithLocation(internal::INFO, file, line,
-        string("ON_CALL(") + obj + ", " + call + ") invoked");
-    return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
-  }
-
-  // Adds a new expectation spec to the function mocker and returns
-  // the newly created spec.
-  internal::TypedExpectation<F>& InternalExpectedAt(
-      const char* file, int line, const char* obj, const char* call) {
-    const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
-    LogWithLocation(internal::INFO, file, line, source_text + " invoked");
-    return function_mocker_->AddNewExpectation(
-        file, line, source_text, matchers_);
-  }
-
- private:
-  template <typename Function>
-  friend class internal::FunctionMocker;
-
-  void SetMatchers(const ArgumentMatcherTuple& matchers) {
-    matchers_ = matchers;
-  }
-
-  // The function mocker that owns this spec.
-  internal::FunctionMockerBase<F>* const function_mocker_;
-  // The argument matchers specified in the spec.
-  ArgumentMatcherTuple matchers_;
-
-  GTEST_DISALLOW_ASSIGN_(MockSpec);
-};  // class MockSpec
-
-// MSVC warns about using 'this' in base member initializer list, so
-// we need to temporarily disable the warning.  We have to do it for
-// the entire class to suppress the warning, even though it's about
-// the constructor only.
-
-#ifdef _MSC_VER
-# pragma warning(push)          // Saves the current warning state.
-# pragma warning(disable:4355)  // Temporarily disables warning 4355.
-#endif  // _MSV_VER
-
-// C++ treats the void type specially.  For example, you cannot define
-// a void-typed variable or pass a void value to a function.
-// ActionResultHolder<T> holds a value of type T, where T must be a
-// copyable type or void (T doesn't need to be default-constructable).
-// It hides the syntactic difference between void and other types, and
-// is used to unify the code for invoking both void-returning and
-// non-void-returning mock functions.
-
-// Untyped base class for ActionResultHolder<T>.
-class UntypedActionResultHolderBase {
- public:
-  virtual ~UntypedActionResultHolderBase() {}
-
-  // Prints the held value as an action's result to os.
-  virtual void PrintAsActionResult(::std::ostream* os) const = 0;
-};
-
-// This generic definition is used when T is not void.
-template <typename T>
-class ActionResultHolder : public UntypedActionResultHolderBase {
- public:
-  explicit ActionResultHolder(T a_value) : value_(a_value) {}
-
-  // The compiler-generated copy constructor and assignment operator
-  // are exactly what we need, so we don't need to define them.
-
-  // Returns the held value and deletes this object.
-  T GetValueAndDelete() const {
-    T retval(value_);
-    delete this;
-    return retval;
-  }
-
-  // Prints the held value as an action's result to os.
-  virtual void PrintAsActionResult(::std::ostream* os) const {
-    *os << "\n          Returns: ";
-    // T may be a reference type, so we don't use UniversalPrint().
-    UniversalPrinter<T>::Print(value_, os);
-  }
-
-  // Performs the given mock function's default action and returns the
-  // result in a new-ed ActionResultHolder.
-  template <typename F>
-  static ActionResultHolder* PerformDefaultAction(
-      const FunctionMockerBase<F>* func_mocker,
-      const typename Function<F>::ArgumentTuple& args,
-      const string& call_description) {
-    return new ActionResultHolder(
-        func_mocker->PerformDefaultAction(args, call_description));
-  }
-
-  // Performs the given action and returns the result in a new-ed
-  // ActionResultHolder.
-  template <typename F>
-  static ActionResultHolder*
-  PerformAction(const Action<F>& action,
-                const typename Function<F>::ArgumentTuple& args) {
-    return new ActionResultHolder(action.Perform(args));
-  }
-
- private:
-  T value_;
-
-  // T could be a reference type, so = isn't supported.
-  GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
-};
-
-// Specialization for T = void.
-template <>
-class ActionResultHolder<void> : public UntypedActionResultHolderBase {
- public:
-  void GetValueAndDelete() const { delete this; }
-
-  virtual void PrintAsActionResult(::std::ostream* /* os */) const {}
-
-  // Performs the given mock function's default action and returns NULL;
-  template <typename F>
-  static ActionResultHolder* PerformDefaultAction(
-      const FunctionMockerBase<F>* func_mocker,
-      const typename Function<F>::ArgumentTuple& args,
-      const string& call_description) {
-    func_mocker->PerformDefaultAction(args, call_description);
-    return NULL;
-  }
-
-  // Performs the given action and returns NULL.
-  template <typename F>
-  static ActionResultHolder* PerformAction(
-      const Action<F>& action,
-      const typename Function<F>::ArgumentTuple& args) {
-    action.Perform(args);
-    return NULL;
-  }
-};
-
-// The base of the function mocker class for the given function type.
-// We put the methods in this class instead of its child to avoid code
-// bloat.
-template <typename F>
-class FunctionMockerBase : public UntypedFunctionMockerBase {
- public:
-  typedef typename Function<F>::Result Result;
-  typedef typename Function<F>::ArgumentTuple ArgumentTuple;
-  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
-
-  FunctionMockerBase() : current_spec_(this) {}
-
-  // The destructor verifies that all expectations on this mock
-  // function have been satisfied.  If not, it will report Google Test
-  // non-fatal failures for the violations.
-  // L < g_gmock_mutex
-  virtual ~FunctionMockerBase() {
-    MutexLock l(&g_gmock_mutex);
-    VerifyAndClearExpectationsLocked();
-    Mock::UnregisterLocked(this);
-    ClearDefaultActionsLocked();
-  }
-
-  // Returns the ON_CALL spec that matches this mock function with the
-  // given arguments; returns NULL if no matching ON_CALL is found.
-  // L = *
-  const OnCallSpec<F>* FindOnCallSpec(
-      const ArgumentTuple& args) const {
-    for (UntypedOnCallSpecs::const_reverse_iterator it
-             = untyped_on_call_specs_.rbegin();
-         it != untyped_on_call_specs_.rend(); ++it) {
-      const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
-      if (spec->Matches(args))
-        return spec;
-    }
-
-    return NULL;
-  }
-
-  // Performs the default action of this mock function on the given arguments
-  // and returns the result. Asserts with a helpful call descrption if there is
-  // no valid return value. This method doesn't depend on the mutable state of
-  // this object, and thus can be called concurrently without locking.
-  // L = *
-  Result PerformDefaultAction(const ArgumentTuple& args,
-                              const string& call_description) const {
-    const OnCallSpec<F>* const spec =
-        this->FindOnCallSpec(args);
-    if (spec != NULL) {
-      return spec->GetAction().Perform(args);
-    }
-    Assert(DefaultValue<Result>::Exists(), "", -1,
-           call_description + "\n    The mock function has no default action "
-           "set, and its return type has no default value set.");
-    return DefaultValue<Result>::Get();
-  }
-
-  // Performs the default action with the given arguments and returns
-  // the action's result.  The call description string will be used in
-  // the error message to describe the call in the case the default
-  // action fails.  The caller is responsible for deleting the result.
-  // L = *
-  virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
-      const void* untyped_args,  // must point to an ArgumentTuple
-      const string& call_description) const {
-    const ArgumentTuple& args =
-        *static_cast<const ArgumentTuple*>(untyped_args);
-    return ResultHolder::PerformDefaultAction(this, args, call_description);
-  }
-
-  // Performs the given action with the given arguments and returns
-  // the action's result.  The caller is responsible for deleting the
-  // result.
-  // L = *
-  virtual UntypedActionResultHolderBase* UntypedPerformAction(
-      const void* untyped_action, const void* untyped_args) const {
-    // Make a copy of the action before performing it, in case the
-    // action deletes the mock object (and thus deletes itself).
-    const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
-    const ArgumentTuple& args =
-        *static_cast<const ArgumentTuple*>(untyped_args);
-    return ResultHolder::PerformAction(action, args);
-  }
-
-  // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
-  // clears the ON_CALL()s set on this mock function.
-  // L >= g_gmock_mutex
-  virtual void ClearDefaultActionsLocked() {
-    g_gmock_mutex.AssertHeld();
-    for (UntypedOnCallSpecs::const_iterator it =
-             untyped_on_call_specs_.begin();
-         it != untyped_on_call_specs_.end(); ++it) {
-      delete static_cast<const OnCallSpec<F>*>(*it);
-    }
-    untyped_on_call_specs_.clear();
-  }
-
- protected:
-  template <typename Function>
-  friend class MockSpec;
-
-  typedef ActionResultHolder<Result> ResultHolder;
-
-  // Returns the result of invoking this mock function with the given
-  // arguments.  This function can be safely called from multiple
-  // threads concurrently.
-  // L < g_gmock_mutex
-  Result InvokeWith(const ArgumentTuple& args) {
-    return static_cast<const ResultHolder*>(
-        this->UntypedInvokeWith(&args))->GetValueAndDelete();
-  }
-
-  // Adds and returns a default action spec for this mock function.
-  // L < g_gmock_mutex
-  OnCallSpec<F>& AddNewOnCallSpec(
-      const char* file, int line,
-      const ArgumentMatcherTuple& m) {
-    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
-    OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
-    untyped_on_call_specs_.push_back(on_call_spec);
-    return *on_call_spec;
-  }
-
-  // Adds and returns an expectation spec for this mock function.
-  // L < g_gmock_mutex
-  TypedExpectation<F>& AddNewExpectation(
-      const char* file,
-      int line,
-      const string& source_text,
-      const ArgumentMatcherTuple& m) {
-    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
-    TypedExpectation<F>* const expectation =
-        new TypedExpectation<F>(this, file, line, source_text, m);
-    const linked_ptr<ExpectationBase> untyped_expectation(expectation);
-    untyped_expectations_.push_back(untyped_expectation);
-
-    // Adds this expectation into the implicit sequence if there is one.
-    Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
-    if (implicit_sequence != NULL) {
-      implicit_sequence->AddExpectation(Expectation(untyped_expectation));
-    }
-
-    return *expectation;
-  }
-
-  // The current spec (either default action spec or expectation spec)
-  // being described on this function mocker.
-  MockSpec<F>& current_spec() { return current_spec_; }
-
- private:
-  template <typename Func> friend class TypedExpectation;
-
-  // Some utilities needed for implementing UntypedInvokeWith().
-
-  // Describes what default action will be performed for the given
-  // arguments.
-  // L = *
-  void DescribeDefaultActionTo(const ArgumentTuple& args,
-                               ::std::ostream* os) const {
-    const OnCallSpec<F>* const spec = FindOnCallSpec(args);
-
-    if (spec == NULL) {
-      *os << (internal::type_equals<Result, void>::value ?
-              "returning directly.\n" :
-              "returning default value.\n");
-    } else {
-      *os << "taking default action specified at:\n"
-          << FormatFileLocation(spec->file(), spec->line()) << "\n";
-    }
-  }
-
-  // Writes a message that the call is uninteresting (i.e. neither
-  // explicitly expected nor explicitly unexpected) to the given
-  // ostream.
-  // L < g_gmock_mutex
-  virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
-                                                ::std::ostream* os) const {
-    const ArgumentTuple& args =
-        *static_cast<const ArgumentTuple*>(untyped_args);
-    *os << "Uninteresting mock function call - ";
-    DescribeDefaultActionTo(args, os);
-    *os << "    Function call: " << Name();
-    UniversalPrint(args, os);
-  }
-
-  // Returns the expectation that matches the given function arguments
-  // (or NULL is there's no match); when a match is found,
-  // untyped_action is set to point to the action that should be
-  // performed (or NULL if the action is "do default"), and
-  // is_excessive is modified to indicate whether the call exceeds the
-  // expected number.
-  //
-  // Critical section: We must find the matching expectation and the
-  // corresponding action that needs to be taken in an ATOMIC
-  // transaction.  Otherwise another thread may call this mock
-  // method in the middle and mess up the state.
-  //
-  // However, performing the action has to be left out of the critical
-  // section.  The reason is that we have no control on what the
-  // action does (it can invoke an arbitrary user function or even a
-  // mock function) and excessive locking could cause a dead lock.
-  // L < g_gmock_mutex
-  virtual const ExpectationBase* UntypedFindMatchingExpectation(
-      const void* untyped_args,
-      const void** untyped_action, bool* is_excessive,
-      ::std::ostream* what, ::std::ostream* why) {
-    const ArgumentTuple& args =
-        *static_cast<const ArgumentTuple*>(untyped_args);
-    MutexLock l(&g_gmock_mutex);
-    TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);
-    if (exp == NULL) {  // A match wasn't found.
-      this->FormatUnexpectedCallMessageLocked(args, what, why);
-      return NULL;
-    }
-
-    // This line must be done before calling GetActionForArguments(),
-    // which will increment the call count for *exp and thus affect
-    // its saturation status.
-    *is_excessive = exp->IsSaturated();
-    const Action<F>* action = exp->GetActionForArguments(this, args, what, why);
-    if (action != NULL && action->IsDoDefault())
-      action = NULL;  // Normalize "do default" to NULL.
-    *untyped_action = action;
-    return exp;
-  }
-
-  // Prints the given function arguments to the ostream.
-  virtual void UntypedPrintArgs(const void* untyped_args,
-                                ::std::ostream* os) const {
-    const ArgumentTuple& args =
-        *static_cast<const ArgumentTuple*>(untyped_args);
-    UniversalPrint(args, os);
-  }
-
-  // Returns the expectation that matches the arguments, or NULL if no
-  // expectation matches them.
-  // L >= g_gmock_mutex
-  TypedExpectation<F>* FindMatchingExpectationLocked(
-      const ArgumentTuple& args) const {
-    g_gmock_mutex.AssertHeld();
-    for (typename UntypedExpectations::const_reverse_iterator it =
-             untyped_expectations_.rbegin();
-         it != untyped_expectations_.rend(); ++it) {
-      TypedExpectation<F>* const exp =
-          static_cast<TypedExpectation<F>*>(it->get());
-      if (exp->ShouldHandleArguments(args)) {
-        return exp;
-      }
-    }
-    return NULL;
-  }
-
-  // Returns a message that the arguments don't match any expectation.
-  // L >= g_gmock_mutex
-  void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args,
-                                         ::std::ostream* os,
-                                         ::std::ostream* why) const {
-    g_gmock_mutex.AssertHeld();
-    *os << "\nUnexpected mock function call - ";
-    DescribeDefaultActionTo(args, os);
-    PrintTriedExpectationsLocked(args, why);
-  }
-
-  // Prints a list of expectations that have been tried against the
-  // current mock function call.
-  // L >= g_gmock_mutex
-  void PrintTriedExpectationsLocked(const ArgumentTuple& args,
-                                    ::std::ostream* why) const {
-    g_gmock_mutex.AssertHeld();
-    const int count = static_cast<int>(untyped_expectations_.size());
-    *why << "Google Mock tried the following " << count << " "
-         << (count == 1 ? "expectation, but it didn't match" :
-             "expectations, but none matched")
-         << ":\n";
-    for (int i = 0; i < count; i++) {
-      TypedExpectation<F>* const expectation =
-          static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
-      *why << "\n";
-      expectation->DescribeLocationTo(why);
-      if (count > 1) {
-        *why << "tried expectation #" << i << ": ";
-      }
-      *why << expectation->source_text() << "...\n";
-      expectation->ExplainMatchResultTo(args, why);
-      expectation->DescribeCallCountTo(why);
-    }
-  }
-
-  // The current spec (either default action spec or expectation spec)
-  // being described on this function mocker.
-  MockSpec<F> current_spec_;
-
-  // There is no generally useful and implementable semantics of
-  // copying a mock object, so copying a mock is usually a user error.
-  // Thus we disallow copying function mockers.  If the user really
-  // wants to copy a mock object, he should implement his own copy
-  // operation, for example:
-  //
-  //   class MockFoo : public Foo {
-  //    public:
-  //     // Defines a copy constructor explicitly.
-  //     MockFoo(const MockFoo& src) {}
-  //     ...
-  //   };
-  GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);
-};  // class FunctionMockerBase
-
-#ifdef _MSC_VER
-# pragma warning(pop)  // Restores the warning state.
-#endif  // _MSV_VER
-
-// Implements methods of FunctionMockerBase.
-
-// Verifies that all expectations on this mock function have been
-// satisfied.  Reports one or more Google Test non-fatal failures and
-// returns false if not.
-// L >= g_gmock_mutex
-
-// Reports an uninteresting call (whose description is in msg) in the
-// manner specified by 'reaction'.
-void ReportUninterestingCall(CallReaction reaction, const string& msg);
-
-}  // namespace internal
-
-// The style guide prohibits "using" statements in a namespace scope
-// inside a header file.  However, the MockSpec class template is
-// meant to be defined in the ::testing namespace.  The following line
-// is just a trick for working around a bug in MSVC 8.0, which cannot
-// handle it if we define MockSpec in ::testing.
-using internal::MockSpec;
-
-// Const(x) is a convenient function for obtaining a const reference
-// to x.  This is useful for setting expectations on an overloaded
-// const mock method, e.g.
-//
-//   class MockFoo : public FooInterface {
-//    public:
-//     MOCK_METHOD0(Bar, int());
-//     MOCK_CONST_METHOD0(Bar, int&());
-//   };
-//
-//   MockFoo foo;
-//   // Expects a call to non-const MockFoo::Bar().
-//   EXPECT_CALL(foo, Bar());
-//   // Expects a call to const MockFoo::Bar().
-//   EXPECT_CALL(Const(foo), Bar());
-template <typename T>
-inline const T& Const(const T& x) { return x; }
-
-// Constructs an Expectation object that references and co-owns exp.
-inline Expectation::Expectation(internal::ExpectationBase& exp)  // NOLINT
-    : expectation_base_(exp.GetHandle().expectation_base()) {}
-
-}  // namespace testing
-
-// A separate macro is required to avoid compile errors when the name
-// of the method used in call is a result of macro expansion.
-// See CompilesWithMethodNameExpandedFromMacro tests in
-// internal/gmock-spec-builders_test.cc for more details.
-#define GMOCK_ON_CALL_IMPL_(obj, call) \
-    ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
-                                                    #obj, #call)
-#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
-
-#define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
-    ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
-#define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_

+ 0 - 93
Src/ThirdParty/gmock/gmock.h

@@ -1,93 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This is the main header file a user should include.
-
-#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
-#define GMOCK_INCLUDE_GMOCK_GMOCK_H_
-
-// This file implements the following syntax:
-//
-//   ON_CALL(mock_object.Method(...))
-//     .With(...) ?
-//     .WillByDefault(...);
-//
-// where With() is optional and WillByDefault() must appear exactly
-// once.
-//
-//   EXPECT_CALL(mock_object.Method(...))
-//     .With(...) ?
-//     .Times(...) ?
-//     .InSequence(...) *
-//     .WillOnce(...) *
-//     .WillRepeatedly(...) ?
-//     .RetiresOnSaturation() ? ;
-//
-// where all clauses are optional and WillOnce() can be repeated.
-
-#include "gmock/gmock-actions.h"
-#include "gmock/gmock-cardinalities.h"
-#include "gmock/gmock-generated-actions.h"
-#include "gmock/gmock-generated-function-mockers.h"
-#include "gmock/gmock-generated-matchers.h"
-#include "gmock/gmock-more-actions.h"
-#include "gmock/gmock-generated-nice-strict.h"
-#include "gmock/gmock-matchers.h"
-#include "gmock/internal/gmock-internal-utils.h"
-
-namespace testing {
-
-// Declares Google Mock flags that we want a user to use programmatically.
-GMOCK_DECLARE_bool_(catch_leaked_mocks);
-GMOCK_DECLARE_string_(verbose);
-
-// Initializes Google Mock.  This must be called before running the
-// tests.  In particular, it parses the command line for the flags
-// that Google Mock recognizes.  Whenever a Google Mock flag is seen,
-// it is removed from argv, and *argc is decremented.
-//
-// No value is returned.  Instead, the Google Mock flag variables are
-// updated.
-//
-// Since Google Test is needed for Google Mock to work, this function
-// also initializes Google Test and parses its flags, if that hasn't
-// been done.
-void InitGoogleMock(int* argc, char** argv);
-
-// This overloaded version can be used in Windows programs compiled in
-// UNICODE mode.
-void InitGoogleMock(int* argc, wchar_t** argv);
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_H_

+ 0 - 277
Src/ThirdParty/gmock/internal/gmock-generated-internal-utils.h

@@ -1,277 +0,0 @@
-// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
-
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file contains template meta-programming utility classes needed
-// for implementing Google Mock.
-
-#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
-#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
-
-#include "gmock/internal/gmock-port.h"
-
-namespace testing {
-
-template <typename T>
-class Matcher;
-
-namespace internal {
-
-// An IgnoredValue object can be implicitly constructed from ANY value.
-// This is used in implementing the IgnoreResult(a) action.
-class IgnoredValue {
- public:
-  // This constructor template allows any value to be implicitly
-  // converted to IgnoredValue.  The object has no data member and
-  // doesn't try to remember anything about the argument.  We
-  // deliberately omit the 'explicit' keyword in order to allow the
-  // conversion to be implicit.
-  template <typename T>
-  IgnoredValue(const T&) {}
-};
-
-// MatcherTuple<T>::type is a tuple type where each field is a Matcher
-// for the corresponding field in tuple type T.
-template <typename Tuple>
-struct MatcherTuple;
-
-template <>
-struct MatcherTuple< ::std::tr1::tuple<> > {
-  typedef ::std::tr1::tuple< > type;
-};
-
-template <typename A1>
-struct MatcherTuple< ::std::tr1::tuple<A1> > {
-  typedef ::std::tr1::tuple<Matcher<A1> > type;
-};
-
-template <typename A1, typename A2>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
-};
-
-template <typename A1, typename A2, typename A3>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
-      Matcher<A4> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
-    typename A6>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5>, Matcher<A6> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
-    typename A6, typename A7>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
-    typename A6, typename A7, typename A8>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
-    typename A6, typename A7, typename A8, typename A9>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
-    typename A6, typename A7, typename A8, typename A9, typename A10>
-struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
-    A10> > {
-  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
-      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
-      Matcher<A10> > type;
-};
-
-// Template struct Function<F>, where F must be a function type, contains
-// the following typedefs:
-//
-//   Result:               the function's return type.
-//   ArgumentN:            the type of the N-th argument, where N starts with 1.
-//   ArgumentTuple:        the tuple type consisting of all parameters of F.
-//   ArgumentMatcherTuple: the tuple type consisting of Matchers for all
-//                         parameters of F.
-//   MakeResultVoid:       the function type obtained by substituting void
-//                         for the return type of F.
-//   MakeResultIgnoredValue:
-//                         the function type obtained by substituting Something
-//                         for the return type of F.
-template <typename F>
-struct Function;
-
-template <typename R>
-struct Function<R()> {
-  typedef R Result;
-  typedef ::std::tr1::tuple<> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid();
-  typedef IgnoredValue MakeResultIgnoredValue();
-};
-
-template <typename R, typename A1>
-struct Function<R(A1)>
-    : Function<R()> {
-  typedef A1 Argument1;
-  typedef ::std::tr1::tuple<A1> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1);
-  typedef IgnoredValue MakeResultIgnoredValue(A1);
-};
-
-template <typename R, typename A1, typename A2>
-struct Function<R(A1, A2)>
-    : Function<R(A1)> {
-  typedef A2 Argument2;
-  typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-struct Function<R(A1, A2, A3)>
-    : Function<R(A1, A2)> {
-  typedef A3 Argument3;
-  typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-struct Function<R(A1, A2, A3, A4)>
-    : Function<R(A1, A2, A3)> {
-  typedef A4 Argument4;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5>
-struct Function<R(A1, A2, A3, A4, A5)>
-    : Function<R(A1, A2, A3, A4)> {
-  typedef A5 Argument5;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6>
-struct Function<R(A1, A2, A3, A4, A5, A6)>
-    : Function<R(A1, A2, A3, A4, A5)> {
-  typedef A6 Argument6;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7>
-struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
-    : Function<R(A1, A2, A3, A4, A5, A6)> {
-  typedef A7 Argument7;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8>
-struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
-    : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
-  typedef A8 Argument8;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9>
-struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
-    : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
-  typedef A9 Argument9;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
-      A9);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
-    typename A5, typename A6, typename A7, typename A8, typename A9,
-    typename A10>
-struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
-    : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
-  typedef A10 Argument10;
-  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
-      A10> ArgumentTuple;
-  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
-  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
-  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
-      A9, A10);
-};
-
-}  // namespace internal
-
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_

+ 0 - 463
Src/ThirdParty/gmock/internal/gmock-internal-utils.h

@@ -1,463 +0,0 @@
-// Copyright 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-
-// Google Mock - a framework for writing C++ mock classes.
-//
-// This file defines some utilities useful for implementing Google
-// Mock.  They are subject to change without notice, so please DO NOT
-// USE THEM IN USER CODE.
-
-#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
-#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
-
-#include <stdio.h>
-#include <ostream>  // NOLINT
-#include <string>
-
-#include "gmock/internal/gmock-generated-internal-utils.h"
-#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
-
-namespace testing {
-namespace internal {
-
-// Converts an identifier name to a space-separated list of lower-case
-// words.  Each maximum substring of the form [A-Za-z][a-z]*|\d+ is
-// treated as one word.  For example, both "FooBar123" and
-// "foo_bar_123" are converted to "foo bar 123".
-string ConvertIdentifierNameToWords(const char* id_name);
-
-// PointeeOf<Pointer>::type is the type of a value pointed to by a
-// Pointer, which can be either a smart pointer or a raw pointer.  The
-// following default implementation is for the case where Pointer is a
-// smart pointer.
-template <typename Pointer>
-struct PointeeOf {
-  // Smart pointer classes define type element_type as the type of
-  // their pointees.
-  typedef typename Pointer::element_type type;
-};
-// This specialization is for the raw pointer case.
-template <typename T>
-struct PointeeOf<T*> { typedef T type; };  // NOLINT
-
-// GetRawPointer(p) returns the raw pointer underlying p when p is a
-// smart pointer, or returns p itself when p is already a raw pointer.
-// The following default implementation is for the smart pointer case.
-template <typename Pointer>
-inline typename Pointer::element_type* GetRawPointer(const Pointer& p) {
-  return p.get();
-}
-// This overloaded version is for the raw pointer case.
-template <typename Element>
-inline Element* GetRawPointer(Element* p) { return p; }
-
-// This comparator allows linked_ptr to be stored in sets.
-template <typename T>
-struct LinkedPtrLessThan {
-  bool operator()(const ::testing::internal::linked_ptr<T>& lhs,
-                  const ::testing::internal::linked_ptr<T>& rhs) const {
-    return lhs.get() < rhs.get();
-  }
-};
-
-// Symbian compilation can be done with wchar_t being either a native
-// type or a typedef.  Using Google Mock with OpenC without wchar_t
-// should require the definition of _STLP_NO_WCHAR_T.
-//
-// MSVC treats wchar_t as a native type usually, but treats it as the
-// same as unsigned short when the compiler option /Zc:wchar_t- is
-// specified.  It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t
-// is a native type.
-#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \
-    (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))
-// wchar_t is a typedef.
-#else
-# define GMOCK_WCHAR_T_IS_NATIVE_ 1
-#endif
-
-// signed wchar_t and unsigned wchar_t are NOT in the C++ standard.
-// Using them is a bad practice and not portable.  So DON'T use them.
-//
-// Still, Google Mock is designed to work even if the user uses signed
-// wchar_t or unsigned wchar_t (obviously, assuming the compiler
-// supports them).
-//
-// To gcc,
-//   wchar_t == signed wchar_t != unsigned wchar_t == unsigned int
-#ifdef __GNUC__
-// signed/unsigned wchar_t are valid types.
-# define GMOCK_HAS_SIGNED_WCHAR_T_ 1
-#endif
-
-// In what follows, we use the term "kind" to indicate whether a type
-// is bool, an integer type (excluding bool), a floating-point type,
-// or none of them.  This categorization is useful for determining
-// when a matcher argument type can be safely converted to another
-// type in the implementation of SafeMatcherCast.
-enum TypeKind {
-  kBool, kInteger, kFloatingPoint, kOther
-};
-
-// KindOf<T>::value is the kind of type T.
-template <typename T> struct KindOf {
-  enum { value = kOther };  // The default kind.
-};
-
-// This macro declares that the kind of 'type' is 'kind'.
-#define GMOCK_DECLARE_KIND_(type, kind) \
-  template <> struct KindOf<type> { enum { value = kind }; }
-
-GMOCK_DECLARE_KIND_(bool, kBool);
-
-// All standard integer types.
-GMOCK_DECLARE_KIND_(char, kInteger);
-GMOCK_DECLARE_KIND_(signed char, kInteger);
-GMOCK_DECLARE_KIND_(unsigned char, kInteger);
-GMOCK_DECLARE_KIND_(short, kInteger);  // NOLINT
-GMOCK_DECLARE_KIND_(unsigned short, kInteger);  // NOLINT
-GMOCK_DECLARE_KIND_(int, kInteger);
-GMOCK_DECLARE_KIND_(unsigned int, kInteger);
-GMOCK_DECLARE_KIND_(long, kInteger);  // NOLINT
-GMOCK_DECLARE_KIND_(unsigned long, kInteger);  // NOLINT
-
-#if GMOCK_WCHAR_T_IS_NATIVE_
-GMOCK_DECLARE_KIND_(wchar_t, kInteger);
-#endif
-
-// Non-standard integer types.
-GMOCK_DECLARE_KIND_(Int64, kInteger);
-GMOCK_DECLARE_KIND_(UInt64, kInteger);
-
-// All standard floating-point types.
-GMOCK_DECLARE_KIND_(float, kFloatingPoint);
-GMOCK_DECLARE_KIND_(double, kFloatingPoint);
-GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
-
-#undef GMOCK_DECLARE_KIND_
-
-// Evaluates to the kind of 'type'.
-#define GMOCK_KIND_OF_(type) \
-  static_cast< ::testing::internal::TypeKind>( \
-      ::testing::internal::KindOf<type>::value)
-
-// Evaluates to true iff integer type T is signed.
-#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
-
-// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
-// is true iff arithmetic type From can be losslessly converted to
-// arithmetic type To.
-//
-// It's the user's responsibility to ensure that both From and To are
-// raw (i.e. has no CV modifier, is not a pointer, and is not a
-// reference) built-in arithmetic types, kFromKind is the kind of
-// From, and kToKind is the kind of To; the value is
-// implementation-defined when the above pre-condition is violated.
-template <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>
-struct LosslessArithmeticConvertibleImpl : public false_type {};
-
-// Converting bool to bool is lossless.
-template <>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>
-    : public true_type {};  // NOLINT
-
-// Converting bool to any integer type is lossless.
-template <typename To>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>
-    : public true_type {};  // NOLINT
-
-// Converting bool to any floating-point type is lossless.
-template <typename To>
-struct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>
-    : public true_type {};  // NOLINT
-
-// Converting an integer to bool is lossy.
-template <typename From>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
-    : public false_type {};  // NOLINT
-
-// Converting an integer to another non-bool integer is lossless iff
-// the target type's range encloses the source type's range.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
-    : public bool_constant<
-      // When converting from a smaller size to a larger size, we are
-      // fine as long as we are not converting from signed to unsigned.
-      ((sizeof(From) < sizeof(To)) &&
-       (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||
-      // When converting between the same size, the signedness must match.
-      ((sizeof(From) == sizeof(To)) &&
-       (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {};  // NOLINT
-
-#undef GMOCK_IS_SIGNED_
-
-// Converting an integer to a floating-point type may be lossy, since
-// the format of a floating-point number is implementation-defined.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>
-    : public false_type {};  // NOLINT
-
-// Converting a floating-point to bool is lossy.
-template <typename From>
-struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>
-    : public false_type {};  // NOLINT
-
-// Converting a floating-point to an integer is lossy.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
-    : public false_type {};  // NOLINT
-
-// Converting a floating-point to another floating-point is lossless
-// iff the target type is at least as big as the source type.
-template <typename From, typename To>
-struct LosslessArithmeticConvertibleImpl<
-  kFloatingPoint, From, kFloatingPoint, To>
-    : public bool_constant<sizeof(From) <= sizeof(To)> {};  // NOLINT
-
-// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic
-// type From can be losslessly converted to arithmetic type To.
-//
-// It's the user's responsibility to ensure that both From and To are
-// raw (i.e. has no CV modifier, is not a pointer, and is not a
-// reference) built-in arithmetic types; the value is
-// implementation-defined when the above pre-condition is violated.
-template <typename From, typename To>
-struct LosslessArithmeticConvertible
-    : public LosslessArithmeticConvertibleImpl<
-  GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {};  // NOLINT
-
-// This interface knows how to report a Google Mock failure (either
-// non-fatal or fatal).
-class FailureReporterInterface {
- public:
-  // The type of a failure (either non-fatal or fatal).
-  enum FailureType {
-    NONFATAL, FATAL
-  };
-
-  virtual ~FailureReporterInterface() {}
-
-  // Reports a failure that occurred at the given source file location.
-  virtual void ReportFailure(FailureType type, const char* file, int line,
-                             const string& message) = 0;
-};
-
-// Returns the failure reporter used by Google Mock.
-FailureReporterInterface* GetFailureReporter();
-
-// Asserts that condition is true; aborts the process with the given
-// message if condition is false.  We cannot use LOG(FATAL) or CHECK()
-// as Google Mock might be used to mock the log sink itself.  We
-// inline this function to prevent it from showing up in the stack
-// trace.
-inline void Assert(bool condition, const char* file, int line,
-                   const string& msg) {
-  if (!condition) {
-    GetFailureReporter()->ReportFailure(FailureReporterInterface::FATAL,
-                                        file, line, msg);
-  }
-}
-inline void Assert(bool condition, const char* file, int line) {
-  Assert(condition, file, line, "Assertion failed.");
-}
-
-// Verifies that condition is true; generates a non-fatal failure if
-// condition is false.
-inline void Expect(bool condition, const char* file, int line,
-                   const string& msg) {
-  if (!condition) {
-    GetFailureReporter()->ReportFailure(FailureReporterInterface::NONFATAL,
-                                        file, line, msg);
-  }
-}
-inline void Expect(bool condition, const char* file, int line) {
-  Expect(condition, file, line, "Expectation failed.");
-}
-
-// Severity level of a log.
-enum LogSeverity {
-  INFO = 0,
-  WARNING = 1
-};
-
-// Valid values for the --gmock_verbose flag.
-
-// All logs (informational and warnings) are printed.
-const char kInfoVerbosity[] = "info";
-// Only warnings are printed.
-const char kWarningVerbosity[] = "warning";
-// No logs are printed.
-const char kErrorVerbosity[] = "error";
-
-// Returns true iff a log with the given severity is visible according
-// to the --gmock_verbose flag.
-bool LogIsVisible(LogSeverity severity);
-
-// Prints the given message to stdout iff 'severity' >= the level
-// specified by the --gmock_verbose flag.  If stack_frames_to_skip >=
-// 0, also prints the stack trace excluding the top
-// stack_frames_to_skip frames.  In opt mode, any positive
-// stack_frames_to_skip is treated as 0, since we don't know which
-// function calls will be inlined by the compiler and need to be
-// conservative.
-void Log(LogSeverity severity, const string& message, int stack_frames_to_skip);
-
-// TODO(wan@google.com): group all type utilities together.
-
-// Type traits.
-
-// is_reference<T>::value is non-zero iff T is a reference type.
-template <typename T> struct is_reference : public false_type {};
-template <typename T> struct is_reference<T&> : public true_type {};
-
-// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.
-template <typename T1, typename T2> struct type_equals : public false_type {};
-template <typename T> struct type_equals<T, T> : public true_type {};
-
-// remove_reference<T>::type removes the reference from type T, if any.
-template <typename T> struct remove_reference { typedef T type; };  // NOLINT
-template <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT
-
-// Invalid<T>() returns an invalid value of type T.  This is useful
-// when a value of type T is needed for compilation, but the statement
-// will not really be executed (or we don't care if the statement
-// crashes).
-template <typename T>
-inline T Invalid() {
-  return *static_cast<typename remove_reference<T>::type*>(NULL);
-}
-template <>
-inline void Invalid<void>() {}
-
-// Given a raw type (i.e. having no top-level reference or const
-// modifier) RawContainer that's either an STL-style container or a
-// native array, class StlContainerView<RawContainer> has the
-// following members:
-//
-//   - type is a type that provides an STL-style container view to
-//     (i.e. implements the STL container concept for) RawContainer;
-//   - const_reference is a type that provides a reference to a const
-//     RawContainer;
-//   - ConstReference(raw_container) returns a const reference to an STL-style
-//     container view to raw_container, which is a RawContainer.
-//   - Copy(raw_container) returns an STL-style container view of a
-//     copy of raw_container, which is a RawContainer.
-//
-// This generic version is used when RawContainer itself is already an
-// STL-style container.
-template <class RawContainer>
-class StlContainerView {
- public:
-  typedef RawContainer type;
-  typedef const type& const_reference;
-
-  static const_reference ConstReference(const RawContainer& container) {
-    // Ensures that RawContainer is not a const type.
-    testing::StaticAssertTypeEq<RawContainer,
-        GTEST_REMOVE_CONST_(RawContainer)>();
-    return container;
-  }
-  static type Copy(const RawContainer& container) { return container; }
-};
-
-// This specialization is used when RawContainer is a native array type.
-template <typename Element, size_t N>
-class StlContainerView<Element[N]> {
- public:
-  typedef GTEST_REMOVE_CONST_(Element) RawElement;
-  typedef internal::NativeArray<RawElement> type;
-  // NativeArray<T> can represent a native array either by value or by
-  // reference (selected by a constructor argument), so 'const type'
-  // can be used to reference a const native array.  We cannot
-  // 'typedef const type& const_reference' here, as that would mean
-  // ConstReference() has to return a reference to a local variable.
-  typedef const type const_reference;
-
-  static const_reference ConstReference(const Element (&array)[N]) {
-    // Ensures that Element is not a const type.
-    testing::StaticAssertTypeEq<Element, RawElement>();
-#if GTEST_OS_SYMBIAN
-    // The Nokia Symbian compiler confuses itself in template instantiation
-    // for this call without the cast to Element*:
-    // function call '[testing::internal::NativeArray<char *>].NativeArray(
-    //     {lval} const char *[4], long, testing::internal::RelationToSource)'
-    //     does not match
-    // 'testing::internal::NativeArray<char *>::NativeArray(
-    //     char *const *, unsigned int, testing::internal::RelationToSource)'
-    // (instantiating: 'testing::internal::ContainsMatcherImpl
-    //     <const char * (&)[4]>::Matches(const char * (&)[4]) const')
-    // (instantiating: 'testing::internal::StlContainerView<char *[4]>::
-    //     ConstReference(const char * (&)[4])')
-    // (and though the N parameter type is mismatched in the above explicit
-    // conversion of it doesn't help - only the conversion of the array).
-    return type(const_cast<Element*>(&array[0]), N, kReference);
-#else
-    return type(array, N, kReference);
-#endif  // GTEST_OS_SYMBIAN
-  }
-  static type Copy(const Element (&array)[N]) {
-#if GTEST_OS_SYMBIAN
-    return type(const_cast<Element*>(&array[0]), N, kCopy);
-#else
-    return type(array, N, kCopy);
-#endif  // GTEST_OS_SYMBIAN
-  }
-};
-
-// This specialization is used when RawContainer is a native array
-// represented as a (pointer, size) tuple.
-template <typename ElementPointer, typename Size>
-class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {
- public:
-  typedef GTEST_REMOVE_CONST_(
-      typename internal::PointeeOf<ElementPointer>::type) RawElement;
-  typedef internal::NativeArray<RawElement> type;
-  typedef const type const_reference;
-
-  static const_reference ConstReference(
-      const ::std::tr1::tuple<ElementPointer, Size>& array) {
-    using ::std::tr1::get;
-    return type(get<0>(array), get<1>(array), kReference);
-  }
-  static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {
-    using ::std::tr1::get;
-    return type(get<0>(array), get<1>(array), kCopy);
-  }
-};
-
-// The following specialization prevents the user from instantiating
-// StlContainer with a reference type.
-template <typename T> class StlContainerView<T&>;
-
-}  // namespace internal
-}  // namespace testing
-
-#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_

+ 0 - 78
Src/ThirdParty/gmock/internal/gmock-port.h

@@ -1,78 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: vadimb@google.com (Vadim Berman)
-//
-// Low-level types and utilities for porting Google Mock to various
-// platforms.  They are subject to change without notice.  DO NOT USE
-// THEM IN USER CODE.
-
-#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
-#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
-
-#include <assert.h>
-#include <stdlib.h>
-#include <iostream>
-
-// Most of the types needed for porting Google Mock are also required
-// for Google Test and are defined in gtest-port.h.
-#include "gtest/internal/gtest-linked_ptr.h"
-#include "gtest/internal/gtest-port.h"
-
-// To avoid conditional compilation everywhere, we make it
-// gmock-port.h's responsibility to #include the header implementing
-// tr1/tuple.  gmock-port.h does this via gtest-port.h, which is
-// guaranteed to pull in the tuple header.
-
-// For MS Visual C++, check the compiler version. At least VS 2003 is
-// required to compile Google Mock.
-#if defined(_MSC_VER) && _MSC_VER < 1310
-# error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
-#endif
-
-// Macro for referencing flags.  This is public as we want the user to
-// use this syntax to reference Google Mock flags.
-#define GMOCK_FLAG(name) FLAGS_gmock_##name
-
-// Macros for declaring flags.
-#define GMOCK_DECLARE_bool_(name) extern bool GMOCK_FLAG(name)
-#define GMOCK_DECLARE_int32_(name) \
-    extern ::testing::internal::Int32 GMOCK_FLAG(name)
-#define GMOCK_DECLARE_string_(name) \
-    extern ::testing::internal::String GMOCK_FLAG(name)
-
-// Macros for defining flags.
-#define GMOCK_DEFINE_bool_(name, default_val, doc) \
-    bool GMOCK_FLAG(name) = (default_val)
-#define GMOCK_DEFINE_int32_(name, default_val, doc) \
-    ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
-#define GMOCK_DEFINE_string_(name, default_val, doc) \
-    ::testing::internal::String GMOCK_FLAG(name) = (default_val)
-
-#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_

+ 0 - 47
Src/ThirdParty/gmock/src/gmock-all.cc

@@ -1,47 +0,0 @@
-// Copyright 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: wan@google.com (Zhanyong Wan)
-//
-// Google C++ Mocking Framework (Google Mock)
-//
-// This file #includes all Google Mock implementation .cc files.  The
-// purpose is to allow a user to build Google Mock by compiling this
-// file alone.
-
-// This line ensures that gmock.h can be compiled on its own, even
-// when it's fused.
-#include "gmock/gmock.h"
-
-// The following lines pull in the real gmock *.cc files.
-#include "src/gmock-cardinalities.cc"
-#include "src/gmock-internal-utils.cc"
-#include "src/gmock-matchers.cc"
-#include "src/gmock-spec-builders.cc"
-#include "src/gmock.cc"

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác