Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginDebug.h

Issue 5750789393874944: [IE] First round of ATL removal (Closed)
Patch Set: Created June 20, 2014, 9:22 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginDebug.h
===================================================================
--- a/src/plugin/PluginDebug.h
+++ b/src/plugin/PluginDebug.h
@@ -8,24 +8,63 @@
public:
#if (defined ENABLE_DEBUG_INFO)
- static void Debug(const CString& error, DWORD dwProcessId=0, DWORD dwThreadId=0);
+ static void Debug(const std::wstring &, DWORD dwProcessId=0, DWORD dwThreadId=0);
+ inline static void Debug(const wchar_t line[], DWORD dwProcessId=0, DWORD dwThreadId=0)
+ {
+ CPluginDebug::Debug( std::wstring( line ), dwProcessId, dwThreadId );
+ }
+ static void Debug(const std::wstring[], size_t, DWORD dwProcessId=0, DWORD dwThreadId=0);
+ template< size_t n_lines >
+ inline static void Debug(const std::wstring (&lines)[n_lines])
+ {
+ CPluginDebug::Debug( lines, n_lines, 0, 0 );
+ }
static void DebugClear();
- static void DebugError(const CString& error);
- static void DebugErrorCode(DWORD errorCode, const CString& error, DWORD dwProcessId=0, DWORD dwThreadId=0);
+
+ /*
+ * About the only reason we need narrow strings is to deal with std::exception::what().
+ */
+ static void DebugError(std::string error);
+ static void DebugErrorCode(DWORD errorCode, const std::wstring & error, DWORD dwProcessId=0, DWORD dwThreadId=0);
#endif
#if (defined ENABLE_DEBUG_RESULT)
- static void DebugResult(const CString& text);
- static void DebugResultDomain(const CString& domain);
- static void DebugResultBlocking(const CString& type, const CString& src, const CString& domain);
- static void DebugResultHiding(const CString& tag, const CString& id, const CString& filter);
+ static void DebugResult(const std::wstring & text);
+ static void DebugResultDomain(const std::wstring & domain);
+ static void DebugResultBlocking(const std::wstring & type, const std::wstring & src, const std::wstring & domain);
+ static void DebugResultHiding(const std::wstring & tag, const std::wstring & id, const std::wstring & filter);
static void DebugResultClear();
#endif
#if (defined ENABLE_DEBUG_RESULT_IGNORED)
- static void DebugResultIgnoring(const CString& type, const CString& src, const CString& domain);
+ static void DebugResultIgnoring(const std::wstring & type, const std::wstring & src, const std::wstring & domain);
#endif
};
+namespace ABP
+{
+ namespace debug
+ {
+ /**
+ * Widen a narrow-character string to a wide-character one.
+ *
+ * This method assumes that the original string is plain ASCII, with no multibyte sequences (such as UTF-8).
+ *
+ * The only reason this function is here is to deal with std::exception::what(), which uses narrow characters.
+ * Therefore this function is in the 'debug' namespace, since these exception texts are for developer use only.
+ */
+ std::wstring widen( std::string );
+
+ /**
+ * Narrow a wide-character string to a narrow-character one.
+ */
+ std::string narrow( std::wstring );
+
+ /**
+ * Truncate a source string to a maximum of 100 characters.
+ */
+ void truncate_source( std::wstring & src );
+ }
+}
#endif // _PLUGIN_DEBUG_H_

Powered by Google App Engine
This is Rietveld