diff options
author | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2010-12-07 06:23:55 +0000 |
---|---|---|
committer | liujisi@google.com <liujisi@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2010-12-07 06:23:55 +0000 |
commit | 1fd96c43a01ec913a89de31c58c0bc9f1e5bf542 (patch) | |
tree | fd75a0bffe10b1e57155cbf70d32d41e44302be0 /src/google/protobuf/stubs/common.h | |
parent | b4d64bf7f3aa65318a5262977e59f42595c4c5d0 (diff) | |
download | protobuf-1fd96c43a01ec913a89de31c58c0bc9f1e5bf542.tar.gz protobuf-1fd96c43a01ec913a89de31c58c0bc9f1e5bf542.tar.bz2 protobuf-1fd96c43a01ec913a89de31c58c0bc9f1e5bf542.zip |
Add new files for vcprojs, fix issues: 165, 211, 228, 240
Diffstat (limited to 'src/google/protobuf/stubs/common.h')
-rw-r--r-- | src/google/protobuf/stubs/common.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 0b4df8a9..5c2bdc51 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -48,6 +48,15 @@ #include <stdint.h> #endif +#if defined(_MSC_VER) && defined(_CPPUNWIND) + #define PROTOBUF_USE_EXCEPTIONS +#elif defined(__EXCEPTIONS) + #define PROTOBUF_USE_EXCEPTIONS +#endif +#ifdef PROTOBUF_USE_EXCEPTIONS +#include <exception> +#endif + #if defined(_WIN32) && defined(GetMessage) // Allow GetMessage to be used as a valid method name in protobuf classes. // windows.h defines GetMessage() as a macro. Let's re-define it as an inline @@ -1172,6 +1181,26 @@ LIBPROTOBUF_EXPORT void OnShutdown(void (*func)()); } // namespace internal +#ifdef PROTOBUF_USE_EXCEPTIONS +class FatalException : public std::exception { + public: + FatalException(const char* filename, int line, const std::string& message) + : filename_(filename), line_(line), message_(message) {} + virtual ~FatalException() throw(); + + virtual const char* what() const throw(); + + const char* filename() const { return filename_; } + int line() const { return line_; } + const std::string& message() const { return message_; } + + private: + const char* filename_; + const int line_; + const std::string message_; +}; +#endif + // This is at the end of the file instead of the beginning to work around a bug // in some versions of MSVC. using namespace std; // Don't do this at home, kids. |